cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [8/8] Introduced plugins directory. Moved ovm into plugins. Introduced build.xml for ovm.
Date Wed, 20 Jun 2012 01:48:00 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e2a32ab4/plugins/hypervisors/ovm/src/com/cloud/ovm/object/Test.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/src/com/cloud/ovm/object/Test.java b/plugins/hypervisors/ovm/src/com/cloud/ovm/object/Test.java
new file mode 100755
index 0000000..9d56f7d
--- /dev/null
+++ b/plugins/hypervisors/ovm/src/com/cloud/ovm/object/Test.java
@@ -0,0 +1,179 @@
+// 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/server/src/com/cloud/deploy/UserDispersingPlanner.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/UserDispersingPlanner.java b/server/src/com/cloud/deploy/UserDispersingPlanner.java
deleted file mode 100644
index dcad1e7..0000000
--- a/server/src/com/cloud/deploy/UserDispersingPlanner.java
+++ /dev/null
@@ -1,215 +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.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;
-    }    
-
-}


Mime
View raw message