You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2014/02/05 02:39:45 UTC
[07/11] git commit: updated refs/heads/master to 54f32a8
Moved the secondary storage service into its own server directory
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4be3b993
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4be3b993
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4be3b993
Branch: refs/heads/master
Commit: 4be3b9933760c7713380112dff6f997cbe127def
Parents: aaa2094
Author: Alex Huang <al...@citrix.com>
Authored: Wed Jan 15 17:37:15 2014 -0800
Committer: Alex Huang <al...@citrix.com>
Committed: Wed Feb 5 01:38:24 2014 +0000
----------------------------------------------------------------------
services/secondary-storage/controller/pom.xml | 50 +
services/secondary-storage/pom.xml | 85 +-
.../module.properties | 18 -
...ing-secondary-storage-discoverer-context.xml | 36 -
services/secondary-storage/server/pom.xml | 105 +
.../module.properties | 18 +
...ing-secondary-storage-discoverer-context.xml | 36 +
.../LocalNfsSecondaryStorageResource.java | 95 +
.../resource/LocalSecondaryStorageResource.java | 240 ++
.../resource/NfsSecondaryStorageResource.java | 2430 ++++++++++++++++++
.../resource/SecondaryStorageDiscoverer.java | 312 +++
.../resource/SecondaryStorageResource.java | 29 +
.../SecondaryStorageResourceHandler.java | 24 +
.../storage/template/DownloadManager.java | 108 +
.../storage/template/DownloadManagerImpl.java | 1080 ++++++++
.../storage/template/UploadManager.java | 82 +
.../storage/template/UploadManagerImpl.java | 550 ++++
.../LocalNfsSecondaryStorageResourceTest.java | 143 ++
.../NfsSecondaryStorageResourceTest.java | 110 +
.../LocalNfsSecondaryStorageResource.java | 95 -
.../resource/LocalSecondaryStorageResource.java | 240 --
.../resource/NfsSecondaryStorageResource.java | 2430 ------------------
.../resource/SecondaryStorageDiscoverer.java | 312 ---
.../resource/SecondaryStorageResource.java | 29 -
.../SecondaryStorageResourceHandler.java | 24 -
.../storage/template/DownloadManager.java | 108 -
.../storage/template/DownloadManagerImpl.java | 1080 --------
.../storage/template/UploadManager.java | 82 -
.../storage/template/UploadManagerImpl.java | 550 ----
.../LocalNfsSecondaryStorageResourceTest.java | 143 --
.../NfsSecondaryStorageResourceTest.java | 110 -
31 files changed, 5419 insertions(+), 5335 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4be3b993/services/secondary-storage/controller/pom.xml
----------------------------------------------------------------------
diff --git a/services/secondary-storage/controller/pom.xml b/services/secondary-storage/controller/pom.xml
new file mode 100644
index 0000000..47a730d
--- /dev/null
+++ b/services/secondary-storage/controller/pom.xml
@@ -0,0 +1,50 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cloud-controller-secondary-storage</artifactId>
+ <name>Apache CloudStack Secondary Storage Controller</name>
+ <parent>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloudstack-service-secondary-storage</artifactId>
+ <version>4.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4be3b993/services/secondary-storage/pom.xml
----------------------------------------------------------------------
diff --git a/services/secondary-storage/pom.xml b/services/secondary-storage/pom.xml
index 2798584..61077a0 100644
--- a/services/secondary-storage/pom.xml
+++ b/services/secondary-storage/pom.xml
@@ -18,88 +18,17 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <artifactId>cloud-secondary-storage</artifactId>
- <name>Apache CloudStack Secondary Storage Service</name>
+ <artifactId>cloudstack-service-secondary-storage</artifactId>
+ <name>Apache CloudStack Secondary Storage</name>
+ <packaging>pom</packaging>
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack-services</artifactId>
<version>4.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <properties>
- <skipTests>true</skipTests>
- </properties>
- <dependencies>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- </dependency>
- <!-- required deps for the systemvm -->
- <dependency>
- <groupId>org.apache.cloudstack</groupId>
- <artifactId>cloud-agent</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cloudstack</groupId>
- <artifactId>cloud-server</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skipTests>${skipTests}</skipTests>
- <systemPropertyVariables>
- <log4j.configuration>file:${project.build.testSourceDirectory}/../conf/log4j.xml</log4j.configuration>
- </systemPropertyVariables>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2.1</version>
- <executions>
- <execution>
- <goals>
- <goal>java</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <mainClass>com.cloud.agent.AgentShell</mainClass>
- <arguments>
- <argument>zone=1</argument>
- <argument>pod=1</argument>
- <argument>host=192.168.56.1</argument>
- <argument>name=192.168.56.10</argument>
- <argument>eth1ip=192.168.56.10</argument>
- <argument>eth2ip=192.168.56.10</argument>
- <argument>guid=SecondaryStorage.1</argument>
- <argument>secondary.storage.vm=false</argument>
- <argument>instance=Secondary</argument>
- </arguments>
- <systemProperties>
- <systemProperty>
- <key>javax.net.ssl.trustStore</key>
- <value>certs/realhostip.keystore</value>
- <key>log.home</key>
- <value>${PWD}/</value>
- </systemProperty>
- </systemProperties>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <modules>
+ <module>controller</module>
+ <module>server</module>
+ </modules>
</project>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4be3b993/services/secondary-storage/resources/META-INF/cloudstack/secondary-storage-discoverer/module.properties
----------------------------------------------------------------------
diff --git a/services/secondary-storage/resources/META-INF/cloudstack/secondary-storage-discoverer/module.properties b/services/secondary-storage/resources/META-INF/cloudstack/secondary-storage-discoverer/module.properties
deleted file mode 100644
index 7ff8a3a..0000000
--- a/services/secondary-storage/resources/META-INF/cloudstack/secondary-storage-discoverer/module.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-name=secondary-storage-discoverer
-parent=discoverer
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4be3b993/services/secondary-storage/resources/META-INF/cloudstack/secondary-storage-discoverer/spring-secondary-storage-discoverer-context.xml
----------------------------------------------------------------------
diff --git a/services/secondary-storage/resources/META-INF/cloudstack/secondary-storage-discoverer/spring-secondary-storage-discoverer-context.xml b/services/secondary-storage/resources/META-INF/cloudstack/secondary-storage-discoverer/spring-secondary-storage-discoverer-context.xml
deleted file mode 100644
index 30521aa..0000000
--- a/services/secondary-storage/resources/META-INF/cloudstack/secondary-storage-discoverer/spring-secondary-storage-discoverer-context.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:aop="http://www.springframework.org/schema/aop"
- 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/context
- http://www.springframework.org/schema/context/spring-context-3.0.xsd"
- >
-
- <bean id="SecondaryStorageDiscoverer"
- class="org.apache.cloudstack.storage.resource.SecondaryStorageDiscoverer">
- <property name="name" value="SecondaryStorage" />
- </bean>
-
-
-</beans>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4be3b993/services/secondary-storage/server/pom.xml
----------------------------------------------------------------------
diff --git a/services/secondary-storage/server/pom.xml b/services/secondary-storage/server/pom.xml
new file mode 100644
index 0000000..29fd7c7
--- /dev/null
+++ b/services/secondary-storage/server/pom.xml
@@ -0,0 +1,105 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cloud-secondary-storage</artifactId>
+ <name>Apache CloudStack Secondary Storage Service</name>
+ <parent>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloudstack-service-secondary-storage</artifactId>
+ <version>4.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <properties>
+ <skipTests>true</skipTests>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+ <!-- required deps for the systemvm -->
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-agent</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipTests}</skipTests>
+ <systemPropertyVariables>
+ <log4j.configuration>file:${project.build.testSourceDirectory}/../conf/log4j.xml</log4j.configuration>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <mainClass>com.cloud.agent.AgentShell</mainClass>
+ <arguments>
+ <argument>zone=1</argument>
+ <argument>pod=1</argument>
+ <argument>host=192.168.56.1</argument>
+ <argument>name=192.168.56.10</argument>
+ <argument>eth1ip=192.168.56.10</argument>
+ <argument>eth2ip=192.168.56.10</argument>
+ <argument>guid=SecondaryStorage.1</argument>
+ <argument>secondary.storage.vm=false</argument>
+ <argument>instance=Secondary</argument>
+ </arguments>
+ <systemProperties>
+ <systemProperty>
+ <key>javax.net.ssl.trustStore</key>
+ <value>certs/realhostip.keystore</value>
+ <key>log.home</key>
+ <value>${PWD}/</value>
+ </systemProperty>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4be3b993/services/secondary-storage/server/resources/META-INF/cloudstack/secondary-storage-discoverer/module.properties
----------------------------------------------------------------------
diff --git a/services/secondary-storage/server/resources/META-INF/cloudstack/secondary-storage-discoverer/module.properties b/services/secondary-storage/server/resources/META-INF/cloudstack/secondary-storage-discoverer/module.properties
new file mode 100644
index 0000000..7ff8a3a
--- /dev/null
+++ b/services/secondary-storage/server/resources/META-INF/cloudstack/secondary-storage-discoverer/module.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+name=secondary-storage-discoverer
+parent=discoverer
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4be3b993/services/secondary-storage/server/resources/META-INF/cloudstack/secondary-storage-discoverer/spring-secondary-storage-discoverer-context.xml
----------------------------------------------------------------------
diff --git a/services/secondary-storage/server/resources/META-INF/cloudstack/secondary-storage-discoverer/spring-secondary-storage-discoverer-context.xml b/services/secondary-storage/server/resources/META-INF/cloudstack/secondary-storage-discoverer/spring-secondary-storage-discoverer-context.xml
new file mode 100644
index 0000000..30521aa
--- /dev/null
+++ b/services/secondary-storage/server/resources/META-INF/cloudstack/secondary-storage-discoverer/spring-secondary-storage-discoverer-context.xml
@@ -0,0 +1,36 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ 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/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ >
+
+ <bean id="SecondaryStorageDiscoverer"
+ class="org.apache.cloudstack.storage.resource.SecondaryStorageDiscoverer">
+ <property name="name" value="SecondaryStorage" />
+ </bean>
+
+
+</beans>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4be3b993/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResource.java b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResource.java
new file mode 100644
index 0000000..9393ee2
--- /dev/null
+++ b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/LocalNfsSecondaryStorageResource.java
@@ -0,0 +1,95 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.storage.resource;
+
+import java.net.URI;
+import java.util.concurrent.Executors;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import org.apache.cloudstack.storage.template.DownloadManagerImpl;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+import com.cloud.storage.JavaStorageLayer;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+
+@Component
+public class LocalNfsSecondaryStorageResource extends NfsSecondaryStorageResource {
+
+ private static final Logger s_logger = Logger.getLogger(LocalNfsSecondaryStorageResource.class);
+
+ public LocalNfsSecondaryStorageResource() {
+ this._dlMgr = new DownloadManagerImpl();
+ ((DownloadManagerImpl)_dlMgr).setThreadPool(Executors.newFixedThreadPool(10));
+ _storage = new JavaStorageLayer();
+ this._inSystemVM = false;
+ }
+
+ @Override
+ public void setParentPath(String path) {
+ this._parent = path;
+ }
+
+ @Override
+ public Answer executeRequest(Command cmd) {
+ return super.executeRequest(cmd);
+ }
+
+ @Override
+ synchronized public String getRootDir(String secUrl) {
+ try {
+ URI uri = new URI(secUrl);
+ String dir = mountUri(uri);
+ return _parent + "/" + dir;
+ } catch (Exception e) {
+ String msg = "GetRootDir for " + secUrl + " failed due to " + e.toString();
+ s_logger.error(msg, e);
+ throw new CloudRuntimeException(msg);
+ }
+ }
+
+ @Override
+ protected void mount(String localRootPath, String remoteDevice, URI uri) {
+ ensureLocalRootPathExists(localRootPath, uri);
+
+ if (mountExists(localRootPath, uri)) {
+ return;
+ }
+
+ attemptMount(localRootPath, remoteDevice, uri);
+
+ // Change permissions for the mountpoint - seems to bypass authentication
+ Script script = new Script(true, "chmod", _timeout, s_logger);
+ script.add("777", localRootPath);
+ String result = script.execute();
+ if (result != null) {
+ String errMsg = "Unable to set permissions for " + localRootPath + " due to " + result;
+ s_logger.error(errMsg);
+ throw new CloudRuntimeException(errMsg);
+ }
+ s_logger.debug("Successfully set 777 permission for " + localRootPath);
+
+ // XXX: Adding the check for creation of snapshots dir here. Might have
+ // to move it somewhere more logical later.
+ checkForSnapshotsDir(localRootPath);
+ checkForVolumesDir(localRootPath);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4be3b993/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/LocalSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/LocalSecondaryStorageResource.java b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/LocalSecondaryStorageResource.java
new file mode 100644
index 0000000..bdfe7e8
--- /dev/null
+++ b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/LocalSecondaryStorageResource.java
@@ -0,0 +1,240 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.storage.resource;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.storage.command.DownloadCommand;
+import org.apache.cloudstack.storage.command.DownloadProgressCommand;
+import org.apache.cloudstack.storage.template.DownloadManager;
+import org.apache.cloudstack.storage.template.DownloadManagerImpl;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CheckHealthAnswer;
+import com.cloud.agent.api.CheckHealthCommand;
+import com.cloud.agent.api.Command;
+import com.cloud.agent.api.ComputeChecksumCommand;
+import com.cloud.agent.api.PingCommand;
+import com.cloud.agent.api.PingStorageCommand;
+import com.cloud.agent.api.ReadyAnswer;
+import com.cloud.agent.api.ReadyCommand;
+import com.cloud.agent.api.SecStorageSetupCommand;
+import com.cloud.agent.api.StartupCommand;
+import com.cloud.agent.api.StartupStorageCommand;
+import com.cloud.agent.api.storage.ListTemplateAnswer;
+import com.cloud.agent.api.storage.ListTemplateCommand;
+import com.cloud.agent.api.to.NfsTO;
+import com.cloud.host.Host;
+import com.cloud.host.Host.Type;
+import com.cloud.resource.ServerResourceBase;
+import com.cloud.storage.Storage;
+import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.storage.StorageLayer;
+import com.cloud.storage.template.TemplateProp;
+import com.cloud.utils.component.ComponentContext;
+
+public class LocalSecondaryStorageResource extends ServerResourceBase implements SecondaryStorageResource {
+ private static final Logger s_logger = Logger.getLogger(LocalSecondaryStorageResource.class);
+ int _timeout;
+
+ String _instance;
+ String _parent;
+
+ String _dc;
+ String _pod;
+ String _guid;
+
+ StorageLayer _storage;
+
+ DownloadManager _dlMgr;
+
+ @Override
+ public void disconnected() {
+ }
+
+ @Override
+ public String getRootDir(String url) {
+ return getRootDir();
+
+ }
+
+ public String getRootDir() {
+ return _parent;
+ }
+
+ @Override
+ public Answer executeRequest(Command cmd) {
+ if (cmd instanceof DownloadProgressCommand) {
+ return _dlMgr.handleDownloadCommand(this, (DownloadProgressCommand)cmd);
+ } else if (cmd instanceof DownloadCommand) {
+ return _dlMgr.handleDownloadCommand(this, (DownloadCommand)cmd);
+ } else if (cmd instanceof CheckHealthCommand) {
+ return new CheckHealthAnswer((CheckHealthCommand)cmd, true);
+ } else if (cmd instanceof SecStorageSetupCommand) {
+ return new Answer(cmd, true, "success");
+ } else if (cmd instanceof ReadyCommand) {
+ return new ReadyAnswer((ReadyCommand)cmd);
+ } else if (cmd instanceof ListTemplateCommand) {
+ return execute((ListTemplateCommand)cmd);
+ } else if (cmd instanceof ComputeChecksumCommand) {
+ return execute((ComputeChecksumCommand)cmd);
+ } else {
+ return Answer.createUnsupportedCommandAnswer(cmd);
+ }
+ }
+
+ private Answer execute(ComputeChecksumCommand cmd) {
+ return new Answer(cmd, false, null);
+ }
+
+ private Answer execute(ListTemplateCommand cmd) {
+ String root = getRootDir();
+ Map<String, TemplateProp> templateInfos = _dlMgr.gatherTemplateInfo(root);
+ return new ListTemplateAnswer(((NfsTO)cmd.getDataStore()).getUrl(), templateInfos);
+ }
+
+ @Override
+ public Type getType() {
+ return Host.Type.LocalSecondaryStorage;
+ }
+
+ @Override
+ public PingCommand getCurrentStatus(final long id) {
+ return new PingStorageCommand(Host.Type.Storage, id, new HashMap<String, Boolean>());
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+ super.configure(name, params);
+
+ _guid = (String)params.get("guid");
+ if (_guid == null) {
+ throw new ConfigurationException("Unable to find the guid");
+ }
+
+ _dc = (String)params.get("zone");
+ if (_dc == null) {
+ throw new ConfigurationException("Unable to find the zone");
+ }
+ _pod = (String)params.get("pod");
+
+ _instance = (String)params.get("instance");
+
+ _parent = (String)params.get("mount.path");
+ if (_parent == null) {
+ throw new ConfigurationException("No directory specified.");
+ }
+
+ _storage = (StorageLayer)params.get(StorageLayer.InstanceConfigKey);
+ if (_storage == null) {
+ String value = (String)params.get(StorageLayer.ClassConfigKey);
+ if (value == null) {
+ value = "com.cloud.storage.JavaStorageLayer";
+ }
+
+ try {
+ Class<StorageLayer> clazz = (Class<StorageLayer>)Class.forName(value);
+ _storage = ComponentContext.inject(clazz);
+ } catch (ClassNotFoundException e) {
+ throw new ConfigurationException("Unable to find class " + value);
+ }
+ }
+
+ if (!_storage.mkdirs(_parent)) {
+ s_logger.warn("Unable to create the directory " + _parent);
+ throw new ConfigurationException("Unable to create the directory " + _parent);
+ }
+
+ s_logger.info("Mount point established at " + _parent);
+
+ params.put("template.parent", _parent);
+ params.put(StorageLayer.InstanceConfigKey, _storage);
+
+ _dlMgr = new DownloadManagerImpl();
+ _dlMgr.configure("DownloadManager", params);
+
+ return true;
+ }
+
+ @Override
+ public boolean start() {
+ return true;
+ }
+
+ @Override
+ public boolean stop() {
+ return true;
+ }
+
+ @Override
+ public StartupCommand[] initialize() {
+
+ final StartupStorageCommand cmd =
+ new StartupStorageCommand(_parent, StoragePoolType.Filesystem, 1024l * 1024l * 1024l * 1024l, _dlMgr.gatherTemplateInfo(_parent));
+ cmd.setResourceType(Storage.StorageResourceType.LOCAL_SECONDARY_STORAGE);
+ cmd.setIqn("local://");
+ fillNetworkInformation(cmd);
+ cmd.setDataCenter(_dc);
+ cmd.setPod(_pod);
+ cmd.setGuid(_guid);
+ cmd.setName(_guid);
+ cmd.setVersion(LocalSecondaryStorageResource.class.getPackage().getImplementationVersion());
+
+ return new StartupCommand[] {cmd};
+ }
+
+ @Override
+ protected String getDefaultScriptsDir() {
+ return "scripts/storage/secondary";
+ }
+
+ @Override
+ public void setName(String name) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setConfigParams(Map<String, Object> params) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Map<String, Object> getConfigParams() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getRunLevel() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public void setRunLevel(int level) {
+ // TODO Auto-generated method stub
+
+ }
+}