Merge branch 'master' into vpc

Conflicts:
	server/src/com/cloud/network/NetworkManagerImpl.java
	server/src/com/cloud/network/rules/RulesManagerImpl.java
This commit is contained in:
Alena Prokharchyk 2012-07-31 13:37:28 -07:00
commit 7706a9c32f
115 changed files with 1738 additions and 612 deletions

1
.gitignore vendored
View File

@ -16,7 +16,6 @@ dist/
cloud-*.tar.bz2
*.log
*.pyc
*.cfg
build.number
api.log.*.gz
cloud.log.*.*

View File

@ -1,4 +1,22 @@
<?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.
-->
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>

View File

@ -1,4 +1,22 @@
<?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.
-->
<projectDescription>
<name>agent</name>
<comment></comment>

View File

@ -18,7 +18,7 @@
# Sample configuration file for CloudStack agent
#resource= the java class, which agent load to execute
resource=com.cloud.agent.resource.computing.LibvirtComputingResource
resource=com.cloud.hypervisor.kvm.resource.LibvirtComputingResource
#workers= number of threads running in agent
workers=5

View File

@ -1,3 +1,20 @@
# 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.
resource=com.cloud.agent.resource.DummyResource
host.mac.address=06\:95\:a4\:00\:03\:ee
guest.network.device=cloudbr0

View File

@ -18,4 +18,4 @@
# management server compile-time environment parameters
paths.pid=@PIDDIR@
paths.scripts=@AGENTLIBDIR@
paths.script=@AGENTLIBDIR@

View File

@ -1,4 +1,22 @@
<?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">

View File

@ -1,3 +1,20 @@
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.
0. Contents
===========
../sbin/vnetd: userspace daemon that runs the vnet

View File

@ -1,3 +1,20 @@
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.
0. Contents
===========
sbin/vnetd: userspace daemon that runs the vnet

View File

@ -17,4 +17,4 @@
# under the License.
#run.sh runs the agent client.
java $1 -Xms128M -Xmx384M -cp cglib-nodep-2.2.jar:trilead-ssh2-build213.jar:cloud-api.jar:cloud-core-extras.jar:cloud-utils.jar:cloud-agent.jar:cloud-console-proxy.jar:cloud-console-common.jar:freemarker.jar:log4j-1.2.15.jar:ws-commons-util-1.0.2.jar:xmlrpc-client-3.1.3.jar:cloud-core.jar:xmlrpc-common-3.1.3.jar:javaee-api-5.0-1.jar:gson-1.3.jar:commons-httpclient-3.1.jar:commons-logging-1.1.1.jar:commons-codec-1.4.jar:commons-collections-3.2.1.jar:commons-pool-1.4.jar:apache-log4j-extras-1.0.jar:libvirt-0.4.5.jar:jna.jar:.:/etc/cloud:./conf com.cloud.agent.AgentShell
java $1 -Xms128M -Xmx384M -cp cglib-nodep-2.2.jar:trilead-ssh2-build213.jar:cloud-api.jar:cloud-core-extras.jar:cloud-utils.jar:cloud-agent.jar:cloud-console-proxy.jar:cloud-console-common.jar:freemarker.jar:log4j-1.2.15.jar:ws-commons-util-1.0.2.jar:xmlrpc-client-3.1.3.jar:cloud-core.jar:xmlrpc-common-3.1.3.jar:javaee-api-5.0-1.jar:gson-1.3.jar:commons-httpclient-3.1.jar:commons-logging-1.1.1.jar:commons-codec-1.4.jar:commons-collections-3.2.1.jar:commons-pool-1.4.jar:apache-log4j-extras-1.0.jar:libvirt-0.4.5.jar:jna.jar:.:/etc/cloud:./*:/usr/share/java/*:./conf com.cloud.agent.AgentShell

View File

@ -29,6 +29,9 @@ public class NicResponse extends BaseResponse {
@SerializedName("networkid") @Param(description="the ID of the corresponding network")
private final IdentityProxy networkId = new IdentityProxy("networks");
@SerializedName("networkname") @Param(description="the name of the corresponding network")
private String networkName ;
@SerializedName(ApiConstants.NETMASK) @Param(description="the netmask of the nic")
private String netmask;
@ -69,6 +72,10 @@ public class NicResponse extends BaseResponse {
this.networkId.setValue(networkid);
}
public void setNetworkName(String networkname) {
this.networkName = networkname;
}
public void setNetmask(String netmask) {
this.netmask = netmask;
}

View File

@ -0,0 +1,21 @@
// 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 com.cloud.network.element;
public interface ConnectivityProvider extends NetworkElement {
}

View File

@ -198,9 +198,14 @@
<!-- ===================== Hypervisors ========================= -->
<target name="compile-hypervisors" depends="compile-ovm, compile-xen, compile-vmware" description="Compile all hypervisors"/>
<target name="build-hypervisors" depends="build-ovm, build-xen, build-vmware" description="Builds all hypervisors"/>
<target name="compile-hypervisors" depends="compile-kvm, compile-ovm, compile-xen, compile-vmware" description="Compile all hypervisors"/>
<target name="build-hypervisors" depends="build-kvm, build-ovm, build-xen, build-vmware" description="Builds all hypervisors"/>
<target name="compile-kvm" depends="-init, compile-core, compile-agent" description="Compile KVM">
<ant antfile="${base.dir}/plugins/hypervisors/kvm/build.xml" target="build"/>
</target>
<target name="build-kvm" depends="compile-kvm" />
<target name="compile-ovm" depends="-init, compile-server" description="Compile OVM">
<ant antfile="${base.dir}/plugins/hypervisors/ovm/build.xml" target="build"/>
</target>

View File

@ -40,7 +40,7 @@
<target name="build-marvin" depends="build-apidocs" description="generates the cloudstackAPIs for marvin">
<echo message="Generating Marvin API Classes"/>
<exec dir="${marvin.src.dir}" executable="python">
<exec dir="${marvin.src.dir}" executable="python" failonerror="true">
<arg value="codegenerator.py" />
<arg value="-s" />
<arg value="${dist.dir}/commands.xml" />
@ -50,7 +50,7 @@
<target name="package-marvin" depends="build-marvin" description="create a distributable tarball of Marvin">
<echo message="Packaging Marvin"/>
<exec dir="${marvin.dir}" executable="python">
<exec dir="${marvin.dir}" executable="python" failonerror="true">
<arg value="setup.py" />
<arg value="sdist" />
</exec>

View File

@ -241,7 +241,7 @@
</condition>
<echo message="deploydb ${server-setup.file} ${templates.file} ${DBROOTPW}" />
<exec dir="${db.scripts.dir}" executable="bash">
<exec dir="${db.scripts.dir}" executable="bash" failonerror="true">
<arg value="deploy-db-dev.sh" />
<arg value="${server-setup.file}" />
<arg value="${templates.file}" />
@ -269,7 +269,7 @@
</condition>
<echo message="deploydb ${server-setup.file} ${templates.file} ${DBROOTPW}" />
<exec dir="${db.scripts.dir}" executable="bash">
<exec dir="${db.scripts.dir}" executable="bash" failonerror="true">
<arg value="deploy-db-simulator.sh" />
<arg value="${server-setup.file}" />
<arg value="${templates.file}" />
@ -401,7 +401,7 @@
<property name="commands.vr.file" location="${dist.dir}/client/conf/virtualrouter_commands.properties" />
<echo message="build-apidocs" />
<exec dir="${apidoc.scripts.dir}" executable="bash">
<exec dir="${apidoc.scripts.dir}" executable="bash" failonerror="true">
<arg value="build-apidoc.sh" />
<arg value="${target.dir}/jar" />
<arg value="${deps.dir}" />

View File

@ -82,7 +82,6 @@
<include name="cloud-commons-collections-3.2.1.jar" />
<include name="cloud-commons-codec-1.4.jar" />
<include name="cloud-commons-pool-1.4.jar" />
<include name="libvirt-0.4.8.jar" />
<include name="cloud-jna.jar" />
<include name="cloud-cglib.jar" />
<include name="jetty-6.1.26.jar" />
@ -93,6 +92,7 @@
<include name="${utils.jar}" />
<include name="${core.jar}" />
<include name="${api.jar}" />
<include name="${kvm.jar}" />
</zipfileset>
<zipfileset dir="${agent.dist.dir}" filemode="770">
@ -112,7 +112,7 @@
</target>
<target name="package-agent" depends="-init-package, package-oss-systemvm, build-systemvm-patch, package-agent-common">
<target name="package-agent" depends="-init-package, package-oss-systemvm, build-systemvm-patch, package-agent-common, build-kvm">
<zip destfile="${dist.dir}/agent.zip" duplicate="preserve" update="true">
<zipfileset dir="${dist.dir}" prefix="vms">
<include name="patch.tgz" />
@ -291,6 +291,17 @@
</zip>
</target>
<target name="package-kvm" depends="package-agent">
<zip destfile="${dist.dir}/agent.zip" update="true">
<zipfileset dir="${jar.dir}">
<include name="cloud-plugin-hypervisor-kvm.jar"/>
</zipfileset>
<zipfileset dir="${deps.dir}">
<include name="libvirt-0.4.8.jar"/>
</zipfileset>
</zip>
</target>
<target name="clean-zip">
<delete dir="${dist.dir}">
<include name="*.zip" />

View File

@ -532,6 +532,7 @@ fi
%files agent-libs
%defattr(0644,root,root,0755)
%{_javadir}/%{name}-agent.jar
%{_javadir}/%{name}-kvm.jar
%files agent
%defattr(0644,root,root,0755)

View File

@ -1 +1,2 @@
/usr/share/java/cloud-agent.jar
/usr/share/java/cloud-plugin-hypervisor-kvm.jar

10
docs/publican.cfg Normal file
View File

@ -0,0 +1,10 @@
# Config::Simple 4.58
# Tue May 29 00:57:27 2012
xml_lang: en-US
type: Book
docname: release-notes-3.0.4
brand: cloudstack
chunk_first: 0
chunk_section_depth: 0
toc_section_depth: 1

View File

@ -68,6 +68,13 @@ ONBOOT="no"
configure that file so that it specifies the IP address, netmask, etc., as shown
in the following example:
</para>
<important>
<title>Hardware Addresses</title>
<para>You should not use the hardware address (aka MAC address) from our example
for your configuration. It is network interface specific, so you should keep the
address already provided in the HWADDR directive.
</para>
</important>
<screen>
DEVICE=eth0
HWADDR=52:54:00:B9:A6:C0
@ -77,6 +84,8 @@ BOOTPROTO=none
IPADDR=172.16.10.2
NETMASK=255.255.255.0
GATEWAY=172.16.10.1
DNS1=8.8.8.8
DNS2=8.8.4.4
</screen>
<note>
<title>IP Addressing</title>
@ -89,26 +98,10 @@ GATEWAY=172.16.10.1
<userinput><replaceable>192.168.55</replaceable>.2</userinput>
</para>
</note>
<important>
<title>Hardware Addresses</title>
<para>You should not use the hardware address (aka MAC address) from our example
for your configuration. It is network interface specific, so you should keep the
address already provided in the HWADDR directive.
</para>
</important>
<para> Now that we have the configuration files properly set up, we need to run a
few commands to start up the network</para>
<screen><prompt># </prompt><userinput><command>chkconfig</command> network on</userinput></screen>
<screen><prompt># </prompt><userinput><command>service</command> network start</userinput></screen>
<para>This should bring the network up successfully, but we now need to enable name resolution.
To do that we will edit <filename>/etc/resolv.conf</filename>. These instructions will add
one of the nameservers from Google, though you are free to add a local nameserver if you wish.
Your <filename>/etc/resolv.conf</filename> should modified to look like:
</para>
<screen>
nameserver 8.8.8.8
</screen>
</section>
<section id="sect-Runbook-Environment-operatingsys-hostname">
<title>Hostname</title>
@ -195,8 +188,6 @@ SELINUXTYPE=targeted
<screen>
<prompt># </prompt><userinput><command>mkdir</command> /primary</userinput>
<prompt># </prompt><userinput><command>mkdir</command> /secondary</userinput>
<prompt># </prompt><userinput><command>chmod</command> 777 /primary</userinput>
<prompt># </prompt><userinput><command>chmod</command> 777 /secondary</userinput>
</screen>
<para>CentOS 6.x releases use NFSv4 by default. NFSv4 requires that domain setting matches on all clients.
In our case, the domain is cloud.priv, so ensure that the domain setting in <filename>/etc/idmapd.conf</filename>
@ -215,17 +206,17 @@ STATD_OUTGOING_PORT=2020
Edit the file <filename>/etc/sysconfig/iptables</filename>
</para>
<screen>
-A INPUT -m state --state NEW -p udp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 32803 -j ACCEPT
-A INPUT -m state --state NEW -p udp --dport 32769 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 892 -j ACCEPT
-A INPUT -m state --state NEW -p udp --dport 892 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 875 -j ACCEPT
-A INPUT -m state --state NEW -p udp --dport 875 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 662 -j ACCEPT
-A INPUT -m state --state NEW -p udp --dport 662 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p udp --dport 111 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 111 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 2049 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 32803 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p udp --dport 32769 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 892 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p udp --dport 892 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 875 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p udp --dport 875 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 662 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p udp --dport 662 -j ACCEPT
</screen>
<para>Now you can restart the iptables service with the following command:
</para>

View File

@ -40,3 +40,10 @@ net.ipv4.netfilter.ip_conntrack_max=1000000
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_max_tw_buckets=1000000
net.core.somaxconn=1000000
# Disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.all.forwarding = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.all.autoconf = 0

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/agent"/>
<classpathentry combineaccessrules="false" kind="src" path="/utils"/>
<classpathentry combineaccessrules="false" kind="src" path="/deps"/>
<classpathentry combineaccessrules="false" kind="src" path="/api"/>
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>KVM</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?>
<pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
</pydev_project>

137
plugins/hypervisors/kvm/build.xml Executable file
View File

@ -0,0 +1,137 @@
<?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.
-->
<project name="Cloud Stack KVM" default="help" basedir=".">
<description>
Cloud Stack ant build file
</description>
<dirname property="kvm.base.dir" file="${ant.file.Cloud Stack KVM}/"/>
<!-- This directory must be set -->
<property name="top.dir" location="${kvm.base.dir}/../../.."/>
<property name="build.dir" location="${top.dir}/build"/>
<echo message="build.dir=${build.dir}; top.dir=${top.dir}; kvm.base.dir=${kvm.base.dir}"/>
<!-- Import anything that the user wants to set-->
<!-- Import properties files and environment variables here -->
<property environment="env" />
<condition property="build-cloud.properties.file" value="${build.dir}/override/build-cloud.properties" else="${build.dir}/build-cloud.properties">
<available file="${build.dir}/override/build-cloud.properties" />
</condition>
<condition property="cloud.properties.file" value="${build.dir}/override/cloud.properties" else="${build.dir}/cloud.properties">
<available file="${build.dir}/override/cloud.properties" />
</condition>
<condition property="override.file" value="${build.dir}/override/replace.properties" else="${build.dir}/replace.properties">
<available file="${build.dir}/override/replace.properties" />
</condition>
<echo message="Using build parameters from ${build-cloud.properties.file}" />
<property file="${build-cloud.properties.file}" />
<echo message="Using company info from ${cloud.properties.file}" />
<property file="${cloud.properties.file}" />
<echo message="Using override file from ${override.file}" />
<property file="${override.file}" />
<property file="${build.dir}/build.number" />
<!-- In case these didn't get defined in the build-cloud.properties -->
<property name="branding.name" value="default" />
<property name="deprecation" value="off" />
<property name="target.compat.version" value="1.6" />
<property name="source.compat.version" value="1.6" />
<property name="debug" value="true" />
<property name="debuglevel" value="lines,source"/>
<echo message="target.dir=${target.dir}; top.dir=${top.dir}"/>
<!-- directories for build and distribution -->
<property name="target.dir" location="${top.dir}/target" />
<property name="classes.dir" location="${target.dir}/classes" />
<property name="jar.dir" location="${target.dir}/jar" />
<property name="dep.cache.dir" location="${target.dir}/dep-cache" />
<property name="build.log" location="${target.dir}/ant_verbose.txt" />
<property name="deps.dir" location="${top.dir}/deps" />
<property name="kvm.jar" value="cloud-plugin-hypervisor-kvm.jar" />
<property name="scripts.target.dir" location="${target.dir}/scripts"/>
<property name="kvm.scripts.dir" location="${base.dir}/plugins/hypervisors/kvm/scripts" />
<import file="${build.dir}/build-common.xml"/>
<echo message="target.dir=${target.dir}; top.dir=${top.dir}"/>
<!-- This section needs to be replaced by some kind of dependency library-->
<path id="deps.classpath">
<!--filelist files="${deps.classpath}" /-->
<fileset dir="${deps.dir}" erroronmissingdir="false">
<include name="*.jar" />
</fileset>
</path>
<path id="cloudstack.classpath">
<fileset dir="${jar.dir}">
<include name="*.jar"/>
</fileset>
</path>
<path id="kvm.classpath">
<path refid="deps.classpath"/>
<path refid="cloudstack.classpath"/>
</path>
<!-- This section needs to be replaced by some kind of dependency library-->
<target name="deploy-kvm" >
<copy todir="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/scripts">
<fileset dir="${kvm.scripts.dir}">
<include name="**/*"/>
</fileset>
</copy>
</target>
<target name="init" description="Initialize binaries directory">
<mkdir dir="${classes.dir}/${kvm.jar}"/>
<mkdir dir="${jar.dir}"/>
</target>
<target name="compile-kvm" depends="init" description="Compiles Xen ">
<compile-java jar.name="${kvm.jar}" top.dir="${kvm.base.dir}" classpath="kvm.classpath" />
</target>
<target name="help" description="help">
<echo level="info" message="This is the build file for kvmserver"/>
<echo level="info" message="You can do a build by doing ant build or clean by ant clean" />
</target>
<target name="clean-kvm">
<delete dir="${classes.dir}/${kvm.jar}"/>
</target>
<target name="build" depends="compile-kvm"/>
<target name="clean" depends="clean-kvm"/>
</project>

