mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
QuickCloud: Enable secondary storage daemon to run outside the system vm
This commit is contained in:
parent
4fd3fca848
commit
e7983b25cc
@ -38,12 +38,10 @@ import java.util.UUID;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.commons.beanutils.PropertyUtils;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
import org.apache.log4j.xml.DOMConfigurator;
|
||||
|
||||
import com.cloud.agent.Agent.ExitStatus;
|
||||
@ -373,6 +371,7 @@ public class AgentShell implements IAgentShell {
|
||||
throw new ConfigurationException("Unable to find the guid");
|
||||
}
|
||||
_guid = UUID.randomUUID().toString();
|
||||
_properties.setProperty("guid", _guid);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -20,6 +20,7 @@ import java.util.Map;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.storage.resource.SecondaryStorageResource;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
@ -35,7 +36,6 @@ import com.cloud.agent.manager.SimulatorManager;
|
||||
import com.cloud.agent.manager.SimulatorManager.AgentType;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.storage.resource.SecondaryStorageResource;
|
||||
import com.cloud.vm.SecondaryStorageVm;
|
||||
|
||||
|
||||
|
||||
@ -21,6 +21,8 @@ import java.util.Map;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource;
|
||||
import org.apache.cloudstack.storage.resource.SecondaryStorageResourceHandler;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
||||
@ -18,6 +18,7 @@ package com.cloud.storage.resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.storage.resource.SecondaryStorageResourceHandler;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
# $2 = new private key
|
||||
|
||||
#set -x
|
||||
set -e
|
||||
|
||||
TMP=/tmp
|
||||
MOUNTPATH=${HOME}/systemvm_mnt
|
||||
@ -29,7 +30,7 @@ TMPDIR=${TMP}/cloud/systemvm
|
||||
|
||||
|
||||
clean_up() {
|
||||
sudo umount $MOUNTPATH
|
||||
$SUDO umount $MOUNTPATH
|
||||
}
|
||||
|
||||
inject_into_iso() {
|
||||
@ -39,23 +40,23 @@ inject_into_iso() {
|
||||
local tmpiso=${TMP}/$1
|
||||
mkdir -p $MOUNTPATH
|
||||
[ ! -f $isofile ] && echo "$(basename $0): Could not find systemvm iso patch file $isofile" && return 1
|
||||
sudo mount -o loop $isofile $MOUNTPATH
|
||||
$SUDO mount -o loop $isofile $MOUNTPATH
|
||||
[ $? -ne 0 ] && echo "$(basename $0): Failed to mount original iso $isofile" && clean_up && return 1
|
||||
diff -q $MOUNTPATH/authorized_keys $newpubkey &> /dev/null && clean_up && return 0
|
||||
sudo cp -b $isofile $backup
|
||||
$SUDO cp -b $isofile $backup
|
||||
[ $? -ne 0 ] && echo "$(basename $0): Failed to backup original iso $isofile" && clean_up && return 1
|
||||
rm -rf $TMPDIR
|
||||
mkdir -p $TMPDIR
|
||||
[ ! -d $TMPDIR ] && echo "$(basename $0): Could not find/create temporary dir $TMPDIR" && clean_up && return 1
|
||||
sudo cp -fr $MOUNTPATH/* $TMPDIR/
|
||||
$SUDO cp -fr $MOUNTPATH/* $TMPDIR/
|
||||
[ $? -ne 0 ] && echo "$(basename $0): Failed to copy from original iso $isofile" && clean_up && return 1
|
||||
sudo cp $newpubkey $TMPDIR/authorized_keys
|
||||
$SUDO cp $newpubkey $TMPDIR/authorized_keys
|
||||
[ $? -ne 0 ] && echo "$(basename $0): Failed to copy key $newpubkey from original iso to new iso " && clean_up && return 1
|
||||
mkisofs -quiet -r -o $tmpiso $TMPDIR
|
||||
[ $? -ne 0 ] && echo "$(basename $0): Failed to create new iso $tmpiso from $TMPDIR" && clean_up && return 1
|
||||
sudo umount $MOUNTPATH
|
||||
$SUDO umount $MOUNTPATH
|
||||
[ $? -ne 0 ] && echo "$(basename $0): Failed to unmount old iso from $MOUNTPATH" && return 1
|
||||
sudo cp -f $tmpiso $isofile
|
||||
$SUDO cp -f $tmpiso $isofile
|
||||
[ $? -ne 0 ] && echo "$(basename $0): Failed to overwrite old iso $isofile with $tmpiso" && return 1
|
||||
rm -rf $TMPDIR
|
||||
}
|
||||
@ -63,12 +64,17 @@ inject_into_iso() {
|
||||
copy_priv_key() {
|
||||
local newprivkey=$1
|
||||
diff -q $newprivkey $(dirname $0)/id_rsa.cloud && return 0
|
||||
sudo cp -fb $newprivkey $(dirname $0)/id_rsa.cloud
|
||||
sudo chmod 644 $(dirname $0)/id_rsa.cloud
|
||||
$SUDO cp -fb $newprivkey $(dirname $0)/id_rsa.cloud
|
||||
$SUDO chmod 644 $(dirname $0)/id_rsa.cloud
|
||||
return $?
|
||||
}
|
||||
|
||||
sudo mkdir -p $MOUNTPATH
|
||||
if [[ `whoami` == cloud* ]]
|
||||
then
|
||||
SUDO=$SUDO
|
||||
fi
|
||||
|
||||
$SUDO mkdir -p $MOUNTPATH
|
||||
|
||||
[ $# -ne 3 ] && echo "Usage: $(basename $0) <new public key file> <new private key file> <systemvm iso path>" && exit 3
|
||||
newpubkey=$1
|
||||
|
||||
@ -31,6 +31,11 @@
|
||||
<artifactId>cloud-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-secondary-storage</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
|
||||
@ -30,6 +30,8 @@ import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.storage.resource.LocalSecondaryStorageResource;
|
||||
import org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
@ -47,8 +49,6 @@ import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VMTemplateHostDao;
|
||||
import com.cloud.storage.dao.VMTemplateZoneDao;
|
||||
import com.cloud.storage.resource.DummySecondaryStorageResource;
|
||||
import com.cloud.storage.resource.LocalSecondaryStorageResource;
|
||||
import com.cloud.storage.resource.NfsSecondaryStorageResource;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.net.NfsUtils;
|
||||
import com.cloud.utils.script.Script;
|
||||
|
||||
@ -32,5 +32,6 @@
|
||||
</build>
|
||||
<modules>
|
||||
<module>console-proxy</module>
|
||||
<module>secondary-storage</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
||||
11
services/secondary-storage/conf/agent.properties
Normal file
11
services/secondary-storage/conf/agent.properties
Normal file
@ -0,0 +1,11 @@
|
||||
#Storage
|
||||
#Sun Mar 24 22:52:35 PDT 2013
|
||||
mount.path=/Users/chiradeep/secondary-storage
|
||||
eth1ip=192.168.56.1
|
||||
name=192.168.56.10
|
||||
eth2ip=192.168.56.10
|
||||
resource=org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource
|
||||
piddir=.
|
||||
instance=SecondaryStorage
|
||||
developer=true
|
||||
secondary.storage.vm=false
|
||||
2
services/secondary-storage/conf/environment.properties
Normal file
2
services/secondary-storage/conf/environment.properties
Normal file
@ -0,0 +1,2 @@
|
||||
paths.script=../../scripts/storage/secondary/
|
||||
paths.pid=.
|
||||
102
services/secondary-storage/conf/log4j-cloud.xml
Normal file
102
services/secondary-storage/conf/log4j-cloud.xml
Normal file
@ -0,0 +1,102 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
|
||||
|
||||
<!-- ================================= -->
|
||||
<!-- Preserve messages in a local file -->
|
||||
<!-- ================================= -->
|
||||
|
||||
<!-- A time/date based rolling appender -->
|
||||
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="File" value="${ss.log.home}systemvm.log"/>
|
||||
<param name="Append" value="true"/>
|
||||
<param name="Threshold" value="DEBUG"/>
|
||||
|
||||
<!-- Rollover at midnight each day -->
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
|
||||
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d %-5p [%c{3}] (%t:%x) %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- ============================== -->
|
||||
<!-- Append messages to the console -->
|
||||
<!-- ============================== -->
|
||||
|
||||
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
|
||||
<param name="Target" value="System.out"/>
|
||||
<param name="Threshold" value="WARN"/>
|
||||
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- ================ -->
|
||||
<!-- Limit categories -->
|
||||
<!-- ================ -->
|
||||
|
||||
<category name="com.cloud.console.ConsoleCanvas">
|
||||
<priority value="WARN"/>
|
||||
</category>
|
||||
|
||||
<category name="com.cloud.consoleproxy.ConsoleProxyAjaxImageHandler">
|
||||
<priority value="WARN"/>
|
||||
</category>
|
||||
|
||||
<category name="com.cloud.consoleproxy.ConsoleProxyViewer">
|
||||
<priority value="WARN"/>
|
||||
</category>
|
||||
|
||||
<category name="com.cloud.consoleproxy">
|
||||
<priority value="INFO"/>
|
||||
</category>
|
||||
|
||||
<category name="com.cloud">
|
||||
<priority value="DEBUG"/>
|
||||
</category>
|
||||
|
||||
<!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
|
||||
<category name="org.apache">
|
||||
<priority value="DEBUG"/>
|
||||
</category>
|
||||
|
||||
<category name="org">
|
||||
<priority value="INFO"/>
|
||||
</category>
|
||||
|
||||
<category name="net">
|
||||
<priority value="INFO"/>
|
||||
</category>
|
||||
|
||||
<!-- ======================= -->
|
||||
<!-- Setup the Root category -->
|
||||
<!-- ======================= -->
|
||||
|
||||
<root>
|
||||
<level value="DEBUG"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</root>
|
||||
|
||||
</log4j:configuration>
|
||||
113
services/secondary-storage/pom.xml
Normal file
113
services/secondary-storage/pom.xml
Normal file
@ -0,0 +1,113 @@
|
||||
<!--
|
||||
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>cloud-services</artifactId>
|
||||
<version>4.2.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${cs.log4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>${cs.gson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>${cs.codec.version}</version>
|
||||
</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-patches</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<plugins>
|
||||
<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>
|
||||
</arguments>
|
||||
<systemProperties>
|
||||
<systemProperty>
|
||||
<key>javax.net.ssl.trustStore</key>
|
||||
<value>certs/realhostip.keystore</value>
|
||||
</systemProperty>
|
||||
</systemProperties>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>vmware</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>nonoss</name>
|
||||
</property>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-plugin-hypervisor-vmware</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-vmware-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
63
services/secondary-storage/scripts/_run.sh
Executable file
63
services/secondary-storage/scripts/_run.sh
Executable file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
# 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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#run.sh runs the console proxy.
|
||||
|
||||
# make sure we delete the old files from the original template
|
||||
rm console-proxy.jar
|
||||
rm console-common.jar
|
||||
rm conf/cloud.properties
|
||||
|
||||
set -x
|
||||
|
||||
CP=./:./conf
|
||||
for file in *.jar
|
||||
do
|
||||
CP=${CP}:$file
|
||||
done
|
||||
keyvalues=
|
||||
|
||||
CMDLINE=$(cat /var/cache/cloud/cmdline)
|
||||
|
||||
#CMDLINE="graphical utf8 eth0ip=0.0.0.0 eth0mask=255.255.255.0 eth1ip=192.168.140.40 eth1mask=255.255.255.0 eth2ip=172.24.0.50 eth2mask=255.255.0.0 gateway=172.24.0.1 dns1=72.52.126.11 template=domP dns2=72.52.126.12 host=192.168.1.142 port=8250 mgmtcidr=192.168.1.0/24 localgw=192.168.140.1 zone=5 pod=5"
|
||||
for i in $CMDLINE
|
||||
do
|
||||
KEY=$(echo $i | cut -s -d= -f1)
|
||||
VALUE=$(echo $i | cut -s -d= -f2)
|
||||
[ "$KEY" == "" ] && continue
|
||||
case $KEY in
|
||||
*)
|
||||
keyvalues="${keyvalues} $KEY=$VALUE"
|
||||
esac
|
||||
done
|
||||
|
||||
tot_mem_k=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}')
|
||||
let "tot_mem_m=tot_mem_k>>10"
|
||||
let "eightypcnt=$tot_mem_m*8/10"
|
||||
let "maxmem=$tot_mem_m-80"
|
||||
|
||||
if [ $maxmem -gt $eightypcnt ]
|
||||
then
|
||||
maxmem=$eightypcnt
|
||||
fi
|
||||
|
||||
java -Djavax.net.ssl.trustStore=./certs/realhostip.keystore -mx${maxmem}m -cp $CP com.cloud.agent.AgentShell $keyvalues $@
|
||||
69
services/secondary-storage/scripts/config_auth.sh
Executable file
69
services/secondary-storage/scripts/config_auth.sh
Executable file
@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
# 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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BASE_DIR="/var/www/html/copy/template/"
|
||||
HTACCESS="$BASE_DIR/.htaccess"
|
||||
|
||||
PASSWDFILE="/etc/httpd/.htpasswd"
|
||||
if [ -d /etc/apache2 ]
|
||||
then
|
||||
PASSWDFILE="/etc/apache2/.htpasswd"
|
||||
fi
|
||||
|
||||
config_htaccess() {
|
||||
mkdir -p $BASE_DIR
|
||||
result=$?
|
||||
echo "Options -Indexes" > $HTACCESS
|
||||
let "result=$result+$?"
|
||||
echo "AuthType Basic" >> $HTACCESS
|
||||
let "result=$result+$?"
|
||||
echo "AuthName \"Authentication Required\"" >> $HTACCESS
|
||||
let "result=$result+$?"
|
||||
echo "AuthUserFile \"$PASSWDFILE\"" >> $HTACCESS
|
||||
let "result=$result+$?"
|
||||
echo "Require valid-user" >> $HTACCESS
|
||||
let "result=$result+$?"
|
||||
return $result
|
||||
}
|
||||
|
||||
write_passwd() {
|
||||
local user=$1
|
||||
local passwd=$2
|
||||
htpasswd -bc $PASSWDFILE $user $passwd
|
||||
return $?
|
||||
}
|
||||
|
||||
if [ $# -ne 2 ] ; then
|
||||
echo $"Usage: `basename $0` username password "
|
||||
exit 0
|
||||
fi
|
||||
|
||||
write_passwd $1 $2
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "Failed to update password"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
config_htaccess
|
||||
exit $?
|
||||
174
services/secondary-storage/scripts/config_ssl.sh
Executable file
174
services/secondary-storage/scripts/config_ssl.sh
Executable file
@ -0,0 +1,174 @@
|
||||
#!/usr/bin/env bash
|
||||
# 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.
|
||||
|
||||
|
||||
|
||||
|
||||
help() {
|
||||
printf " -c use customized key/cert\n"
|
||||
printf " -k path of private key\n"
|
||||
printf " -p path of certificate of public key\n"
|
||||
printf " -t path of certificate chain\n"
|
||||
}
|
||||
|
||||
|
||||
config_httpd_conf() {
|
||||
local ip=$1
|
||||
local srvr=$2
|
||||
cp -f /etc/httpd/conf/httpd.conf.orig /etc/httpd/conf/httpd.conf
|
||||
sed -i -e "s/Listen.*:80$/Listen $ip:80/" /etc/httpd/conf/httpd.conf
|
||||
echo "<VirtualHost $ip:443> " >> /etc/httpd/conf/httpd.conf
|
||||
echo " DocumentRoot /var/www/html/" >> /etc/httpd/conf/httpd.conf
|
||||
echo " ServerName $srvr" >> /etc/httpd/conf/httpd.conf
|
||||
echo " SSLEngine on" >> /etc/httpd/conf/httpd.conf
|
||||
echo " SSLCertificateFile /etc/httpd/ssl/certs/realhostip.crt" >> /etc/httpd/conf/httpd.conf
|
||||
echo " SSLCertificateKeyFile /etc/httpd/ssl/keys/realhostip.key" >> /etc/httpd/conf/httpd.conf
|
||||
echo "</VirtualHost>" >> /etc/httpd/conf/httpd.conf
|
||||
}
|
||||
|
||||
config_apache2_conf() {
|
||||
local ip=$1
|
||||
local srvr=$2
|
||||
cp -f /etc/apache2/sites-available/default.orig /etc/apache2/sites-available/default
|
||||
cp -f /etc/apache2/sites-available/default-ssl.orig /etc/apache2/sites-available/default-ssl
|
||||
sed -i -e "s/<VirtualHost.*>/<VirtualHost $ip:80>/" /etc/apache2/sites-available/default
|
||||
sed -i -e "s/<VirtualHost.*>/<VirtualHost $ip:443>/" /etc/apache2/sites-available/default-ssl
|
||||
sed -i -e "s/Listen .*:80/Listen $ip:80/g" /etc/apache2/ports.conf
|
||||
sed -i -e "s/Listen .*:443/Listen $ip:443/g" /etc/apache2/ports.conf
|
||||
sed -i -e "s/NameVirtualHost .*:80/NameVirtualHost $ip:80/g" /etc/apache2/ports.conf
|
||||
sed -i 's/ssl-cert-snakeoil.key/cert_apache.key/' /etc/apache2/sites-available/default-ssl
|
||||
sed -i 's/ssl-cert-snakeoil.pem/cert_apache.crt/' /etc/apache2/sites-available/default-ssl
|
||||
}
|
||||
|
||||
copy_certs() {
|
||||
local certdir=$(dirname $0)/certs
|
||||
local mydir=$(dirname $0)
|
||||
if [ -d $certdir ] && [ -f $customPrivKey ] && [ -f $customPrivCert ] ; then
|
||||
mkdir -p /etc/httpd/ssl/keys && mkdir -p /etc/httpd/ssl/certs && cp $customprivKey /etc/httpd/ssl/keys && cp $customPrivCert /etc/httpd/ssl/certs
|
||||
return $?
|
||||
fi
|
||||
if [ ! -z customCertChain ] && [ -f $customCertChain ] ; then
|
||||
cp $customCertChain /etc/httpd/ssl/certs
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
copy_certs_apache2() {
|
||||
local certdir=$(dirname $0)/certs
|
||||
local mydir=$(dirname $0)
|
||||
if [ -f $customPrivKey ] && [ -f $customPrivCert ] ; then
|
||||
cp $customPrivKey /etc/ssl/private/cert_apache.key && cp $customPrivCert /etc/ssl/certs/cert_apache.crt
|
||||
fi
|
||||
if [ ! -z "$customCertChain" ] && [ -f "$customCertChain" ] ; then
|
||||
cp $customCertChain /etc/ssl/certs/cert_apache_chain.crt
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
cflag=
|
||||
cpkflag=
|
||||
cpcflag=
|
||||
cccflag=
|
||||
customPrivKey=$(dirname $0)/certs/realhostip.key
|
||||
customPrivCert=$(dirname $0)/certs/realhostip.crt
|
||||
customCertChain=
|
||||
publicIp=
|
||||
hostName=
|
||||
while getopts 'i:h:k:p:t:c' OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
c) cflag=1
|
||||
;;
|
||||
k) cpkflag=1
|
||||
customPrivKey="$OPTARG"
|
||||
;;
|
||||
p) cpcflag=1
|
||||
customPrivCert="$OPTARG"
|
||||
;;
|
||||
t) cccflag=1
|
||||
customCertChain="$OPTARG"
|
||||
;;
|
||||
i) publicIp="$OPTARG"
|
||||
;;
|
||||
h) hostName="$OPTARG"
|
||||
;;
|
||||
?) help
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
if [ -z "$publicIp" ] || [ -z "$hostName" ]
|
||||
then
|
||||
help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$cflag" == "1" ]
|
||||
then
|
||||
if [ "$cpkflag$cpcflag" != "11" ]
|
||||
then
|
||||
help
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$customPrivKey" ]
|
||||
then
|
||||
printf "priviate key file is not exist\n"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ ! -f "$customPrivCert" ]
|
||||
then
|
||||
printf "public certificate is not exist\n"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
if [ "$cccflag" == "1" ]
|
||||
then
|
||||
if [ ! -f "$customCertChain" ]
|
||||
then
|
||||
printf "certificate chain is not exist\n"
|
||||
exit 4
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -d /etc/apache2 ]
|
||||
then
|
||||
copy_certs_apache2
|
||||
else
|
||||
copy_certs
|
||||
fi
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "Failed to copy certificates"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ -d /etc/apache2 ]
|
||||
then
|
||||
config_apache2_conf $publicIp $hostName
|
||||
/etc/init.d/apache2 stop
|
||||
/etc/init.d/apache2 start
|
||||
else
|
||||
config_httpd_conf $publicIp $hostName
|
||||
fi
|
||||
|
||||
|
||||
50
services/secondary-storage/scripts/ipfirewall.sh
Executable file
50
services/secondary-storage/scripts/ipfirewall.sh
Executable file
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
# 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.
|
||||
|
||||
BASE_DIR="/var/www/html/copy/"
|
||||
HTACCESS="$BASE_DIR/.htaccess"
|
||||
|
||||
config_htaccess() {
|
||||
mkdir -p $BASE_DIR
|
||||
result=$?
|
||||
echo "Options -Indexes" > $HTACCESS
|
||||
let "result=$result+$?"
|
||||
echo "order deny,allow" >> $HTACCESS
|
||||
let "result=$result+$?"
|
||||
echo "deny from all" >> $HTACCESS
|
||||
let "result=$result+$?"
|
||||
return $result
|
||||
}
|
||||
|
||||
ips(){
|
||||
echo "allow from $1" >> $HTACCESS
|
||||
result=$?
|
||||
return $result
|
||||
}
|
||||
|
||||
is_append="$1"
|
||||
shift
|
||||
if [ $is_append != "true" ]; then
|
||||
config_htaccess
|
||||
fi
|
||||
for i in $@
|
||||
do
|
||||
ips "$i"
|
||||
done
|
||||
exit $?
|
||||
|
||||
48
services/secondary-storage/scripts/run-proxy.sh
Normal file
48
services/secondary-storage/scripts/run-proxy.sh
Normal file
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
# 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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#run.sh runs the console proxy.
|
||||
|
||||
# make sure we delete the old files from the original template
|
||||
rm console-proxy.jar
|
||||
rm console-common.jar
|
||||
rm conf/cloud.properties
|
||||
|
||||
CP=./:./conf
|
||||
for file in *.jar
|
||||
do
|
||||
CP=${CP}:$file
|
||||
done
|
||||
|
||||
#CMDLINE=$(cat /proc/cmdline)
|
||||
#for i in $CMDLINE
|
||||
# do
|
||||
# KEY=$(echo $i | cut -d= -f1)
|
||||
# VALUE=$(echo $i | cut -d= -f2)
|
||||
# case $KEY in
|
||||
# mgmt_host)
|
||||
# MGMT_HOST=$VALUE
|
||||
# ;;
|
||||
# esac
|
||||
# done
|
||||
|
||||
java -mx700m -cp $CP:./conf com.cloud.consoleproxy.ConsoleProxy $@
|
||||
18
services/secondary-storage/scripts/run.bat
Normal file
18
services/secondary-storage/scripts/run.bat
Normal file
@ -0,0 +1,18 @@
|
||||
rem Licensed to the Apache Software Foundation (ASF) under one
|
||||
rem or more contributor license agreements. See the NOTICE file
|
||||
rem distributed with this work for additional information
|
||||
rem regarding copyright ownership. The ASF licenses this file
|
||||
rem to you under the Apache License, Version 2.0 (the
|
||||
rem "License"); you may not use this file except in compliance
|
||||
rem with the License. You may obtain a copy of the License at
|
||||
rem
|
||||
rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
rem
|
||||
rem Unless required by applicable law or agreed to in writing,
|
||||
rem software distributed under the License is distributed on an
|
||||
rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
rem KIND, either express or implied. See the License for the
|
||||
rem specific language governing permissions and limitations
|
||||
rem under the License.
|
||||
|
||||
java -mx700m -cp cloud-console-proxy.jar;;cloud-console-common.jar;log4j-1.2.15.jar;apache-log4j-extras-1.0.jar;gson-1.3.jar;commons-logging-1.1.1.jar;.;.\conf; com.cloud.consoleproxy.ConsoleProxy %*
|
||||
45
services/secondary-storage/scripts/run.sh
Executable file
45
services/secondary-storage/scripts/run.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
# 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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#_run.sh runs the agent client.
|
||||
|
||||
# set -x
|
||||
|
||||
while true
|
||||
do
|
||||
./_run.sh "$@" &
|
||||
wait
|
||||
ex=$?
|
||||
if [ $ex -eq 0 ] || [ $ex -eq 1 ] || [ $ex -eq 66 ] || [ $ex -gt 128 ]; then
|
||||
# permanent errors
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
# user stop agent by service cloud stop
|
||||
grep 'stop' /usr/local/cloud/systemvm/user_request &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
timestamp=$(date)
|
||||
echo "$timestamp User stops cloud.com service" >> /var/log/cloud.log
|
||||
exit 0
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
136
services/secondary-storage/scripts/ssvm-check.sh
Normal file
136
services/secondary-storage/scripts/ssvm-check.sh
Normal file
@ -0,0 +1,136 @@
|
||||
#!/usr/bin/env bash
|
||||
# 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.
|
||||
|
||||
|
||||
# Health check script for the Secondary Storage VM
|
||||
|
||||
# DNS server is specified.
|
||||
|
||||
|
||||
CMDLINE=/var/cache/cloud/cmdline
|
||||
for i in `cat $CMDLINE`
|
||||
do
|
||||
key=`echo $i | cut -d= -f1`
|
||||
value=`echo $i | cut -d= -f2`
|
||||
case $key in
|
||||
host)
|
||||
MGMTSERVER=$value
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
# ping dns server
|
||||
echo ================================================
|
||||
DNSSERVER=`egrep '^nameserver' /etc/resolv.conf | awk '{print $2}'| head -1`
|
||||
echo "First DNS server is " $DNSSERVER
|
||||
ping -c 2 $DNSSERVER
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "Good: Can ping DNS server"
|
||||
else
|
||||
echo "WARNING: cannot ping DNS server"
|
||||
echo "route follows"
|
||||
route -n
|
||||
fi
|
||||
|
||||
|
||||
# check dns resolve
|
||||
echo ================================================
|
||||
nslookup download.cloud.com 1> /tmp/dns 2>&1
|
||||
grep 'no servers could' /tmp/dns 1> /dev/null 2>&1
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "ERROR: DNS not resolving download.cloud.com"
|
||||
echo resolv.conf follows
|
||||
cat /etc/resolv.conf
|
||||
exit 2
|
||||
else
|
||||
echo "Good: DNS resolves download.cloud.com"
|
||||
fi
|
||||
|
||||
|
||||
# check to see if we have the NFS volume mounted
|
||||
echo ================================================
|
||||
mount|grep -v sunrpc|grep nfs 1> /dev/null 2>&1
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "NFS is currently mounted"
|
||||
# check for write access
|
||||
for MOUNTPT in `mount|grep -v sunrpc|grep nfs| awk '{print $3}'`
|
||||
do
|
||||
if [ $MOUNTPT != "/proc/xen" ] # mounted by xen
|
||||
then
|
||||
echo Mount point is $MOUNTPT
|
||||
touch $MOUNTPT/foo
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "Good: Can write to mount point"
|
||||
rm $MOUNTPT/foo
|
||||
else
|
||||
echo "ERROR: Cannot write to mount point"
|
||||
echo "You need to export with norootsquash"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "ERROR: NFS is not currently mounted"
|
||||
echo "Try manually mounting from inside the VM"
|
||||
NFSSERVER=`awk '{print $17}' $CMDLINE|awk -F= '{print $2}'|awk -F: '{print $1}'`
|
||||
echo "NFS server is " $NFSSERVER
|
||||
ping -c 2 $NFSSERVER
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "Good: Can ping NFS server"
|
||||
else
|
||||
echo "WARNING: cannot ping NFS server"
|
||||
echo routing table follows
|
||||
route -n
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# check for connectivity to the management server
|
||||
echo ================================================
|
||||
echo Management server is $MGMTSERVER. Checking connectivity.
|
||||
socatout=$(echo | socat - TCP:$MGMTSERVER:8250,connect-timeout=3 2>&1)
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "Good: Can connect to management server port 8250"
|
||||
else
|
||||
echo "ERROR: Cannot connect to $MGMTSERVER port 8250"
|
||||
echo $socatout
|
||||
exit 4
|
||||
fi
|
||||
|
||||
|
||||
# check for the java process running
|
||||
echo ================================================
|
||||
ps -eaf|grep -v grep|grep java 1> /dev/null 2>&1
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "Good: Java process is running"
|
||||
else
|
||||
echo "ERROR: Java process not running. Try restarting the SSVM."
|
||||
exit 3
|
||||
fi
|
||||
|
||||
echo ================================================
|
||||
echo Tests Complete. Look for ERROR or WARNING above.
|
||||
|
||||
exit 0
|
||||
@ -14,7 +14,7 @@
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.storage.resource;
|
||||
package org.apache.cloudstack.storage.resource;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetAddress;
|
||||
@ -27,6 +27,10 @@ import java.util.Random;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.storage.template.DownloadManager;
|
||||
import org.apache.cloudstack.storage.template.DownloadManagerImpl;
|
||||
import org.apache.cloudstack.storage.template.UploadManager;
|
||||
import org.apache.cloudstack.storage.template.UploadManagerImpl;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
@ -58,11 +62,7 @@ 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.DownloadManager;
|
||||
import com.cloud.storage.template.DownloadManagerImpl;
|
||||
import com.cloud.storage.template.TemplateInfo;
|
||||
import com.cloud.storage.template.UploadManager;
|
||||
import com.cloud.storage.template.UploadManagerImpl;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
@ -14,13 +14,15 @@
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.storage.resource;
|
||||
package org.apache.cloudstack.storage.resource;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.storage.template.DownloadManager;
|
||||
import org.apache.cloudstack.storage.template.DownloadManagerImpl;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
@ -46,8 +48,6 @@ 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.DownloadManager;
|
||||
import com.cloud.storage.template.DownloadManagerImpl;
|
||||
import com.cloud.storage.template.TemplateInfo;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.storage.resource;
|
||||
package org.apache.cloudstack.storage.resource;
|
||||
|
||||
import static com.cloud.utils.S3Utils.deleteDirectory;
|
||||
import static com.cloud.utils.S3Utils.getDirectory;
|
||||
@ -46,6 +46,11 @@ import java.util.concurrent.Callable;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.storage.template.DownloadManager;
|
||||
import org.apache.cloudstack.storage.template.DownloadManagerImpl;
|
||||
import org.apache.cloudstack.storage.template.DownloadManagerImpl.ZfsPathParser;
|
||||
import org.apache.cloudstack.storage.template.UploadManager;
|
||||
import org.apache.cloudstack.storage.template.UploadManagerImpl;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
@ -97,18 +102,12 @@ import com.cloud.host.Host;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.resource.ServerResourceBase;
|
||||
import com.cloud.storage.StorageLayer;
|
||||
import com.cloud.storage.template.DownloadManager;
|
||||
import com.cloud.storage.template.DownloadManagerImpl;
|
||||
import com.cloud.storage.template.DownloadManagerImpl.ZfsPathParser;
|
||||
import com.cloud.storage.template.TemplateInfo;
|
||||
import com.cloud.storage.template.TemplateLocation;
|
||||
import com.cloud.storage.template.UploadManager;
|
||||
import com.cloud.storage.template.UploadManagerImpl;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.S3Utils;
|
||||
import com.cloud.utils.S3Utils.FileNamingStrategy;
|
||||
import com.cloud.utils.S3Utils.ObjectNamingStrategy;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.utils.script.OutputInterpreter;
|
||||
@ -133,7 +132,7 @@ SecondaryStorageResource {
|
||||
String _role;
|
||||
Map<String, Object> _params;
|
||||
StorageLayer _storage;
|
||||
boolean _inSystemVM = false;
|
||||
protected boolean _inSystemVM = false;
|
||||
boolean _sslCopy = false;
|
||||
|
||||
DownloadManager _dlMgr;
|
||||
@ -150,7 +149,7 @@ SecondaryStorageResource {
|
||||
private String _storageNetmask;
|
||||
private String _storageGateway;
|
||||
private final List<String> nfsIps = new ArrayList<String>();
|
||||
final private String _parent = "/mnt/SecStorage";
|
||||
private String _parent = "/mnt/SecStorage";
|
||||
final private String _tmpltDir = "/var/cloudstack/template";
|
||||
final private String _tmpltpp = "template.properties";
|
||||
@Override
|
||||
@ -397,8 +396,8 @@ SecondaryStorageResource {
|
||||
@Override
|
||||
public boolean accept(final File directory,
|
||||
final String fileName) {
|
||||
File fileToUpload = new File(directory.getAbsolutePath() + "/" + fileName);
|
||||
return !fileName.startsWith(".") && !fileToUpload.isDirectory();
|
||||
File fileToUpload = new File(directory.getAbsolutePath() + "/" + fileName);
|
||||
return !fileName.startsWith(".") && !fileToUpload.isDirectory();
|
||||
}
|
||||
}, new ObjectNamingStrategy() {
|
||||
@Override
|
||||
@ -1107,9 +1106,7 @@ SecondaryStorageResource {
|
||||
}
|
||||
|
||||
private Answer execute(ListTemplateCommand cmd) {
|
||||
if (!_inSystemVM){
|
||||
return new Answer(cmd, true, null);
|
||||
}
|
||||
|
||||
if (cmd.getSwift() != null) {
|
||||
Map<String, TemplateInfo> templateInfos = swiftListTemplate(cmd.getSwift());
|
||||
return new ListTemplateAnswer(cmd.getSwift().toString(), templateInfos);
|
||||
@ -1121,9 +1118,6 @@ SecondaryStorageResource {
|
||||
}
|
||||
|
||||
private Answer execute(ListVolumeCommand cmd) {
|
||||
if (!_inSystemVM){
|
||||
return new Answer(cmd, true, null);
|
||||
}
|
||||
|
||||
String root = getRootDir(cmd.getSecUrl());
|
||||
Map<Long, TemplateInfo> templateInfos = _dlMgr.gatherVolumeInfo(root);
|
||||
@ -1217,7 +1211,9 @@ SecondaryStorageResource {
|
||||
}
|
||||
|
||||
public String allowOutgoingOnPrivate(String destCidr) {
|
||||
|
||||
if (!_inSystemVM) {
|
||||
return null;
|
||||
}
|
||||
Script command = new Script("/bin/bash", s_logger);
|
||||
String intf = "eth1";
|
||||
command.add("-c");
|
||||
@ -1392,6 +1388,9 @@ SecondaryStorageResource {
|
||||
|
||||
|
||||
synchronized public String getRootDir(String secUrl) {
|
||||
if (!_inSystemVM) {
|
||||
return _parent;
|
||||
}
|
||||
try {
|
||||
URI uri = new URI(secUrl);
|
||||
String nfsHost = uri.getHost();
|
||||
@ -1474,6 +1473,11 @@ SecondaryStorageResource {
|
||||
_publicIp = (String) params.get("eth2ip");
|
||||
_hostname = (String) params.get("name");
|
||||
|
||||
String inSystemVM = (String) params.get("secondary.storage.vm");
|
||||
if (inSystemVM == null || "true".equalsIgnoreCase(inSystemVM)) {
|
||||
_inSystemVM = true;
|
||||
}
|
||||
|
||||
_storageIp = (String) params.get("storageip");
|
||||
if (_storageIp == null) {
|
||||
s_logger.warn("Wait, there is no storageip in /proc/cmdline, something wrong!");
|
||||
@ -1505,7 +1509,10 @@ SecondaryStorageResource {
|
||||
throw new ConfigurationException("Unable to find class " + value);
|
||||
}
|
||||
}
|
||||
_storage.mkdirs(_parent);
|
||||
|
||||
if (_inSystemVM)
|
||||
_storage.mkdirs(_parent);
|
||||
|
||||
_configSslScr = Script.findScript(getDefaultScriptsDir(), "config_ssl.sh");
|
||||
if (_configSslScr != null) {
|
||||
s_logger.info("config_ssl.sh found in " + _configSslScr);
|
||||
@ -1539,10 +1546,12 @@ SecondaryStorageResource {
|
||||
|
||||
_instance = (String)params.get("instance");
|
||||
|
||||
if (!_inSystemVM) {
|
||||
_parent = (String) params.get("mount.path");
|
||||
}
|
||||
|
||||
String inSystemVM = (String)params.get("secondary.storage.vm");
|
||||
if (inSystemVM == null || "true".equalsIgnoreCase(inSystemVM)) {
|
||||
_inSystemVM = true;
|
||||
|
||||
if (_inSystemVM) {
|
||||
_localgw = (String)params.get("localgw");
|
||||
if (_localgw != null) { // can only happen inside service vm
|
||||
String mgmtHost = (String) params.get("host");
|
||||
@ -1581,6 +1590,9 @@ SecondaryStorageResource {
|
||||
}
|
||||
|
||||
private void startAdditionalServices() {
|
||||
if (!_inSystemVM) {
|
||||
return;
|
||||
}
|
||||
Script command = new Script("/bin/bash", s_logger);
|
||||
command.add("-c");
|
||||
command.add("if [ -f /etc/init.d/ssh ]; then service ssh restart; else service sshd restart; fi ");
|
||||
@ -1598,6 +1610,9 @@ SecondaryStorageResource {
|
||||
}
|
||||
|
||||
private void addRouteToInternalIpOrCidr(String localgw, String eth1ip, String eth1mask, String destIpOrCidr) {
|
||||
if (!_inSystemVM) {
|
||||
return;
|
||||
}
|
||||
s_logger.debug("addRouteToInternalIp: localgw=" + localgw + ", eth1ip=" + eth1ip + ", eth1mask=" + eth1mask + ",destIp=" + destIpOrCidr);
|
||||
if (destIpOrCidr == null) {
|
||||
s_logger.debug("addRouteToInternalIp: destIp is null");
|
||||
@ -1637,6 +1652,9 @@ SecondaryStorageResource {
|
||||
}
|
||||
|
||||
private void configureSSL() {
|
||||
if (!_inSystemVM) {
|
||||
return;
|
||||
}
|
||||
Script command = new Script(_configSslScr);
|
||||
command.add("-i", _publicIp);
|
||||
command.add("-h", _hostname);
|
||||
@ -1647,6 +1665,9 @@ SecondaryStorageResource {
|
||||
}
|
||||
|
||||
private void configureSSL(String prvkeyPath, String prvCertPath, String certChainPath) {
|
||||
if (!_inSystemVM) {
|
||||
return;
|
||||
}
|
||||
Script command = new Script(_configSslScr);
|
||||
command.add("-i", _publicIp);
|
||||
command.add("-h", _hostname);
|
||||
@ -1758,13 +1779,15 @@ SecondaryStorageResource {
|
||||
if(_publicIp != null)
|
||||
cmd.setPublicIpAddress(_publicIp);
|
||||
|
||||
Script command = new Script("/bin/bash", s_logger);
|
||||
command.add("-c");
|
||||
command.add("ln -sf " + _parent + " /var/www/html/copy");
|
||||
String result = command.execute();
|
||||
if (result != null) {
|
||||
s_logger.warn("Error in linking err=" + result);
|
||||
return null;
|
||||
if (_inSystemVM) {
|
||||
Script command = new Script("/bin/bash", s_logger);
|
||||
command.add("-c");
|
||||
command.add("ln -sf " + _parent + " /var/www/html/copy");
|
||||
String result = command.execute();
|
||||
if (result != null) {
|
||||
s_logger.warn("Error in linking err=" + result);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return new StartupCommand[] {cmd};
|
||||
}
|
||||
@ -1810,33 +1833,50 @@ SecondaryStorageResource {
|
||||
return "./scripts/storage/secondary";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@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 void setConfigParams(Map<String, Object> params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@Override
|
||||
public int getRunLevel() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRunLevel(int level) {
|
||||
// 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
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillNetworkInformation(final StartupCommand cmd) {
|
||||
final String dummyMac = "00:06:0A:0B:0C:0D";
|
||||
final String dummyNetmask = "255.255.255.0";
|
||||
if (!_inSystemVM) {
|
||||
cmd.setPrivateIpAddress(_eth1ip);
|
||||
cmd.setPrivateMacAddress(dummyMac);
|
||||
cmd.setPrivateNetmask(dummyNetmask);
|
||||
cmd.setPublicIpAddress(_publicIp);
|
||||
cmd.setPublicMacAddress(dummyMac);
|
||||
cmd.setPublicNetmask(dummyNetmask);
|
||||
cmd.setName(_hostname);
|
||||
} else {
|
||||
super.fillNetworkInformation(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -14,7 +14,7 @@
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.storage.resource;
|
||||
package org.apache.cloudstack.storage.resource;
|
||||
import com.cloud.agent.api.storage.ssCommand;
|
||||
import com.cloud.resource.ServerResource;
|
||||
/**
|
||||
@ -14,7 +14,7 @@
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.storage.resource;
|
||||
package org.apache.cloudstack.storage.resource;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
@ -14,18 +14,20 @@
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.storage.template;
|
||||
package org.apache.cloudstack.storage.template;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.storage.resource.SecondaryStorageResource;
|
||||
|
||||
import com.cloud.agent.api.storage.DownloadAnswer;
|
||||
import com.cloud.agent.api.storage.DownloadCommand;
|
||||
import com.cloud.agent.api.storage.DownloadCommand.Proxy;
|
||||
import com.cloud.agent.api.storage.DownloadCommand.ResourceType;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.resource.SecondaryStorageResource;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.template.TemplateDownloader;
|
||||
import com.cloud.storage.template.TemplateInfo;
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
||||
public interface DownloadManager extends Manager {
|
||||
@ -14,7 +14,7 @@
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.storage.template;
|
||||
package org.apache.cloudstack.storage.template;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@ -41,6 +41,7 @@ import java.util.concurrent.Executors;
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.storage.resource.SecondaryStorageResource;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.storage.DownloadAnswer;
|
||||
@ -54,10 +55,22 @@ import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.StorageLayer;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
import com.cloud.storage.resource.SecondaryStorageResource;
|
||||
import com.cloud.storage.template.HttpTemplateDownloader;
|
||||
import com.cloud.storage.template.IsoProcessor;
|
||||
import com.cloud.storage.template.LocalTemplateDownloader;
|
||||
import com.cloud.storage.template.Processor;
|
||||
import com.cloud.storage.template.Processor.FormatInfo;
|
||||
import com.cloud.storage.template.QCOW2Processor;
|
||||
import com.cloud.storage.template.RawImageProcessor;
|
||||
import com.cloud.storage.template.ScpTemplateDownloader;
|
||||
import com.cloud.storage.template.TemplateConstants;
|
||||
import com.cloud.storage.template.TemplateDownloader;
|
||||
import com.cloud.storage.template.TemplateDownloader.DownloadCompleteCallback;
|
||||
import com.cloud.storage.template.TemplateDownloader.Status;
|
||||
import com.cloud.storage.template.TemplateInfo;
|
||||
import com.cloud.storage.template.TemplateLocation;
|
||||
import com.cloud.storage.template.VhdProcessor;
|
||||
import com.cloud.storage.template.VmdkProcessor;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
@ -743,21 +756,27 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
|
||||
|
||||
TemplateInfo tInfo = loc.getTemplateInfo();
|
||||
|
||||
if ((tInfo.size == tInfo.physicalSize) && (tInfo.installPath.endsWith(ImageFormat.OVA.getFileExtension()))) {
|
||||
if ((tInfo.getSize() == tInfo.getPhysicalSize())
|
||||
&& (tInfo.getInstallPath().endsWith(ImageFormat.OVA.getFileExtension()))) {
|
||||
try {
|
||||
Processor processor = _processors.get("VMDK Processor");
|
||||
VmdkProcessor vmdkProcessor = (VmdkProcessor)processor;
|
||||
long vSize = vmdkProcessor.getTemplateVirtualSize(path, tInfo.installPath.substring(tInfo.installPath.lastIndexOf(File.separator) + 1));
|
||||
tInfo.size = vSize;
|
||||
long vSize =
|
||||
vmdkProcessor.getTemplateVirtualSize(
|
||||
path,
|
||||
tInfo.getInstallPath().substring(
|
||||
tInfo.getInstallPath().lastIndexOf(File.separator) + 1));
|
||||
tInfo.setSize(vSize);
|
||||
loc.updateVirtualSize(vSize);
|
||||
loc.save();
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Unable to get the virtual size of the template: " + tInfo.installPath + " due to " + e.getMessage());
|
||||
s_logger.error("Unable to get the virtual size of the template: " + tInfo.getInstallPath()
|
||||
+ " due to " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
result.put(tInfo.templateName, tInfo);
|
||||
s_logger.debug("Added template name: " + tInfo.templateName + ", path: " + tmplt);
|
||||
result.put(tInfo.getTemplateName(), tInfo);
|
||||
s_logger.debug("Added template name: " + tInfo.getTemplateName() + ", path: " + tmplt);
|
||||
}
|
||||
/*
|
||||
for (String tmplt : isoTmplts) {
|
||||
@ -800,21 +819,27 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
|
||||
|
||||
TemplateInfo vInfo = loc.getTemplateInfo();
|
||||
|
||||
if ((vInfo.size == vInfo.physicalSize) && (vInfo.installPath.endsWith(ImageFormat.OVA.getFileExtension()))) {
|
||||
if ((vInfo.getSize() == vInfo.getPhysicalSize())
|
||||
&& (vInfo.getInstallPath().endsWith(ImageFormat.OVA.getFileExtension()))) {
|
||||
try {
|
||||
Processor processor = _processors.get("VMDK Processor");
|
||||
VmdkProcessor vmdkProcessor = (VmdkProcessor)processor;
|
||||
long vSize = vmdkProcessor.getTemplateVirtualSize(path, vInfo.installPath.substring(vInfo.installPath.lastIndexOf(File.separator) + 1));
|
||||
vInfo.size = vSize;
|
||||
long vSize =
|
||||
vmdkProcessor.getTemplateVirtualSize(
|
||||
path,
|
||||
vInfo.getInstallPath().substring(
|
||||
vInfo.getInstallPath().lastIndexOf(File.separator) + 1));
|
||||
vInfo.setSize(vSize);
|
||||
loc.updateVirtualSize(vSize);
|
||||
loc.save();
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Unable to get the virtual size of the volume: " + vInfo.installPath + " due to " + e.getMessage());
|
||||
s_logger.error("Unable to get the virtual size of the volume: " + vInfo.getInstallPath()
|
||||
+ " due to " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
result.put(vInfo.getId(), vInfo);
|
||||
s_logger.debug("Added volume name: " + vInfo.templateName + ", path: " + vol);
|
||||
s_logger.debug("Added volume name: " + vInfo.getTemplateName() + ", path: " + vol);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -14,7 +14,9 @@
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.storage.template;
|
||||
package org.apache.cloudstack.storage.template;
|
||||
|
||||
import org.apache.cloudstack.storage.resource.SecondaryStorageResource;
|
||||
|
||||
import com.cloud.agent.api.storage.CreateEntityDownloadURLAnswer;
|
||||
import com.cloud.agent.api.storage.CreateEntityDownloadURLCommand;
|
||||
@ -24,7 +26,7 @@ import com.cloud.agent.api.storage.UploadAnswer;
|
||||
import com.cloud.agent.api.storage.UploadCommand;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Upload.Status;
|
||||
import com.cloud.storage.resource.SecondaryStorageResource;
|
||||
import com.cloud.storage.template.TemplateUploader;
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
||||
public interface UploadManager extends Manager {
|
||||
@ -14,7 +14,7 @@
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.storage.template;
|
||||
package org.apache.cloudstack.storage.template;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
@ -30,6 +30,7 @@ import java.util.concurrent.Executors;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.storage.resource.SecondaryStorageResource;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.storage.CreateEntityDownloadURLAnswer;
|
||||
@ -43,7 +44,9 @@ import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.StorageLayer;
|
||||
import com.cloud.storage.Upload;
|
||||
import com.cloud.storage.UploadVO;
|
||||
import com.cloud.storage.resource.SecondaryStorageResource;
|
||||
import com.cloud.storage.template.FtpTemplateUploader;
|
||||
import com.cloud.storage.template.Processor;
|
||||
import com.cloud.storage.template.TemplateUploader;
|
||||
import com.cloud.storage.template.TemplateUploader.Status;
|
||||
import com.cloud.storage.template.TemplateUploader.UploadCompleteCallback;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
@ -142,5 +142,38 @@
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>quicksvr</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>quicksvr</name>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<executable>python</executable>
|
||||
<arguments>
|
||||
<argument>../marvin/marvin/deployDataCenter.py</argument>
|
||||
<argument>-i</argument>
|
||||
<argument>quickcloud.cfg</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
||||
120
tools/devcloud/quickcloud.cfg
Normal file
120
tools/devcloud/quickcloud.cfg
Normal file
@ -0,0 +1,120 @@
|
||||
# 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.
|
||||
#
|
||||
|
||||
{
|
||||
"zones": [
|
||||
{
|
||||
"name": "QuickCloud00",
|
||||
"enabled" : "True",
|
||||
"details" : [
|
||||
{"key" : "enable.secstorage.vm", "value": "False"},
|
||||
{"key" : "enable.consoleproxy.vm", "value": "False"}
|
||||
],
|
||||
"physical_networks": [
|
||||
{
|
||||
"broadcastdomainrange": "Zone",
|
||||
"name": "test-network",
|
||||
"traffictypes": [
|
||||
{
|
||||
"typ": "Guest"
|
||||
},
|
||||
{
|
||||
"typ": "Management"
|
||||
}
|
||||
],
|
||||
"providers": [
|
||||
{
|
||||
"broadcastdomainrange": "ZONE",
|
||||
"name": "VirtualRouter"
|
||||
},
|
||||
{
|
||||
"broadcastdomainrange": "Pod",
|
||||
"name": "SecurityGroupProvider"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"dns2": "4.4.4.4",
|
||||
"dns1": "8.8.8.8",
|
||||
"securitygroupenabled": "true",
|
||||
"localstorageenabled": "true",
|
||||
"networktype": "Basic",
|
||||
"pods": [
|
||||
{
|
||||
"endip": "192.168.56.220",
|
||||
"name": "test00",
|
||||
"startip": "192.168.56.200",
|
||||
"guestIpRanges": [
|
||||
{
|
||||
"startip": "192.168.56.100",
|
||||
"endip": "192.168.56.199",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "192.168.56.1"
|
||||
}
|
||||
],
|
||||
"netmask": "255.255.255.0",
|
||||
"clusters": [
|
||||
{
|
||||
"clustername": "test000",
|
||||
"hypervisor": "XenServer",
|
||||
"hosts": [
|
||||
{
|
||||
"username": "root",
|
||||
"url": "http://192.168.56.10/",
|
||||
"password": "password"
|
||||
}
|
||||
],
|
||||
"clustertype": "CloudManaged"
|
||||
}
|
||||
],
|
||||
"gateway": "192.168.56.1"
|
||||
}
|
||||
],
|
||||
"internaldns1": "192.168.56.1",
|
||||
"secondaryStorages": [
|
||||
{
|
||||
"url": "nfs://192.168.56.10:/opt/storage/secondary"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"logger": [
|
||||
{
|
||||
"name": "TestClient",
|
||||
"file": "testclient.log"
|
||||
},
|
||||
{
|
||||
"name": "TestCase",
|
||||
"file": "testcase.log"
|
||||
}
|
||||
],
|
||||
"mgtSvr": [
|
||||
{
|
||||
"mgtSvrIp": "127.0.0.1",
|
||||
"port": 8096
|
||||
}
|
||||
],
|
||||
"dbSvr":
|
||||
{
|
||||
"dbSvr": "127.0.0.1",
|
||||
"port": 3306,
|
||||
"user": "cloud",
|
||||
"passwd": "cloud",
|
||||
"db": "cloud"
|
||||
}
|
||||
}
|
||||
@ -162,9 +162,9 @@ class cloudConnection(object):
|
||||
else:
|
||||
requests.pop(param)
|
||||
i = 0
|
||||
for v in value:
|
||||
for key, val in v.iteritems():
|
||||
requests["%s[%d].%s"%(param,i,key)] = val
|
||||
for val in value:
|
||||
for k,v in val.iteritems():
|
||||
requests["%s[%d].%s"%(param,i,k)] = v
|
||||
i = i + 1
|
||||
|
||||
if self.logging is not None:
|
||||
|
||||
@ -270,6 +270,12 @@ class deployDataCenters():
|
||||
zoneCmd.allocationstate = allocation_state
|
||||
return self.apiClient.updateZone(zoneCmd)
|
||||
|
||||
def updateZoneDetails(self, zoneid, details):
|
||||
zoneCmd = updateZone.updateZoneCmd()
|
||||
zoneCmd.id = zoneid
|
||||
zoneCmd.details = details
|
||||
return self.apiClient.updateZone(zoneCmd)
|
||||
|
||||
def createZones(self, zones):
|
||||
for zone in zones:
|
||||
createzone = createZone.createZoneCmd()
|
||||
@ -320,7 +326,15 @@ class deployDataCenters():
|
||||
zoneId)
|
||||
|
||||
self.createSecondaryStorages(zone.secondaryStorages, zoneId)
|
||||
self.enableZone(zoneId, "Enabled")
|
||||
|
||||
enabled = getattr(zone, 'enabled', 'True')
|
||||
if enabled == 'True' or enabled == 'None':
|
||||
self.enableZone(zoneId, "Enabled")
|
||||
details = getattr(zone, 'details')
|
||||
if details is not None:
|
||||
det = [d.__dict__ for d in details]
|
||||
self.updateZoneDetails(zoneId, det)
|
||||
|
||||
return
|
||||
|
||||
def isEipElbZone(self, zone):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user