Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加surfs部分的代码 #1236

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions conf/db/upgrade/V2.3.1.1__schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
CREATE TABLE if not exists `zstack`.`SurfsBackupStorageVO` (
`uuid` varchar(32) NOT NULL UNIQUE,
`fsid` varchar(64) DEFAULT NULL,
`poolName` varchar(255) NOT NULL,
PRIMARY KEY (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE if not exists `zstack`.`SurfsBackupStorageNodeVO` (
`uuid` varchar(32) NOT NULL UNIQUE,
`sshUsername` varchar(64) NOT NULL,
`sshPassword` varchar(255) NOT NULL,
`hostname` varchar(255) NOT NULL,
`status` varchar(255) NOT NULL,
`nodeAddr` varchar(255) NOT NULL,
`sshPort` int unsigned NOT NULL,
`nodePort` int unsigned NOT NULL,
`backupStorageUuid` varchar(32) NOT NULL,
`lastOpDate` timestamp ON UPDATE CURRENT_TIMESTAMP,
`createDate` timestamp,
PRIMARY KEY (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE if not exists `zstack`.`SurfsPrimaryStorageVO` (
`uuid` varchar(32) NOT NULL UNIQUE,
`fsid` varchar(64) DEFAULT NULL,
`rootVolumePoolName` varchar(255) NOT NULL,
`dataVolumePoolName` varchar(255) NOT NULL,
`imageCachePoolName` varchar(255) NOT NULL,
`userKey` varchar(255) DEFAULT NULL,
PRIMARY KEY (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE if not exists `zstack`.`SurfsPrimaryStorageNodeVO` (
`uuid` varchar(32) NOT NULL UNIQUE,
`sshUsername` varchar(64) NOT NULL,
`sshPassword` varchar(255) NOT NULL,
`hostname` varchar(255) NOT NULL,
`status` varchar(255) NOT NULL,
`nodeAddr` varchar(255) NOT NULL,
`sshPort` int unsigned NOT NULL,
`nodePort` int unsigned NOT NULL,
`primaryStorageUuid` varchar(32) NOT NULL,
`lastOpDate` timestamp ON UPDATE CURRENT_TIMESTAMP,
`createDate` timestamp,
PRIMARY KEY (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE if not exists `zstack`.`SurfsCapacityVO` (
`fsid` varchar(64) NOT NULL UNIQUE,
`totalCapacity` bigint unsigned DEFAULT 0,
`availableCapacity` bigint unsigned DEFAULT 0,
`lastOpDate` timestamp ON UPDATE CURRENT_TIMESTAMP,
`createDate` timestamp,
PRIMARY KEY (`fsid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE if not exists `zstack`.`SurfsPoolClassVO` (
`uuid` varchar(32) NOT NULL UNIQUE,
`fsid` varchar(64) NOT NULL,
`clsname` varchar(32) NOT NULL,
`clsdisplayname` varchar(64) NOT NULL,
`isrootcls` tinyint(1) NOT NULL DEFAULT 0,
`isactive` tinyint(1) NOT NULL DEFAULT 0,
`totalCapacity` bigint unsigned DEFAULT 0,
`availableCapacity` bigint unsigned DEFAULT 0,
`lastOpDate` timestamp ON UPDATE CURRENT_TIMESTAMP,
`createDate` timestamp,
PRIMARY KEY (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

delimiter //
drop procedure if exists do_surfs_alter //
create procedure do_surfs_alter()
begin
IF not exists(select CONSTRAINT_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where CONSTRAINT_NAME='fkSurfsBackupStorageNodeVOBackupStorageEO') then
ALTER TABLE SurfsBackupStorageNodeVO ADD CONSTRAINT fkSurfsBackupStorageNodeVOBackupStorageEO FOREIGN KEY (backupStorageUuid) REFERENCES BackupStorageEO (uuid) ON DELETE CASCADE;
END IF;
IF not exists(select CONSTRAINT_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where CONSTRAINT_NAME='fkSurfsBackupStorageVOBackupStorageEO') then
ALTER TABLE SurfsBackupStorageVO ADD CONSTRAINT fkSurfsBackupStorageVOBackupStorageEO FOREIGN KEY (uuid) REFERENCES BackupStorageEO (uuid) ON UPDATE RESTRICT ON DELETE CASCADE;
END IF;
IF not exists(select CONSTRAINT_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where CONSTRAINT_NAME='fkSurfsPrimaryStorageNodeVOPrimaryStorageEO') then
ALTER TABLE SurfsPrimaryStorageNodeVO ADD CONSTRAINT fkSurfsPrimaryStorageNodeVOPrimaryStorageEO FOREIGN KEY (primaryStorageUuid) REFERENCES PrimaryStorageEO (uuid) ON DELETE CASCADE;
END IF;
IF not exists(select CONSTRAINT_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where CONSTRAINT_NAME='fkSurfsPrimaryStorageVOPrimaryStorageEO') then
ALTER TABLE SurfsPrimaryStorageVO ADD CONSTRAINT fkSurfsPrimaryStorageVOPrimaryStorageEO FOREIGN KEY (uuid) REFERENCES PrimaryStorageEO (uuid) ON UPDATE RESTRICT ON DELETE CASCADE;
END IF;
end;//
call do_surfs_alter() //
drop procedure if exists do_surfs_alter //
delimiter ;


53 changes: 53 additions & 0 deletions conf/globalConfig/surfs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<globalConfig xmlns="http://zstack.org/schema/zstack">
<config>
<name>backupStorage.image.download.timeout</name>
<description>timeout of command of downloading images to surfs backup storage, in seconds.</description>
<category>surfs</category>
<defaultValue>3600</defaultValue>
<type>java.lang.Long</type>
</config>
<config>
<name>imageCache.cleanup.interval</name>
<description>interval to cleanup stale image cache on primary storage, in seconds.</description>
<category>surfs</category>
<defaultValue>43200</defaultValue>
<type>java.lang.Long</type>
</config>
<config>
<name>primaryStorage.deletePool</name>
<description>delete all primary storage related pools when deleting the surfs primary storage</description>
<category>surfs</category>
<defaultValue>false</defaultValue>
<type>java.lang.Boolean</type>
</config>
<config>
<name>primaryStorage.node.reconnectDelay</name>
<description>the delay to reconnect a primary storage surfs node after a ping failure, in seconds</description>
<category>surfs</category>
<defaultValue>30</defaultValue>
<type>java.lang.Integer</type>
</config>
<config>
<name>backupStorage.node.reconnectDelay</name>
<description>the delay to reconnect a backup storage surfs node after a ping failure, in seconds</description>
<category>surfs</category>
<defaultValue>30</defaultValue>
<type>java.lang.Integer</type>
</config>
<config>
<name>primaryStorage.node.autoReconnect</name>
<description>whether to automatically reconnect a surfs primary storage node when it's unable to be pinged</description>
<category>surfs</category>
<defaultValue>true</defaultValue>
<type>java.lang.Boolean</type>
</config>
<config>
<name>backupStorage.node.autoReconnect</name>
<description>whether to automatically reconnect a surfs backup storage node when it's unable to be pinged</description>
<category>surfs</category>
<defaultValue>true</defaultValue>
<type>java.lang.Boolean</type>
</config>
</globalConfig>

5 changes: 5 additions & 0 deletions conf/persistence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@
<class>org.zstack.storage.fusionstor.primary.FusionstorPrimaryStorageMonVO</class>
<class>org.zstack.storage.fusionstor.primary.FusionstorPrimaryStorageVO</class>
<class>org.zstack.storage.fusionstor.FusionstorCapacityVO</class>
<class>org.zstack.storage.surfs.backup.SurfsBackupStorageVO</class>
<class>org.zstack.storage.surfs.backup.SurfsBackupStorageNodeVO</class>
<class>org.zstack.storage.surfs.backup.SurfsPrimaryStorageVO</class>
<class>org.zstack.storage.surfs.backup.SurfsPrimaryStorageNodeVO</class>
<class>org.zstack.storage.surfs.SurfsCapacityVO</class>
<class>org.zstack.core.gc.GarbageCollectorVO</class>
<class>org.zstack.header.storage.primary.ImageCacheVolumeRefVO</class>
<class>org.zstack.network.service.virtualrouter.lb.VirtualRouterLoadBalancerRefVO</class>
Expand Down
60 changes: 60 additions & 0 deletions conf/serviceConfig/surfs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<service xmlns="http://zstack.org/schema/zstack">
<interceptor>SurfsApiInterceptor</interceptor>

<message>
<name>org.zstack.storage.surfs.backup.APIAddSurfsBackupStorageMsg</name>
<serviceId>storage.backup</serviceId>
</message>

<message>
<name>org.zstack.storage.surfs.backup.APIAddNodeToSurfsBackupStorageMsg</name>
<serviceId>storage.backup</serviceId>
</message>

<message>
<name>org.zstack.storage.surfs.backup.APIUpdateSurfsBackupStorageNodeMsg</name>
<serviceId>storage.backup</serviceId>
</message>

<message>
<name>org.zstack.storage.surfs.backup.APIRemoveNodeFromSurfsBackupStorageMsg</name>
<serviceId>storage.backup</serviceId>
</message>

<message>
<name>org.zstack.storage.surfs.backup.APIQuerySurfsBackupStorageMsg</name>
<serviceId>query</serviceId>
</message>

<message>
<name>org.zstack.storage.surfs.primary.APIAddSurfsPrimaryStorageMsg</name>
<serviceId>storage.primary</serviceId>
</message>

<message>
<name>org.zstack.storage.surfs.primary.APIAddNodeToSurfsPrimaryStorageMsg</name>
<serviceId>storage.primary</serviceId>
</message>

<message>
<name>org.zstack.storage.surfs.primary.APIUpdateSurfsPrimaryStorageNodeMsg</name>
<serviceId>storage.primary</serviceId>
</message>

<message>
<name>org.zstack.storage.surfs.primary.APIRemoveNodeFromSurfsPrimaryStorageMsg</name>
<serviceId>storage.primary</serviceId>
</message>

<message>
<name>org.zstack.storage.surfs.primary.APIQuerySurfsPrimaryStorageMsg</name>
<serviceId>query</serviceId>
</message>

<message>
<name>org.zstack.storage.surfs.primary.APIQuerySurfsPoolClassMsg</name>
<serviceId>query</serviceId>
</message>
</service>

5 changes: 5 additions & 0 deletions conf/springConfigXml/HostAllocatorManager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<value>Ceph</value>
<value>XSky</value>
</util:list>

<util:list id="SurfsMetric">
<value>Surfs</value>
</util:list>

<util:list id="FusionstorMetric">
<value>Fusionstor</value>
Expand All @@ -55,6 +59,7 @@
<entry key="SftpBackupStorage" value-ref="SftpBackupStorageMetric"/>
<entry key="Fusionstor" value-ref="FusionstorMetric"/>
<entry key="Ceph" value-ref="CephMetric"/>
<entry key="Surfs" value-ref="SurfsMetric"/>
<entry key="ImageStoreBackupStorage" value-ref="ImageStoreBackupStorageMetric"/>
<entry key="SimulatorBackupStorage" value-ref="SimulatorBackupStorageMetric"/>
<entry key="VCenter" value-ref="VCenterMetric"/>
Expand Down
43 changes: 43 additions & 0 deletions conf/springConfigXml/surfs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:zstack="http://zstack.org/schema/zstack"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://zstack.org/schema/zstack
http://zstack.org/schema/zstack/plugin.xsd"
default-init-method="init" default-destroy-method="destroy">
<bean id="SurfsBackupStorageFactory" class="org.zstack.storage.surfs.backup.SurfsBackupStorageFactory">
<zstack:plugin>
<zstack:extension interface="org.zstack.header.storage.backup.BackupStorageFactory" />
<zstack:extension interface="org.zstack.storage.surfs.SurfsCapacityUpdateExtensionPoint" />
<zstack:extension interface="org.zstack.header.Component" />
</zstack:plugin>
</bean>
<bean id="SurfsPrimaryStorageFactory" class="org.zstack.storage.surfs.primary.SurfsPrimaryStorageFactory">
<zstack:plugin>
<zstack:extension interface="org.zstack.header.storage.primary.PrimaryStorageFactory" />
<zstack:extension interface="org.zstack.storage.surfs.SurfsCapacityUpdateExtensionPoint" />
<zstack:extension interface="org.zstack.kvm.KVMStartVmExtensionPoint" />
<zstack:extension interface="org.zstack.kvm.KVMAttachVolumeExtensionPoint" />
<zstack:extension interface="org.zstack.kvm.KVMDetachVolumeExtensionPoint" />
<zstack:extension interface="org.zstack.header.storage.snapshot.CreateTemplateFromVolumeSnapshotExtensionPoint" />
<zstack:extension interface="org.zstack.kvm.KvmSetupSelfFencerExtensionPoint" />
<zstack:extension interface="org.zstack.header.Component" />
</zstack:plugin>
</bean>
<bean id="SurfsPrimaryStorageVmMigrationExtension" class="org.zstack.storage.surfs.primary.SurfsPrimaryStorageVmMigrationExtension">
<zstack:plugin>
<zstack:extension interface="org.zstack.header.vm.VmInstanceMigrateExtensionPoint" />
</zstack:plugin>
</bean>
<bean id="SurfsApiInterceptor" class="org.zstack.storage.surfs.SurfsApiInterceptor">
<zstack:plugin>
<zstack:extension interface="org.zstack.header.apimediator.ApiMessageInterceptor" />
</zstack:plugin>
</bean>
</beans>

1 change: 1 addition & 0 deletions conf/zstack.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<import resource="springConfigXml/BackupStorageManager.xml"/>
<import resource="springConfigXml/CascadeFacade.xml"/>
<import resource="springConfigXml/ceph.xml"/>
<import resource="springConfigXml/surfs.xml"/>
<import resource="springConfigXml/CloudBus.xml"/>
<import resource="springConfigXml/ClusterManager.xml"/>
<import resource="springConfigXml/ConfigurationManager.xml"/>
Expand Down
3 changes: 2 additions & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
<module>eip</module>
<module>mediator</module>
<module>localstorage</module>
<module>ceph</module>
<module>surfs</module>
<module>ceph</module>
<module>fusionstor</module>
<module>loadBalancer</module>
<module>flatNetworkProvider</module>
Expand Down
80 changes: 80 additions & 0 deletions plugin/surfs/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.zstack</groupId>
<artifactId>plugin</artifactId>
<version>2.3.0</version>
</parent>
<artifactId>surfs</artifactId>
<name>surfs</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.zstack</groupId>
<artifactId>kvm</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.zstack</groupId>
<artifactId>sftpBackupStorage</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.zstack</groupId>
<artifactId>storage</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${project.compiler.version}</version>
<configuration>
<source>${project.java.version}</source>
<target>${project.java.version}</target>
<debug>true</debug>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>${aspectj.plugin.version}</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<source>${project.java.version}</source>
<target>${project.java.version}</target>
<complianceLevel>${project.java.version}</complianceLevel>
<XnoInline>true</XnoInline>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
<aspectLibrary>
<groupId>org.zstack</groupId>
<artifactId>core</artifactId>
</aspectLibrary>
<aspectLibrary>
<groupId>org.zstack</groupId>
<artifactId>header</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.zstack.storage.surfs;

/**
* Created by zhouhaiping 2017-09-04
*/
public enum NodeStatus {
Connecting,
Connected,
Disconnected
}
Loading