View File

@ -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.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
import java.io.File;
import java.io.FileInputStream;
@ -97,7 +97,6 @@ import com.cloud.resource.ServerResourceBase;
import com.cloud.storage.Storage;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Volume;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.template.TemplateInfo;
import com.cloud.utils.PropertiesUtil;
import com.cloud.utils.exception.CloudRuntimeException;

View File

@ -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.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
import java.util.HashMap;
import java.util.Map;

View File

@ -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.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
import java.io.File;
import java.util.concurrent.Callable;
@ -23,7 +23,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.libvirt.Connect;
import org.libvirt.LibvirtException;
import org.libvirt.StoragePool;
import org.libvirt.StoragePoolInfo;

View File

@ -14,14 +14,13 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import org.apache.log4j.Logger;
import org.libvirt.Connect;
import com.cloud.utils.script.OutputInterpreter;
import com.cloud.utils.script.Script;

View File

@ -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.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
import java.util.ArrayList;
import java.util.List;

View File

@ -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.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
import java.io.IOException;
import java.io.StringReader;

View File

@ -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.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
import java.io.BufferedReader;
import java.io.File;
@ -153,26 +153,26 @@ import com.cloud.agent.api.to.NicTO;
import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.agent.api.to.VolumeTO;
import com.cloud.agent.resource.computing.KVMHABase.NfsStoragePool;
import com.cloud.agent.resource.computing.LibvirtVMDef.ConsoleDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.DevicesDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.DiskDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.DiskDef.diskProtocol;
import com.cloud.agent.resource.computing.LibvirtVMDef.FeaturesDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.GraphicDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.GuestDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.GuestResourceDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.InputDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.InterfaceDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.InterfaceDef.hostNicType;
import com.cloud.agent.resource.computing.LibvirtVMDef.SerialDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.TermPolicy;
import com.cloud.agent.resource.computing.LibvirtVMDef.ClockDef;
import com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.ConsoleDef;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DevicesDef;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef.diskProtocol;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.FeaturesDef;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.GraphicDef;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.GuestDef;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.GuestResourceDef;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InputDef;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef.hostNicType;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.SerialDef;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.TermPolicy;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.ClockDef;
import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource;
import com.cloud.agent.storage.KVMPhysicalDisk;
import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.agent.storage.KVMStoragePool;
import com.cloud.agent.storage.KVMStoragePoolManager;
import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk;
import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.hypervisor.kvm.storage.KVMStoragePool;
import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager;
import com.cloud.dc.Vlan;
import com.cloud.exception.InternalErrorException;
import com.cloud.host.Host.Type;

View File

@ -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.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
import org.apache.log4j.Logger;
import org.libvirt.Connect;

View File

