You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2012/06/20 03:48:00 UTC
[4/8] Introduced plugins directory. Moved ovm into plugins.
Introduced build.xml for ovm.
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/ovm/src/com/cloud/ovm/object/OvmVlan.java
----------------------------------------------------------------------
diff --git a/ovm/src/com/cloud/ovm/object/OvmVlan.java b/ovm/src/com/cloud/ovm/object/OvmVlan.java
deleted file mode 100644
index d95dfb9..0000000
--- a/ovm/src/com/cloud/ovm/object/OvmVlan.java
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by 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.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.ovm.object;
-
-import org.apache.xmlrpc.XmlRpcException;
-
-public class OvmVlan extends OvmObject {
- public static class Details {
- public String name;
- public int vid;
- public String pif;
-
- public String toJson() {
- return Coder.toJson(this);
- }
- }
-
- public static String create(Connection c, Details d) throws XmlRpcException {
- Object[] params = {d.toJson()};
- String res = (String)c.call("OvmNetwork.createVlan", params);
- Details ret = Coder.fromJson(res, Details.class);
- return ret.name;
- }
-
- public static void delete(Connection c, String name) throws XmlRpcException {
- Object[] params = {name};
- c.call("OvmNetwork.deleteVlan", params);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/ovm/src/com/cloud/ovm/object/OvmVm.java
----------------------------------------------------------------------
diff --git a/ovm/src/com/cloud/ovm/object/OvmVm.java b/ovm/src/com/cloud/ovm/object/OvmVm.java
deleted file mode 100644
index 2b53833..0000000
--- a/ovm/src/com/cloud/ovm/object/OvmVm.java
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by 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.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.ovm.object;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.xmlrpc.XmlRpcException;
-
-import com.cloud.ovm.object.OvmHost.Details;
-
-public class OvmVm extends OvmObject {
- public static final String CD = "CD";
- public static final String HDD = "HDD";
- public static final String HVM = "HVM";
- public static final String PV = "PV";
- public static final String FROMCONFIGFILE = "FROMCONFIGFILE";
-
- public static class Details {
- public int cpuNum;
- public long memory;
- public OvmDisk.Details rootDisk;
- public List<OvmDisk.Details> disks;
- public List<OvmVif.Details> vifs;
- public String name;
- public String uuid;
- public String powerState;
- public String bootDev;
- public String type;
-
- public Details() {
- disks = new ArrayList<OvmDisk.Details>();
- vifs = new ArrayList<OvmVif.Details>();
- }
-
- public String toJson() {
- return Coder.toJson(this);
- }
- }
-
- public OvmVm() {
- }
-
- /*********** XML RPC Call **************/
- public static void create(Connection c, Details d) throws XmlRpcException {
- Object[] params = {d.toJson()};
- c.call("OvmVm.create", params);
- }
-
- public static Map<String, String> reboot(Connection c, String vmName) throws XmlRpcException {
- Object[] params = {vmName};
- String res = (String) c.call("OvmVm.reboot", params);
- return Coder.mapFromJson(res);
- }
-
- public static void stop(Connection c, String vmName) throws XmlRpcException {
- Object[] params = {vmName};
- /* Agent will destroy vm if vm shutdowns failed due to timout after 10 mins, so we set timeout to 20 mins here*/
- c.callTimeoutInSec("OvmVm.stop", params, 1200);
- }
-
- public static Details getDetails(Connection c, String vmName) throws XmlRpcException {
- Object[] params = {vmName};
- String res = (String)c.call("OvmVm.getDetails", params);
- return Coder.fromJson(res, OvmVm.Details.class);
- }
-
- public static Map<String, String> getVmStats(Connection c, String vmName) throws XmlRpcException {
- Object[] params = {vmName};
- String res = (String)c.call("OvmVm.getVmStats", params);
- return Coder.mapFromJson(res);
- }
-
- public static void migrate(Connection c, String vmName, String dest) throws XmlRpcException {
- Object[] params = {vmName, dest};
- c.call("OvmVm.migrate", params);
- }
-
- public static Map<String, String> register(Connection c, String vmName) throws XmlRpcException {
- Object[] params = {vmName};
- String res = (String) c.call("OvmVm.register", params);
- return Coder.mapFromJson(res);
- }
-
- public static Integer getVncPort(Connection c, String vmName) throws XmlRpcException {
- Object[] params = {vmName};
- String res = (String) c.call("OvmVm.getVncPort", params);
- Map<String, String> result = Coder.mapFromJson(res);
- return Integer.parseInt(result.get("vncPort"));
- }
-
- public static void detachOrAttachIso(Connection c, String vmName, String iso, Boolean isAttach) throws XmlRpcException {
- Object[] params = {vmName, iso, isAttach};
- c.call("OvmVm.detachOrAttachIso", params);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/ovm/src/com/cloud/ovm/object/OvmVolume.java
----------------------------------------------------------------------
diff --git a/ovm/src/com/cloud/ovm/object/OvmVolume.java b/ovm/src/com/cloud/ovm/object/OvmVolume.java
deleted file mode 100644
index a64c963..0000000
--- a/ovm/src/com/cloud/ovm/object/OvmVolume.java
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by 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.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.ovm.object;
-
-import org.apache.xmlrpc.XmlRpcException;
-
-public class OvmVolume extends OvmObject {
- public static class Details {
- public String name;
- public String uuid;
- public String poolUuid;
- public Long size;
- public String path;
-
- public String toJson() {
- return Coder.toJson(this);
- }
- }
-
- public static Details createDataDsik(Connection c, String poolUuid, String size, Boolean isRoot) throws XmlRpcException {
- Object[] params = {poolUuid, size, isRoot};
- String res = (String) c.call("OvmVolume.createDataDisk", params);
- Details result = Coder.fromJson(res, Details.class);
- return result;
- }
-
- public static Details createFromTemplate(Connection c, String poolUuid, String templateUrl) throws XmlRpcException {
- Object[] params = {poolUuid, templateUrl};
- String res = (String) c.callTimeoutInSec("OvmVolume.createFromTemplate", params, 3600*3);
- Details result = Coder.fromJson(res, Details.class);
- return result;
- }
-
- public static void destroy(Connection c, String poolUuid, String path) throws XmlRpcException {
- Object[] params = {poolUuid, path};
- c.call("OvmVolume.destroy", params);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/ovm/src/com/cloud/ovm/object/Test.java
----------------------------------------------------------------------
diff --git a/ovm/src/com/cloud/ovm/object/Test.java b/ovm/src/com/cloud/ovm/object/Test.java
deleted file mode 100644
index 9d56f7d..0000000
--- a/ovm/src/com/cloud/ovm/object/Test.java
+++ /dev/null
@@ -1,179 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by 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.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.ovm.object;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import com.cloud.utils.Pair;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
-public class Test {
- public static void main(String[] args) {
- try {
- /*Connection c = new Connection("192.168.105.155", "oracle", "password");
- Utils util = new UtilsImpl(c);
- Storage storage = new StorageImpl(c);
- String[] res = util.listDir("/etc", 1);
- for (String s : res) {
- System.out.println(s);
- }
-
-
- Pool pool = new PoolImpl(c);
-
- //pool.registerServer("192.168.105.155", Pool.ServerType.SITE);
- //pool.registerServer("192.168.105.155", Pool.ServerType.UTILITY);
- //pool.registerServer("192.168.105.155", Pool.ServerType.XEN);
- System.out.println("Is:" + pool.isServerRegistered());
- //String ip = pool.getMasterIp();
- //System.out.println("IP:" + ip);
- System.out.println(pool.getServerConfig());
- System.out.println(pool.getServerXmInfo());
- System.out.println(pool.getHostInfo());
- System.out.println(pool.getAgentVersion());
- String[] srs = storage.listSr();
- for (int i=0; i<srs.length; i++) {
- System.out.println(srs[i]);
- }
- String spuuid = storage.createSp(StorageType.OVSSPNFS, "192.168.110.232:/export/frank/nfs");
- System.out.println(spuuid);
- String sruuid = storage.createSr(spuuid, "hi");
- System.out.println(sruuid);
- storage.initSr();
- Pair<Long, Long> spaceInfo = storage.getSrSpaceInfo("192.168.110.232:/export/frank/nfs");
- System.out.println("Total:" + spaceInfo.first());
- System.out.println("Free:" + spaceInfo.second());*/
- OvmVm.Details vm = new OvmVm.Details();
- vm.cpuNum = 1;
- vm.memory = 512;
- vm.name = "Test";
- vm.uuid = "This-is-a-test";
- OvmDisk.Details rootDisk = new OvmDisk.Details();
- rootDisk.path = "/root/root.raw";
- rootDisk.type = OvmDisk.WRITE;
- vm.rootDisk = rootDisk;
- OvmDisk.Details dataDisk = new OvmDisk.Details();
- dataDisk.path = "/tmp/data.raw";
- dataDisk.type = OvmDisk.SHAREDWRITE;
- vm.disks.add(dataDisk);
- vm.disks.add(dataDisk);
- vm.disks.add(dataDisk);
- vm.disks.add(dataDisk);
- vm.disks.add(dataDisk);
- OvmVif.Details vif = new OvmVif.Details();
- vif.mac = "00:ff:ff:ff:ff:ee";
- vif.bridge = "xenbr0";
- vif.type = OvmVif.NETFRONT;
- vm.vifs.add(vif);
- vm.vifs.add(vif);
- vm.vifs.add(vif);
- vm.vifs.add(vif);
- vm.vifs.add(vif);
- //System.out.println(vm.toJson());
- Connection c = new Connection("192.168.189.12", "oracle", "password");
- //System.out.println(Coder.toJson(OvmHost.getDetails(c)));
- String txt = "{\"MasterIp\": \"192.168.189.12\", \"dom0Memory\": 790626304, \"freeMemory\": 16378757120, \"totalMemory\": 17169383424, \"cpuNum\": 4, \"agentVersion\": \"2.3-38\", \"cpuSpeed\": 2261}";
- //OvmHost.Details d = new GsonBuilder().create().fromJson(txt, OvmHost.Details.class);
- //OvmHost.Details d = Coder.fromJson(txt, OvmHost.Details.class);
- //OvmHost.Details d = OvmHost.getDetails(c);
- //System.out.println(Coder.toJson(d));
-// OvmStoragePool.Details pool = new OvmStoragePool.Details();
-// pool.path = "192.168.110.232:/export/frank/ovs";
-// pool.type = OvmStoragePool.NFS;
-// pool.uuid = "123";
-// System.out.println(pool.toJson());
-
- String cmd = null;
- System.out.println(args.length);
- if (args.length >= 1) {
- cmd = args[0];
- OvmVm.Details d = new OvmVm.Details();
- d.cpuNum = 1;
- d.memory = 512 * 1024 * 1024;
- d.name = "MyTest";
- d.uuid = "1-2-3-4-5";
- OvmDisk.Details r = new OvmDisk.Details();
- r.path = "/var/ovs/mount/60D0985974CA425AAF5D01A1F161CC8B/running_pool/36_systemvm/System.img";
- r.type = OvmDisk.WRITE;
- d.rootDisk = r;
- OvmVif.Details v = new OvmVif.Details();
- v.mac = "00:16:3E:5C:B1:D1";
- v.bridge = "xenbr0";
- v.type = OvmVif.NETFRONT;
- d.vifs.add(v);
- System.out.println(d.toJson());
-
- if (cmd.equalsIgnoreCase("create")) {
- // String s =
- // "{\"cpuNum\":1,\"memory\":512,\"rootDisk\":{\"type\":\"w\",\"path\":\"/var/ovs/mount/60D0985974CA425AAF5D01A1F161CC8B/running_pool/36_systemvm/System.img\"},\"disks\":[],\"vifs\":[{\"mac\":\"00:16:3E:5C:B1:D1\",\"bridge\":\"xenbr0\",\"type\":\"netfront\"}],\"name\":\"MyTest\",\"uuid\":\"1-2-3-4-5\"}";
- OvmVm.create(c, d);
- // c.call("OvmVm.echo", new Object[]{s});
- } else if (cmd.equalsIgnoreCase("reboot")) {
- Map<String, String> res = OvmVm.reboot(c, "MyTest");
- System.out.println(res.get("vncPort"));
- //OvmVm.stop(c, "MyTest");
- //OvmVm.create(c, d);
- } else if (cmd.equalsIgnoreCase("stop")) {
- OvmVm.stop(c, "MyTest");
- } else if (cmd.equalsIgnoreCase("details")) {
- OvmVm.Details ddd = OvmVm.getDetails(c, "MyTest");
- System.out.println(ddd.vifs.size());
- System.out.println(ddd.rootDisk.path);
- System.out.println(ddd.powerState);
- } else if (cmd.equalsIgnoreCase("all")) {
- System.out.println(OvmHost.getAllVms(c));
- } else if (cmd.equalsIgnoreCase("createBridge")) {
- OvmBridge.Details bd = new OvmBridge.Details();
- bd.name = "xenbr10";
- bd.attach = args[1];
- OvmBridge.create(c, bd);
- } else if (cmd.equalsIgnoreCase("createVlan")) {
- OvmVlan.Details vd = new OvmVlan.Details();
- vd.pif = "eth0";
- vd.vid = 1000;
- String vname = OvmVlan.create(c, vd);
- System.out.println(vname);
- } else if (cmd.equalsIgnoreCase("delVlan")) {
- OvmVlan.delete(c, args[1]);
- } else if (cmd.equalsIgnoreCase("delBr")) {
- OvmBridge.delete(c, args[1]);
- } else if (cmd.equalsIgnoreCase("getBrs")) {
- List<String> brs = OvmBridge.getAllBridges(c);
- System.out.println(brs);
- } else if (cmd.equalsIgnoreCase("getBrDetails")) {
- OvmBridge.Details brd = OvmBridge.getDetails(c, args[1]);
- System.out.println(brd.interfaces);
- }
-
- }
-
- List<String> l = new ArrayList<String>();
- l.add("4b4d8951-f0b6-36c5-b4f3-a82ff2611c65");
- System.out.println(Coder.toJson(l));
-
-// Map<String, String> res = OvmHost.getPerformanceStats(c, "xenbr0");
-// System.out.println(res.toString());
-// String stxt = "{\"vifs\": [{\"bridge\": \"xenbr0\", \"mac\": \"00:16:3E:5C:B1:D1\", \"type\": \"netfront\"}], \"powerState\": \"RUNNING\", \"disks\": [], \"cpuNum\": 1, \"memory\": 536870912, \"rootDisk\": {\"path\": \"/var/ovs/mount/60D0985974CA425AAF5D01A1F161CC8B/running_pool/MyTest/System.img\", \"type\": \"w\"}}";
-// OvmVm.Details ddd = Coder.fromJson(stxt, OvmVm.Details.class);
-// System.out.println(ddd.vifs.size());
-// System.out.println(ddd.rootDisk.path);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/deployment-planner/user-dispersing/.classpath
----------------------------------------------------------------------
diff --git a/plugins/deployment-planner/user-dispersing/.classpath b/plugins/deployment-planner/user-dispersing/.classpath
new file mode 100755
index 0000000..a246f5e
--- /dev/null
+++ b/plugins/deployment-planner/user-dispersing/.classpath
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/api"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/core"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/server"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/utils"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/deployment-planner/user-dispersing/.project
----------------------------------------------------------------------
diff --git a/plugins/deployment-planner/user-dispersing/.project b/plugins/deployment-planner/user-dispersing/.project
new file mode 100755
index 0000000..d9b2d40
--- /dev/null
+++ b/plugins/deployment-planner/user-dispersing/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>user-dispersing</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/deployment-planner/user-dispersing/.settings/org.eclipse.jdt.core.prefs
----------------------------------------------------------------------
diff --git a/plugins/deployment-planner/user-dispersing/.settings/org.eclipse.jdt.core.prefs b/plugins/deployment-planner/user-dispersing/.settings/org.eclipse.jdt.core.prefs
new file mode 100755
index 0000000..d0ee7df
--- /dev/null
+++ b/plugins/deployment-planner/user-dispersing/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Tue Jun 19 15:34:37 PDT 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/deployment-planner/user-dispersing/build.xml
----------------------------------------------------------------------
diff --git a/plugins/deployment-planner/user-dispersing/build.xml b/plugins/deployment-planner/user-dispersing/build.xml
new file mode 100644
index 0000000..60a1f2d
--- /dev/null
+++ b/plugins/deployment-planner/user-dispersing/build.xml
@@ -0,0 +1,609 @@
+<?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 User Dispersing Deployment Planner" default="help" basedir=".">
+ <description>
+ Cloud Stack ant build file
+ </description>
+
+ <!--
+ Test
+ Always use this variable to refer to the base directory because this
+ variable is changeable
+ -->
+ <dirname property="base.dir" file="${ant.file.Cloud Stack}/.." />
+ <property name="build.dir" location="${base.dir}/build" />
+
+ <!-- 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="${base.dir}/build/build.number" />
+
+ <import file="${build.dir}/build-common.xml" />
+
+ <!-- In case these didn't get defined in the build-cloud.properties -->
+ <property name="branding.name" value="default" />
+ <property name="tomcat.home" value="${env.CATALINA_HOME}" />
+ <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"/>
+
+ <!-- directories for build and distribution -->
+ <property name="dist.dir" location="${base.dir}/dist/" />
+ <property name="target.dir" location="${base.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="${base.dir}/deps" />
+ <property name="tools.jar.dir" location="${base.dir}/tools/tooljars" />
+
+ <!-- directories for client compilation-->
+ <property name="client.dir" location="${base.dir}/client" />
+ <property name="client.test.dir" location="${client.dir}/test" />
+ <property name="client.target.dir" location="${target.dir}/ui" />
+ <property name="ui.user.dir" location="${base.dir}/ui" />
+ <property name="setup.db.dir" location="${base.dir}/setup/db" />
+ <property name="setup.apidoc.dir" location="${base.dir}/setup/apidoc" />
+
+ <!-- directories for server compilation-->
+ <property name="server.dir" location="${base.dir}/server" />
+ <property name="server.test.dir" location="${server.dir}/test" />
+ <property name="server.dist.dir" location="${dist.dir}/client" />
+ <property name="db.scripts.dir" location="${target.dir}/db"/>
+ <property name="apidoc.scripts.dir" location="${base.dir}/setup/apidoc/"/>
+
+ <!-- directories for core code compilation-->
+ <property name="core.dir" location="${base.dir}/core" />
+ <property name="core.test.dir" location="${core.dir}/test/" />
+
+ <!-- directories for agent code compilation-->
+ <property name="agent.dir" location="${base.dir}/agent" />
+ <property name="agent.test.dir" location="${utils.dir}/test/" />
+ <property name="agent.dist.dir" location="${dist.dir}/agent" />
+
+ <property name="scripts.dir" location="${base.dir}/scripts" />
+ <property name="scripts.target.dir" location="${target.dir}/scripts"/>
+
+ <!-- directories for console proxy compilation-->
+ <property name="console-proxy.dir" location="${base.dir}/console-proxy" />
+ <property name="console-proxy.dist.dir" location="${dist.dir}/console-proxy" />
+
+ <property name="tools.dir" location="${base.dir}/tools" />
+ <!-- <property name="antcontrib.dir" location="${tools.dir}/tools/ant/apache-ant-1.8.0/lib" />-->
+ <property name="deploy.dir" location="${build.dir}/deploy" />
+ <property name="production.dir" location="${deploy.dir}/production" />
+ <property name="meld.home" location="/usr/local/bin" />
+ <property name="assertion" value="-da" />
+
+ <!-- directory for vmware-base library -->
+ <property name="vmware-base.dir" location="${base.dir}/vmware-base" />
+
+ <!-- directories for branding -->
+ <property name="branding.dir" location="${build.dir}/deploy/branding/${branding.name}" />
+
+ <property name="core.jar" value="cloud-core.jar" />
+ <property name="utils.jar" value="cloud-utils.jar" />
+ <property name="server.jar" value="cloud-server.jar" />
+ <property name="agent.jar" value="cloud-agent.jar" />
+ <property name="console-proxy.jar" value="cloud-console-proxy.jar" />
+ <property name="api.jar" value="cloud-api.jar"/>
+ <property name="vmware-base.jar" value="cloud-vmware-base.jar" />
+
+ <!--
+ Import information about the build version and company information
+ -->
+ <property name="version" value="${company.major.version}.${company.minor.version}.${company.patch.version}" />
+
+ <!-- Class paths -->
+ <path id="prod.src.path">
+ <pathelement location="${server.dir}/src" />
+ <pathelement location="${utils.dir}/src" />
+ <pathelement location="${core.dir}/src" />
+ <pathelement location="${agent.dir}/src" />
+ </path>
+
+ <path id="src.classpath">
+ </path>
+
+ <path id="compile.deps.classpath">
+ <fileset dir="${tools.jar.dir}" erroronmissingdir="true">
+ <include name="*.jar" />
+ </fileset>
+ </path>
+
+ <path id="deps.classpath">
+ <!--filelist files="${deps.classpath}" /-->
+ <fileset dir="${deps.dir}" erroronmissingdir="false">
+ <include name="*.jar" />
+ </fileset>
+ <path refid="compile.deps.classpath" />
+ </path>
+
+ <path id="dist.classpath">
+ <fileset dir="${target.dir}">
+ <include name="**/*.jar" />
+ </fileset>
+ <fileset dir="${target.dir}/jar">
+ <include name="**/*.jar" />
+ </fileset>
+ </path>
+
+ <path id="test.classpath">
+ <fileset dir="${dist.dir}">
+ <include name="**/*.jar" />
+ </fileset>
+ </path>
+
+ <!-- directories for util code compilation-->
+ <property name="utils.dir" location="${base.dir}/utils" />
+ <property name="utils.test.dir" location="${utils.dir}/test/" />
+ <path id="utils.classpath">
+ <path refid="deps.classpath" />
+ </path>
+ <target name="compile-utils" depends="-init" description="Compile the utilities jar that is shared.">
+ <compile-java jar.name="${utils.jar}" top.dir="${utils.dir}" classpath="utils.classpath" >
+ <include-files>
+ <fileset dir="${utils.dir}/certs">
+ <include name="*.keystore" />
+ </fileset>
+ </include-files>
+ </compile-java>
+ </target>
+
+ <property name="api.dir" location="${base.dir}/api" />
+ <property name="api.test.dir" location="${api.dir}/test/" />
+ <path id="api.classpath">
+ <path refid="deps.classpath" />
+ <path refid="dist.classpath"/>
+ </path>
+ <target name="compile-api" depends="-init, compile-utils" description="Compile the utilities jar that is shared.">
+ <compile-java jar.name="${api.jar}" top.dir="${api.dir}" classpath="api.classpath" />
+ </target>
+
+ <path id="core.classpath">
+ <path refid="deps.classpath" />
+ <path refid="dist.classpath" />
+ </path>
+ <target name="compile-core" depends="-init, compile-utils, compile-api, compile-vmware-base" description="Compile the core business logic.">
+ <compile-java jar.name="${core.jar}" top.dir="${core.dir}" classpath="core.classpath" />
+ </target>
+
+ <path id="vmware-base.classpath">
+ <path refid="deps.classpath" />
+ <path refid="dist.classpath" />
+ </path>
+ <target name="compile-vmware-base" depends="-init, compile-utils" description="Compile the VMware support library">
+ <compile-java jar.name="${vmware-base.jar}" top.dir="${vmware-base.dir}" classpath="vmware-base.classpath" />
+ </target>
+
+ <path id="server.classpath">
+ <path refid="deps.classpath" />
+ <path refid="dist.classpath" />
+ </path>
+ <target name="compile-server" depends="-init, compile-utils, compile-core, compile-agent" description="Compile the management server.">
+ <compile-java jar.name="${server.jar}" top.dir="${server.dir}" classpath="server.classpath" />
+ </target>
+
+ <path id="client.classpath">
+ <path refid="deps.classpath" />
+ <path refid="dist.classpath" />
+ </path>
+
+ <target name="build-scripts" depends="-init">
+ <copy todir="${scripts.target.dir}">
+ <fileset dir="${scripts.dir}">
+ <include name="**/*"/>
+ <exclude name="**/fsimage.so"/>
+ <exclude name="**/ping.tar.bz2"/>
+ <exclude name="**/vhd-util"/>
+ <exclude name="**/.*" />
+ </fileset>
+ <filterset>
+ <filter token="VERSION" value="${impl.version}"/>
+ </filterset>
+ </copy>
+ <copy todir="${scripts.target.dir}">
+ <fileset dir="${scripts.dir}">
+ <include name="**/fsimage.so"/>
+ <include name="**/ping.tar.bz2"/>
+ <include name="**/vhd-util"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="build-ui" depends="-init" description="Builds the UI">
+ <mkdir dir="${client.target.dir}" />
+ <copy todir="${client.target.dir}">
+ <fileset dir="${ui.user.dir}">
+ <include name="**/*.html" />
+ <include name="**/*.js"/>
+ <include name="**/*.jsp"/>
+ <exclude name="**/.classpath" />
+ <exclude name="**/.project" />
+ </fileset>
+ <filterset>
+ <filter token="VERSION" value="${impl.version}"/>
+ </filterset>
+ </copy>
+ <copy todir="${client.target.dir}">
+ <fileset dir="${ui.user.dir}">
+ <include name="**/*"/>
+ <exclude name="**/*.html" />
+ <exclude name="**/*.js"/>
+ <exclude name="**/*.jsp"/>
+ <exclude name="**/.classpath" />
+ <exclude name="**/.project" />
+ </fileset>
+ </copy>
+ <copy todir="${client.target.dir}">
+ <fileset dir="${client.dir}/WEB-INF/classes">
+ <include name="**/*.properties"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="build-ovm" depends="compile-ovm" />
+
+ <target name="build-server" depends="compile-server">
+ <mkdir dir="${server.dist.dir}" />
+ <mkdir dir="${server.dist.dir}/lib" />
+ <mkdir dir="${server.dist.dir}/conf" />
+
+ <copy todir="${jar.dir}">
+ <fileset dir="${deps.dir}">
+ <include name="cloud-*.jar"/>
+ </fileset>
+ </copy>
+
+ <copy overwrite="true" todir="${server.dist.dir}/conf">
+ <fileset dir="${base.dir}/client/tomcatconf">
+ <include name="*.in" />
+ </fileset>
+ <globmapper from="*.in" to="*" />
+ <filterchain>
+ <filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
+ <param type="propertiesfile" value="${override.file}" />
+ </filterreader>
+ </filterchain>
+ </copy>
+
+ <copy overwrite="true" todir="${server.dist.dir}/conf">
+ <fileset dir="${server.dir}/src/com/cloud/migration">
+ <include name="*.xml" />
+ </fileset>
+ </copy>
+
+ <copy overwrite="true" todir="${db.scripts.dir}">
+ <fileset dir="${setup.db.dir}">
+ <include name="**/*"/>
+ </fileset>
+ <filterset>
+ <filter token="VERSION" value="${impl.version}"/>
+ </filterset>
+ </copy>
+ </target>
+
+ <path id="console-proxy.classpath">
+ <path refid="deps.classpath" />
+ <path refid="dist.classpath" />
+ </path>
+ <target name="compile-console-proxy" depends="-init" description="Compile the console proxy.">
+ <compile-java jar.name="${console-proxy.jar}" top.dir="${console-proxy.dir}" classpath="console-proxy.classpath" >
+ <include-files>
+ <fileset dir="${console-proxy.dir}/certs">
+ <include name="*.keystore" />
+ <include name="*.crt" />
+ <include name="*.key" />
+ </fileset>
+ </include-files>
+ </compile-java>
+ </target>
+
+ <target name="copy-console-proxy" depends="-init">
+ <property name="copyto.dir" value="${console-proxy.dist.dir}" />
+ <mkdir dir="${copyto.dir}" />
+ <mkdir dir="${copyto.dir}/conf" />
+ <mkdir dir="${copyto.dir}/logs" />
+ <mkdir dir="${copyto.dir}/applet" />
+ <mkdir dir="${copyto.dir}/images" />
+ <mkdir dir="${copyto.dir}/js" />
+ <mkdir dir="${copyto.dir}/ui" />
+ <mkdir dir="${copyto.dir}/css" />
+ <mkdir dir="${copyto.dir}/certs" />
+
+ <copy todir="${copyto.dir}">
+ <fileset dir="${deps.dir}">
+ <include name="log4j-1.2.15.jar" />
+ <include name="apache-log4j-extras-1.0.jar" />
+ <include name="gson.jar" />
+ </fileset>
+ </copy>
+
+ <copy todir="${copyto.dir}">
+ <fileset dir="${jar.dir}">
+ <include name="cloud-console-proxy.jar" />
+ </fileset>
+ </copy>
+ <copy todir="${copyto.dir}/conf">
+ <fileset dir="${production.dir}/consoleproxy/conf">
+ <include name="log4j-cloud.xml" />
+ <include name="consoleproxy.properties" />
+ </fileset>
+ </copy>
+ <copy todir="${copyto.dir}/images">
+ <fileset dir="${console-proxy.dir}/images">
+ <include name="*.jpg" />
+ <include name="*.gif" />
+ <include name="*.png" />
+ <include name="*.cur" />
+ </fileset>
+ </copy>
+ <copy todir="${copyto.dir}/js">
+ <fileset dir="${console-proxy.dir}/js">
+ <include name="*.js" />
+ </fileset>
+ </copy>
+ <copy todir="${copyto.dir}/ui">
+ <fileset dir="${console-proxy.dir}/ui">
+ <include name="*.ftl" />
+ </fileset>
+ </copy>
+ <copy todir="${copyto.dir}/css">
+ <fileset dir="${console-proxy.dir}/css">
+ <include name="*.css" />
+ </fileset>
+ </copy>
+ <copy todir="${copyto.dir}/certs">
+ <fileset dir="${console-proxy.dir}/certs">
+ <include name="*.keystore" />
+ <include name="*.crt" />
+ <include name="*.key" />
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="build-console-proxy" depends="-init, compile-console-proxy, copy-console-proxy">
+ <copy todir="${console-proxy.dist.dir}">
+ <fileset dir="${console-proxy.dir}/scripts">
+ </fileset>
+ </copy>
+ <copy todir="${console-proxy.dist.dir}/conf">
+ <fileset dir="${console-proxy.dir}/conf">
+ </fileset>
+ </copy>
+ </target>
+
+
+ <path id="agent.classpath">
+ <path refid="deps.classpath" />
+ <fileset dir="${target.dir}">
+ <include name="**/${core.jar}" />
+ <include name="**/${utils.jar}" />
+ <include name="**/${api.jar}"/>
+ </fileset>
+ </path>
+ <target name="compile-agent" depends="-init, compile-utils, compile-core, compile-api" description="Compile the management agent.">
+ <compile-java jar.name="${agent.jar}" top.dir="${agent.dir}" classpath="agent.classpath" />
+ </target>
+
+ <target name="build-agent" depends="-init, compile-agent">
+ <mkdir dir="${agent.dist.dir}" />
+ <mkdir dir="${agent.dist.dir}/scripts" />
+ <mkdir dir="${agent.dist.dir}/conf" />
+ <mkdir dir="${agent.dist.dir}/logs" />
+ <mkdir dir="${agent.dist.dir}/db" />
+ <mkdir dir="${agent.dist.dir}/storagehdpatch" />
+
+ <condition property="agent.properties" value="override/agent.properties" else="agent.properties">
+ <available file="${agent.dir}/conf/override/agent.properties" />
+ </condition>
+
+ <condition property="developer.properties" value="override/developer.properties" else="developer.properties">
+ <available file="${agent.dir}/conf/override/developer.properties" />
+ </condition>
+
+ <copy overwrite="true" todir="${agent.dist.dir}/conf" flatten="true">
+ <fileset dir="${agent.dir}/conf">
+ <include name="${agent.properties}" />
+ <include name="${developer.properties}" />
+ </fileset>
+ <filterchain>
+ <filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
+ <param type="propertiesfile" value="${override.file}" />
+ </filterreader>
+ </filterchain>
+ </copy>
+
+ <copy overwrite="true" todir="${agent.dist.dir}/conf" flatten="true">
+ <fileset dir="${agent.dir}/conf">
+ <include name="log4j-cloud.xml.in" />
+ </fileset>
+ <globmapper from="*.in" to="*" />
+ <filterchain>
+ <filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
+ <param type="propertiesfile" value="${override.file}" />
+ </filterreader>
+ </filterchain>
+ </copy>
+ <delete file="${agent.dist.dir}/conf/log4j-cloud.xml.in"/>
+
+ <copy todir="${agent.dist.dir}">
+ <fileset dir="${agent.dir}/scripts">
+ <include name="agent.sh" />
+ <include name="run.sh" />
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="build-servers" depends="-init, build-server" />
+
+ <target name="build-opensource" depends="-init, build-server, build-agent, build-scripts, build-ui, build-ovm, package-oss-systemvm-iso">
+ <copy overwrite="true" todir="${dist.dir}">
+ <fileset dir="${base.dir}/build/deploy/">
+ <include name="deploy-agent.sh" />
+ <include name="deploy-server.sh" />
+ <include name="deploy-console-proxy.sh" />
+ <include name="install.sh" />
+ </fileset>
+ <fileset dir="${base.dir}/client">
+ <include name="setup/**/*" />
+ </fileset>
+ </copy>
+
+ <copy overwrite="true" todir="${jar.dir}">
+ <fileset dir="${deps.dir}">
+ <include name="vmware-*.jar" />
+ </fileset>
+ </copy>
+
+ <chmod file="${dist.dir}/deploy-agent.sh" perm="uog+xr" />
+ <chmod file="${dist.dir}/deploy-server.sh" perm="uog+xr" />
+ </target>
+
+
+ <target name="build-systemvm-patch" depends="-init">
+ <mkdir dir="${dist.dir}" />
+ <mkdir dir="${dist.dir}/build-patch" />
+ <mkdir dir="${dist.dir}/build-patch/usr/sbin" />
+ <copy overwrite="true" todir="${dist.dir}/build-patch">
+ <fileset dir="${base.dir}/patches/systemvm/debian/config/" >
+ <include name="**/*"/>
+ </fileset>
+ <fileset dir="${base.dir}/patches/systemvm/debian/vpn/" >
+ <include name="**/*"/>
+ </fileset>
+ <fileset dir="${base.dir}/patches/systemvm/debian/xe/" >
+ <include name="**/*"/>
+ <exclude name="**/xe-*" />
+ <exclude name="**/xen-*" />
+ </fileset>
+ </copy>
+ <copy overwrite="true" todir="${dist.dir}/build-patch/usr/sbin/">
+ <fileset dir="${base.dir}/patches/systemvm/debian/xe/" >
+ <include name="**/xe-*" />
+ <include name="**/xen-*" />
+ </fileset>
+ </copy>
+ <tar destfile="${dist.dir}/patch.tar">
+ <tarfileset dir="${dist.dir}/build-patch/" filemode="755">
+ <include name="**/*"/>
+ <exclude name="**/.classpath" />
+ <exclude name="**/.project" />
+ <exclude name="**/wscript_build" />
+ </tarfileset>
+ </tar>
+ <copy file="${base.dir}/patches/systemvm/debian/config/root/.ssh/authorized_keys" todir="${dist.dir}/"/>
+ <gzip destfile="${dist.dir}/cloud-scripts.tgz" src="${dist.dir}/patch.tar"/>
+ <delete file="${dist.dir}/patch.tar"/>
+ <delete dir="${dist.dir}/build-patch"/>
+ </target>
+
+ <target name="help">
+ <echo level="info" message="Ant Build File for CloudStack" />
+ <echo level="info" message="Type 'ant -projecthelp' to get a list of targets and their descriptions." />
+ </target>
+ <target name="usage" depends="help" />
+
+ <target name="-init">
+ <mkdir dir="${dist.dir}" />
+ <mkdir dir="${target.dir}" />
+ <record name="${build.log}" loglevel="verbose" action="start" />
+
+ <!-- create a UTC build timestamp using ISO 8601 formatting -->
+ <tstamp>
+ <format property="utc.build.timestamp" pattern="yyyy-MM-dd'T'HH:mm:ss'Z'" timezone="GMT" />
+ </tstamp>
+
+ <!-- remember who/where did the build -->
+ <exec executable="hostname" outputproperty="host.name" />
+ <property name="builder.at" value="${user.name} at ${host.name}" />
+ <property name="builder.id" value="${builder.at}, on ${utc.build.timestamp}" />
+ <property name="built.by" value="${builder.at}, ${utc.build.timestamp}" />
+ <echo level="info" message="builder: ${builder.id}" />
+
+ <!-- set build.number property, stored in eponymous file -->
+ <buildnumber file="${build.dir}/build.number" />
+ <condition property="impl.version" value="${version}.${manual.build.number}" else="${version}.${utc.build.timestamp}">
+ <isset property="manual.build.number"/>
+ </condition>
+
+ <echo message="Build number is ${impl.version}" />
+
+ <!-- Create the build directory structure used by compile -->
+ <mkdir dir="${jar.dir}" />
+ <mkdir dir="${docs.dir}" />
+ <mkdir dir="${dep.cache.dir}" />
+ <record name="${build.log}" action="stop" />
+ </target>
+
+ <target name="clean" description="clean up files generated by the build">
+ <delete file="${build.log}" />
+ <delete dir="${classes.dir}" />
+ <delete dir="${jar.dir}" />
+ <delete dir="${dist.dir}" />
+ <delete dir="${unittest.dir}"/>
+ </target>
+
+ <!-- ===================== Ovm.Jar ===================== -->
+ <property name="ovm.jar" value="cloud-ovm.jar" />
+ <property name="ovm.dir" location="${base.dir}/ovm" />
+ <property name="ovm-scripts.dir" location="${ovm.dir}/scripts" />
+ <path id="ovm.classpath" >
+ <path refid="deps.classpath" />
+ <path refid="dist.classpath" />
+ </path>
+ <target name="compile-ovm" depends="-init, compile-server" description="Compile OVM">
+ <compile-java jar.name="${ovm.jar}" top.dir="${ovm.dir}" classpath="ovm.classpath" />
+ </target>
+
+ <target name="compile-all" description="Compile all of the jars" depends="compile-utils, compile-api, compile-core, compile-server, compile-ovm"/>
+
+ <target name="clean-all" depends="clean, clean-awsapi" description="Clean all of the generated files, including dependency cache and javadoc">
+ <delete dir="${target.dir}" />
+ </target>
+</project>
+
+
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/deployment-planner/user-dispersing/src/com/cloud/deploy/UserDispersingPlanner.java
----------------------------------------------------------------------
diff --git a/plugins/deployment-planner/user-dispersing/src/com/cloud/deploy/UserDispersingPlanner.java b/plugins/deployment-planner/user-dispersing/src/com/cloud/deploy/UserDispersingPlanner.java
new file mode 100644
index 0000000..dcad1e7
--- /dev/null
+++ b/plugins/deployment-planner/user-dispersing/src/com/cloud/deploy/UserDispersingPlanner.java
@@ -0,0 +1,215 @@
+// Copyright 2012 Citrix Systems, Inc. Licensed under the
+// Apache License, Version 2.0 (the "License"); you may not use this
+// file except in compliance with the License. Citrix Systems, Inc.
+// reserves all rights not expressly granted by 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.
+//
+// Automatically generated by addcopyright.py at 04/03/2012
+package com.cloud.deploy;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import javax.ejb.Local;
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.configuration.Config;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.Pair;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
+
+@Local(value=DeploymentPlanner.class)
+public class UserDispersingPlanner extends FirstFitPlanner implements DeploymentPlanner {
+
+ private static final Logger s_logger = Logger.getLogger(UserDispersingPlanner.class);
+
+ /**
+ * This method should reorder the given list of Cluster Ids by applying any necessary heuristic
+ * for this planner
+ * For UserDispersingPlanner we need to order the clusters by considering the number of VMs for this account
+ * @return List<Long> ordered list of Cluster Ids
+ */
+ @Override
+ protected List<Long> reorderClusters(long id, boolean isZone, Pair<List<Long>, Map<Long, Double>> clusterCapacityInfo, VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan){
+ List<Long> clusterIdsByCapacity = clusterCapacityInfo.first();
+ if(vmProfile.getOwner() == null){
+ return clusterIdsByCapacity;
+ }
+ long accountId = vmProfile.getOwner().getAccountId();
+ Pair<List<Long>, Map<Long, Double>> clusterIdsVmCountInfo = listClustersByUserDispersion(id, isZone, accountId);
+
+ //now we have 2 cluster lists - one ordered by capacity and the other by number of VMs for this account
+ //need to apply weights to these to find the correct ordering to follow
+
+ if(_userDispersionWeight == 1.0f){
+ List<Long> clusterIds = clusterIdsVmCountInfo.first();
+ clusterIds.retainAll(clusterIdsByCapacity);
+ return clusterIds;
+ }else{
+ //apply weights to the two lists
+ return orderByApplyingWeights(clusterCapacityInfo, clusterIdsVmCountInfo, accountId);
+ }
+
+
+ }
+
+ /**
+ * This method should reorder the given list of Pod Ids by applying any necessary heuristic
+ * for this planner
+ * For UserDispersingPlanner we need to order the pods by considering the number of VMs for this account
+ * @return List<Long> ordered list of Pod Ids
+ */
+ @Override
+ protected List<Long> reorderPods(Pair<List<Long>, Map<Long, Double>> podCapacityInfo, VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan){
+ List<Long> podIdsByCapacity = podCapacityInfo.first();
+ if(vmProfile.getOwner() == null){
+ return podIdsByCapacity;
+ }
+ long accountId = vmProfile.getOwner().getAccountId();
+
+ Pair<List<Long>, Map<Long, Double>> podIdsVmCountInfo = listPodsByUserDispersion(plan.getDataCenterId(), accountId);
+
+ //now we have 2 pod lists - one ordered by capacity and the other by number of VMs for this account
+ //need to apply weights to these to find the correct ordering to follow
+
+ if(_userDispersionWeight == 1.0f){
+ List<Long> podIds = podIdsVmCountInfo.first();
+ podIds.retainAll(podIdsByCapacity);
+ return podIds;
+ }else{
+ //apply weights to the two lists
+ return orderByApplyingWeights(podCapacityInfo, podIdsVmCountInfo, accountId);
+ }
+
+ }
+
+ protected Pair<List<Long>, Map<Long, Double>> listClustersByUserDispersion(long id, boolean isZone, long accountId){
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug("Applying Userdispersion heuristic to clusters for account: "+ accountId);
+ }
+ Pair<List<Long>, Map<Long, Double>> clusterIdsVmCountInfo;
+ if(isZone){
+ clusterIdsVmCountInfo = _vmInstanceDao.listClusterIdsInZoneByVmCount(id, accountId);
+ }else{
+ clusterIdsVmCountInfo = _vmInstanceDao.listClusterIdsInPodByVmCount(id, accountId);
+ }
+ if (s_logger.isTraceEnabled()) {
+ s_logger.trace("List of clusters in ascending order of number of VMs: "+ clusterIdsVmCountInfo.first());
+ }
+ return clusterIdsVmCountInfo;
+ }
+
+ protected Pair<List<Long>, Map<Long, Double>> listPodsByUserDispersion(long dataCenterId, long accountId) {
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug("Applying Userdispersion heuristic to pods for account: "+ accountId);
+ }
+ Pair<List<Long>, Map<Long, Double>> podIdsVmCountInfo = _vmInstanceDao.listPodIdsInZoneByVmCount(dataCenterId, accountId);
+ if (s_logger.isTraceEnabled()) {
+ s_logger.trace("List of pods in ascending order of number of VMs: "+ podIdsVmCountInfo.first());
+ }
+
+ return podIdsVmCountInfo;
+ }
+
+
+ private List<Long> orderByApplyingWeights(Pair<List<Long>, Map<Long, Double>> capacityInfo, Pair<List<Long>, Map<Long, Double>> vmCountInfo, long accountId){
+ List<Long> capacityOrderedIds = capacityInfo.first();
+ List<Long> vmCountOrderedIds = vmCountInfo.first();
+ Map<Long, Double> capacityMap = capacityInfo.second();
+ Map<Long, Double> vmCountMap = vmCountInfo.second();
+
+ if (s_logger.isTraceEnabled()) {
+ s_logger.trace("Capacity Id list: "+ capacityOrderedIds + " , capacityMap:"+capacityMap);
+ }
+ if (s_logger.isTraceEnabled()) {
+ s_logger.trace("Vm Count Id list: "+ vmCountOrderedIds + " , vmCountMap:"+vmCountMap);
+ }
+
+
+ List<Long> idsReorderedByWeights = new ArrayList<Long>();
+ float capacityWeight = (1.0f -_userDispersionWeight);
+
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug("Applying userDispersionWeight: "+ _userDispersionWeight);
+ }
+ //normalize the vmCountMap
+ LinkedHashMap<Long, Double> normalisedVmCountIdMap= new LinkedHashMap<Long, Double>();
+
+ Long totalVmsOfAccount = _vmInstanceDao.countRunningByAccount(accountId);
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug("Total VMs for account: "+ totalVmsOfAccount);
+ }
+ for(Long id : vmCountOrderedIds){
+ Double normalisedCount = vmCountMap.get(id) / totalVmsOfAccount;
+ normalisedVmCountIdMap.put(id, normalisedCount);
+ }
+
+ //consider only those ids that are in capacity map.
+
+ SortedMap<Double, List<Long>> sortedMap= new TreeMap<Double, List<Long>>();
+ for(Long id : capacityOrderedIds){
+ Double weightedCapacityValue = capacityMap.get(id) * capacityWeight;
+ Double weightedVmCountValue = normalisedVmCountIdMap.get(id) * _userDispersionWeight;
+ Double totalWeight = weightedCapacityValue + weightedVmCountValue;
+ if(sortedMap.containsKey(totalWeight)){
+ List<Long> idList = sortedMap.get(totalWeight);
+ idList.add(id);
+ sortedMap.put(totalWeight, idList);
+ }else{
+ List<Long> idList = new ArrayList<Long>();
+ idList.add(id);
+ sortedMap.put(totalWeight, idList);
+ }
+ }
+
+ for(List<Long> idList : sortedMap.values()){
+ idsReorderedByWeights.addAll(idList);
+ }
+
+ if (s_logger.isTraceEnabled()) {
+ s_logger.trace("Reordered Id list: "+ idsReorderedByWeights);
+ }
+
+ return idsReorderedByWeights;
+ }
+
+
+ @Override
+ public boolean canHandle(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid) {
+ if(vm.getHypervisorType() != HypervisorType.BareMetal){
+ //check the allocation strategy
+ if (_allocationAlgorithm != null && _allocationAlgorithm.equals(AllocationAlgorithm.userdispersing.toString())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ float _userDispersionWeight;
+
+
+ @Override
+ public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+ super.configure(name, params);
+
+ String weight = _configDao.getValue(Config.VmUserDispersionWeight.key());
+ _userDispersionWeight = NumbersUtil.parseFloat(weight, 1.0f);
+
+
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/hypervisors/ovm/.classpath
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/.classpath b/plugins/hypervisors/ovm/.classpath
new file mode 100755
index 0000000..45bd29e
--- /dev/null
+++ b/plugins/hypervisors/ovm/.classpath
@@ -0,0 +1,15 @@
+<?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="/core"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/utils"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/server"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/api"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/deps"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/vmware-base"/>
+ <classpathentry kind="src" path="/agent-simulator"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/agent"/>
+ <classpathentry exported="true" kind="lib" path="/deps/cloud-xmlrpc-common-3.1.3.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/hypervisors/ovm/.project
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/.project b/plugins/hypervisors/ovm/.project
new file mode 100755
index 0000000..6ef55a5
--- /dev/null
+++ b/plugins/hypervisors/ovm/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ovm</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>
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/hypervisors/ovm/build.xml
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/build.xml b/plugins/hypervisors/ovm/build.xml
new file mode 100755
index 0000000..e63b049
--- /dev/null
+++ b/plugins/hypervisors/ovm/build.xml
@@ -0,0 +1,128 @@
+<?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 OVM" default="help" basedir=".">
+ <description>
+ Cloud Stack ant build file
+ </description>
+
+ <dirname property="ovm.base.dir" file="${ant.file.Cloud Stack OVM}/"/>
+ <!-- This directory must be set -->
+ <property name="top.dir" location="${ovm.base.dir}/../../.."/>
+ <property name="build.dir" location="${top.dir}/build"/>
+
+ <echo message="build.dir=${build.dir}; top.dir=${top.dir}; ovm.base.dir=${ovm.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="ovm.jar" value="cloud-ovm.jar" />
+ <property name="ovm-scripts.dir" location="${ovm.base.dir}/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="ovm.classpath">
+ <path refid="deps.classpath"/>
+ <path refid="cloudstack.classpath"/>
+ </path>
+
+ <!-- This section needs to be replaced by some kind of dependency library-->
+
+
+ <target name="init" description="Initialize binaries directory">
+ <mkdir dir="${classes.dir}/${ovm.jar}"/>
+ <mkdir dir="${jar.dir}"/>
+ </target>
+
+ <target name="compile-ovm" depends="init" description="Compile OVM">
+ <compile-java jar.name="${ovm.jar}" top.dir="${ovm.base.dir}" classpath="ovm.classpath" />
+ </target>
+
+ <target name="help" description="help">
+ <echo level="info" message="This is the build file for OVM"/>
+ <echo level="info" message="You can do a build by doing ant build or clean by ant clean" />
+ </target>
+
+ <target name="clean-ovm">
+ <delete dir="${classes.dir}/${ovm.jar}"/>
+ </target>
+
+ <target name="build" depends="compile-ovm"/>
+ <target name="clean" depends="clean-ovm"/>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/ConfigFileOps.py
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/ConfigFileOps.py b/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/ConfigFileOps.py
new file mode 100755
index 0000000..c8bffe2
--- /dev/null
+++ b/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/ConfigFileOps.py
@@ -0,0 +1,171 @@
+# Copyright 2012 Citrix Systems, Inc. Licensed under the
+# Apache License, Version 2.0 (the "License"); you may not use this
+# file except in compliance with the License. Citrix Systems, Inc.
+# reserves all rights not expressly granted by 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.
+#
+# Automatically generated by addcopyright.py at 04/03/2012
+import re
+class ConfigFileOps:
+ class entry:
+ def __init__(self, name, value, op, separator):
+ self.name = name
+ self.value = value
+ self.state = "new"
+ self.op = op
+ self.separator = separator
+ def setState(self, state):
+ self.state = state
+ def getState(self):
+ return self.state
+
+ def __init__(self, fileName, cfg=None):
+ self.fileName = fileName
+ self.entries = []
+ self.backups = []
+
+ if cfg is not None:
+ cfg.cfoHandlers.append(self)
+
+ def addEntry(self, name, value, separator="="):
+ e = self.entry(name, value, "add", separator)
+ self.entries.append(e)
+
+ def rmEntry(self, name, value, separator="="):
+ entry = self.entry(name, value, "rm", separator)
+ self.entries.append(entry)
+
+ def getEntry(self, name, separator="="):
+ try:
+ ctx = file(self.fileName).read(-1)
+ match = re.search("^" + name + ".*", ctx, re.MULTILINE)
+ if match is None:
+ return ""
+ line = match.group(0).split(separator, 1)
+ return line[1]
+ except:
+ return ""
+
+ def save(self):
+ fp = open(self.fileName, "r")
+ newLines = []
+ for line in fp.readlines():
+ matched = False
+ for entry in self.entries:
+ if entry.op == "add":
+ if entry.separator == "=":
+ matchString = "^\ *" + entry.name + ".*"
+ elif entry.separator == " ":
+ matchString = "^\ *" + entry.name + "\ *" + entry.value
+ else:
+ if entry.separator == "=":
+ matchString = "^\ *" + entry.name + "\ *=\ *" + entry.value
+ else:
+ matchString = "^\ *" + entry.name + "\ *" + entry.value
+
+ match = re.match(matchString, line)
+ if match is not None:
+ if entry.op == "add" and entry.separator == "=":
+ newline = entry.name + "=" + entry.value + "\n"
+ entry.setState("set")
+ newLines.append(newline)
+ self.backups.append([line, newline])
+ matched = True
+ break
+ elif entry.op == "rm":
+ entry.setState("set")
+ self.backups.append([line, None])
+ matched = True
+ break
+
+ if not matched:
+ newLines.append(line)
+
+ for entry in self.entries:
+ if entry.getState() != "set":
+ if entry.op == "add":
+ newline = entry.name + entry.separator + entry.value + "\n"
+ newLines.append(newline)
+ self.backups.append([None, newline])
+ entry.setState("set")
+
+ fp.close()
+
+ file(self.fileName, "w").writelines(newLines)
+
+ def replace_line(self, startswith,stanza,always_add=False):
+ lines = [ s.strip() for s in file(self.fileName).readlines() ]
+ newlines = []
+ replaced = False
+ for line in lines:
+ if re.search(startswith, line):
+ if stanza is not None:
+ newlines.append(stanza)
+ self.backups.append([line, stanza])
+ replaced = True
+ else: newlines.append(line)
+ if not replaced and always_add:
+ newlines.append(stanza)
+ self.backups.append([None, stanza])
+ newlines = [ s + '\n' for s in newlines ]
+ file(self.fileName,"w").writelines(newlines)
+
+ def replace_or_add_line(self, startswith,stanza):
+ return self.replace_line(startswith,stanza,always_add=True)
+
+ def add_lines(self, lines, addToBackup=True):
+ fp = file(self.fileName).read(-1)
+ sh = re.escape(lines)
+ match = re.search(sh, fp, re.MULTILINE)
+ if match is not None:
+ return
+
+ fp += lines
+ file(self.fileName, "w").write(fp)
+ self.backups.append([None, lines])
+
+ def replace_lines(self, src, dst, addToBackup=True):
+ fp = file(self.fileName).read(-1)
+ sh = re.escape(src)
+ if dst is None:
+ dst = ""
+ repl,nums = re.subn(sh, dst, fp)
+ if nums <=0:
+ return
+ file(self.fileName, "w").write(repl)
+ if addToBackup:
+ self.backups.append([src, dst])
+
+ def append_lines(self, match_lines, append_lines):
+ fp = file(self.fileName).read(-1)
+ sh = re.escape(match_lines)
+ match = re.search(sh, fp, re.MULTILINE)
+ if match is None:
+ return
+
+ sh = re.escape(append_lines)
+ if re.search(sh, fp, re.MULTILINE) is not None:
+ return
+
+ newlines = []
+ for line in file(self.fileName).readlines():
+ if re.search(match_lines, line) is not None:
+ newlines.append(line + append_lines)
+ self.backups.append([line, line + append_lines])
+ else:
+ newlines.append(line)
+
+ file(self.fileName, "w").writelines(newlines)
+
+ def backup(self):
+ for oldLine, newLine in self.backups:
+ if newLine is None:
+ self.add_lines(oldLine, False)
+ else:
+ self.replace_lines(newLine, oldLine, False)
+
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/Fixget_storage_reposExceptionDueToWrongReturnValueCheck.patch
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/Fixget_storage_reposExceptionDueToWrongReturnValueCheck.patch b/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/Fixget_storage_reposExceptionDueToWrongReturnValueCheck.patch
new file mode 100755
index 0000000..7c41e55
--- /dev/null
+++ b/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/Fixget_storage_reposExceptionDueToWrongReturnValueCheck.patch
@@ -0,0 +1,13 @@
+diff --git a/OVSXUtility.py b/OVSXUtility.py
+index 4a98bc8..1053ef7 100644
+--- a/OVSXUtility.py
++++ b/OVSXUtility.py
+@@ -160,7 +160,7 @@ def get_storage_repos():
+ l = parse_storage_repos()
+ for sr in l:
+ d = get_storage_free_space(sr)
+- if d:
++ if len(d) > 0:
+ d_repos_space[sr] = d[sr]
+
+ if not d_repos_space:
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmCommonModule.py
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmCommonModule.py b/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmCommonModule.py
new file mode 100755
index 0000000..aae6f71
--- /dev/null
+++ b/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmCommonModule.py
@@ -0,0 +1,156 @@
+# Copyright 2012 Citrix Systems, Inc. Licensed under the
+# Apache License, Version 2.0 (the "License"); you may not use this
+# file except in compliance with the License. Citrix Systems, Inc.
+# reserves all rights not expressly granted by 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.
+#
+# Automatically generated by addcopyright.py at 04/03/2012
+'''
+Created on May 17, 2011
+
+@author: frank
+'''
+
+try:
+ import json
+except ImportError:
+ import simplejson as json
+
+from OvmObjectModule import *
+import types
+import logging
+import popen2
+import subprocess
+from OvmFaultConstants import toErrCode, dispatchErrCode, NoVmFoundException, ShellExceutedFailedException
+from xmlrpclib import Fault as XmlRpcFault
+from OVSCommons import *
+from OvmLoggerModule import OvmLogger
+from OVSXXenStore import xen_get_vm_path
+from OVSSiteRMServer import get_master_ip
+
+HEARTBEAT_TIMESTAMP_FORMAT='<timestamp>%s</timestamp>'
+HEARTBEAT_TIMESTAMP_PATTERN='(\<timestamp\>\d+.\d+<\/timestamp\>)'
+HEARTBEAT_DIR='heart_beat'
+ETC_HOSTS='/etc/hosts'
+HOSTNAME_FILE='/etc/sysconfig/network'
+OWNER_FILE_PREFIX='host_'
+OCFS2_CONF='/etc/ocfs2/cluster.conf'
+
+logger = OvmLogger('OvmCommon')
+
+def setAttrFromDict(obj, name, refDict, convertFunc=None):
+ if not convertFunc:
+ setattr(obj, name, refDict[name])
+ else:
+ setattr(obj, name, convertFunc(refDict[name]))
+
+def safeSetAttr(obj, name, value):
+ if not hasattr(obj, name): raise Exception("%s doesn't have attribute %s"%(obj.__class__.__name__, name))
+ setattr(obj, name, value)
+
+def toAscii(jstr):
+ return str(jstr).encode('ascii', 'ignore')
+
+def toAsciiHook(dct):
+ for k in dct:
+ v = dct[k]
+ if type(v) is types.UnicodeType:
+ v = toAscii(v)
+ del dct[k]
+ k = toAscii(k)
+ dct[k] = v
+ return dct
+
+def asciiLoads(jStr):
+ jStr = str(jStr).replace("'", '"').replace('False', 'false').replace('True', 'true')
+ return json.loads(jStr, object_hook=toAsciiHook)
+
+def exceptionIfNoSuccess(str, errMsg=None):
+ if not errMsg: errMsg = str
+ if not "success" in str: raise Exception("%s (%s)"%(errMsg, str))
+
+def successToMap(str, sep=';'):
+ if not str.startswith("success"): raise Exception(str)
+ str = str[len('success:'):]
+ dct = {}
+ for pair in str.split(sep):
+ (key, value) = pair.split('=', 1)
+ dct[key] = value
+ return dct
+
+def jsonSuccessToMap(str):
+ dct = json.loads(str)
+ if dct['status'] != 'SUCC': raise Exception(str)
+ return dct['value']
+
+def safeDictSet(obj, dct, name):
+ if not hasattr(obj, name): raise Exception("%s has no attribute %s for encoding"%(obj.__class__.__name__, name))
+ dct[name] = getattr(obj, name)
+
+def normalizeToGson(str):
+ return str.replace('\\', '').strip('"').replace('"{', '{').replace('}"', '}');
+
+def toGson(obj):
+ return normalizeToGson(json.dumps(obj))
+
+def MtoBytes(M):
+ return M * 1024 * 1024
+
+def BytesToM(bytes):
+ return bytes/(1024*1024)
+
+def BytesToG(bytes):
+ return bytes/(1024*1024*1024)
+
+def runCmd(cmds):
+ process = subprocess.Popen(cmds, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = process.communicate()
+ if process.returncode != 0:
+ raise ShellExceutedFailedException(stderr, process.returncode)
+ return stdout
+
+def doCmd(lst):
+ cmds = [str(i) for i in lst]
+ cmdStr = ' '.join(cmds)
+ logger.debug(doCmd, cmdStr)
+ res = runCmd(cmdStr)
+ logger.debug(doCmd, 'result:' + res)
+ return res
+
+def execute(cmd):
+ p = popen2.Popen3(cmd, True)
+ if (p.wait() != 0):
+ raise Exception("Failed to execute command. Command: " + cmd + ", Error: " + p.childerr.read())
+ return p.fromchild.read()
+
+def getDomId(vm_name):
+ return execute("xm list | grep " + vm_name + " | awk '{print $2}'").strip()
+
+def raiseExceptionIfFail(res):
+ if not "success" in res and not "SUCC" in res: raise Exception(res)
+
+def ipToHeartBeatFileName(ip):
+ return ip.replace('.', '_') + "_HEARTBEAT"
+
+def getVmNameFromConfigureFile(cfgPath):
+ fd = open(cfgPath)
+ for i in fd.readlines():
+ i = i.strip()
+ if i.startswith('name'):
+ (key, value) = i.split("=", 1)
+ value = value.strip().strip("'")
+ fd.close()
+ return value
+ fd.close()
+ raise Exception('Cannot find vm name in %s'%cfgPath)
+
+def makeOwnerFileName():
+ hostIp = successToMap(get_master_ip())['ip']
+ ownerFileName = OWNER_FILE_PREFIX + hostIp.replace('.', '_')
+ return ownerFileName
+
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmDiskModule.py
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmDiskModule.py b/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmDiskModule.py
new file mode 100755
index 0000000..7ae6c72
--- /dev/null
+++ b/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmDiskModule.py
@@ -0,0 +1,62 @@
+# Copyright 2012 Citrix Systems, Inc. Licensed under the
+# Apache License, Version 2.0 (the "License"); you may not use this
+# file except in compliance with the License. Citrix Systems, Inc.
+# reserves all rights not expressly granted by 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.
+#
+# Automatically generated by addcopyright.py at 04/03/2012
+'''
+Created on May 17, 2011
+
+@author: frank
+'''
+
+from OvmCommonModule import *
+
+class OvmDiskDecoder(json.JSONDecoder):
+ def decode(self, jStr):
+ deDict = asciiLoads(jStr)
+ disk = OvmDisk()
+ setAttrFromDict(disk, 'path', deDict)
+ setAttrFromDict(disk, 'type', deDict)
+ setAttrFromDict(disk, 'isIso', deDict)
+ return disk
+
+class OvmDiskEncoder(json.JSONEncoder):
+ def default(self, obj):
+ if not isinstance(obj, OvmDisk): raise Exception("%s is not instance of OvmDisk"%type(obj))
+ dct = {}
+ safeDictSet(obj, dct, 'path')
+ safeDictSet(obj, dct, 'type')
+ return dct
+
+def fromOvmDisk(disk):
+ return normalizeToGson(json.dumps(disk, cls=OvmDiskEncoder))
+
+def fromOvmDiskList(diskList):
+ return [fromOvmDisk(d) for d in diskList]
+
+def toOvmDisk(jStr):
+ return json.loads(jStr, cls=OvmDiskDecoder)
+
+def toOvmDiskList(jStr):
+ disks = []
+ for i in jStr:
+ d = toOvmDisk(i)
+ disks.append(d)
+ return disks
+
+class OvmDisk(OvmObject):
+ path = ''
+ type = ''
+ isIso = False
+
+
+if __name__ == "__main__":
+ print toOvmDisk('''{"type":"w","path":"/data/data.raw"}''')
+ print toOvmDisk('''{"path":"/data/data.raw'","type":"w"}''')
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmDispatcher.py
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmDispatcher.py b/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmDispatcher.py
new file mode 100755
index 0000000..8db558e
--- /dev/null
+++ b/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmDispatcher.py
@@ -0,0 +1,58 @@
+# Copyright 2012 Citrix Systems, Inc. Licensed under the
+# Apache License, Version 2.0 (the "License"); you may not use this
+# file except in compliance with the License. Citrix Systems, Inc.
+# reserves all rights not expressly granted by 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.
+#
+# Automatically generated by addcopyright.py at 04/03/2012
+import types
+from OvmCommonModule import *
+from xmlrpclib import Fault
+from OVSCommons import *
+import OvmFaultConstants
+
+import OvmHostModule
+import OvmStoragePoolModule
+import OvmVmModule
+import OvmNetworkModule
+import OvmVolumeModule
+import OvmSecurityGroupModule
+from OvmHaHeartBeatModule import OvmHaHeartBeat
+
+ExposedClass = {}
+logger = OvmLogger('OvmDispatcher')
+def InitOvmDispacther():
+ global ExposedClass
+ modules = [ eval(attr) for attr in globals() if isinstance(eval(attr), types.ModuleType) ]
+ for m in modules:
+ for name in dir(m):
+ clz = getattr(m, name)
+ if type(clz) is types.TypeType and issubclass(clz, OvmObject):
+ ExposedClass[name] = clz
+ logger.debug(InitOvmDispacther, "Discovered exposed class:\n\n%s"%"\n".join(ExposedClass))
+
+@exposed
+def OvmDispatch(methodName, *params):
+ global ExposedClass
+ p = methodName.split('.')
+ if len(p) != 2:
+ logger.error(OvmDispatch, "%s is not a vaild format, should be classname.methodname"%p)
+ raise Fault(dispatchErrCode('InvalidCallMethodFormat'), "%s is not a vaild format, should be classname.methodname"%p)
+ clzName = p[0]
+ funcName = p[1]
+ if clzName not in ExposedClass.keys():
+ logger.error(OvmDispatch, "class %s is not exposed by agent"%clzName)
+ raise Fault(dispatchErrCode('InvaildClass'), "class %s is not exposed by agent"%clzName)
+ clz = ExposedClass[clzName]
+ if not hasattr(clz, funcName):
+ logger.error(OvmDispatch, "class %s has no function %s"%(clzName, funcName))
+ raise Fault(dispatchErrCode('InvaildFunction'), "class %s has no function %s"%(clzName, funcName))
+ logger.debug(OvmDispatch, "Entering %s.%s ===>"%(clzName, funcName))
+ rs = getattr(clz, funcName)(*params)
+ logger.debug(OvmDispatch, "Exited %s.%s <==="%(clzName, funcName))
+ return rs
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmDontTouchOCFS2ClusterWhenAgentStart.patch
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmDontTouchOCFS2ClusterWhenAgentStart.patch b/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmDontTouchOCFS2ClusterWhenAgentStart.patch
new file mode 100755
index 0000000..dfe8462
--- /dev/null
+++ b/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmDontTouchOCFS2ClusterWhenAgentStart.patch
@@ -0,0 +1,13 @@
+diff --git a/OVSAgentAutoStart.py b/OVSAgentAutoStart.py
+index 88fa18c..794a363 100755
+--- a/OVSAgentAutoStart.py
++++ b/OVSAgentAutoStart.py
+@@ -111,8 +111,6 @@ def prepare_cluster_heartbeat():
+ JOBS = [
+ ["command", join(dirname(__file__), "utils/upgrade_agent.py")],
+ ["function", "get_agent_version", ()],
+- ["function", "prepare_cluster_root", ()],
+- ["function", "prepare_cluster_heartbeat", ()],
+ ["command", join(dirname(__file__), "utils/upgrade.py")],
+ ["command_bg", join(dirname(__file__), "OVSRemasterServer.py")],
+ ["command_bg", join(dirname(__file__), "OVSMonitorServer.py")],
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmFaultConstants.py
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmFaultConstants.py b/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmFaultConstants.py
new file mode 100755
index 0000000..9c3c7b9
--- /dev/null
+++ b/plugins/hypervisors/ovm/scripts/vm/hypervisor/ovm/OvmFaultConstants.py
@@ -0,0 +1,95 @@
+# Copyright 2012 Citrix Systems, Inc. Licensed under the
+# Apache License, Version 2.0 (the "License"); you may not use this
+# file except in compliance with the License. Citrix Systems, Inc.
+# reserves all rights not expressly granted by 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.
+#
+# Automatically generated by addcopyright.py at 04/03/2012
+OvmDispatcherStub = 0
+OvmHostErrCodeStub = 1000
+OvmVmErrCodeStub = 2000
+OvmStoragePoolErrCodeStub = 3000
+OvmNetworkErrCodeStub = 4000
+OvmVolumeErrCodeStub = 5000
+OvmOCFS2ErrCodeStub = 6000
+
+class NoVmFoundException(Exception):
+ pass
+
+class ShellExceutedFailedException(Exception):
+ stderr = ''
+ errCode = -1000
+
+ def __init__(self, err, code):
+ Exception.__init__(self, "%s, return code:%s"%(err, code))
+ self.stderr = err
+ self.errCode = code
+
+errCode = {
+ # OvmDispatch is not class, these error codes are reserved
+ "OvmDispatch.InvalidCallMethodFormat":OvmDispatcherStub+1,
+ "OvmDispatch.InvaildClass":OvmDispatcherStub+2,
+ "OvmDispatch.InvaildFunction":OvmDispatcherStub+3,
+ "OvmVm.reboot":OvmDispatcherStub+4,
+
+ "OvmHost.registerAsMaster":OvmHostErrCodeStub+1,
+ "OvmHost.registerAsVmServer":OvmHostErrCodeStub+2,
+ "OvmHost.ping":OvmHostErrCodeStub+3,
+ "OvmHost.getDetails":OvmHostErrCodeStub+4,
+ "OvmHost.getPerformanceStats":OvmHostErrCodeStub+5,
+ "OvmHost.getAllVms":OvmHostErrCodeStub+6,
+ "OvmHost.fence":OvmHostErrCodeStub+7,
+ "OvmHost.setupHeartBeat":OvmHostErrCodeStub+8,
+ "OvmHost.pingAnotherHost":OvmHostErrCodeStub+9,
+
+ "OvmVm.create":OvmVmErrCodeStub+1,
+ "OvmVm.stop":OvmVmErrCodeStub+2,
+ "OvmVm.getDetails":OvmVmErrCodeStub+3,
+ "OvmVm.getVmStats":OvmVmErrCodeStub+4,
+ "OvmVm.migrate":OvmVmErrCodeStub+5,
+ "OvmVm.register":OvmVmErrCodeStub+6,
+ "OvmVm.getVncPort":OvmVmErrCodeStub+7,
+ "OvmVm.detachOrAttachIso":OvmVmErrCodeStub+8,
+
+ "OvmStoragePool.create":OvmStoragePoolErrCodeStub+1,
+ "OvmStoragePool.getDetailsByUuid":OvmStoragePoolErrCodeStub+2,
+ "OvmStoragePool.downloadTemplate":OvmStoragePoolErrCodeStub+3,
+ "OvmStoragePool.prepareOCFS2Nodes":OvmStoragePoolErrCodeStub+4,
+ "OvmStoragePool.createTemplateFromVolume":OvmStoragePoolErrCodeStub+5,
+ "OvmStoragePool._umount":OvmStoragePoolErrCodeStub+6,
+ "OvmStoragePool.copyVolume":OvmStoragePoolErrCodeStub+7,
+ "OvmStoragePool.delete":OvmStoragePoolErrCodeStub+8,
+
+ "OvmNetwork.createBridge":OvmNetworkErrCodeStub+1,
+ "OvmNetwork.deleteBridge":OvmNetworkErrCodeStub+2,
+ "OvmNetwork.createVlan":OvmNetworkErrCodeStub+3,
+ "OvmNetwork.deleteVlan":OvmNetworkErrCodeStub+4,
+ "OvmNetwork.getAllBridges":OvmNetworkErrCodeStub+5,
+ "OvmNetwork.getBridgeByIp":OvmNetworkErrCodeStub+6,
+ "OvmNetwork.createVlanBridge":OvmNetworkErrCodeStub+7,
+ "OvmNetwork.deleteVlanBridge":OvmNetworkErrCodeStub+8,
+
+ "OvmVolume.createDataDisk":OvmVolumeErrCodeStub+1,
+ "OvmVolume.createFromTemplate":OvmVolumeErrCodeStub+2,
+ "OvmVolume.destroy":OvmVolumeErrCodeStub+3,
+
+ "OvmOCFS2._addNode":OvmOCFS2ErrCodeStub+1,
+}
+
+
+def toErrCode(clz, func):
+ global errCode
+ if not callable(func): raise Exception("%s is not a callable, cannot get error code"%func)
+ name = clz.__name__ + '.' + func.__name__
+ if name not in errCode.keys(): return -1
+ return errCode[name]
+
+def dispatchErrCode(funcName):
+ name = "OvmDispatch." + funcName
+ if name not in errCode.keys(): return -1
+ return errCode[name]