@ -14,14 +14,12 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@ -32,13 +30,12 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import com.cloud.agent.resource.computing.LibvirtVMDef.DiskDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.InterfaceDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.InterfaceDef.nicModel;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef.nicModel;
/**
* @author chiradeep

View File

@ -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.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
import java.util.ArrayList;
import java.util.List;

View File

@ -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.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
public class LibvirtSecretDef {

View File

@ -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.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
public class LibvirtStoragePoolDef {
public enum poolType {

View File

@ -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.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
import java.io.IOException;
import java.io.StringReader;

View File

@ -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.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
public class LibvirtStorageVolumeDef {
public enum volFormat {

View File

@ -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.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
import java.io.IOException;
import java.io.StringReader;

View File

@ -14,10 +14,9 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

View File

@ -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.agent.resource.computing;
package com.cloud.hypervisor.kvm.resource;
import java.io.IOException;
import java.io.StringReader;

View File

@ -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.agent.storage;
package com.cloud.hypervisor.kvm.storage;
public class KVMPhysicalDisk {
private String path;

View File

@ -14,11 +14,11 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.storage;
package com.cloud.hypervisor.kvm.storage;
import java.util.List;
import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.storage.Storage.StoragePoolType;
public interface KVMStoragePool {

View File

@ -14,15 +14,15 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.storage;
package com.cloud.hypervisor.kvm.storage;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.cloud.agent.resource.computing.KVMHABase;
import com.cloud.agent.resource.computing.KVMHABase.PoolType;
import com.cloud.agent.resource.computing.KVMHAMonitor;
import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.hypervisor.kvm.resource.KVMHABase;
import com.cloud.hypervisor.kvm.resource.KVMHABase.PoolType;
import com.cloud.hypervisor.kvm.resource.KVMHAMonitor;
import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StorageLayer;

View File

@ -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.agent.storage;
package com.cloud.hypervisor.kvm.storage;
public class KVMVirtualDisk {

View File

@ -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.agent.storage;
package com.cloud.hypervisor.kvm.storage;
import java.io.File;
import java.net.URI;
@ -33,17 +33,17 @@ import org.libvirt.StorageVol;
import org.libvirt.StoragePoolInfo.StoragePoolState;
import com.cloud.agent.api.ManageSnapshotCommand;
import com.cloud.agent.resource.computing.LibvirtConnection;
import com.cloud.agent.resource.computing.LibvirtSecretDef;
import com.cloud.agent.resource.computing.LibvirtSecretDef.usage;
import com.cloud.agent.resource.computing.LibvirtStoragePoolDef;
import com.cloud.agent.resource.computing.LibvirtStoragePoolXMLParser;
import com.cloud.agent.resource.computing.LibvirtStorageVolumeDef;
import com.cloud.agent.resource.computing.LibvirtStoragePoolDef.poolType;
import com.cloud.agent.resource.computing.LibvirtStoragePoolDef.authType;
import com.cloud.agent.resource.computing.LibvirtStorageVolumeDef.volFormat;
import com.cloud.agent.resource.computing.LibvirtStorageVolumeXMLParser;
import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.hypervisor.kvm.resource.LibvirtConnection;
import com.cloud.hypervisor.kvm.resource.LibvirtSecretDef;
import com.cloud.hypervisor.kvm.resource.LibvirtSecretDef.usage;
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef;
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolXMLParser;
import com.cloud.hypervisor.kvm.resource.LibvirtStorageVolumeDef;
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.poolType;
import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.authType;
import com.cloud.hypervisor.kvm.resource.LibvirtStorageVolumeDef.volFormat;
import com.cloud.hypervisor.kvm.resource.LibvirtStorageVolumeXMLParser;
import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.exception.InternalErrorException;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StorageLayer;

View File

@ -14,13 +14,13 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.storage;
package com.cloud.hypervisor.kvm.storage;
import java.util.List;
import org.libvirt.StoragePool;
import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.storage.Storage.StoragePoolType;
public class LibvirtStoragePool implements KVMStoragePool {

View File

@ -14,13 +14,11 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.storage;
package com.cloud.hypervisor.kvm.storage;
import java.util.List;
import org.libvirt.StoragePool;
import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.storage.Storage.StoragePoolType;
public interface StorageAdaptor {

View File

@ -90,7 +90,7 @@ import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.dao.NicDao;
@Local(value = NetworkElement.class)
public class NiciraNvpElement extends AdapterBase implements NetworkElement, NiciraNvpElementService, ResourceStateAdapter {
public class NiciraNvpElement extends AdapterBase implements ConnectivityProvider, NiciraNvpElementService, ResourceStateAdapter {
private static final Logger s_logger = Logger.getLogger(NiciraNvpElement.class);
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();

View File

@ -160,9 +160,9 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
}
// Name is either the given name or the uuid
String name = implemented.getName();
String name = network.getName();
if (name == null || name.isEmpty()) {
name = implemented.getUuid();
name = ((NetworkVO)network).getUuid();
}
if (name.length() > 40 ) {
name = name.substring(0, 39); // max length 40
@ -179,7 +179,7 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
String transportzoneuuid = niciraNvpHost.getDetail("transportzoneuuid");
String transportzoneisotype = niciraNvpHost.getDetail("transportzoneisotype");
CreateLogicalSwitchCommand cmd = new CreateLogicalSwitchCommand(transportzoneuuid, transportzoneisotype, network.getName(),
CreateLogicalSwitchCommand cmd = new CreateLogicalSwitchCommand(transportzoneuuid, transportzoneisotype, name,
context.getDomain().getName() + "-" + context.getAccount().getAccountName());
CreateLogicalSwitchAnswer answer = (CreateLogicalSwitchAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);

View File

@ -170,7 +170,7 @@ public class NiciraNvpResource implements ServerResource {
private Answer executeRequest(CreateLogicalSwitchCommand cmd) {
LogicalSwitch logicalSwitch = new LogicalSwitch();
logicalSwitch.setDisplay_name("lswitch-" + cmd.getOwnerName());
logicalSwitch.setDisplay_name("lswitch-" + cmd.getName());
logicalSwitch.setPort_isolation_enabled(false);
// Set transport binding

View File

@ -8,7 +8,7 @@
# 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.
#
#
# Automatically generated by addcopyright.py at 04/03/2012
from utilities import writeProgressBar, bash
from cloudException import CloudRuntimeException, CloudInternalException, formatExceptionInfo
@ -26,7 +26,7 @@ class serviceCfgBase(object):
self.cfoHandlers = []
self.syscfg = syscfg
self.netMgrRunning = False
def configration(self):
writeProgressBar("Configure " + self.serviceName + " ...", None)
result = False
@ -34,7 +34,7 @@ class serviceCfgBase(object):
result = self.config()
if result is None:
result = False
self.status = result
writeProgressBar(None, result)
return result
@ -53,29 +53,29 @@ class serviceCfgBase(object):
raise CloudRuntimeException("Configure %s failed, Please check the /var/log/cloud/setupManagement.log for detail"%self.serviceName)
else:
raise CloudRuntimeException("Configure %s failed, Please check the /var/log/cloud/setupAgent.log for detail"%self.serviceName)
def backup(self):
if self.status is None:
return True
writeProgressBar("Restore " + self.serviceName + " ...", None)
result = False
try:
for cfo in self.cfoHandlers:
cfo.backup()
result = self.restore()
except (CloudRuntimeException, CloudInternalException), e:
logging.debug(e)
writeProgressBar(None, result)
def config(self):
return True
def restore(self):
return True
class networkConfigBase:
def __init__(self, syscfg):
self.netcfg = networkConfig()
@ -93,9 +93,9 @@ class networkConfigBase:
if not self.netcfg.isBridge(br):
raise CloudInternalException("%s is not a bridge"%br)
preCfged = True
return preCfged
def cfgNetwork(self, dev=None, brName=None):
if dev is None:
device = self.netcfg.getDefaultNetwork()
@ -116,7 +116,7 @@ class networkConfigBase:
enslavedDev = self.netcfg.getEnslavedDev(device.name, 1)
if enslavedDev is None:
raise CloudInternalException("Failed to get enslaved devices on bridge:%s"%device.name)
brDevice = device
device = self.netcfg.getDevInfo(enslavedDev)
brName = brDevice.name
@ -124,7 +124,7 @@ class networkConfigBase:
self.brName = brName
self.dev = device.name
def writeToCfgFile(self):
pass
@ -133,7 +133,7 @@ class networkConfigUbuntu(serviceCfgBase, networkConfigBase):
super(networkConfigUbuntu, self).__init__(syscfg)
networkConfigBase.__init__(self, syscfg)
self.netCfgFile = "/etc/network/interfaces"
def getNetworkMethod(self, line):
if line.find("static") != -1:
return "static"
@ -142,7 +142,7 @@ class networkConfigUbuntu(serviceCfgBase, networkConfigBase):
else:
logging.debug("Failed to find the network method from:%s"%line)
raise CloudInternalException("Failed to find the network method from /etc/network/interfaces")
def addBridge(self, br, dev):
bash("ifdown %s"%dev.name)
for line in file(self.netCfgFile).readlines():
@ -177,34 +177,34 @@ class networkConfigUbuntu(serviceCfgBase, networkConfigBase):
raise CloudInternalException("Missing device configuration, Need to add your network configuration into /etc/network/interfaces at first")
else:
raise CloudInternalException("Missing bridge/device network configuration, need to add your network configuration into /etc/network/interfaces at first")
def config(self):
try:
if super(networkConfigUbuntu, self).isPreConfiged():
return True
self.netMgrRunning = self.syscfg.svo.isServiceRunning("network-manager")
super(networkConfigUbuntu, self).cfgNetwork()
if self.netMgrRunning:
self.syscfg.svo.stopService("network-manager")
self.syscfg.svo.disableService("network-manager")
if not bash("ifup %s"%self.brName).isSuccess():
raise CloudInternalException("Can't start network:%s"%self.brName, bash.getErrMsg(self))
self.syscfg.env.nics.append(self.brName)
self.syscfg.env.nics.append(self.brName)
self.syscfg.env.nics.append(self.brName)
return True
except:
raise
def restore(self):
try:
if self.netMgrRunning:
self.syscfg.svo.enableService("network-manager")
self.syscfg.svo.startService("network-manager")
bash("/etc/init.d/networking stop")
bash("/etc/init.d/networking start")
return True
@ -216,11 +216,11 @@ class networkConfigRedhat(serviceCfgBase, networkConfigBase):
def __init__(self, syscfg):
super(networkConfigRedhat, self).__init__(syscfg)
networkConfigBase.__init__(self, syscfg)
def writeToCfgFile(self, brName, dev):
self.devCfgFile = "/etc/sysconfig/network-scripts/ifcfg-%s"%dev.name
self.brCfgFile = "/etc/sysconfig/network-scripts/ifcfg-%s"%brName
isDevExist = os.path.exists(self.devCfgFile)
isBrExist = os.path.exists(self.brCfgFile)
if isDevExist and isBrExist:
@ -234,35 +234,35 @@ class networkConfigRedhat(serviceCfgBase, networkConfigBase):
raise CloudInternalException("Missing device configuration, Need to add your network configuration into /etc/sysconfig/network-scripts at first")
else:
raise CloudInternalException("Missing bridge/device network configuration, need to add your network configuration into /etc/sysconfig/network-scripts at first")
def addBridge(self, brName, dev):
bash("ifdown %s"%dev.name)
if not os.path.exists(self.brCfgFile):
shutil.copy(self.devCfgFile, self.brCfgFile)
#config device file at first: disable nm, set onboot=yes if not
cfo = configFileOps(self.devCfgFile, self)
cfo.addEntry("NM_CONTROLLED", "no")
cfo.addEntry("ONBOOT", "yes")
cfo.addEntry("BRIDGE", brName)
cfo.save()
cfo = configFileOps(self.brCfgFile, self)
cfo.addEntry("NM_CONTROLLED", "no")
cfo.addEntry("ONBOOT", "yes")
cfo.addEntry("DEVICE", brName)
cfo.addEntry("TYPE", "Bridge")
cfo.save()
def config(self):
try:
if super(networkConfigRedhat, self).isPreConfiged():
return True
super(networkConfigRedhat, self).cfgNetwork()
self.netMgrRunning = self.syscfg.svo.isServiceRunning("NetworkManager")
if self.netMgrRunning:
self.syscfg.svo.stopService("NetworkManager")
@ -274,14 +274,14 @@ class networkConfigRedhat(serviceCfgBase, networkConfigBase):
if not bash("service network restart").isSuccess():
raise CloudInternalException("Can't restart network")
self.syscfg.env.nics.append(self.brName)
self.syscfg.env.nics.append(self.brName)
self.syscfg.env.nics.append(self.brName)
return True
except:
raise
def restore(self):
try:
if self.netMgrRunning:
@ -292,12 +292,12 @@ class networkConfigRedhat(serviceCfgBase, networkConfigBase):
except:
logging.debug(formatExceptionInfo())
return False
class cgroupConfig(serviceCfgBase):
def __init__(self, syscfg):
super(cgroupConfig, self).__init__(syscfg)
self.serviceName = "Cgroup"
def config(self):
try:
cfo = configFileOps("/etc/cgconfig.conf", self)
@ -314,14 +314,14 @@ class cgroupConfig(serviceCfgBase):
cfo = configFileOps("/etc/cgrules.conf", self)
cfgline = "root:/usr/sbin/libvirtd cpu virt/\n"
cfo.add_lines(cfgline)
self.syscfg.svo.stopService("cgred", True)
if not self.syscfg.svo.enableService("cgred"):
return False
return True
except:
raise
def restore(self):
try:
self.syscfg.svo.stopService("cgconfig")
@ -332,7 +332,7 @@ class cgroupConfig(serviceCfgBase):
except:
logging.debug(formatExceptionInfo())
return False
class nfsConfig(serviceCfgBase):
def __init__(self, syscfg):
super(nfsConfig, self).__init__(syscfg)
@ -342,24 +342,24 @@ class nfsConfig(serviceCfgBase):
try:
if not os.path.exists("/etc/nfsmount.conf"):
return True
cfo = configFileOps("/etc/nfsmount.conf")
cfo.addEntry("AC", "False")
cfo.save()
self.syscfg.svo.enableService("rpcbind")
self.syscfg.svo.stopService("rpcbind")
self.syscfg.svo.startService("rpcbind")
self.syscfg.svo.enableService("nfs")
self.syscfg.svo.stopService("nfs")
self.syscfg.svo.startService("nfs")
return True
except:
logging.debug(formatExceptionInfo())
return False
class securityPolicyConfigUbuntu(serviceCfgBase):
def __init__(self, syscfg):
super(securityPolicyConfigUbuntu, self).__init__(syscfg)
@ -371,7 +371,7 @@ class securityPolicyConfigUbuntu(serviceCfgBase):
if not cmd.isSuccess() or cmd.getStdout() == "":
self.spRunning = False
return True
if not bash("apparmor_status |grep libvirt").isSuccess():
return True
@ -384,7 +384,7 @@ class securityPolicyConfigUbuntu(serviceCfgBase):
except:
raise CloudRuntimeException("Failed to configure apparmor, please see the /var/log/cloud/setupAgent.log for detail, \
or you can manually disable it before starting myCloud")
def restore(self):
try:
self.syscfg.svo.enableService("apparmor")
@ -393,7 +393,7 @@ class securityPolicyConfigUbuntu(serviceCfgBase):
except:
logging.debug(formatExceptionInfo())
return False
class securityPolicyConfigRedhat(serviceCfgBase):
def __init__(self, syscfg):
super(securityPolicyConfigRedhat, self).__init__(syscfg)
@ -401,10 +401,10 @@ class securityPolicyConfigRedhat(serviceCfgBase):
def config(self):
selinuxEnabled = True
if not bash("selinuxenabled").isSuccess():
selinuxEnabled = False
if selinuxEnabled:
try:
bash("setenforce 0")
@ -416,7 +416,7 @@ class securityPolicyConfigRedhat(serviceCfgBase):
or you can manually disable it before starting myCloud")
else:
return True
def restore(self):
try:
bash("setenforce 1")
@ -429,7 +429,7 @@ class libvirtConfigRedhat(serviceCfgBase):
def __init__(self, syscfg):
super(libvirtConfigRedhat, self).__init__(syscfg)
self.serviceName = "Libvirt"
def config(self):
try:
cfo = configFileOps("/etc/libvirt/libvirtd.conf", self)
@ -438,14 +438,14 @@ class libvirtConfigRedhat(serviceCfgBase):
cfo.addEntry("auth_tcp", "\"none\"")
cfo.addEntry("listen_tls", "0")
cfo.save()
cfo = configFileOps("/etc/sysconfig/libvirtd", self)
cfo.addEntry("export CGROUP_DAEMON", "'cpu:/virt'")
cfo.addEntry("LIBVIRTD_ARGS", "-l")
cfo.save()
filename = "/etc/libvirt/qemu.conf"
cfo = configFileOps(filename, self)
cfo.addEntry("cgroup_controllers", "[\"cpu\"]")
cfo.addEntry("security_driver", "\"none\"")
@ -453,23 +453,23 @@ class libvirtConfigRedhat(serviceCfgBase):
cfo.addEntry("group", "\"root\"")
cfo.addEntry("vnc_listen", "\"0.0.0.0\"")
cfo.save()
self.syscfg.svo.stopService("libvirtd")
if not self.syscfg.svo.startService("libvirtd"):
return False
return True
except:
raise
def restore(self):
pass
class libvirtConfigUbuntu(serviceCfgBase):
def __init__(self, syscfg):
super(libvirtConfigUbuntu, self).__init__(syscfg)
self.serviceName = "Libvirt"
def setupLiveMigration(self):
cfo = configFileOps("/etc/libvirt/libvirtd.conf", self)
cfo.addEntry("listen_tcp", "1")
@ -477,20 +477,20 @@ class libvirtConfigUbuntu(serviceCfgBase):
cfo.addEntry("auth_tcp", "\"none\"");
cfo.addEntry("listen_tls", "0")
cfo.save()
if os.path.exists("/etc/init/libvirt-bin.conf"):
cfo = configFileOps("/etc/init/libvirt-bin.conf", self)
cfo.replace_line("exec /usr/sbin/libvirtd","exec /usr/sbin/libvirtd -d -l")
else:
cfo = configFileOps("/etc/default/libvirt-bin", self)
cfo.replace_or_add_line("libvirtd_opts=","libvirtd_opts='-l -d'")
def config(self):
try:
self.setupLiveMigration()
filename = "/etc/libvirt/qemu.conf"
cfo = configFileOps(filename, self)
cfo.addEntry("security_driver", "\"none\"")
cfo.addEntry("user", "\"root\"")
@ -511,12 +511,12 @@ class libvirtConfigUbuntu(serviceCfgBase):
except:
logging.debug(formatExceptionInfo())
return False
class firewallConfigUbuntu(serviceCfgBase):
def __init__(self, syscfg):
super(firewallConfigUbuntu, self).__init__(syscfg)
self.serviceName = "Firewall"
def config(self):
try:
ports = "22 1798 16509".split()
@ -529,43 +529,43 @@ class firewallConfigUbuntu(serviceCfgBase):
return True
except:
raise
def restore(self):
return True
class firewallConfigBase(serviceCfgBase):
def __init__(self, syscfg):
super(firewallConfigBase, self).__init__(syscfg)
self.serviceName = "Firewall"
self.serviceName = "Firewall"
self.rules = []
def allowPort(self, port):
status = False
try:
status = bash("iptables-save|grep INPUT|grep -w %s"%port).isSuccess()
except:
pass
if not status:
if not status:
redo = False
result = True
try:
result = bash("iptables -I INPUT -p tcp -m tcp --dport %s -j ACCEPT"%port).isSuccess()
except:
redo = True
if not result or redo:
bash("sleep 30")
bash("iptables -I INPUT -p tcp -m tcp --dport %s -j ACCEPT"%port)
def config(self):
try:
for port in self.ports:
self.allowPort(port)
for rule in self.rules:
bash("iptables " + rule)
bash("iptables-save > /etc/sysconfig/iptables")
self.syscfg.svo.stopService("iptables")
self.syscfg.svo.startService("iptables")
@ -575,7 +575,7 @@ class firewallConfigBase(serviceCfgBase):
def restore(self):
return True
class firewallConfigAgent(firewallConfigBase):
def __init__(self, syscfg):
super(firewallConfigAgent, self).__init__(syscfg)
@ -595,10 +595,10 @@ class cloudAgentConfig(serviceCfgBase):
self.serviceName = "myCloud"
elif syscfg.env.agentMode == "Console":
self.serviceName = "Console Proxy"
def configMyCloud(self):
try:
cfo = configFileOps("/etc/cloud/agent/agent.properties", self)
cfo = configFileOps("/etc/cloud/agent/agent.properties", self)
cfo.addEntry("host", self.syscfg.env.mgtSvr)
cfo.addEntry("zone", self.syscfg.env.zone)
cfo.addEntry("port", "443")
@ -611,16 +611,16 @@ class cloudAgentConfig(serviceCfgBase):
cfo.addEntry("mount.path", "/mnt")
cfo.addEntry("resource", "com.cloud.storage.resource.LocalSecondaryStorageResource|com.cloud.agent.resource.computing.CloudZonesComputingResource")
cfo.save()
#self.syscfg.svo.stopService("cloud-agent")
#self.syscfg.svo.enableService("cloud-agent")
return True
except:
raise
def configAgent(self):
try:
cfo = configFileOps("/etc/cloud/agent/agent.properties", self)
cfo = configFileOps("/etc/cloud/agent/agent.properties", self)
cfo.addEntry("host", self.syscfg.env.mgtSvr)
cfo.addEntry("zone", self.syscfg.env.zone)
cfo.addEntry("pod", self.syscfg.env.pod)
@ -632,19 +632,19 @@ class cloudAgentConfig(serviceCfgBase):
cfo.addEntry("guid", str(self.syscfg.env.uuid))
if cfo.getEntry("local.storage.uuid") == "":
cfo.addEntry("local.storage.uuid", str(bash("uuidgen").getStdout()))
cfo.addEntry("resource", "com.cloud.agent.resource.computing.LibvirtComputingResource")
cfo.addEntry("resource", "com.cloud.hypervisor.kvm.resource.LibvirtComputingResource")
cfo.save()
self.syscfg.svo.stopService("cloud-agent")
bash("sleep 30")
self.syscfg.svo.enableService("cloud-agent")
return True
except:
raise
def configConsole(self):
try:
cfo = configFileOps("/etc/cloud/agent/agent.properties", self)
cfo = configFileOps("/etc/cloud/agent/agent.properties", self)
cfo.addEntry("host", self.syscfg.env.mgtSvr)
cfo.addEntry("zone", self.syscfg.env.zone)
cfo.addEntry("pod", self.syscfg.env.pod)
@ -656,13 +656,13 @@ class cloudAgentConfig(serviceCfgBase):
cfo.addEntry("guid", str(self.syscfg.env.uuid))
cfo.addEntry("resource", "com.cloud.agent.resource.computing.consoleProxyResource")
cfo.save()
self.syscfg.svo.stopService("cloud-agent")
self.syscfg.svo.enableService("cloud-agent")
return True
except:
raise
def config(self):
if self.syscfg.env.agentMode == "Agent":
return self.configAgent()
@ -670,7 +670,7 @@ class cloudAgentConfig(serviceCfgBase):
return self.configMyCloud()
elif self.syscfg.env.agentMode == "console":
return self.configConsole()
def restore(self):
return True
@ -688,10 +688,10 @@ class sudoersConfig(serviceCfgBase):
return True
except:
raise
def restore(self):
return True
class firewallConfigServer(firewallConfigBase):
def __init__(self, syscfg):
super(firewallConfigServer, self).__init__(syscfg)
@ -708,18 +708,18 @@ class ubuntuFirewallConfigServer(firewallConfigServer):
status = bash("iptables-save|grep INPUT|grep -w %s"%port).isSuccess()
except:
pass
if not status:
if not status:
bash("ufw allow %s/tcp"%port)
def config(self):
try:
for port in self.ports:
self.allowPort(port)
#FIXME: urgly make /root writable
#FIXME: urgly make /root writable
bash("sudo chmod 0777 /root")
return True
except:
raise

View File

@ -23,6 +23,20 @@ usage() {
}
if [ ! -f "/etc/modprobe.d/disable-ipv6" ] ; then
# disable IPv6 until reboot
if [ -d "/proc/sys/net/ipv6/conf/all" ] ; then
/sbin/sysctl -w net.ipv6.conf.all.forwarding=0
/sbin/sysctl -w net.ipv6.conf.all.accept_ra=0
/sbin/sysctl -w net.ipv6.conf.all.accept_redirects=0
/sbin/sysctl -w net.ipv6.conf.all.autoconf=0
/sbin/sysctl -w net.ipv6.conf.all.disable_ipv6=1
fi
# reinstate the disable-ipv6 file
echo "alias ipv6 no" > /etc/modprobe.d/disable-ipv6
echo "alias net-pf-10 off" >> /etc/modprobe.d/disable-ipv6
fi
#removing iptables entry for vnc ports
iptables -D RH-Firewall-1-INPUT -p tcp -m tcp --dport 5900:6099 -j ACCEPT 2>&1

View File

@ -88,7 +88,7 @@ import com.cloud.host.dao.HostDao;
import com.cloud.host.dao.HostTagsDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.HypervisorGuruManager;
import com.cloud.hypervisor.kvm.resource.KvmDummyResourceBase;
import com.cloud.hypervisor.kvm.discoverer.KvmDummyResourceBase;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.resource.Discoverer;
import com.cloud.resource.ResourceManager;

View File

@ -1578,6 +1578,7 @@ public class ApiResponseHelper implements ResponseGenerator {
nicResponse.setGateway(singleNicProfile.getGateway());
nicResponse.setNetmask(singleNicProfile.getNetmask());
nicResponse.setNetworkid(singleNicProfile.getNetworkId());
nicResponse.setNetworkName(ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId()).getName());
if (acct.getType() == Account.ACCOUNT_TYPE_ADMIN) {
if (singleNicProfile.getBroadCastUri() != null) {
nicResponse.setBroadcastUri(singleNicProfile.getBroadCastUri().toString());

View File

@ -56,7 +56,6 @@ import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.api.ApiConstants;
import com.cloud.host.Host.Type;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.hypervisor.kvm.resource.KvmDummyResourceBase;
import com.cloud.resource.ServerResource;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.script.OutputInterpreter;

View File

@ -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.hypervisor.kvm.resource;
package com.cloud.hypervisor.kvm.discoverer;
import java.util.HashMap;
import java.util.Map;
@ -31,7 +31,6 @@ import com.cloud.host.Host.Type;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.resource.ServerResource;
import com.cloud.resource.ServerResourceBase;
import com.cloud.vm.VirtualMachine.State;
public class KvmDummyResourceBase extends ServerResourceBase implements ServerResource {
private String _zoneId;

View File

@ -51,11 +51,9 @@ import com.cloud.host.Status;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.kvm.resource.KvmDummyResourceBase;
import com.cloud.hypervisor.kvm.discoverer.KvmDummyResourceBase;
import com.cloud.network.NetworkManager;
import com.cloud.network.PhysicalNetworkSetupInfo;
import com.cloud.network.PhysicalNetworkVO;
import com.cloud.network.Networks.TrafficType;
import com.cloud.resource.Discoverer;
import com.cloud.resource.DiscovererBase;
import com.cloud.resource.ResourceManager;
@ -66,9 +64,6 @@ import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.component.Inject;
import com.cloud.utils.script.Script;
import com.cloud.utils.ssh.SSHCmdHelper;
import com.trilead.ssh2.ChannelCondition;
import com.trilead.ssh2.SCPClient;
import com.trilead.ssh2.Session;
@Local(value=Discoverer.class)
public class KvmServerDiscoverer extends DiscovererBase implements Discoverer,

View File

@ -127,6 +127,7 @@ import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao;
import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO;
import com.cloud.network.element.ConnectivityProvider;
import com.cloud.network.element.DhcpServiceProvider;
import com.cloud.network.element.FirewallServiceProvider;
import com.cloud.network.element.IpDeployer;
@ -959,6 +960,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
deployer = ((PortForwardingServiceProvider) element).getIpDeployer(network);
} else if (element instanceof RemoteAccessVPNServiceProvider) {
deployer = ((RemoteAccessVPNServiceProvider) element).getIpDeployer(network);
} else if (element instanceof ConnectivityProvider) {
// Nothing to do
s_logger.debug("ConnectivityProvider " + element.getClass().getSimpleName() + " has no ip associations");
continue;
} else {
throw new CloudRuntimeException("Fail to get ip deployer for element: " + element);
}
@ -2970,6 +2975,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
"service disabled are allowed in security group enabled zone");
}
}
//don't allow eip/elb networks in Advance zone
if (ntwkOff.getElasticIp() || ntwkOff.getElasticLb()) {
throw new InvalidParameterValueException("Elastic IP and Elastic LB services are supported in zone of type " + NetworkType.Basic);
}
}
// VlanId can be specified only when network offering supports it
@ -3273,11 +3283,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags), searchFilter,
permittedAccounts));
} else if (domainId == null || listAll) {
} else if (domainId == null) {
networksToReturn.addAll(listAccountSpecificNetworksByDomainPath(
buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags), searchFilter, path,
isRecursive));
networksToReturn.addAll(listDomainSpecificNetworksByDomainPath(
buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags), searchFilter, path,
isRecursive));
}
} else {
networksToReturn = _networksDao.search(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId,
@ -3458,6 +3472,22 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
return _networksDao.search(sc, searchFilter);
}
private List<NetworkVO> listDomainSpecificNetworksByDomainPath(SearchCriteria<NetworkVO> sc, Filter searchFilter, String path, boolean isRecursive) {
SearchCriteria<NetworkVO> accountSC = _networksDao.createSearchCriteria();
accountSC.addAnd("aclType", SearchCriteria.Op.EQ, ACLType.Domain.toString());
if (path != null) {
if (isRecursive) {
sc.setJoinParameters("domainSearch", "path", path + "%");
} else {
sc.setJoinParameters("domainSearch", "path", path);
}
}
sc.addAnd("id", SearchCriteria.Op.SC, accountSC);
return _networksDao.search(sc, searchFilter);
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_DELETE, eventDescription = "deleting network", async = true)
public boolean deleteNetwork(long networkId) {
@ -3657,7 +3687,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
s_logger.debug("Sending destroy to " + element);
}
element.destroy(network);
if (!element.destroy(network)) {
success = false;
s_logger.warn("Unable to complete destroy of the network: failed to destroy network element " + element.getName());
}
} catch (ResourceUnavailableException e) {
s_logger.warn("Unable to complete destroy of the network due to element: " + element.getName(), e);
success = false;
@ -6223,6 +6256,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
success = false;
}
//release all static nats for the network
if (!_rulesMgr.applyStaticNatForNetwork(networkId, false, caller, true)) {
s_logger.warn("Failed to disable static nats as part of shutdownNetworkRules for network id " + networkId);
success = false;
}
// Get all ip addresses, mark as releasing and release them on the backend
Network network = getNetwork(networkId);

View File

@ -78,4 +78,13 @@ public interface RulesManager extends RulesService {
boolean disableStaticNat(long ipAddressId, Account caller, long callerUserId, boolean releaseIpIfElastic) throws ResourceUnavailableException;
/**
* @param networkId
* @param continueOnError
* @param caller
* @param forRevoke
* @return
*/
boolean applyStaticNatForNetwork(long networkId, boolean continueOnError, Account caller, boolean forRevoke);
}

View File

@ -1255,15 +1255,60 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
@Override
public boolean applyStaticNatForIp(long sourceIpId, boolean continueOnError, Account caller, boolean forRevoke) {
IpAddress sourceIp = _ipAddressDao.findById(sourceIpId);
List<StaticNat> staticNats = createStaticNatForIp(sourceIp, caller, forRevoke);
if (staticNats != null && !staticNats.isEmpty()) {
try {
if (!_networkMgr.applyStaticNats(staticNats, continueOnError)) {
return false;
}
} catch (ResourceUnavailableException ex) {
s_logger.warn("Failed to create static nat rule due to ", ex);
return false;
}
}
return true;
}
@Override
public boolean applyStaticNatForNetwork(long networkId, boolean continueOnError, Account caller, boolean forRevoke) {
List<? extends IpAddress> staticNatIps = _ipAddressDao.listStaticNatPublicIps(networkId);
List<StaticNat> staticNats = new ArrayList<StaticNat>();
IpAddress sourceIp = _ipAddressDao.findById(sourceIpId);
for (IpAddress staticNatIp : staticNatIps) {
staticNats.addAll(createStaticNatForIp(staticNatIp, caller, forRevoke));
}
if (staticNats != null && !staticNats.isEmpty()) {
if (forRevoke) {
s_logger.debug("Found " + staticNats.size() + " static nats to disable for network id " + networkId);
}
try {
if (!_networkMgr.applyStaticNats(staticNats, continueOnError)) {
return false;
}
} catch (ResourceUnavailableException ex) {
s_logger.warn("Failed to create static nat rule due to ", ex);
return false;
}
} else {
s_logger.debug("Found 0 static nat rules to apply for network id " + networkId);
}
if (!sourceIp.isOneToOneNat()) {
s_logger.debug("Source ip id=" + sourceIpId + " is not one to one nat");
return true;
}
protected List<StaticNat> createStaticNatForIp(IpAddress sourceIp, Account caller, boolean forRevoke) {
List<StaticNat> staticNats = new ArrayList<StaticNat>();
if (!sourceIp.isOneToOneNat()) {
s_logger.debug("Source ip id=" + sourceIp + " is not one to one nat");
return staticNats;
}
Long networkId = sourceIp.getAssociatedWithNetworkId();
if (networkId == null) {
throw new CloudRuntimeException("Ip address is not associated with any network");
@ -1292,19 +1337,9 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
}
StaticNatImpl staticNat = new StaticNatImpl(sourceIp.getAllocatedToAccountId(), sourceIp.getAllocatedInDomainId(),
networkId, sourceIpId, dstIp, forRevoke);
networkId, sourceIp.getId(), dstIp, forRevoke);
staticNats.add(staticNat);
try {
if (!_networkMgr.applyStaticNats(staticNats, continueOnError)) {
return false;
}
} catch (ResourceUnavailableException ex) {
s_logger.warn("Failed to create static nat rule due to ", ex);
return false;
}
return true;
return staticNats;
}
@Override

View File

@ -98,7 +98,7 @@ import com.cloud.host.dao.HostDetailsDao;
import com.cloud.host.dao.HostTagsDao;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.kvm.resource.KvmDummyResourceBase;
import com.cloud.hypervisor.kvm.discoverer.KvmDummyResourceBase;
import com.cloud.network.IPAddressVO;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.org.Cluster;

View File

@ -344,7 +344,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
SecurityGroupVMMapDao _securityGroupVMMapDao;
@Inject
protected ItWorkDao _workDao;
VolumeHostDao _volumeHostDao;
@Inject
protected VolumeHostDao _volumeHostDao;
@Inject
ResourceTagDao _resourceTagDao;

View File

@ -417,4 +417,10 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana
return null;
}
@Override
public void prepareStop(VirtualMachineProfile<UserVmVO> profile) {
// TODO Auto-generated method stub
}
}

View File

@ -136,6 +136,7 @@ def choose_category(fn):
return v
raise Exception('Need to add a category for %s to %s:known_categories' %
(fn, __file__))
sys.exit(1)
for f in sys.argv:

View File

@ -124,23 +124,11 @@ version="1.0">
<div id="footer">
<div id="footer_mainmaster">
<p>Copyright 2011, 2012 Citrix Systems, Inc. All rights reserved </p>
<p>Copyright © 2012 The Apache Software Foundation, Licensed under the
<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0.</a> <br />
Apache and the Apache feather logo are trademarks of The Apache Software Foundation.</p>
</div>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-16163918-1");
pageTracker._setDomainName(".cloud.com");
pageTracker._trackPageview();
} catch(err) {}</script>
<script type="text/javascript" language="javascript">llactid=14481</script>
<script type="text/javascript" language="javascript" src="http://t5.trackalyzer.com/trackalyze.js"></script><div class="clear"></div>
</div>
</div>
</body>

View File

@ -161,22 +161,13 @@ version="1.0">
<li> <a href="#"> Contacts</a> </li>
</ul>
<p>Copyright 2010 CloudStack, Inc. All rights reserved </p>
<p>Copyright © 2012 The Apache Software Foundation, Licensed under the
<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0.</a> <br />
Apache and the Apache feather logo are trademarks of The Apache Software Foundation.</p>
</div>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-16163918-1");
pageTracker._setDomainName(".cloud.com");
pageTracker._trackPageview();
} catch(err) {}</script>
<script type="text/javascript" language="javascript">llactid=14481</script>
<script type="text/javascript" language="javascript" src="http://t5.trackalyzer.com/trackalyze.js"></script><!-- #EndLibraryItem --><div class="clear"></div>
</div>
</div>
</body>

View File

@ -126,23 +126,12 @@ version="1.0">
</div>
<div id="footer">
<div id="footer_mainmaster">
<p>Copyright 2011, 2012 Citrix Systems, Inc. All rights reserved </p>
<p>Copyright © 2012 The Apache Software Foundation, Licensed under the
<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0.</a> <br />
Apache and the Apache feather logo are trademarks of The Apache Software Foundation.</p>
</div>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-16163918-1");
pageTracker._setDomainName(".cloud.com");
pageTracker._trackPageview();
} catch(err) {}</script>
<script type="text/javascript" language="javascript">llactid=14481</script>
<script type="text/javascript" language="javascript" src="http://t5.trackalyzer.com/trackalyze.js"></script><div class="clear"></div>
</div>
</div>
</body>

View File

@ -8,22 +8,11 @@
<div id="footer">
<div id="footer_mainmaster">
<p>Copyright 2011, 2012 Citrix Systems, Inc. All rights reserved </p>
<p>Copyright © 2012 The Apache Software Foundation, Licensed under the
<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0.</a> <br />
Apache and the Apache feather logo are trademarks of The Apache Software Foundation.</p>
</div>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-16163918-1");
pageTracker._setDomainName(".cloud.com");
pageTracker._trackPageview();
} catch(err) {}</script>
<script type="text/javascript" language="javascript">llactid=14481</script>
<script type="text/javascript" language="javascript" src="http://t5.trackalyzer.com/trackalyze.js"></script><div class="clear"></div>
</div>
</div>
</body>

View File

@ -124,23 +124,12 @@ version="1.0">
<div id="footer">
<div id="footer_mainmaster">
<p>Copyright 2011, 2012 Citrix Systems, Inc. All rights reserved </p>
<p>Copyright © 2012 The Apache Software Foundation, Licensed under the
<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0.</a> <br />
Apache and the Apache feather logo are trademarks of The Apache Software Foundation.</p>
</div>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-16163918-1");
pageTracker._setDomainName(".cloud.com");
pageTracker._trackPageview();
} catch(err) {}</script>
<script type="text/javascript" language="javascript">llactid=14481</script>
<script type="text/javascript" language="javascript" src="http://t5.trackalyzer.com/trackalyze.js"></script><div class="clear"></div>
</div>
</div>
</body>

View File

@ -2010,8 +2010,7 @@ CREATE TABLE `cloud`.`physical_network_service_providers` (
`removed` datetime COMMENT 'date removed if not null',
PRIMARY KEY (`id`),
CONSTRAINT `fk_pnetwork_service_providers__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE,
CONSTRAINT `uc_service_providers__uuid` UNIQUE (`uuid`),
UNIQUE KEY(`physical_network_id`, `provider_name`)
CONSTRAINT `uc_service_providers__uuid` UNIQUE (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`external_load_balancer_devices` (

View File

@ -19,10 +19,10 @@
-- Schema upgrade from 3.0.3 to 4.0.0;
--;
# RBD Primary Storage pool support (commit: 406fd95d87bfcdbb282d65589ab1fb6e9fd0018a)
-- RBD Primary Storage pool support (commit: 406fd95d87bfcdbb282d65589ab1fb6e9fd0018a)
ALTER TABLE `storage_pool` ADD `user_info` VARCHAR( 255 ) NULL COMMENT 'Authorization information for the storage pool. Used by network filesystems' AFTER `host_address`;
# Resource tags (commit: 62d45b9670520a1ee8b520509393d4258c689b50)
-- Resource tags (commit: 62d45b9670520a1ee8b520509393d4258c689b50)
CREATE TABLE `cloud`.`resource_tags` (
`id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
`uuid` varchar(40),
@ -41,7 +41,7 @@ CREATE TABLE `cloud`.`resource_tags` (
CONSTRAINT `uc_resource_tags__uuid` UNIQUE (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Nicira Integration (commit: 79c7da07abd4294f150851aa0c2d06a28564c5a9)
-- Nicira Integration (commit: 79c7da07abd4294f150851aa0c2d06a28564c5a9)
CREATE TABLE `cloud`.`external_nicira_nvp_devices` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`uuid` varchar(255) UNIQUE,
@ -61,3 +61,21 @@ CREATE TABLE `cloud`.`nicira_nvp_nic_map` (
`nic` varchar(255) UNIQUE COMMENT 'cloudstack uuid of the nic connected to this logical switch port',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- rrq 5839
-- Remove the unique constraint on physical_network_id, provider_name from physical_network_service_providers
-- Because the name of this contraint is not set we need this roundabout way
-- The key is also used by the foreign key constraint so drop and recreate that one
ALTER TABLE physical_network_service_providers DROP FOREIGN KEY fk_pnetwork_service_providers__physical_network_id;
SET @constraintname = (select CONCAT(CONCAT('DROP INDEX ', A.CONSTRAINT_NAME), ' ON physical_network_service_providers' )
from information_schema.key_column_usage A
JOIN information_schema.key_column_usage B ON B.table_name = 'physical_network_service_providers' AND B.COLUMN_NAME = 'provider_name' AND A.COLUMN_NAME ='physical_network_id' AND B.CONSTRAINT_NAME=A.CONSTRAINT_NAME
where A.table_name = 'physical_network_service_providers');
PREPARE stmt1 FROM @constraintname;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
AlTER TABLE physical_network_service_providers ADD CONSTRAINT `fk_pnetwork_service_providers__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE

View File

@ -19,13 +19,15 @@
# under the License.
Vagrant::Config.run do |config|
config.vm.box = "devcloudbase-ubuntu-12-04-64bit"
config.vm.box = "devcloud"
# TODO: Get a URL to host the base image
# config.vm.box_url = "http://domain.com/path/to/above.box"
config.vm.guest = :xen
config.ssh.username = "devcloud"
# Uncomment this line to enable the console for debugging the
# build process.
#config.vm.boot_mode = :gui
config.vm.boot_mode = :gui
# Setup port forwarding
config.vm.forward_port 22, 2222
@ -46,27 +48,4 @@ Vagrant::Config.run do |config|
puppet.module_path = "puppet-devcloudinitial"
end
# Enable provisioning with Puppet stand alone. Puppet manifests
# are contained in a directory path relative to this Vagrantfile.
# You will need to create the manifests directory and a manifest in
# the file my_box.pp in the manifests_path directory.
#
# An example Puppet manifest to provision the message of the day:
#
# # group { "puppet":
# # ensure => "present",
# # }
# #
# # File { owner => 0, group => 0, mode => 0644 }
# #
# # file { '/etc/motd':
# # content => "Welcome to your Vagrant-built virtual machine!
# # Managed by Puppet.\n"
# # }
#
# config.vm.provision :puppet do |puppet|
# puppet.manifests_path = "manifests"
# puppet.manifest_file = "my_box.pp"
# end
end

View File

@ -3,7 +3,7 @@
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
GRUB_DEFAULT=2
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=2

View File

@ -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.
include puppet-devcloudinitial

View File

@ -1,15 +1,32 @@
# 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.
class puppet-devcloudinitial {
package { 'linux-headers-3.2.0-23-generic':
ensure => latest,
}
package { 'xen-hypervisor-4.1-amd64':
package { 'xen-hypervisor-4.1-i386':
ensure => latest,
}
package { 'xcp-xapi':
require => Package['xen-hypervisor-4.1-amd64'],
require => Package['xen-hypervisor-4.1-i386'],
ensure => latest,
}
@ -38,7 +55,7 @@ class puppet-devcloudinitial {
}
file { '/etc/default/grub':
require => Package['xen-hypervisor-4.1-amd64'],
require => Package['xen-hypervisor-4.1-i386'],
ensure => 'file',
source => 'puppet:///modules/puppet-devcloudinitial/grub',
group => '0',
@ -53,7 +70,7 @@ class puppet-devcloudinitial {
}
file { '/usr/share/qemu':
require => Package['xen-hypervisor-4.1-amd64'],
require => Package['xen-hypervisor-4.1-i386'],
ensure => 'directory',
group => '0',
mode => '755',
@ -78,7 +95,7 @@ class puppet-devcloudinitial {
}
file { '/etc/default/xen':
require => Package['xen-hypervisor-4.1-amd64'],
require => Package['xen-hypervisor-4.1-i386'],
ensure => 'file',
source => 'puppet:///modules/puppet-devcloudinitial/xen-defaults',
group => '0',

51
tools/devcloud/devcloudbox/Vagrantfile vendored Normal file
View File

@ -0,0 +1,51 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# 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.
Vagrant::Config.run do |config|
config.vm.box = "devcloud"
# TODO: Get a URL to host the base image
# config.vm.box_url = "http://domain.com/path/to/above.box"
config.vm.guest = :xen
config.ssh.username = "devcloud"
# Uncomment this line to enable the console for debugging the
# build process.
# config.vm.boot_mode = :gui
# Setup port forwarding
config.vm.forward_port 22, 2222
config.vm.forward_port 8080, 8080
config.vm.forward_port 8443, 8443
config.vm.forward_port 5901, 5901
config.vm.forward_port 8787, 8787
config.vm.forward_port 8250, 8250
# Ensure the VM has the right virtual resources
#config.vm.
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "puppet-devcloud"
puppet.manifest_file = "init.pp"
puppet.with_ssh = true
puppet.pp_path = "/etc/puppet"
puppet.module_path = "puppet-devcloud"
end
end

View File

@ -0,0 +1,8 @@
name 'puppet-devcloud'
version '0.0.1'
source ''
author 'Apache Software Foundation'
license 'Apache 2.0'
summary 'CloudStack DevCloud configuration module'
description 'Devcloud setup module.'
project_page 'http://cloudstack.org'

View File

@ -0,0 +1,21 @@
#!/bin/sh
# 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.
mac=`/sbin/ifconfig xenbr0 |/bin/grep HWaddr |/usr/bin/awk '{print $5}'`
/sbin/ebtables -I FORWARD -d ! $mac -i eth0 -p IPV4 --ip-prot udp --ip-dport 67:68 -j DROP
exit 0

View File

@ -0,0 +1,25 @@
#!/bin/sh
# 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.
/usr/bin/xe sr-list | /bin/grep local-storage
rc=$?
if [[ $rc != 0 ]] ; then
hostuuid=`xe host-list |grep uuid|awk '{print $5}'`;
xe sr-create host-uuid=$hostuuid name-label=local-storage shared=false type=file device-config:location=/opt/storage/primary
fi
exit 0

View File

@ -0,0 +1,25 @@
#!/bin/sh
# 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.
grep 0.0.0.0 /usr/lib/xcp/lib/vncterm-wrapper
rc=$?
if [[ $rc != 0 ]] ; then
sed -i 's/VNCTERM_LISTEN=.\+/VNCTERM_LISTEN="-v 0.0.0.0:1"/' /usr/lib/xcp/lib/vncterm-wrapper
fi
exit 0

View File

@ -0,0 +1 @@
/opt/storage/secondary *(rw,no_subtree_check,no_root_squash,fsid=0)

View File

@ -0,0 +1,17 @@
# Generated by iptables-save v1.4.12 on Sat Jul 28 03:18:44 2012
*mangle
:PREROUTING ACCEPT [397:23804]
:INPUT ACCEPT [397:23804]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [238:22820]
:POSTROUTING ACCEPT [238:22820]
-A POSTROUTING -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill
COMMIT
# Completed on Sat Jul 28 03:18:44 2012
# Generated by iptables-save v1.4.12 on Sat Jul 28 03:18:44 2012
*filter
:INPUT ACCEPT [453:27164]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [273:26476]
COMMIT
# Completed on Sat Jul 28 03:18:44 2012

View File

@ -0,0 +1,23 @@
#!/bin/sh
# 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.
export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32
cd /opt/cloudstack/incubator-cloudstack/
nohup ant run > /dev/null 2>&1 &
exit 0

View File

@ -0,0 +1,27 @@
#!/bin/sh
# 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.
cd /opt/cloudstack
git clone https://git-wip-us.apache.org/repos/asf/incubator-cloudstack.git
rc=$?
if [[ $rc != 0 ]] ; then
cd /opt/cloudstack/incubator-cloudstack
git pull origin master
fi
exit 0

View File

@ -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.
include puppet-devcloud

View File

@ -0,0 +1,320 @@
# 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.
class puppet-devcloud {
package { 'ebtables':
ensure => latest,
}
service { 'ebtables':
require => Package['ebtables'],
ensure => 'running',
enable => 'true',
}
package { 'iptables':
ensure => latest,
}
file { '/etc/iptables.save':
require => Package['iptables'],
ensure => 'file',
source => 'puppet:///modules/puppet-devcloud/iptables.save',
group => '0',
mode => '644',
owner => '0',
}
file { '/tmp/configebtables.sh':
ensure => 'file',
source => 'puppet:///modules/puppet-devcloud/configebtables.sh',
group => '0',
mode => '777',
owner => '0',
}
exec { "/tmp/configebtables.sh":
require => [
File['/tmp/configebtables.sh'],
Service['ebtables']
],
subscribe => Package['ebtables'],
refreshonly => true,
cwd => '/',
path => '/sbin/:/usr/bin/:/bin',
}
package { 'nfs-server':
ensure => latest,
}
file { '/opt/storage':
ensure => 'directory',
group => '0',
mode => '755',
owner => '0',
}
file { '/opt/storage/secondary':
ensure => 'directory',
group => '0',
mode => '755',
owner => '0',
}
file { '/opt/storage/secondary/template':
ensure => 'directory',
group => '0',
mode => '755',
owner => '0',
}
file { '/opt/storage/secondary/template/tmpl':
ensure => 'directory',
group => '0',
mode => '755',
owner => '0',
}
file { '/opt/storage/secondary/template/tmpl/1':
ensure => 'directory',
group => '0',
mode => '755',
owner => '0',
}
file { '/opt/storage/secondary/template/tmpl/1/1':
ensure => 'directory',
group => '0',
mode => '755',
owner => '0',
}
file { '/opt/storage/secondary/template/tmpl/1/5':
ensure => 'directory',
group => '0',
mode => '755',
owner => '0',
}
file { '/etc/exports':
require => Package['nfs-server'],
ensure => 'file',
source => 'puppet:///modules/puppet-devcloud/exports',
mode => '644',
owner => '0',
group => '0',
}
service { 'nfs-kernel-server':
require => Package['nfs-server'],
ensure => 'running',
enable => 'true',
}
exec { '/usr/bin/wget http://download.cloud.com/templates/devcloud/defaulttemplates/1/dc68eb4c-228c-4a78-84fa-b80ae178fbfd.vhd -P /opt/storage/secondary/template/tmpl/1/1/':
creates => '/opt/storage/secondary/template/tmpl/1/1/dc68eb4c-228c-4a78-84fa-b80ae178fbfd.vhd',
require => File['/opt/storage/secondary/template/tmpl/1/1/'],
timeout => '0',
}
exec { '/usr/bin/wget http://download.cloud.com/templates/devcloud/defaulttemplates/1/template.properties -P /opt/storage/secondary/template/tmpl/1/1/':
creates => '/opt/storage/secondary/template/tmpl/1/1/template.properties',
require => File['/opt/storage/secondary/template/tmpl/1/1/'],
}
exec { '/usr/bin/wget http://download.cloud.com/templates/devcloud/defaulttemplates/5/ce5b212e-215a-3461-94fb-814a635b2215.vhd -P /opt/storage/secondary/template/tmpl/1/5/':
creates => '/opt/storage/secondary/template/tmpl/1/5/ce5b212e-215a-3461-94fb-814a635b2215.vhd',
require => File['/opt/storage/secondary/template/tmpl/1/5/'],
timeout => '0',
}
exec { '/usr/bin/wget http://download.cloud.com/templates/devcloud/defaulttemplates/5/template.properties -P /opt/storage/secondary/template/tmpl/1/5/':
creates => '/opt/storage/secondary/template/tmpl/1/5/template.properties',
require => File['/opt/storage/secondary/template/tmpl/1/5/'],
}
exec { 'getecho':
command => '/usr/bin/wget http://download.cloud.com/templates/devcloud/echo -P /usr/lib/xcp/plugins/',
creates => '/usr/lib/xcp/plugins/echo',
}
exec { '/bin/chmod -R 777 /usr/lib/xcp':
require => Exec['getecho'],
}
file { '/opt/storage/primary':
ensure => 'directory',
group => '0',
mode => '755',
owner => '0',
}
file { '/tmp/configlocalstorage.sh':
ensure => 'file',
group => '0',
mode => '777',
owner => '0',
source => 'puppet:///modules/puppet-devcloud/configlocalstorage.sh',
}
exec { "configlocal":
require => [
File['/opt/storage/primary'],
File['/tmp/configlocalstorage.sh']
],
command => '/tmp/configlocalstorage.sh',
cwd => '/',
}
file { '/tmp/configvnc.sh':
ensure => 'file',
source => 'puppet:///modules/puppet-devcloud/configvnc.sh',
mode => '777',
group => '0',
owner => '0',
}
exec { "configvnc":
require => File['/tmp/configvnc.sh'],
command => '/tmp/configvnc.sh',
cwd => '/',
}
package { 'git':
ensure => latest,
}
package { 'unzip':
ensure => latest,
}
package { 'mysql-server':
ensure => latest,
}
package { 'ant':
ensure => latest,
}
package { 'openjdk-6-jdk':
ensure => latest,
}
file { '/opt/cloudstack':
ensure => 'directory',
group => '0',
mode => '755',
owner => '0',
}
file { '/tmp/updatecode.sh':
ensure => 'file',
source => 'puppet:///modules/puppet-devcloud/updatecode.sh',
mode => '777',
owner => '0',
group => '0',
}
exec { 'get_code':
require => [
Package['git'],
File['/opt/cloudstack/'],
File['/tmp/updatecode.sh']
],
command => '/tmp/updatecode.sh',
cwd => '/opt/cloudstack/',
timeout => '0',
}
file { '/opt/cloudstack/incubator-cloudstack/target':
ensure => 'directory',
group => '0',
mode => '755',
owner => '0',
require => Exec['get_code'],
}
file { '/opt/cloudstack/incubator-cloudstack/dist':
ensure => 'directory',
group => '0',
mode => '755',
owner => '0',
require => Exec['get_code'],
}
exec { 'downloadtomcat':
command => '/usr/bin/wget http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.zip -P /opt/cloudstack/',
creates => '/opt/cloudstack/apache-tomcat-6.0.32.zip',
require => File['/opt/cloudstack/'],
timeout => '0',
}
exec { "unziptomcat":
require => [
Package['unzip'],
Exec["downloadtomcat"]
],
creates => "/opt/cloudstack/apache-tomcat-6.0.32",
command => "/usr/bin/unzip apache-tomcat-6.0.32.zip",
cwd => "/opt/cloudstack",
timeout => '0',
}
exec { "catalina_home":
require => Exec["unziptomcat"],
unless => '/bin/grep CATALINA_HOME /root/.bashrc',
command => '/bin/echo "export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32" >> /root/.bashrc',
cwd => '/',
}
package { 'mkisofs':
ensure => latest,
}
exec { "build_cloudstack":
require => [
Package['ant'],
Exec["catalina_home"],
File['/opt/cloudstack/incubator-cloudstack/dist'],
File['/opt/cloudstack/incubator-cloudstack/target'],
Package['mkisofs']
],
command => "/usr/bin/ant clean-all build-all deploy-server deploydb",
cwd => "/opt/cloudstack/incubator-cloudstack/",
timeout => '0',
}
file { '/opt/cloudstack/startdevcloud.sh':
ensure => 'file',
source => 'puppet:///modules/puppet-devcloud/startdevcloud.sh',
mode => '777',
owner => '0',
group => '0',
}
exec { "start_cloudstack":
require => [
Exec["build_cloudstack"],
File["/opt/cloudstack/startdevcloud.sh"]
],
command => "/opt/cloudstack/startdevcloud.sh",
cwd => "/opt/cloudstack/",
}
}

View File

@ -121,7 +121,7 @@ postsetup() {
mkdir incubator-cloudstack/dist
wget http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.zip -P /opt/cloudstack/
unzip apache-tomcat-6.0.32.zip
echo "exportCATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32" >> /root/.bashrc
echo "export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32" >> /root/.bashrc
cd ~
fi

View File

@ -1,12 +0,0 @@
To use:
Preconfiguration phase -
- [setup your box in vagrant and place the contents of tools/devcloud/puppet into the box's folder]
- vagrant up; vagrant ssh
- sudo bash
- ln -s /vagrant/puppet-devcloudinitial /etc/puppet/modules/puppet-devcloudinitial
- cd /vagrant
- puppet apply --fsconfig fileserver.conf --debug --verbose -e "include puppet-devcloudinitial"
Postconfiguration phase -
TODO

View File

@ -1 +0,0 @@
include puppet-devcloudinitial

View File

@ -1 +0,0 @@
Nothing in this directory yet, but it will contain the scripts and preconfiguration files to build the basic Ubuntu 12.04 server used in devcloud.

View File

@ -1,43 +0,0 @@
group { 'vagranttest':
ensure => 'present',
gid => '5000',
}
group { 'admin':
ensure => 'present',
gid => '1002',
}
user { 'vagranttest':
ensure => 'present',
comment => 'vagrant,,,',
gid => '5000',
groups => ['adm', 'cdrom', 'dip', 'plugdev', 'lpadmin', 'sambashare', 'admin'],
home => '/home/vagranttest',
shell => '/bin/bash',
uid => '5000',
}
file { '/home/vagranttest':
ensure => 'directory',
group => '1002',
mode => '755',
owner => '5000',
}
file { '/home/vagranttest/.ssh':
ensure => 'directory',
group => '1002',
mode => '775',
owner => '5000',
}
$auth_key = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"
file { '/home/vagranttest/.ssh/authorized_keys':
ensure => 'file',
content => $auth_key,
group => '1002',
mode => '664',
owner => '5000',
}

View File

@ -0,0 +1,42 @@
# 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.
apt-get -y update
apt-get -y upgrade
apt-get -y install vim
apt-get -y install ruby
apt-get -y install rubygems
apt-get -y install puppet
apt-get clean
# Setup sudo to allow no-password sudo for "admin"
groupadd -r admin
usermod -a -G admin devcloud
sed -i -e '/Defaults\s\+env_reset/a Defaults\texempt_group=admin' /etc/sudoers
sed -i -e 's/%admin ALL=(ALL) ALL/%admin ALL=NOPASSWD:ALL/g' /etc/sudoers
mkdir /home/devcloud/.ssh
chmod 700 /home/devcloud/.ssh
cd /home/devcloud/.ssh
wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -O authorized_keys
chmod 600 /home/devcloud/.ssh/authorized_keys
chown -R devcloud /home/devcloud/.ssh
# Zero out the free space to save space in the final image:
dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY

View File

@ -1,102 +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.
from functools import partial
import unittest
import nose
import nose.config
import nose.core
import os
import sys
import logging
from cloudstackTestCase import cloudstackTestCase
from nose.suite import ContextSuite, ContextSuiteFactory
class CloudStackTestSelector(nose.selector.Selector):
"""
custom test selector for cloudstackTestCase
"""
def wantClass(self, cls):
if issubclass(cls, cloudstackTestCase):
return nose.selector.Selector.wantClass(self, cls)
def testCaseLogger(message, logger=None):
if logger is not None:
logger.debug(message)
class NoseTestExecuteEngine(object):
def __init__(self, testclient=None, workingdir=None, clientLog=None, resultLog=None, format="text"):
self.testclient = testclient
self.logformat = logging.Formatter("%(asctime)s - %(levelname)s - %(name)s - %(message)s")
self.suite = []
realPath = os.path.abspath(workingdir)
if clientLog is not None:
self.logfile = clientLog
self.logger = logging.getLogger("NoseTestExecuteEngine")
fh = logging.FileHandler(self.logfile)
fh.setFormatter(self.logformat)
self.logger.addHandler(fh)
self.logger.setLevel(logging.DEBUG)
if resultLog is not None:
ch = logging.StreamHandler()
ch.setLevel(logging.ERROR)
ch.setFormatter(self.logformat)
self.logger.addHandler(ch)
fp = open(resultLog, "w")
self.testResultLogFile = fp
else:
self.testResultLogFile = sys.stdout
if workingdir is not None and os.path.exists(realPath + '/' + '__init__.py'):
self.loader = nose.loader.TestLoader()
[self.suite.append(test) for test in self.loader.discover(workingdir, "test*.py")]
for test in self.suite:
self.injectTestCase(test)
print self.suite[0].countTestCases()
else:
raise Exception("Single module test runs unsupported using Nose")
if format == "text":
self.runner = nose.core.TextTestRunner(stream=self.testResultLogFile, descriptions=1, verbosity=2, config=None)
else:
raise Exception("XML runner not supported under nose")
def runTests(self):
#testProgram = nose.core.TestProgram(argv=["--process-timeout=3600"], testRunner = self.runner, testLoader = self.loader)
testProgram = nose.core.TestProgram(argv=["--process-timeout=3600"], testRunner = self.runner, suite = self.suite)
testProgram.runTests()
def injectTestCase(self, testSuites):
for test in testSuites:
if isinstance(test, unittest.BaseTestSuite):
self.injectTestCase(test)
else:
#logger bears the name of the test class
testcaselogger = logging.getLogger("testclient.testcase.%s"%test.__class__.__name__)
fh = logging.FileHandler(self.logfile)
fh.setFormatter(self.logformat)
testcaselogger.addHandler(fh)
testcaselogger.setLevel(logging.DEBUG)
#inject testclient and logger into each unittest
setattr(test, "testClient", self.testclient)
setattr(test, "debug", partial(testCaseLogger, logger=testcaselogger))
setattr(test.__class__, "clstestclient", self.testclient)
if hasattr(test, "UserName"):
self.testclient.createNewApiClient(test.UserName, test.DomainName, test.AcctType)

Some files were not shown because too many files have changed in this diff Show More