diff --git a/agent-simulator/.classpath b/agent-simulator/.classpath
new file mode 100644
index 00000000000..264339135e1
--- /dev/null
+++ b/agent-simulator/.classpath
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/agent-simulator/.project b/agent-simulator/.project
new file mode 100644
index 00000000000..f3d551aaa5e
--- /dev/null
+++ b/agent-simulator/.project
@@ -0,0 +1,17 @@
+
+
+ agent-simulator
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/agent-simulator/db/create-schema-simulator.sql b/agent-simulator/db/create-schema-simulator.sql
new file mode 100644
index 00000000000..7cb7ef908a1
--- /dev/null
+++ b/agent-simulator/db/create-schema-simulator.sql
@@ -0,0 +1,73 @@
+DROP TABLE IF EXISTS `cloud`.`mockhost`;
+DROP TABLE IF EXISTS `cloud`.`mocksecstorage`;
+DROP TABLE IF EXISTS `cloud`.`mockstoragepool`;
+DROP TABLE IF EXISTS `cloud`.`mockvm`;
+DROP TABLE IF EXISTS `cloud`.`mockvolume`;
+
+CREATE TABLE `cloud`.`mockhost` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `name` varchar(255) NOT NULL,
+ `private_ip_address` char(40),
+ `private_mac_address` varchar(17),
+ `private_netmask` varchar(15),
+ `storage_ip_address` char(40),
+ `storage_netmask` varchar(15),
+ `storage_mac_address` varchar(17),
+ `public_ip_address` char(40),
+ `public_netmask` varchar(15),
+ `public_mac_address` varchar(17),
+ `guid` varchar(255) UNIQUE,
+ `version` varchar(40) NOT NULL,
+ `data_center_id` bigint unsigned NOT NULL,
+ `pod_id` bigint unsigned,
+ `cluster_id` bigint unsigned COMMENT 'foreign key to cluster',
+ `cpus` int(10) unsigned,
+ `speed` int(10) unsigned,
+ `ram` bigint unsigned,
+ `capabilities` varchar(255) COMMENT 'host capabilities in comma separated list',
+ `vm_id` bigint unsigned,
+ `resource` varchar(255) DEFAULT NULL COMMENT 'If it is a local resource, this is the class name',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`mocksecstorage` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `url` varchar(255),
+ `capacity` bigint unsigned,
+ `mount_point` varchar(255),
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`mockstoragepool` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `guid` varchar(255),
+ `mount_point` varchar(255),
+ `capacity` bigint,
+ `pool_type` varchar(40),
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+
+CREATE TABLE `cloud`.`mockvm` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `name` varchar(255),
+ `host_id` bigint unsigned,
+ `type` varchar(40),
+ `state` varchar(40),
+ `vnc_port` bigint unsigned,
+ `memory` bigint unsigned,
+ `cpu` bigint unsigned,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+
+CREATE TABLE `cloud`.`mockvolume` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `name` varchar(255),
+ `size` bigint unsigned,
+ `path` varchar(255),
+ `pool_id` bigint unsigned,
+ `type` varchar(40),
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
diff --git a/agent-simulator/scripts/__old__/deletePod.sh b/agent-simulator/scripts/__old__/deletePod.sh
new file mode 100755
index 00000000000..3fa60735bbc
--- /dev/null
+++ b/agent-simulator/scripts/__old__/deletePod.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+pod_query="GET http://10.91.30.226:8096/client/?command=deletePod&id=$x HTTP/1.0\n\n"
+
+
+echo -e $pod_query | nc -v -q 20 10.91.30.226 8096
+
diff --git a/agent-simulator/scripts/__old__/deleteServiceOffering.sh b/agent-simulator/scripts/__old__/deleteServiceOffering.sh
new file mode 100755
index 00000000000..e3a204f44cb
--- /dev/null
+++ b/agent-simulator/scripts/__old__/deleteServiceOffering.sh
@@ -0,0 +1,12 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+delete_so="GET http://10.91.30.226:8096/client/?command=deleteServiceOffering&id=$x HTTP/1.0\n\n"
+
+echo -e $delete_so | nc -v -q 20 10.91.30.226 8096
+
diff --git a/agent-simulator/scripts/__old__/deleteVlan.sh b/agent-simulator/scripts/__old__/deleteVlan.sh
new file mode 100755
index 00000000000..5cc3cd2b619
--- /dev/null
+++ b/agent-simulator/scripts/__old__/deleteVlan.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+vlan_query="GET http://10.91.30.226:8096/client/?command=deleteVlanIpRange&id=$x HTTP/1.0\n\n"
+
+
+echo -e $vlan_query | nc -v -q 20 10.91.30.226 8096
+
diff --git a/agent-simulator/scripts/__old__/deployVirtualMachine.sh b/agent-simulator/scripts/__old__/deployVirtualMachine.sh
new file mode 100755
index 00000000000..4c9200cc4e3
--- /dev/null
+++ b/agent-simulator/scripts/__old__/deployVirtualMachine.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+zoneid=$1
+templateId=$2
+serviceOfferingId=$3
+
+query="GET http://10.91.30.226:8096/client/?command=deployVirtualMachine&zoneId=$1&templateId=$2&serviceOfferingId=$3&account=admin&domainid=1 HTTP/1.0\n\n"
+
+echo -e $query | nc -v -q 20 10.91.30.226 8096
diff --git a/agent-simulator/scripts/__old__/listRouters.sh b/agent-simulator/scripts/__old__/listRouters.sh
new file mode 100755
index 00000000000..5a4fc23dade
--- /dev/null
+++ b/agent-simulator/scripts/__old__/listRouters.sh
@@ -0,0 +1,9 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+query="GET http://10.91.30.226:8096/client/?command=listRouters&zoneId=$1&account=admin&domainid=1 HTTP/1.0\n\n"
+
+echo -e $query | nc -v 10.91.30.226 8096
diff --git a/agent-simulator/scripts/__old__/listVirtualMachine.sh b/agent-simulator/scripts/__old__/listVirtualMachine.sh
new file mode 100755
index 00000000000..bd810f5a395
--- /dev/null
+++ b/agent-simulator/scripts/__old__/listVirtualMachine.sh
@@ -0,0 +1,9 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+query="GET http://10.91.28.33:8096/client/?command=listVirtualMachines&zoneId=$1&account=admin&domainid=1 HTTP/1.0\n\n"
+
+echo -e $query | nc -v -q 20 10.91.28.33 8096
diff --git a/agent-simulator/scripts/__old__/queryAsyncJobResult.sh b/agent-simulator/scripts/__old__/queryAsyncJobResult.sh
new file mode 100755
index 00000000000..f74ec9a1bd7
--- /dev/null
+++ b/agent-simulator/scripts/__old__/queryAsyncJobResult.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+ #
+ # Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
+ #
+ #
+ # This software is licensed under the GNU General Public License v3 or later.
+ #
+ # It is free software: you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation, either version 3 of the License, or any later version.
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with this program. If not, see .
+ #
+ #
+
+
+usage() {
+ printf "Query job result Usage: %s: -h management-server -j jobid\n" $(basename $0) >&2
+}
+
+#options
+jflag=
+hflag=
+
+jobid=
+host="127.0.0.1" #defaults to localhost
+
+while getopts 'h:j:' OPTION
+do
+ case $OPTION in
+ h) hflag=1
+ host="$OPTARG"
+ ;;
+ j) jflag=1
+ jobid="$OPTARG"
+ ;;
+ ?) usage
+ exit 2
+ ;;
+ esac
+done
+
+if [ $jflag != "1" ]
+then
+ usage
+ exit 2
+fi
+
+
+job_query="GET http://$host:8096/client/?command=queryAsyncJobResult&jobid=$jobid HTTP/1.0\n\n"
+echo -e $job_query | nc -v -w 60 $host 8096
diff --git a/agent-simulator/scripts/__old__/run.sh b/agent-simulator/scripts/__old__/run.sh
new file mode 100644
index 00000000000..a1e54c7b062
--- /dev/null
+++ b/agent-simulator/scripts/__old__/run.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+#run.sh runs the agent simulator client.
+java -cp cloud-utils.jar:agent-simulator.jar:log4j-1.2.15.jar:apache-log4j-extras-1.0.jar:ws-commons-util-1.0.2.jar:xmlrpc-client-3.1.3.jar:cloud-agent.jar:cloud-core.jar:xmlrpc-common-3.1.3.jar:javaee-api-5.0-1.jar:gson-1.3.jar:commons-httpclient-3.1.jar:commons-logging-1.1.1.jar:commons-codec-1.4.jar:commons-collections-3.2.1.jar:commons-pool-1.4.jar:.:./conf com.cloud.agent.AgentSimulator $@
+
+
diff --git a/agent-simulator/scripts/__old__/setupDirectPods.sh b/agent-simulator/scripts/__old__/setupDirectPods.sh
new file mode 100755
index 00000000000..fd1b8c2db5c
--- /dev/null
+++ b/agent-simulator/scripts/__old__/setupDirectPods.sh
@@ -0,0 +1,18 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+y=$2
+name=$3
+
+pod_query="GET http://10.91.30.226:8096/client/?command=createPod&zoneId=1&name=SSP$name&cidr=182.$x.$y.0%2F24&startIp=182.$x.$y.2&endIp=182.$x.$y.252&gateway=182.$x.$y.1
+HTTP/1.0\n\n"
+
+echo -e $pod_query | nc -v -q 20 10.91.30.226 8096
+
+#vlan_query="GET http://10.91.30.226/client/?command=createVlanIpRange&vlan=untagged&zoneid=1&podId=$name&forVirtualNetwork=false&gateway=172.$y.$x.1&netmask=255.255.255.0&startip=172.$y.$x.2&endip=172.$y.$x.252 HTTP/1.0\n\n"
+
+#echo -e $vlan_query | nc -v -q 20 10.91.30.226 8096
diff --git a/agent-simulator/scripts/__old__/setupHosts.sh b/agent-simulator/scripts/__old__/setupHosts.sh
new file mode 100755
index 00000000000..def8b0aafbc
--- /dev/null
+++ b/agent-simulator/scripts/__old__/setupHosts.sh
@@ -0,0 +1,25 @@
+
+ #
+ # Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
+ #
+ #
+ # This software is licensed under the GNU General Public License v3 or later.
+ #
+ # It is free software: you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation, either version 3 of the License, or any later version.
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with this program. If not, see .
+ #
+ #
+
+
+name=$1
+
+host_query="GET http://10.91.30.226:8096/client/?command=addHost&zoneId=1&podId=$((name+250))&username=sim&password=sim&clustername=simulator-$name&hosttags=RP$name&url=http%3A%2F%2Fsim HTTP/1.0\n\n"
+echo -e $host_query | nc -v -w 60 10.91.30.226 8096
diff --git a/agent-simulator/scripts/__old__/setupPodAndNetwork.sh b/agent-simulator/scripts/__old__/setupPodAndNetwork.sh
new file mode 100755
index 00000000000..5f62c39d9ea
--- /dev/null
+++ b/agent-simulator/scripts/__old__/setupPodAndNetwork.sh
@@ -0,0 +1,41 @@
+
+ #
+ # Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
+ #
+ #
+ # This software is licensed under the GNU General Public License v3 or later.
+ #
+ # It is free software: you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation, either version 3 of the License, or any later version.
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with this program. If not, see .
+ #
+ #
+
+
+workers=$1
+x=$2 #CIDR - 16bytes
+y=$3 #CIDR - 8 bytes
+
+for name in `seq 1 $workers`
+do
+ pod_query="GET http://10.91.30.226:8096/client/?command=createPod&zoneId=1&name=RP$name&cidr=182.$x.$y.0%2F24&startIp=182.$x.$y.2&endIp=182.$x.$y.252&gateway=182.$x.$y.1 HTTP/1.0\n\n"
+ vlan_query="GET http://10.91.30.226:8096/client/?command=createVlanIpRange&vlan=untagged&zoneid=1&podId=$((name+250))&forVirtualNetwork=false&gateway=182.$y.$x.1&netmask=255.255.255.0&startip=182.$y.$x.2&endip=182.$y.$x.252 HTTP/1.0\n\n"
+ so_query="GET http://10.91.30.226:8096/client/?command=createServiceOffering&name=RP$name&displayText=RP$name&storageType=local&cpuNumber=1&cpuSpeed=1000&memory=512&offerha=false&usevirtualnetwork=false&hosttags=RP$name HTTP/1.0\n\n"
+
+ echo -e $pod_query | nc -v -w 20 10.91.30.226 8096
+ echo -e $vlan_query | nc -v -w 20 10.91.30.226 8096
+ echo -e $so_query | nc -v -w 20 10.91.30.226 8096
+
+ let x+=1
+ let y+=1
+done
+
+
+
diff --git a/agent-simulator/scripts/__old__/setupServiceOffering.sh b/agent-simulator/scripts/__old__/setupServiceOffering.sh
new file mode 100755
index 00000000000..7e995144335
--- /dev/null
+++ b/agent-simulator/scripts/__old__/setupServiceOffering.sh
@@ -0,0 +1,11 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+so_query="GET http://10.91.30.226:8096/client/?command=createServiceOffering&name=SO$x&displayText=SO$x&storageType=local&cpuNumber=1&cpuSpeed=1000&memory=512&offerha=false&usevirtualnetwork=false&hosttags=SP$x HTTP/1.0\n\n"
+
+echo -e $so_query | nc -v -q 20 10.91.30.226 8096
diff --git a/agent-simulator/scripts/__old__/setupVlan.sh b/agent-simulator/scripts/__old__/setupVlan.sh
new file mode 100755
index 00000000000..2f1190f2889
--- /dev/null
+++ b/agent-simulator/scripts/__old__/setupVlan.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+y=$2
+name=$3
+
+vlan_query="GET http://10.91.30.226/client/?command=createVlanIpRange&vlan=untagged&zoneid=1&podId=$name&forVirtualNetwork=false&gateway=172.$x.$y.1&netmask=255.255.255.0&startip=172.$x.$y.2&endip=172.$x.$y.252 HTTP/1.0\n\n"
+
+echo -e $vlan_query | nc -v -q 20 10.91.30.226 8096
diff --git a/agent-simulator/scripts/__old__/simulator_advanced.sh b/agent-simulator/scripts/__old__/simulator_advanced.sh
new file mode 100755
index 00000000000..0f1462d2ecd
--- /dev/null
+++ b/agent-simulator/scripts/__old__/simulator_advanced.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+a=$1 #CIDR - 16bytes
+b=$2 #CIDR - 8 bytes
+host=$3
+zoneid=$4
+
+zone_query="GET http://$host/client/?command=createZone&networktype=Advanced&securitygroupenabled=false&name=SimulatorAdvanced&dns1=4.2.2.2&internaldns1=4.2.2.2&vlan=10-4000&guestcidraddress=10.1.1.0%2F24 HTTP/1.0\n\n"
+echo -e $zone_query | nc -v -w 120 $host 8096
+
+let x=a
+let y=b
+for name in `seq 1 1`
+do
+ pod_query="GET http://$host/client/?command=createPod&zoneid=$zoneid&name=POD$name&netmask=255.255.0.0&startIp=172.$x.$y.2&endIp=172.$x.$y.252&gateway=172.$x.$y.1 HTTP/1.0\n\n"
+ vlan_query="GET http://$host/client/?command=createVlanIpRange&forVirtualNetwork=true&vlan=untagged&zoneid=$zoneid&podId=$name&gateway=172.$y.$x.1&netmask=255.255.255.0&startip=172.$y.$x.2&endip=172.$y.$x.252 HTTP/1.0\n\n"
+ echo -e $pod_query | nc -v -w 20 $host 8096
+ echo -e $vlan_query | nc -v -w 20 $host 8096
+done
+let x+=1
+let y+=1
+
+name=1
+
+clusterid=1
+for cluster in `seq 1 1`
+do
+ cluster_query="GET http://$host/client/?command=addCluster&hypervisor=Simulator&clustertype=CloudManaged&zoneid=$zoneid&podId=1&clustername=POD$name-CLUSTER$cluster HTTP/1.0\n\n"
+ echo -e $cluster_query | nc -v -w 120 $host 8096
+
+ host_query="GET http://$host/client/?command=addHost&zoneid=$zoneid&podId=1&username=sim&password=sim&clusterid=$cluster&hypervisor=Simulator&clustertype=CloudManaged&url=http%3A%2F%2Fsim HTTP/1.0\n\n"
+ echo -e $host_query | nc -v -w 6000 $host 8096
+
+ spool_query="GET http://$host/client/?command=createStoragePool&zoneid=$zoneid&podId=1&clusterid=$cluster&name=SPOOL$cluster&url=nfs://172.1.25.$((cluster+1))/export/share/$cluster HTTP/1.0\n\n"
+ echo -e $spool_query | nc -v -w 6000 $host 8096
+ let clusterid+=1
+done
+
+sstorquery="GET http://$host/client/?command=addSecondaryStorage&zoneid=$zoneid&url=nfs://172.1.25.32/export/share/ HTTP/1.0\n\n"
+echo -e $sstorquery | nc -v -w 6000 $host 8096
diff --git a/agent-simulator/scripts/__old__/simulator_basic.sh b/agent-simulator/scripts/__old__/simulator_basic.sh
new file mode 100755
index 00000000000..17815005f38
--- /dev/null
+++ b/agent-simulator/scripts/__old__/simulator_basic.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+a=$1 #CIDR - 16bytes
+b=$2 #CIDR - 8 bytes
+host=$3 #MSHOST
+zoneid=$4
+
+zone_query="GET http://$host/client/?command=createZone&networktype=Basic&securitygroupenabled=false&name=SimulatorBasic&dns1=4.2.2.2&internaldns1=4.2.2.2&vlan=10-4000 HTTP/1.0\n\n"
+echo -e $zone_query | nc -v -w 120 $host 8096
+
+let x=a
+let y=b
+
+for name in `seq $zoneid 1`
+do
+ pod_query="GET http://$host/client/?command=createPod&zoneId=$zoneid&name=POD$name&netmask=255.255.255.0&startIp=172.$x.$y.2&endIp=172.$x.$y.252&gateway=172.$x.$y.1 HTTP/1.0\n\n"
+ vlan_query="GET http://$host/client/?command=createVlanIpRange&vlan=untagged&zoneid=$zoneid&podId=$name&forVirtualNetwork=false&gateway=172.$y.$x.1&netmask=255.255.255.0&startip=172.$y.$x.2&endip=172.$y.$x.252 HTTP/1.0\n\n"
+ echo -e $pod_query | nc -v -w 20 $host 8096
+ echo -e $vlan_query | nc -v -w 20 $host 8096
+
+ let x+=1
+ let y+=1
+done
+
+clusterid=1
+
+for podid in `seq $zoneid 1`
+do
+ cluster_query="GET http://$host/client/?command=addCluster&hypervisor=Simulator&clustertype=CloudManaged&zoneid=$zoneid&podId=$podid&clustername=POD$name-CLUSTER$cluster HTTP/1.0\n\n"
+ echo -e $cluster_query | nc -v -w 120 $host 8096
+
+ host_query="GET http://$host/client/?command=addHost&zoneId=$zoneid&podId=$podid&username=sim&password=sim&clusterid=$clusterid&url=http%3A%2F%2Fsim&hypervisor=Simulator&clustertype=CloudManaged HTTP/1.0\n\n"
+ echo -e $host_query | nc -v -w 6000 $host 8096
+ let clusterid+=1
+done
+
+sstorquery="GET http://$host/client/?command=addSecondaryStorage&zoneid=$zoneid&url=nfs://172.1.25.32/export/share/ HTTP/1.0\n\n"
+echo -e $sstorquery | nc -v -w 6000 $host 8096
diff --git a/agent-simulator/scripts/__old__/startRouter.sh b/agent-simulator/scripts/__old__/startRouter.sh
new file mode 100755
index 00000000000..8667d263790
--- /dev/null
+++ b/agent-simulator/scripts/__old__/startRouter.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+start_router="GET http://10.91.30.226:8096/client/?command=startRouter&id=$x HTTP/1.0\n\n"
+
+
+echo -e $start_router | nc -v -q 60 10.91.30.226 8096
+
diff --git a/agent-simulator/scripts/__old__/testQuery.sh b/agent-simulator/scripts/__old__/testQuery.sh
new file mode 100755
index 00000000000..21a7a1094b1
--- /dev/null
+++ b/agent-simulator/scripts/__old__/testQuery.sh
@@ -0,0 +1,9 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+test="GET http://10.91.30.226:8096/?command=listEvents&page=1 HTTP/1.0\n\n"
+echo -e $test | nc -v -q 20 10.91.30.226 8096
+
diff --git a/agent-simulator/scripts/addHostStats.py b/agent-simulator/scripts/addHostStats.py
new file mode 100644
index 00000000000..98910fbd4d8
--- /dev/null
+++ b/agent-simulator/scripts/addHostStats.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+
+from datetime import datetime
+import sys
+import matplotlib.cbook as cbook
+import matplotlib.image as image
+import matplotlib.pyplot as plt
+
+def formGraph(list_timedelta):
+ """ Draw a graph of the performance of host add response """
+ plt.plot(list(map(lambda x:x.seconds, list_timedelta)))
+ plt.ylabel("time(s) to add host")
+ plt.xlabel("number of hosts")
+ plt.title("Add Host Performance")
+ plt.grid(True)
+ plt.show()
+
+
+if __name__=='__main__':
+ time_file=open(sys.argv[1], 'r')
+ timelist=[]
+ diffs=[]
+ for line in time_file.readlines():
+ try:
+ timelist.append(datetime.strptime(line.strip(), "%d %b %Y %H:%M:%S"))
+ except ValueError:
+ print "Unable to parse:",line
+
+ stime=timelist[:-1]
+ btime=timelist[1:]
+
+ diffs=list(map(lambda x,y: y - x,stime,btime))
+
+ formGraph(diffs)
+
+
+
diff --git a/agent-simulator/scripts/addHosts.png b/agent-simulator/scripts/addHosts.png
new file mode 100644
index 00000000000..ae40e5022ed
Binary files /dev/null and b/agent-simulator/scripts/addHosts.png differ
diff --git a/agent-simulator/scripts/guava/__old__/1000routers.sh b/agent-simulator/scripts/guava/__old__/1000routers.sh
new file mode 100755
index 00000000000..ee0f6b6a7e7
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/1000routers.sh
@@ -0,0 +1,24 @@
+#
+# Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+#
+
+
+
+
+zoneid=$1
+templateId=$2
+serviceOfferingId=$3
+
+for j in `seq 1 100`
+do
+ let add=0
+ for i in `seq 1 10`
+ do
+ let account=$(($i+$add))
+ echo Account Name: , $account
+ query="GET http://127.0.0.1/client/?command=deployVirtualMachine&zoneId=$1&hypervisor=Simulator&templateId=$2&serviceOfferingId=$3&account=DummyAccount$account&domainid=1 HTTP/1.0\n\n"
+ echo -e $query | nc -v -q 20 127.0.0.1 8096
+ done
+ let add=add+10
+ sleep 60s
+done
diff --git a/agent-simulator/scripts/guava/__old__/createAdminAccount.sh b/agent-simulator/scripts/guava/__old__/createAdminAccount.sh
new file mode 100755
index 00000000000..0f9ac86b138
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/createAdminAccount.sh
@@ -0,0 +1,11 @@
+#
+# Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+#
+
+
+
+name=$1
+
+account_query="GET http://127.0.0.1/client/?command=createAccount&accounttype=1&email=simulator%40simulator.com&username=$name&firstname=first$name&lastname=last$name&password=5f4dcc3b5aa765d61d8327deb882cf99&account=$name&domainid=1 HTTP/1.1\n\n"
+
+echo -e $account_query | nc -v -q 120 127.0.0.1 8096
diff --git a/agent-simulator/scripts/guava/__old__/createStoragePool.sh b/agent-simulator/scripts/guava/__old__/createStoragePool.sh
new file mode 100755
index 00000000000..fde068c51f5
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/createStoragePool.sh
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+#
+
+
+spool_query="GET http://127.0.0.1/client/?command=createStoragePool&zoneId=1&podId=1&clusterid=1&name=SPOOL&url=nfs://10.91.25.6/export/share/1 HTTP/1.0\n\n"
+echo -e $spool_query | nc -v -q 60 127.0.0.1 8096
diff --git a/agent-simulator/scripts/guava/__old__/createUserAccount.sh b/agent-simulator/scripts/guava/__old__/createUserAccount.sh
new file mode 100755
index 00000000000..ae99d26b74f
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/createUserAccount.sh
@@ -0,0 +1,11 @@
+#
+# Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+#
+
+
+
+name=$1
+
+account_query="GET http://127.0.0.1/client/?command=createAccount&accounttype=0&email=simulator%40simulator.com&username=$name&firstname=first$name&lastname=last$name&password=5f4dcc3b5aa765d61d8327deb882cf99&account=$name&domainid=1 HTTP/1.1\n\n"
+
+echo -e $account_query | nc -v -q 120 127.0.0.1 8096
diff --git a/agent-simulator/scripts/guava/__old__/deleteAccount.sh b/agent-simulator/scripts/guava/__old__/deleteAccount.sh
new file mode 100755
index 00000000000..360117168cd
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/deleteAccount.sh
@@ -0,0 +1,12 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+delete="GET http://127.0.0.1/client/?command=deleteAccount&id=$x HTTP/1.0\n\n"
+
+echo -e $delete | nc -v -q 60 127.0.0.1 8096
+
diff --git a/agent-simulator/scripts/guava/__old__/deletePod.sh b/agent-simulator/scripts/guava/__old__/deletePod.sh
new file mode 100755
index 00000000000..3156fd7b912
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/deletePod.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+pod_query="GET http://10.91.30.219:8096/client/?command=deletePod&id=$x HTTP/1.0\n\n"
+
+
+echo -e $pod_query | nc -v -q 20 10.91.30.219 8096
+
diff --git a/agent-simulator/scripts/guava/__old__/deleteServiceOffering.sh b/agent-simulator/scripts/guava/__old__/deleteServiceOffering.sh
new file mode 100755
index 00000000000..d4b864c6b54
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/deleteServiceOffering.sh
@@ -0,0 +1,12 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+delete_so="GET http://10.91.30.219:8096/client/?command=deleteServiceOffering&id=$x HTTP/1.0\n\n"
+
+echo -e $delete_so | nc -v -q 20 10.91.30.219 8096
+
diff --git a/agent-simulator/scripts/guava/__old__/deleteVlan.sh b/agent-simulator/scripts/guava/__old__/deleteVlan.sh
new file mode 100755
index 00000000000..70e865c8d6e
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/deleteVlan.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+vlan_query="GET http://10.91.30.219:8096/client/?command=deleteVlanIpRange&id=$x HTTP/1.0\n\n"
+
+
+echo -e $vlan_query | nc -v -q 20 10.91.30.219 8096
+
diff --git a/agent-simulator/scripts/guava/__old__/deployVirtualMachine.sh b/agent-simulator/scripts/guava/__old__/deployVirtualMachine.sh
new file mode 100755
index 00000000000..ddc1f35f4ea
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/deployVirtualMachine.sh
@@ -0,0 +1,14 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+zoneid=$1
+templateId=$2
+serviceOfferingId=$3
+networkIds=$4
+
+query="GET http://10.91.30.219/client/?command=deployVirtualMachine&zoneId=$1&hypervisor=Simulator&templateId=$2&serviceOfferingId=$3&networkIds=$4&account=admin&domainid=1 HTTP/1.0\n\n"
+
+echo -e $query | nc -v -q 20 10.91.30.219 8096
diff --git a/agent-simulator/scripts/guava/__old__/destroyVirtualMachine.sh b/agent-simulator/scripts/guava/__old__/destroyVirtualMachine.sh
new file mode 100755
index 00000000000..46bffffe6c4
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/destroyVirtualMachine.sh
@@ -0,0 +1,12 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+destroy="GET http://10.91.30.219:8096/client/?command=destroyVirtualMachine&id=$x HTTP/1.0\n\n"
+
+echo -e $destroy | nc -v -q 60 10.91.30.219 8096
+
diff --git a/agent-simulator/scripts/guava/__old__/listCapacity.sh b/agent-simulator/scripts/guava/__old__/listCapacity.sh
new file mode 100755
index 00000000000..b30da8c0c87
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/listCapacity.sh
@@ -0,0 +1,9 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+query="GET http://10.91.30.219:8096/client/?command=listCapacity&zoneId=$1&podid=$2&response=json HTTP/1.0\n\n"
+
+echo -e $query | nc -v -q 120 10.91.30.219 8096
diff --git a/agent-simulator/scripts/guava/__old__/listEvents.sh b/agent-simulator/scripts/guava/__old__/listEvents.sh
new file mode 100755
index 00000000000..aad3b5f5bbe
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/listEvents.sh
@@ -0,0 +1,9 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+test="GET http://10.91.30.219:8096/?command=listEvents HTTP/1.0\n\n"
+echo -e $test | nc -v -q 120 10.91.30.219 8096
+
diff --git a/agent-simulator/scripts/guava/__old__/listHosts.sh b/agent-simulator/scripts/guava/__old__/listHosts.sh
new file mode 100755
index 00000000000..2e29e64fe64
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/listHosts.sh
@@ -0,0 +1,9 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+query="GET http://10.91.30.219:8096/client/?command=listHosts&zoneId=$1&account=admin&domainid=1&page=$2 HTTP/1.0\n\n"
+
+echo -e $query | nc -v -q 120 10.91.30.219 8096
diff --git a/agent-simulator/scripts/guava/__old__/listRouters.sh b/agent-simulator/scripts/guava/__old__/listRouters.sh
new file mode 100755
index 00000000000..f7293fd363e
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/listRouters.sh
@@ -0,0 +1,9 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+query="GET http://10.91.30.219:8096/client/?command=listRouters&zoneId=$1&account=admin&domainid=1 HTTP/1.0\n\n"
+
+echo -e $query | nc -v -q 120 10.91.30.219 8096
diff --git a/agent-simulator/scripts/guava/__old__/listTemplates.sh b/agent-simulator/scripts/guava/__old__/listTemplates.sh
new file mode 100755
index 00000000000..1b5c8520e46
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/listTemplates.sh
@@ -0,0 +1,9 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+query="GET http://10.91.30.219:8096/client/?command=listTemplates&templatefilter=featured&zoneid=$1 HTTP/1.0\n\n"
+
+echo -e $query | nc -v -q 120 10.91.30.219 8096
diff --git a/agent-simulator/scripts/guava/__old__/listVirtualMachine.sh b/agent-simulator/scripts/guava/__old__/listVirtualMachine.sh
new file mode 100755
index 00000000000..9559d4754df
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/listVirtualMachine.sh
@@ -0,0 +1,9 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+query="GET http://10.91.30.219:8096/client/?command=listVirtualMachines&zoneId=$1&account=admin&domainid=1 HTTP/1.0\n\n"
+
+echo -e $query | nc -v -q 120 10.91.30.219 8096
diff --git a/agent-simulator/scripts/guava/__old__/load.sh b/agent-simulator/scripts/guava/__old__/load.sh
new file mode 100755
index 00000000000..98f54c82697
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/load.sh
@@ -0,0 +1,15 @@
+for x in `seq 3 2082`
+do
+ start_vm="GET http://127.0.0.1:8096/client/?command=startVirtualMachine&id=$x HTTP/1.0\n\n"
+ echo -e $start_vm | nc -v -q 60 127.0.0.1 8096
+done
+
+sleep 60s
+
+for x in `seq 3 1102`
+do
+ stop_vm="GET http://127.0.0.1/client/?command=stopVirtualMachine&id=$x HTTP/1.0\n\n"
+ echo -e $stop_vm | nc -v -q 60 127.0.0.1 8096
+done
+
+sleep 60s
diff --git a/agent-simulator/scripts/guava/__old__/networkShutDown.sh b/agent-simulator/scripts/guava/__old__/networkShutDown.sh
new file mode 100755
index 00000000000..21d434dcc26
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/networkShutDown.sh
@@ -0,0 +1,8 @@
+x=$1
+y=$2
+
+for i in `seq $x $y`
+do
+ stop_vm="GET http://127.0.0.1/client/?command=stopVirtualMachine&id=$i HTTP/1.0\n\n"
+ echo -e $stop_vm | nc -v -q 60 127.0.0.1 8096
+done
diff --git a/agent-simulator/scripts/guava/__old__/networkStart.sh b/agent-simulator/scripts/guava/__old__/networkStart.sh
new file mode 100755
index 00000000000..cfee671bb0e
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/networkStart.sh
@@ -0,0 +1,8 @@
+x=$1
+y=$2
+
+for i in `seq $x $y`
+do
+ start_vm="GET http://127.0.0.1:8096/client/?command=startVirtualMachine&id=$i HTTP/1.0\n\n"
+ echo -e $start_vm | nc -v -q 60 127.0.0.1 8096
+done
diff --git a/agent-simulator/scripts/guava/__old__/reconnectStats.sh b/agent-simulator/scripts/guava/__old__/reconnectStats.sh
new file mode 100755
index 00000000000..d08ceb97bf2
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/reconnectStats.sh
@@ -0,0 +1,16 @@
+#/bin/bash
+
+
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+name=$1
+while [ 1 ]
+do
+ mysql -s -r -uroot -Dcloud -h10.1.1.215 -e"select count(id),now(),max(disconnected),mgmt_server_id,status from host group by mgmt_server_id,status;" >> $1
+ sleep 5
+ echo --------------------------------------------------------------------------------------------------------------------- >> $1
+done
diff --git a/agent-simulator/scripts/guava/__old__/setup.sh b/agent-simulator/scripts/guava/__old__/setup.sh
new file mode 100755
index 00000000000..274b1009d37
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/setup.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+#setup for Guava hosts in the simulator
+
+#1. 1 host per cluster
+#2. 100 clusters in a pod
+
+zone_query="GET http://10.91.30.219/client/?command=createZone&networktype=Advanced&securitygroupenabled=false&name=Go&dns1=4.2.2.2&internaldns1=4.2.2.2&vlan=500-1000&guestcidraddress=10.1.1.0%2F24 HTTP/1.0\n\n"
+echo -e $zone_query | nc -v -q 120 10.91.30.219 8096
+
+pod_query="GET http://10.91.30.219/client/?command=createPod&zoneId=1&name=Guava&netmask=255.255.0.0&startIp=172.1.2.2&endIp=172.1.255.252&gateway=172.1.2.1 HTTP/1.0\n\n"
+echo -e $pod_query | nc -v -q 120 10.91.30.219 8096
+
+vlan_query="GET http://10.91.30.219/client/?command=createVlanIpRange&forVirtualNetwork=true&zoneId=1&vlan=untagged&gateway=172.2.1.1&netmask=255.255.0.0&startip=172.2.1.2&endip=172.2.255.254 HTTP/1.0\n\n"
+echo -e $vlan_query | nc -v -q 120 10.91.30.219 8096
+
+for name in `seq 1 100`
+do
+ cluster_query="GET http://10.91.30.219/client/?command=addCluster&hypervisor=Simulator&clustertype=CloudManaged&zoneId=1&podId=1&clustername=CS$name HTTP/1.0\n\n"
+ echo -e $cluster_query | nc -v -q 120 10.91.30.219 8096
+
+ host_query="GET http://10.91.30.219/client/api?_=1302625706202&command=addHost&zoneId=1&podId=1&clusterid=$name&hypervisor=Simulator&clustertype=CloudManaged&hosttags=&username=sim&password=sim&url=http%3A%2F%2Fsim HTTP/1.0\n\n"
+ echo -e $host_query | nc -v -q 60 10.91.30.219 8096
+
+ spool_query="GET http://10.91.30.219/client/?command=createStoragePool&zoneId=1&podId=1&clusterid=$name&name=SPOOL$name&url=nfs://172.1.25.$name/export/share/$name HTTP/1.0\n\n"
+ echo -e $spool_query | nc -v -q 60 10.91.30.219 8096
+done
diff --git a/agent-simulator/scripts/guava/__old__/setupDirectPods.sh b/agent-simulator/scripts/guava/__old__/setupDirectPods.sh
new file mode 100755
index 00000000000..3834845a2b1
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/setupDirectPods.sh
@@ -0,0 +1,18 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+y=$2
+name=$3
+
+pod_query="GET http://10.91.30.219:8096/client/?command=createPod&zoneId=1&name=SSP$name&cidr=182.$x.$y.0%2F24&startIp=182.$x.$y.2&endIp=182.$x.$y.252&gateway=182.$x.$y.1
+HTTP/1.0\n\n"
+
+echo -e $pod_query | nc -v -q 20 10.91.30.219 8096
+
+#vlan_query="GET http://10.91.30.219/client/?command=createVlanIpRange&vlan=untagged&zoneid=1&podId=$name&forVirtualNetwork=false&gateway=172.$y.$x.1&netmask=255.255.255.0&startip=172.$y.$x.2&endip=172.$y.$x.252 HTTP/1.0\n\n"
+
+#echo -e $vlan_query | nc -v -q 20 10.91.30.219 8096
diff --git a/agent-simulator/scripts/guava/__old__/setupHosts.sh b/agent-simulator/scripts/guava/__old__/setupHosts.sh
new file mode 100755
index 00000000000..d4e5ce1bda7
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/setupHosts.sh
@@ -0,0 +1,10 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+name=$1
+
+host_query="GET http://10.91.30.219:8096/client/?command=addHost&zoneId=1&podId=$((name+250))&username=sim&password=sim&clustername=simulator-$name&hosttags=RP$name&url=http%3A%2F%2Fsim HTTP/1.0\n\n"
+echo -e $host_query | nc -v -q 60 10.91.30.219 8096
diff --git a/agent-simulator/scripts/guava/__old__/setupPodAndNetwork.sh b/agent-simulator/scripts/guava/__old__/setupPodAndNetwork.sh
new file mode 100755
index 00000000000..bf87f5da851
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/setupPodAndNetwork.sh
@@ -0,0 +1,26 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+workers=$1
+x=$2 #CIDR - 16bytes
+y=$3 #CIDR - 8 bytes
+
+for name in `seq 1 $workers`
+do
+ pod_query="GET http://10.91.30.219:8096/client/?command=createPod&zoneId=1&name=RP$name&cidr=182.$x.$y.0%2F24&startIp=182.$x.$y.2&endIp=182.$x.$y.252&gateway=182.$x.$y.1 HTTP/1.0\n\n"
+ vlan_query="GET http://10.91.30.219:8096/client/?command=createVlanIpRange&vlan=untagged&zoneid=1&podId=$((name+250))&forVirtualNetwork=false&gateway=182.$y.$x.1&netmask=255.255.255.0&startip=182.$y.$x.2&endip=182.$y.$x.252 HTTP/1.0\n\n"
+ so_query="GET http://10.91.30.219:8096/client/?command=createServiceOffering&name=RP$name&displayText=RP$name&storageType=local&cpuNumber=1&cpuSpeed=1000&memory=512&offerha=false&usevirtualnetwork=false&hosttags=RP$name HTTP/1.0\n\n"
+
+ echo -e $pod_query | nc -v -q 20 10.91.30.219 8096
+ echo -e $vlan_query | nc -v -q 20 10.91.30.219 8096
+ echo -e $so_query | nc -v -q 20 10.91.30.219 8096
+
+ let x+=1
+ let y+=1
+done
+
+
+
diff --git a/agent-simulator/scripts/guava/__old__/setupServiceOffering.sh b/agent-simulator/scripts/guava/__old__/setupServiceOffering.sh
new file mode 100755
index 00000000000..12e65e5be43
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/setupServiceOffering.sh
@@ -0,0 +1,11 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+so_query="GET http://10.91.30.219:8096/client/?command=createServiceOffering&name=SO$x&displayText=SO$x&storageType=local&cpuNumber=1&cpuSpeed=1000&memory=512&offerha=false&usevirtualnetwork=false&hosttags=SP$x HTTP/1.0\n\n"
+
+echo -e $so_query | nc -v -q 20 10.91.30.219 8096
diff --git a/agent-simulator/scripts/guava/__old__/setupVlan.sh b/agent-simulator/scripts/guava/__old__/setupVlan.sh
new file mode 100755
index 00000000000..ec477439638
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/setupVlan.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+y=$2
+name=$3
+
+vlan_query="GET http://10.91.30.219/client/?command=createVlanIpRange&vlan=untagged&zoneid=1&podId=$name&forVirtualNetwork=false&gateway=172.$x.$y.1&netmask=255.255.255.0&startip=172.$x.$y.2&endip=172.$x.$y.252 HTTP/1.0\n\n"
+
+echo -e $vlan_query | nc -v -q 20 10.91.30.219 8096
diff --git a/agent-simulator/scripts/guava/__old__/startRouter.sh b/agent-simulator/scripts/guava/__old__/startRouter.sh
new file mode 100755
index 00000000000..f127735bb53
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/startRouter.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+start_router="GET http://10.91.30.219:8096/client/?command=startRouter&id=$x HTTP/1.0\n\n"
+
+
+echo -e $start_router | nc -v -q 60 10.91.30.219 8096
+
diff --git a/agent-simulator/scripts/guava/__old__/startVirtualMachine.sh b/agent-simulator/scripts/guava/__old__/startVirtualMachine.sh
new file mode 100755
index 00000000000..84fd7c35acb
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/startVirtualMachine.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+start_vm="GET http://10.91.30.219:8096/client/?command=startVirtualMachine&id=$x HTTP/1.0\n\n"
+
+
+echo -e $start_vm | nc -v -q 60 10.91.30.219 8096
+
diff --git a/agent-simulator/scripts/guava/__old__/stopVirtualMachine.sh b/agent-simulator/scripts/guava/__old__/stopVirtualMachine.sh
new file mode 100755
index 00000000000..9884df84586
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/stopVirtualMachine.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+stop_vm="GET http://127.0.0.1/client/?command=stopVirtualMachine&id=$x HTTP/1.0\n\n"
+
+
+echo -e $stop_vm | nc -v -q 60 127.0.0.1 8096
+
diff --git a/agent-simulator/scripts/guava/__old__/stress.sh b/agent-simulator/scripts/guava/__old__/stress.sh
new file mode 100755
index 00000000000..f88bae6aca3
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/stress.sh
@@ -0,0 +1,39 @@
+zoneid=1
+templateid=3
+account="u"
+x=$1
+y=$2
+p=$3
+q=$4
+
+for i in `seq 1 3`
+do
+ serviceOfferingId=10
+ query="GET http://127.0.0.1/client/?command=deployVirtualMachine&zoneId=$zoneid&hypervisor=Simulator&templateId=$templateid&serviceOfferingId=$serviceOfferingId&account=$account&domainid=1 HTTP/1.0\n\n"
+ echo -e $query | nc -v -q 20 127.0.0.1 8096
+done
+
+sleep 15s
+
+for x in `seq $x $y`
+do
+ destroy="GET http://127.0.0.1:8096/client/?command=destroyVirtualMachine&id=$x HTTP/1.0\n\n"
+ echo -e $destroy | nc -v -q 60 127.0.0.1 8096
+done
+
+sleep 240s
+
+for i in `seq 1 30`
+do
+ serviceOfferingId=9
+ query="GET http://127.0.0.1/client/?command=deployVirtualMachine&zoneId=$zoneid&hypervisor=Simulator&templateId=$templateid&serviceOfferingId=$serviceOfferingId&account=$account&domainid=1 HTTP/1.0\n\n"
+ echo -e $query | nc -v -q 20 127.0.0.1 8096
+done
+
+sleep 150s
+
+for x in `seq $p $q`
+do
+ destroy="GET http://127.0.0.1:8096/client/?command=destroyVirtualMachine&id=$x HTTP/1.0\n\n"
+ echo -e $destroy | nc -v -q 60 127.0.0.1 8096
+done
diff --git a/agent-simulator/scripts/guava/__old__/stress2.sh b/agent-simulator/scripts/guava/__old__/stress2.sh
new file mode 100755
index 00000000000..ace23a889ff
--- /dev/null
+++ b/agent-simulator/scripts/guava/__old__/stress2.sh
@@ -0,0 +1,120 @@
+#!/bin/bash
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+############################################################
+#
+# Setup Stress. Destroy and Deploy Virtual Machines on
+# Guava like environment
+#
+#Environment
+#1. 1 host per cluster
+#2. 100 clusters in a pod
+
+# Create 300 Accounts
+# Deploy 300 VMs
+# Destroy 300 VMs
+# Repeat
+############################################################
+
+
+usage() {
+ printf "Setup Stress\nUsage: %s: -h management-server -z zoneid [-d delay] [-t templateid] -s service-offering-id [-n number of accounts]\n" $(basename $0) >&2
+}
+
+create_account() {
+ seq=$1
+ account_query="GET http://$host/client/?command=createAccount&accounttype=0&email=simulator%40simulator.com&username=$account_prefix$seq&firstname=first$seq&lastname=last$seq&password=5f4dcc3b5aa765d61d8327deb882cf99&account=$account_prefix$seq&domainid=1 HTTP/1.1\n\n"
+ echo -e $account_query | nc -v -q 120 $host 8096
+}
+
+stress() {
+ #Deploy 300 VMs in these accounts
+ for ((i=1;i<=$numberofaccounts;i++))
+ do
+ out=$(./deployVirtualMachine.sh -h $host -z $zoneid -t $template -s $service -a $account_prefix$i)
+ id=$(echo $out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ echo "deployed vm with id: " $id
+ VmArray[$i]=$id
+ done
+ sleep $delay
+
+ rindex=$(($RANDOM%$numberofaccounts))
+ #Stop/Start 300 VMs at random
+ for ((i=1;i<=$numberofaccounts;i++))
+ do
+ ./stopVirtualMachine.sh -h $host -i ${VmArray:$rindex}
+ rindex=$(($RANDOM%$numberofaccounts))
+ echo "stopped vm with id: " ${VmArray:$rindex}
+
+ ./startVirtualMachine.sh -h $host -i ${VmArray:$rindex}
+ rindex=$(($RANDOM%$numberofaccounts))
+ echo "started vm with id: " ${VmArray:$rindex}
+ done
+ sleep $delay
+}
+
+#options
+hflag=1
+zflag=
+dflag=1
+tflag=1
+sflag=
+nflag=1
+
+
+declare -a VmArray
+host="127.0.0.1" #default localhost
+zoneid=
+delay=300 #default 5 minutes
+template=2 #default centos
+service=
+account_prefix="USER"
+numberofaccounts=300
+
+while getopts 'h:z:d:t:s:n:' OPTION
+do
+ case $OPTION in
+ h) hflag=1
+ host="$OPTARG"
+ ;;
+ z) zflag=1
+ zoneid="$OPTARG"
+ ;;
+ d) dflag=1
+ delay="$OPTARG"
+ ;;
+ t) tflag=1
+ template="$OPTARG"
+ ;;
+ s) sflag=1
+ service="$OPTARG"
+ ;;
+ n) nflag=1
+ numberofaccounts="$OPTARG"
+ ;;
+ ?) usage
+ exit 2
+ ;;
+ esac
+done
+
+if [ $hflag$zflag$dflag$tflag$sflag$nflag != "111111" ]
+then
+ usage
+ exit 2
+fi
+
+#Create 300 Accounts
+#for ((i=1;i<=$numberofaccounts;i++))
+#do
+# create_account $i
+#done
+
+for i in {1..5}
+do
+ #Do the stress test
+ stress
+done
diff --git a/agent-simulator/scripts/run.bat b/agent-simulator/scripts/run.bat
new file mode 100644
index 00000000000..b28bbc0b824
--- /dev/null
+++ b/agent-simulator/scripts/run.bat
@@ -0,0 +1,2 @@
+java -cp cloud-utils.jar;agent-simulator.jar;log4j-1.2.15.jar;apache-log4j-extras-1.0.jar;ws-commons-util-1.0.2.jar;xmlrpc-client-3.1.3.jar;cloud-agent.jar;cloud-core.jar;xmlrpc-common-3.1.3.jar;javaee-api-5.0-1.jar;gson-1.3.jar;commons-httpclient-3.1.jar;commons-logging-1.1.1.jar;commons-codec-1.3.jar;commons-collections-3.2.1.jar;commons-pool-1.4.jar;.\;.\conf com.cloud.agent.AgentSimulator %*
+
diff --git a/agent-simulator/scripts/zucchini/__old__/deletePod.sh b/agent-simulator/scripts/zucchini/__old__/deletePod.sh
new file mode 100755
index 00000000000..3fa60735bbc
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/deletePod.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+pod_query="GET http://10.91.30.226:8096/client/?command=deletePod&id=$x HTTP/1.0\n\n"
+
+
+echo -e $pod_query | nc -v -q 20 10.91.30.226 8096
+
diff --git a/agent-simulator/scripts/zucchini/__old__/deleteServiceOffering.sh b/agent-simulator/scripts/zucchini/__old__/deleteServiceOffering.sh
new file mode 100755
index 00000000000..e3a204f44cb
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/deleteServiceOffering.sh
@@ -0,0 +1,12 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+delete_so="GET http://10.91.30.226:8096/client/?command=deleteServiceOffering&id=$x HTTP/1.0\n\n"
+
+echo -e $delete_so | nc -v -q 20 10.91.30.226 8096
+
diff --git a/agent-simulator/scripts/zucchini/__old__/deleteVlan.sh b/agent-simulator/scripts/zucchini/__old__/deleteVlan.sh
new file mode 100755
index 00000000000..5cc3cd2b619
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/deleteVlan.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+vlan_query="GET http://10.91.30.226:8096/client/?command=deleteVlanIpRange&id=$x HTTP/1.0\n\n"
+
+
+echo -e $vlan_query | nc -v -q 20 10.91.30.226 8096
+
diff --git a/agent-simulator/scripts/zucchini/__old__/deployBulk-sg.sh b/agent-simulator/scripts/zucchini/__old__/deployBulk-sg.sh
new file mode 100755
index 00000000000..73b09d6fbfd
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/deployBulk-sg.sh
@@ -0,0 +1,194 @@
+#!/bin/bash
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+usage() {
+ printf "Deploy many VMs: %s: -h management-server -n numberofvms [[-b batchsize] [-w wait for success] [-d db-node]]\n" $(basename $0) >&2
+ printf "-w option when specifed waits for successful deployment of batchsize (specifed by -b option) number of VMs. default batchsize =100\n"
+}
+
+getSgListRandom() {
+ num_groups=$((RANDOM%groups_per_vm))
+ if [[ $num_groups -eq 0 ]]; then
+ num_groups=1 #set back to default
+ fi
+
+ #form sg list string
+ local sg_list=""
+ for ((i=0;i<$num_groups;i++))
+ do
+ sgid=$((RANDOM%numberofgroups))
+ if [[ $sgid -eq 0 || $sgid -eq 1 ]]; then
+ sgid=1 #set back to default security group
+ sg_list=$sgid","$sg_list
+ continue
+ fi
+
+ sg_exists="GET http://$host/client/?command=listSecurityGroups&id=$sgid HTTP/1.0\n\n"
+ sg_out=$(echo -e $sg_exists | nc -v -q 60 $host 8096)
+ count=$(echo $sg_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ if [[ $count != "1" ]]; then #FAIL: Invalid security group was randomly selected
+ continue
+ fi
+ sg_list=$sgid","$sg_list
+ done
+ echo "$sg_list"
+}
+
+
+waitDeploy() {
+ local dbnode=$1
+ local batchsize=$2
+ while [ 1 ]
+ do
+ donecount=$(mysql -uroot -Dcloud -h$dbnode -s -r --skip-column-names -e"select count(*) from async_job where job_cmd like '%DeployVM%' and last_updated is null")
+ echo "[DEBUG] " $(date) " " $donecount " VMs still deploying"
+ if [[ $donecount == "0" || $donecount -eq 0 ]]
+ then
+ break
+ fi
+ sleep $(($donecount*2))s #2 seconds per VM
+ done
+}
+
+hflag=
+nflag=1
+wflag=
+bflag=
+dflag=
+iterator=0
+
+declare -a sg_array=('79' '79' '79' '79' '79' '79' '79' '79' '79')
+#declare -a sg_array=('72' '73' '74' '75' '76' '77' '78' '79' '80')
+
+host="127.0.0.1" #defaults to locahost
+numberofvms=1040 #defaults
+batchsize=100 #default
+dbnode=
+waitSuccess=false
+
+while getopts 'h:n:b:d:w' OPTION
+do
+ case $OPTION in
+ h) hflag=1
+ host="$OPTARG"
+ ;;
+ n) nflag=1
+ numberofvms="$OPTARG"
+ ;;
+ w) wflag=1
+ waitSuccess=true
+ ;;
+ b) bflag=1
+ batchsize="$OPTARG"
+ ;;
+ d) dflag=1
+ dbnode="$OPTARG"
+ ;;
+ ?) usage
+ exit 2
+ ;;
+ esac
+done
+
+if [ $hflag$nflag != "11" ]
+then
+ usage
+ exit 2
+fi
+
+if [[ $wflag == "1" && $dflag != "1" ]]
+then
+ echo "please specify dbnode -d option"
+ usage
+ exit 2
+fi
+
+
+if [[ $bflag == "1" && $wflag != "1" ]]
+then
+ echo "-w option mandatory when -b is given"
+ usage
+ exit 2
+fi
+
+tag1=$(($numberofvms*5/13))
+tag2=$(($numberofvms*2/13))
+tag3=$(($numberofvms*6/13))
+
+tag1_so=9 #defaults from a regular installation
+tag2_so=10
+tag3_so=11
+vmcount=0
+
+echo -n "Service Offering ID with TAG1 hosttag: "
+read tag1_so
+
+echo -n "Service Offering ID with TAG2 hosttag: "
+read tag2_so
+
+echo -n "Service Offering ID with TAG3 hosttag: "
+read tag3_so
+
+echo "Deploying TAG1 VMs with Service Offering: " $tag1_so
+for ((c=1;c<$tag1;c++))
+do
+ if [[ $vmcount -eq $batchsize && waitSuccess ]]
+ then
+ waitDeploy $dbnode $batchsize
+ vmcount=0
+ fi
+ sglist=${sg_array[$((iterator % 9))]}
+ iterator=$((iterator+1))
+
+ job_out=$(./deployVirtualMachine.sh -h $host -z 1 -t 2 -s $tag1_so -u -g $sglist)
+ job_id=$(echo $job_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ vmid=$(echo $job_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ echo "[DEBUG] $(date) deployed vm: " $vmid " in job: " $job_id
+
+ vmcount=$((vmcount+1))
+done
+
+sleep 60s
+
+echo "Deploying TAG2 VMs with Service Offering: " $tag2_so
+for ((c=1;c<$tag2;c++))
+do
+ if [[ $vmcount -eq $batchsize && wflag == "1" ]]
+ then
+ waitDeploy $dbnode $batchsize
+ vmcount=0
+ fi
+ sglist=${sg_array[$((iterator % 9))]}
+ iterator=$((iterator+1))
+
+ job_out=$(./deployVirtualMachine.sh -h $host -z 1 -t 2 -s $tag2_so -u -g $sglist)
+ job_id=$(echo $job_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ vmid=$(echo $job_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ echo "[DEBUG] $(date) deployed vm: " $vmid " in job: " $job_id
+
+ vmcount=$((vmcount+1))
+done
+
+sleep 60s
+
+echo "Deploying TAG3 VMs with Service Offering: " $tag3_so
+for ((c=1;c<$tag3;c++))
+do
+ if [[ $vmcount -eq $batchsize && wflag == "1" ]]
+ then
+ waitDeploy $dbnode $batchsize
+ vmcount=0
+ fi
+ sglist=${sg_array[$((iterator % 9))]}
+ iterator=$((iterator+1))
+
+ job_out=$(./deployVirtualMachine.sh -h $host -z 1 -t 2 -s $tag3_so -u -g $sglist)
+ job_id=$(echo $job_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ vmid=$(echo $job_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ echo "[DEBUG] $(date) deployed vm: " $vmid " in job: " $job_id
+
+ vmcount=$((vmcount+1))
+done
diff --git a/agent-simulator/scripts/zucchini/__old__/deployBulk.sh b/agent-simulator/scripts/zucchini/__old__/deployBulk.sh
new file mode 100755
index 00000000000..076892131d1
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/deployBulk.sh
@@ -0,0 +1,147 @@
+#!/bin/bash
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+usage() {
+ printf "Deploy many VMs: %s: -h management-server -n numberofvms [[-b batchsize] [-w wait for success] [-d db-node]]\n" $(basename $0) >&2
+}
+
+waitDeploy() {
+ local dbnode=$1
+ local batchsize=$2
+ while [ 1 ]
+ do
+ donecount=$(mysql -uroot -Dcloud -h$dbnode -s -r --skip-column-names -e"select count(*) from async_job where job_cmd like '%DeployVM%' and last_updated is null")
+ echo "[DEBUG] " $(date) " " $donecount " VMs still deploying"
+ if [[ $donecount == "0" || $donecount -eq 0 ]]
+ then
+ break
+ fi
+ sleep $(($donecount*2))s #2 seconds per VM
+ done
+}
+
+hflag=
+nflag=1
+wflag=
+bflag=
+dflag=
+iterator=0
+
+host="127.0.0.1" #defaults to locahost
+numberofvms=1040 #defaults
+numberofgroups=
+groups_per_vm=1 #default one group per vm
+batchsize=100
+waitSuccess=false
+
+while getopts 'h:n:b:d:w' OPTION
+do
+ case $OPTION in
+ h) hflag=1
+ host="$OPTARG"
+ ;;
+ n) nflag=1
+ numberofvms="$OPTARG"
+ ;;
+ w) wflag=1
+ waitSuccess=true
+ ;;
+ b) bflag=1
+ batchsize="$OPTARG"
+ ;;
+ d) dflag=1
+ dbnode="$OPTARG"
+ ;;
+ ?) usage
+ exit 2
+ ;;
+ esac
+done
+
+if [ $hflag$nflag != "11" ]
+then
+ usage
+ exit 2
+fi
+
+if [[ $wflag == "1" && $dflag != "1" ]]
+then
+ echo "please specify dbnode -d option"
+ usage
+ exit 2
+fi
+
+
+if [[ $bflag == "1" && $wflag != "1" ]]
+then
+ echo "-w option mandatory when -b is given"
+ usage
+ exit 2
+fi
+
+tag1=$(($numberofvms*5/13))
+tag2=$(($numberofvms*2/13))
+tag3=$(($numberofvms*6/13))
+
+tag1_so=9 #defaults from a regular installation
+tag2_so=10
+tag3_so=11
+vmcount=0
+
+echo -n "Service Offering ID with TAG1 hosttag: "
+read tag1_so
+
+echo -n "Service Offering ID with TAG2 hosttag: "
+read tag2_so
+
+echo -n "Service Offering ID with TAG3 hosttag: "
+read tag3_so
+
+echo "Deploying TAG1 VMs with Service Offering: " $tag1_so
+for ((c=1;c<$tag1;c++))
+do
+ if [[ $vmcount -eq $batchsize && waitSuccess ]]
+ then
+ waitDeploy $dbnode $batchsize
+ vmcount=0
+ fi
+ job_out=$(./deployVirtualMachine.sh -h $host -z 1 -t 2 -s $tag1_so -u)
+ job_id=$(echo $job_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ vmid=$(echo $job_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ echo "[DEBUG] $(date) deployed vm: " $vmid " in job: " $job_id
+ vmcount=$((vmcount+1))
+done
+
+echo "Deploying TAG2 VMs with Service Offering: " $tag2_so
+for ((c=1;c<$tag2;c++))
+do
+ if [[ $vmcount -eq $batchsize && waitSuccess ]]
+ then
+ waitDeploy $dbnode $batchsize
+ vmcount=0
+ fi
+ job_out=$(./deployVirtualMachine.sh -h $host -z 1 -t 2 -s $tag2_so -u)
+ job_id=$(echo $job_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ vmid=$(echo $job_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ echo "[DEBUG] $(date) deployed vm: " $vmid " in job: " $job_id
+ vmcount=$((vmcount+1))
+done
+
+
+echo "Deploying TAG3 VMs with Service Offering: " $tag3_so
+for ((c=1;c<$tag3;c++))
+do
+ if [[ $vmcount -eq $batchsize && waitSuccess ]]
+ then
+ waitDeploy $dbnode $batchsize
+ vmcount=0
+ fi
+ job_out=$(./deployVirtualMachine.sh -h $host -z 1 -t 2 -s $tag3_so -u)
+ job_id=$(echo $job_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ vmid=$(echo $job_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ echo "[DEBUG] $(date) deployed vm: " $vmid " in job: " $job_id
+ vmcount=$((vmcount+1))
+done
diff --git a/agent-simulator/scripts/zucchini/__old__/deployVirtualMachine.sh b/agent-simulator/scripts/zucchini/__old__/deployVirtualMachine.sh
new file mode 100755
index 00000000000..4c9200cc4e3
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/deployVirtualMachine.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+zoneid=$1
+templateId=$2
+serviceOfferingId=$3
+
+query="GET http://10.91.30.226:8096/client/?command=deployVirtualMachine&zoneId=$1&templateId=$2&serviceOfferingId=$3&account=admin&domainid=1 HTTP/1.0\n\n"
+
+echo -e $query | nc -v -q 20 10.91.30.226 8096
diff --git a/agent-simulator/scripts/zucchini/__old__/destroySystemVm.sh b/agent-simulator/scripts/zucchini/__old__/destroySystemVm.sh
new file mode 100755
index 00000000000..3a164eca85d
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/destroySystemVm.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+usage() {
+ printf "Destroy System Virtual Machine\nUsage: %s: -h management-server-ip -i vmid\n" $(basename $0) >&2
+}
+
+
+hflag=
+iflag=
+
+vmid=
+host="127.0.0.1" #defaults to localhost
+
+while getopts 'h:i:' OPTION
+do
+ case $OPTION in
+ h) hflag=1
+ host="$OPTARG"
+ ;;
+ i) iflag=1
+ vmid="$OPTARG"
+ ;;
+ ?) usage
+ exit 2
+ ;;
+ esac
+done
+
+if [[ $iflag != "1" ]]
+then
+ usage
+ exit 2
+fi
+
+destroy="GET http://$host:8096/client/?command=destroySystemVm&id=$vmid HTTP/1.0\n\n"
+echo -e $destroy | nc -v -w 60 $host 8096
+
diff --git a/agent-simulator/scripts/zucchini/__old__/destroyVirtualMachine.sh b/agent-simulator/scripts/zucchini/__old__/destroyVirtualMachine.sh
new file mode 100755
index 00000000000..a0abf6911a1
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/destroyVirtualMachine.sh
@@ -0,0 +1,12 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+destroy="GET http://10.91.30.226:8096/client/?command=destroyVirtualMachine&id=$x HTTP/1.0\n\n"
+
+echo -e $destroy | nc -v -q 60 10.91.30.226 8096
+
diff --git a/agent-simulator/scripts/zucchini/__old__/listCapacity.sh b/agent-simulator/scripts/zucchini/__old__/listCapacity.sh
new file mode 100755
index 00000000000..c6cf457f9a4
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/listCapacity.sh
@@ -0,0 +1,9 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+query="GET http://10.91.30.226:8096/client/?command=listCapacity&zoneId=$1&podid=$2&response=json HTTP/1.0\n\n"
+
+echo -e $query | nc -v -q 120 10.91.30.226 8096
diff --git a/agent-simulator/scripts/zucchini/__old__/listEvents.sh b/agent-simulator/scripts/zucchini/__old__/listEvents.sh
new file mode 100755
index 00000000000..2e8b837d33d
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/listEvents.sh
@@ -0,0 +1,9 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+test="GET http://10.91.30.226:8096/?command=listEvents&page=1 HTTP/1.0\n\n"
+echo -e $test | nc -v -q 120 10.91.30.226 8096
+
diff --git a/agent-simulator/scripts/zucchini/__old__/listHosts.sh b/agent-simulator/scripts/zucchini/__old__/listHosts.sh
new file mode 100755
index 00000000000..3d92be0cdbe
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/listHosts.sh
@@ -0,0 +1,9 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+query="GET http://10.91.30.226:8096/client/?command=listHosts&zoneId=$1&account=admin&domainid=1&page=$2 HTTP/1.0\n\n"
+
+echo -e $query | nc -v -q 120 10.91.30.226 8096
diff --git a/agent-simulator/scripts/zucchini/__old__/listRouters.sh b/agent-simulator/scripts/zucchini/__old__/listRouters.sh
new file mode 100755
index 00000000000..c7cea4c9f21
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/listRouters.sh
@@ -0,0 +1,9 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+query="GET http://10.91.30.226:8096/client/?command=listRouters&zoneId=$1&account=admin&domainid=1 HTTP/1.0\n\n"
+
+echo -e $query | nc -v -q 120 10.91.30.226 8096
diff --git a/agent-simulator/scripts/zucchini/__old__/listTemplates.sh b/agent-simulator/scripts/zucchini/__old__/listTemplates.sh
new file mode 100755
index 00000000000..ec7a17cf6f1
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/listTemplates.sh
@@ -0,0 +1,9 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+query="GET http://10.91.30.212:8096/client/?command=listTemplates&templatefilter=featured&zoneid=$1 HTTP/1.0\n\n"
+
+echo -e $query | nc -v -w 120 10.91.30.212 8096
diff --git a/agent-simulator/scripts/zucchini/__old__/listVirtualMachine.sh b/agent-simulator/scripts/zucchini/__old__/listVirtualMachine.sh
new file mode 100755
index 00000000000..6d9e30f6f49
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/listVirtualMachine.sh
@@ -0,0 +1,9 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+query="GET http://10.91.30.226:8096/client/?command=listVirtualMachines&zoneId=$1&account=admin&domainid=1 HTTP/1.0\n\n"
+
+echo -e $query | nc -v -q 120 10.91.30.226 8096
diff --git a/agent-simulator/scripts/zucchini/__old__/monitor.sh b/agent-simulator/scripts/zucchini/__old__/monitor.sh
new file mode 100755
index 00000000000..140a20348b9
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/monitor.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+host=$1
+
+while [ 1 ]
+do
+ echo ==== $(date) ====
+# mysql -uroot -Dcloud -h$host -e"select count(*), status, mgmt_server_id from host group by status, mgmt_server_id;"
+ mysql -uroot -Dcloud -h$host -e"select count(*), state, type from vm_instance group by state, type;"
+ mysql -uroot -Dcloud -h$host -e"select avg(timestampdiff(second,created,last_updated)),count(id),job_cmd,job_status,job_result_code from async_job where last_updated is not null group by job_cmd,job_status,job_result_code;"
+ mysql -uroot -Dcloud -h$host -e "select count(*) as locks from op_lock;"
+ echo === last 5 successful DeployVM ===
+ mysql -uroot -Dcloud -h$host -e"select created,last_updated,id, timestampdiff(second,created,last_updated) from async_job where job_cmd like '%DeployVM%' and job_result_code=0 and last_updated is not null order by id desc limit 5;"
+ echo === nwgroup status ===
+ mysql -uroot -Dcloud -h$host -e"select step, count(*) from op_nwgrp_work group by step;"
+ mysql -uroot -Dcloud -h$host -e"select avg(timestampdiff(second,created,taken)), count(id),mgmt_server_id from op_nwgrp_work where step='Done' and taken is not null and created < taken group by mgmt_server_id;"
+ mysql -uroot -Dcloud -h$host -e"select id,mgmt_server_id,instance_id,created,taken,timestampdiff(second,created,taken) from op_nwgrp_work where taken is not null and created!=taken order by id desc limit 5;"
+ echo
+ echo
+ echo
+ sleep 30s
+done
diff --git a/agent-simulator/scripts/zucchini/__old__/newsetup.sh b/agent-simulator/scripts/zucchini/__old__/newsetup.sh
new file mode 100755
index 00000000000..67029fdf1f5
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/newsetup.sh
@@ -0,0 +1,224 @@
+#!/bin/bash
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+############################################################
+#
+# zucchini uses local storage, before setting up make sure
+# * xen.public.network.device is set
+# * use.local.storage and systemvm.use.local.storage are true
+# * optionally turn off stats collectors
+# * expunge.delay and expunge.interval are 60s
+# * ping.interval is around 3m
+# * turn off dns updates to entire zone, network.dns.basiczone.update=pod
+# * capacity.skipcounting.hours=0
+# * direct.agent.load.size=1000
+
+#
+# This script will only setup an approximate number of hosts. To achieve the ratio
+# of 5:2:6 hosts the total number of hosts is brought close to a number divisible
+# by 13. So if 4000 hosts are added, you might see only 3900 come up
+#
+# 10 hosts per pod @ 1 host per cluster in a single zone
+#
+# Each pod has a /25, so 128 addresses. I think we reserved 5 IP addresses for system VMs in each pod.
+# Then we had something like 60 addresses for hosts and 60 addresses for VMs.
+
+#Environment
+#1. Approximately 10 hosts per pod.
+#2. Only 3 host tags.
+#3. With in each pod, the host tags are the same. Homogenous Pods
+#4. The ratio of hosts for the three tags should be 5/2/6
+#5. In simulator.properties, workers=1
+############################################################
+
+usage() {
+ printf "Setup Zucchini Like Environment\nUsage: %s: -h management-server -z zoneid [-d delay] -n numberofhosts\n" $(basename $0) >&2
+}
+
+a=1 #CIDR - 16bytes
+b=2 #CIDR - 8 bytes
+
+#options
+hflag=1
+zflag=
+dflag=1
+nflag=1
+
+host="127.0.0.1" #default localhost
+zoneid=
+delay=300 #default 5 minutes
+numberofhosts=1300 #default 1300 hosts
+tag1="TAG1"
+tag2="TAG2"
+tag3="TAG3"
+
+while getopts 'h:z:d:n:' OPTION
+do
+ case $OPTION in
+ h) hflag=1
+ host="$OPTARG"
+ ;;
+ z) zflag=1
+ zoneid="$OPTARG"
+ ;;
+ d) dflag=1
+ delay="$OPTARG"
+ ;;
+ n) nflag=1
+ numberofhosts="$OPTARG"
+ ;;
+ ?) usage
+ exit 2
+ ;;
+ esac
+done
+
+if [ $zflag$nflag != "11" ]
+then
+ usage
+ exit 2
+fi
+
+numberofpods=$(($numberofhosts/10)) #10 hosts per pod
+tag_one_range=$(($numberofpods*5/13))
+tag_two_range=$(($numberofpods*2/13))
+tag_three_range=$(($numberofpods-$tag_one_range-$tag_two_range))
+
+clusters_per_pod=10 #each cluster has one host
+hosts_per_pod=10
+
+
+declare -a pod_array
+declare -a cluster_array
+
+echo "Split Ratio :: " $tag_one_range":"$tag_two_range":"$tag_three_range
+
+#create the zone
+zone_query="GET http://$host/client/?command=createZone&networktype=Basic&securitygroupenabled=false&name=Zucchini&dns1=4.2.2.2&internaldns1=4.2.2.2 HTTP/1.0\n\n"
+echo -e $zone_query | nc -v -w $delay $host 8096
+
+#Add Secondary Storage
+sstor_query="GET http://$host/client/?command=addSecondaryStorage&zoneid=$zoneid&url=nfs://172.16.15.32/export/share/secondary HTTP/1.0\n\n"
+echo -e $sstor_query | nc -v -w $delay $host 8096
+
+let x=a
+let y=b
+
+echo "[DEBUG] $(date) Starting Creation of $numberofpods Pods"
+for ((name=1;name<=$numberofpods;name++))
+do
+ echo "[DEBUG] $(date) Creating pod[POD$name]"
+ pod_query="GET http://$host/client/?command=createPod&zoneId=$zoneid&name=POD$name&netmask=255.255.255.128&startIp=172.$x.$y.130&endIp=172.$x.$y.189&gateway=172.$x.$y.129 HTTP/1.0\n\n"
+ pod_out=$(echo -e $pod_query | nc -v -w $delay $host 8096)
+ pod_id=$(echo $pod_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ if ! [[ "$pod_id" =~ ^[0-9]+$ ]] ; then
+ exec >&2; echo "[ERROR] $(date) pod [POD$name] creation failed"; continue
+ fi
+ echo "[DEBUG] $(date) Created pod["$pod_id":POD"$name"]"
+ pod_array[$name]=$pod_id
+
+ echo "[DEBUG] $(date) Creating vlan for pod[POD$name]"
+ vlan_query="GET http://$host/client/?command=createVlanIpRange&vlan=untagged&zoneid=$zoneid&podId=$pod_id&forVirtualNetwork=false&gateway=172.$x.$y.129&netmask=255.255.255.128&startip=172.$x.$y.190&endip=172.$x.$y.249 HTTP/1.0\n\n"
+ vlan_out=$(echo -e $vlan_query | nc -v -w $delay $host 8096)
+ vlan_id=$(echo $vlan_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ if ! [[ "$vlan_id" =~ ^[0-9]+$ ]] ; then
+ let y+=1
+ if [ "$y" -eq 256 ]
+ then
+ let x+=1
+ y=1
+ fi
+ exec >&2; echo "[ERROR] $(date) vlan creation for pod[POD$name] failed"; continue
+ fi
+ echo "[DEBUG] $(date) Created vlan for pod[POD$name]"
+
+ #add clusters
+ echo "[DEBUG] $(date) Starting Creation of $clusters_per_pod clusters for pod[POD$name]"
+ for ((cluster=1;cluster<=$clusters_per_pod;cluster++))
+ do
+ echo "[DEBUG] $(date) Creating cluster[POD$name-CLUSTER$cluster] for pod[POD$name]"
+ cluster_query="GET http://$host/client/?command=addCluster&hypervisor=Simulator&clustertype=CloudManaged&zoneId=$zoneid&podId=$pod_id&clustername=POD$name-CLUSTER$cluster HTTP/1.0\n\n"
+ cluster_out=$(echo -e $cluster_query | nc -v -w $delay $host 8096)
+ cluster_id=$(echo $cluster_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ if ! [[ "$cluster_id" =~ ^[0-9]+$ ]] ; then
+ exec >&2; echo "[ERROR] $(date) cluster[POD$name-CLUSTER$cluster] creation for pod[POD$name] failed"; continue
+ fi
+ echo "[DEBUG] $(date) Created cluster["$cluster_id":POD"$name"-CLUSTER"$cluster"]"
+ cluster_array[$(($name*$clusters_per_pod + $cluster))]=$cluster_id
+ done
+ echo "[DEBUG] $(date) Finished Creating clusters for pod[POD$name]"
+ let y+=1
+ if [ "$y" -eq 256 ]
+ then
+ let x+=1
+ y=1
+ fi
+done
+echo "[DEBUG] $(date) Finished Creating $numberofpods Pods"
+
+#echo "DEBUG:Pods and Clusters"
+#echo "PODS:("${#pod_array[@]}")" ${pod_array[@]}
+#echo "CLUSTERS:("${#cluster_array[@]}")" ${cluster_array[@]}
+echo
+echo
+
+#Add hosts
+#TAG1
+for ((i=1;i<=$tag_one_range;i++))
+do
+ podid=${pod_array[$i]}
+ for ((j=1;j<=$hosts_per_pod;j++))
+ do
+ clusterid=${cluster_array[$(($i*$clusters_per_pod + $j))]}
+ host_query="GET http://$host/client/?command=addHost&zoneId=$zoneid&podId=$podid&username=sim&password=sim&clusterid=$clusterid&url=http%3A%2F%2Fsim&hypervisor=Simulator&clustertype=CloudManaged&hosttags=$tag1 HTTP/1.0\n\n"
+ host_out=$(echo -e $host_query | nc -v -w $delay $host 8096)
+ host_id=$(echo $host_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ if ! [[ "$host_id" =~ ^[0-9]+$ ]] ; then
+ exec >&2; echo "[ERROR] $(date) host addition failed in [pod:$podid,cluster:$clusterid]"; continue
+ fi
+ host_name=$(echo $host_out | sed 's/\(.*\)\(SimulatedAgent.[-0-9a-zA-Z]*\)\(.*\)/\2/g')
+ echo "[DEBUG] $date added host [$host_id:$host_name] to [pod:$podid,cluster:$clusterid] for TAG1"
+ done
+done
+
+#TAG2
+for ((i=$(($tag_one_range + 1));i<=$(($tag_one_range + $tag_two_range));i++))
+do
+ podid=${pod_array[$i]}
+ for ((j=1;j<=$hosts_per_pod;j++))
+ do
+ clusterid=${cluster_array[$(($i*$clusters_per_pod + $j))]}
+ host_query="GET http://$host/client/?command=addHost&zoneId=$zoneid&podId=$podid&username=sim&password=sim&clusterid=$clusterid&url=http%3A%2F%2Fsim&hypervisor=Simulator&clustertype=CloudManaged&hosttags=$tag2 HTTP/1.0\n\n"
+ host_out=$(echo -e $host_query | nc -v -w $delay $host 8096)
+ host_id=$(echo $host_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ if ! [[ "$host_id" =~ ^[0-9]+$ ]] ; then
+ exec >&2; echo "[ERROR] $(date) host addition failed in [pod:$podid,cluster:$clusterid]"; continue
+ fi
+ host_name=$(echo $host_out | sed 's/\(.*\)\(SimulatedAgent.[-0-9a-zA-Z]*\)\(.*\)/\2/g')
+ echo "[DEBUG] $date added host [$host_id:$host_name] to [pod:$podid,cluster:$clusterid] for TAG2"
+ done
+done
+
+#TAG3
+for ((i=$(($tag_two_range + $tag_one_range + 1));i<=$(($tag_three_range + $tag_two_range + $tag_one_range));i++))
+do
+ podid=${pod_array[$i]}
+ for ((j=1;j<=$hosts_per_pod;j++))
+ do
+ clusterid=${cluster_array[$(($i*$clusters_per_pod + $j))]}
+ host_query="GET http://$host/client/?command=addHost&zoneId=$zoneid&podId=$podid&username=sim&password=sim&clusterid=$clusterid&url=http%3A%2F%2Fsim&hypervisor=Simulator&clustertype=CloudManaged&hosttags=$tag3 HTTP/1.0\n\n"
+ host_out=$(echo -e $host_query | nc -v -w $delay $host 8096)
+ host_id=$(echo $host_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ if ! [[ "$host_id" =~ ^[0-9]+$ ]] ; then
+ exec >&2; echo "[ERROR] $(date) host addition failed in [pod:$podid,cluster:$clusterid]"; continue
+ fi
+ host_name=$(echo $host_out | sed 's/\(.*\)\(SimulatedAgent.[-0-9a-zA-Z]*\)\(.*\)/\2/g')
+ echo "[DEBUG] $date added host [$host_id:$host_name] to [pod:$podid,cluster:$clusterid] for TAG3"
+ done
+done
+
+echo "Setup complete"
+exit 0
diff --git a/agent-simulator/scripts/zucchini/__old__/reconnectStats.sh b/agent-simulator/scripts/zucchini/__old__/reconnectStats.sh
new file mode 100755
index 00000000000..d08ceb97bf2
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/reconnectStats.sh
@@ -0,0 +1,16 @@
+#/bin/bash
+
+
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+name=$1
+while [ 1 ]
+do
+ mysql -s -r -uroot -Dcloud -h10.1.1.215 -e"select count(id),now(),max(disconnected),mgmt_server_id,status from host group by mgmt_server_id,status;" >> $1
+ sleep 5
+ echo --------------------------------------------------------------------------------------------------------------------- >> $1
+done
diff --git a/agent-simulator/scripts/zucchini/__old__/setup.sh b/agent-simulator/scripts/zucchini/__old__/setup.sh
new file mode 100755
index 00000000000..5100c6f7974
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/setup.sh
@@ -0,0 +1,81 @@
+#!/bin/bash
+
+
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+#setup for zucchini hosts in the simulator
+
+#1. Approximately 10 hosts per pod.
+#2. Only 3 host tags.
+#3. With in each pod, the host tags are the same.
+#4. The ratio of hosts for the three tags should be 5/2/6
+
+a=$1 #CIDR - 16bytes
+b=$2 #CIDR - 8 bytes
+
+zone_query="GET http://10.91.30.219/client/?command=createZone&name=Zucchini&dns1=4.2.2.2&internaldns1=4.2.2.2&vlan=10-4000&guestcidraddress=10.1.1.0%2F24 HTTP/1.0\n\n"
+echo -e $zone_query | nc -v -q 120 10.91.30.219 8096
+
+# Pod Ratio: 38:15:47 @ 10 hosts per pod
+let x=a
+let y=b
+for name in `seq 1 152`
+do
+ pod_query="GET http://10.91.30.219:8096/client/?command=createPod&zoneId=1&name=POD$name&cidr=172.$x.$y.0%2F24&startIp=172.$x.$y.2&endIp=172.$x.$y.252&gateway=172.$x.$y.1 HTTP/1.0\n\n"
+ vlan_query="GET http://10.91.30.219:8096/client/?command=createVlanIpRange&vlan=untagged&zoneid=1&podId=$name&forVirtualNetwork=false&gateway=172.$y.$x.1&netmask=255.255.255.0&startip=172.$y.$x.2&endip=172.$y.$x.252 HTTP/1.0\n\n"
+ echo -e $pod_query | nc -v -q 20 10.91.30.219 8096
+ echo -e $vlan_query | nc -v -q 20 10.91.30.219 8096
+
+ for cluster in `seq 1 10`
+ do
+ host_query="GET http://10.91.30.219:8096/client/?command=addHost&zoneId=1&podId=$name&username=sim&password=sim&clustername=simulator-POD$name-CLUSTER$cluster&hosttags=TAG1&url=http%3A%2F%2Fsim HTTP/1.0\n\n"
+ echo -e $host_query | nc -v -q 6000 10.91.30.219 8096
+ done
+
+ let x+=1
+ let y+=1
+done
+
+#reset for tag2
+let x=a
+let y=b
+for name in `seq 153 212`
+do
+ pod_query="GET http://10.91.30.219:8096/client/?command=createPod&zoneId=1&name=POD$name&cidr=182.$x.$y.0%2F24&startIp=182.$x.$y.2&endIp=182.$x.$y.252&gateway=182.$x.$y.1 HTTP/1.0\n\n"
+ vlan_query="GET http://10.91.30.219:8096/client/?command=createVlanIpRange&vlan=untagged&zoneid=1&podId=$name&forVirtualNetwork=false&gateway=182.$y.$x.1&netmask=255.255.255.0&startip=182.$y.$x.2&endip=182.$y.$x.252 HTTP/1.0\n\n"
+ echo -e $pod_query | nc -v -q 20 10.91.30.219 8096
+ echo -e $vlan_query | nc -v -q 20 10.91.30.219 8096
+
+ for cluster in `seq 1 10`
+ do
+ host_query="GET http://10.91.30.219:8096/client/?command=addHost&zoneId=1&podId=$name&username=sim&password=sim&clustername=simulator-POD$name-CLUSTER$cluster&hosttags=TAG2&url=http%3A%2F%2Fsim HTTP/1.0\n\n"
+ echo -e $host_query | nc -v -q 6000 10.91.30.219 8096
+ done
+
+ let x+=1
+ let y+=1
+done
+
+#reset for TAG3
+let x=a
+let y=b
+for name in `seq 213 400`
+do
+ pod_query="GET http://10.91.30.219:8096/client/?command=createPod&zoneId=1&name=POD$name&cidr=192.$x.$y.0%2F24&startIp=192.$x.$y.2&endIp=192.$x.$y.252&gateway=192.$x.$y.1 HTTP/1.0\n\n"
+ vlan_query="GET http://10.91.30.219:8096/client/?command=createVlanIpRange&vlan=untagged&zoneid=1&podId=$name&forVirtualNetwork=false&gateway=192.$y.$x.1&netmask=255.255.255.0&startip=192.$y.$x.2&endip=192.$y.$x.252 HTTP/1.0\n\n"
+ echo -e $pod_query | nc -v -q 20 10.91.30.219 8096
+ echo -e $vlan_query | nc -v -q 20 10.91.30.219 8096
+
+ for cluster in `seq 1 10`
+ do
+ host_query="GET http://10.91.30.219:8096/client/?command=addHost&zoneId=1&podId=$name&username=sim&password=sim&clustername=simulator-POD$name-CLUSTER$cluster&hosttags=TAG3&url=http%3A%2F%2Fsim HTTP/1.0\n\n"
+ echo -e $host_query | nc -v -q 6000 10.91.30.219 8096
+ done
+
+ let x+=1
+ let y+=1
+done
diff --git a/agent-simulator/scripts/zucchini/__old__/setupDirectPods.sh b/agent-simulator/scripts/zucchini/__old__/setupDirectPods.sh
new file mode 100755
index 00000000000..5d1d28c236d
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/setupDirectPods.sh
@@ -0,0 +1,18 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+y=$2
+name=$3
+
+pod_query="GET http://10.91.30.212:8096/client/?command=createPod&zoneId=1&name=SSP$name&cidr=182.$x.$y.0%2F24&startIp=182.$x.$y.2&endIp=182.$x.$y.252&gateway=182.$x.$y.1
+HTTP/1.0\n\n"
+
+echo -e $pod_query | nc -v -w 20 10.91.30.212 8096
+
+#vlan_query="GET http://10.91.30.212/client/?command=createVlanIpRange&vlan=untagged&zoneid=1&podId=$name&forVirtualNetwork=false&gateway=172.$y.$x.1&netmask=255.255.255.0&startip=172.$y.$x.2&endip=172.$y.$x.252 HTTP/1.0\n\n"
+
+#echo -e $vlan_query | nc -v -w 20 10.91.30.212 8096
diff --git a/agent-simulator/scripts/zucchini/__old__/setupHosts.sh b/agent-simulator/scripts/zucchini/__old__/setupHosts.sh
new file mode 100755
index 00000000000..6cef7d5b83f
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/setupHosts.sh
@@ -0,0 +1,10 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+name=$1
+
+host_query="GET http://10.91.30.226:8096/client/?command=addHost&zoneId=1&podId=$((name+250))&username=sim&password=sim&clustername=simulator-$name&hosttags=RP$name&url=http%3A%2F%2Fsim HTTP/1.0\n\n"
+echo -e $host_query | nc -v -q 60 10.91.30.226 8096
diff --git a/agent-simulator/scripts/zucchini/__old__/setupPodAndNetwork.sh b/agent-simulator/scripts/zucchini/__old__/setupPodAndNetwork.sh
new file mode 100755
index 00000000000..4ab4a577963
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/setupPodAndNetwork.sh
@@ -0,0 +1,26 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+workers=$1
+x=$2 #CIDR - 16bytes
+y=$3 #CIDR - 8 bytes
+
+for name in `seq 1 $workers`
+do
+ pod_query="GET http://10.91.30.226:8096/client/?command=createPod&zoneId=1&name=RP$name&cidr=182.$x.$y.0%2F24&startIp=182.$x.$y.2&endIp=182.$x.$y.252&gateway=182.$x.$y.1 HTTP/1.0\n\n"
+ vlan_query="GET http://10.91.30.226:8096/client/?command=createVlanIpRange&vlan=untagged&zoneid=1&podId=$((name+250))&forVirtualNetwork=false&gateway=182.$y.$x.1&netmask=255.255.255.0&startip=182.$y.$x.2&endip=182.$y.$x.252 HTTP/1.0\n\n"
+ so_query="GET http://10.91.30.226:8096/client/?command=createServiceOffering&name=RP$name&displayText=RP$name&storageType=local&cpuNumber=1&cpuSpeed=1000&memory=512&offerha=false&usevirtualnetwork=false&hosttags=RP$name HTTP/1.0\n\n"
+
+ echo -e $pod_query | nc -v -q 20 10.91.30.226 8096
+ echo -e $vlan_query | nc -v -q 20 10.91.30.226 8096
+ echo -e $so_query | nc -v -q 20 10.91.30.226 8096
+
+ let x+=1
+ let y+=1
+done
+
+
+
diff --git a/agent-simulator/scripts/zucchini/__old__/setupServiceOffering.sh b/agent-simulator/scripts/zucchini/__old__/setupServiceOffering.sh
new file mode 100755
index 00000000000..7e995144335
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/setupServiceOffering.sh
@@ -0,0 +1,11 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+so_query="GET http://10.91.30.226:8096/client/?command=createServiceOffering&name=SO$x&displayText=SO$x&storageType=local&cpuNumber=1&cpuSpeed=1000&memory=512&offerha=false&usevirtualnetwork=false&hosttags=SP$x HTTP/1.0\n\n"
+
+echo -e $so_query | nc -v -q 20 10.91.30.226 8096
diff --git a/agent-simulator/scripts/zucchini/__old__/setupVlan.sh b/agent-simulator/scripts/zucchini/__old__/setupVlan.sh
new file mode 100755
index 00000000000..cd5903bfed3
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/setupVlan.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+y=$2
+name=$3
+
+vlan_query="GET http://10.91.30.212/client/?command=createVlanIpRange&vlan=untagged&zoneid=1&podId=$name&forVirtualNetwork=false&gateway=172.$x.$y.1&netmask=255.255.255.0&startip=172.$x.$y.2&endip=172.$x.$y.252 HTTP/1.0\n\n"
+
+echo -e $vlan_query | nc -v -w 20 10.91.30.212 8096
diff --git a/agent-simulator/scripts/zucchini/__old__/setup_sg.sh b/agent-simulator/scripts/zucchini/__old__/setup_sg.sh
new file mode 100755
index 00000000000..a4d8563bb92
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/setup_sg.sh
@@ -0,0 +1,248 @@
+#!/bin/bash
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+############################################################
+#
+# zucchini uses local storage, before setting up make sure
+# * xen.public.network.device is set
+# * use.local.storage and systemvm.use.local.storage are true
+# * optionally turn off stats collectors
+# * expunge.delay and expunge.interval are 60s
+# * ping.interval is around 3m
+# * turn off dns updates to entire zone, network.dns.basiczone.update=pod
+# * capacity.skipcounting.hours=0
+# * direct.agent.load.size=1000
+# * security groups are enabled
+
+#
+# This script will only setup an approximate number of hosts. To achieve the ratio
+# of 5:2:6 hosts the total number of hosts is brought close to a number divisible
+# by 13. So if 4000 hosts are added, you might see only 3900 come up
+#
+# 10 hosts per pod @ 1 host per cluster in a single zone
+#
+# Each pod has a /25, so 128 addresses. I think we reserved 5 IP addresses for system VMs in each pod.
+# Then we had something like 60 addresses for hosts and 60 addresses for VMs.
+
+#Environment
+#1. Approximately 10 hosts per pod.
+#2. Only 3 host tags.
+#3. With in each pod, the host tags are the same. Homogenous Pods
+#4. The ratio of hosts for the three tags should be 5/2/6
+#5. In simulator.properties, workers=1
+############################################################
+
+usage() {
+ printf "Setup Zucchini Like Environment\nUsage: %s: -h management-server -z zoneid [-d delay] -n numberofhosts [-g numberof security groups]\n" $(basename $0) >&2
+}
+
+a=1 #CIDR - 16bytes
+b=2 #CIDR - 8 bytes
+
+#options
+hflag=1
+zflag=
+dflag=1
+nflag=1
+gflag=1
+
+host="127.0.0.1" #default localhost
+zoneid=
+delay=300 #default 5 minutes
+numberofhosts=1300 #default 1300 hosts
+numberofgroups=130 #default 130 groups
+tag1="TAG1"
+tag2="TAG2"
+tag3="TAG3"
+
+while getopts 'h:z:d:n:g:' OPTION
+do
+ case $OPTION in
+ h) hflag=1
+ host="$OPTARG"
+ ;;
+ z) zflag=1
+ zoneid="$OPTARG"
+ ;;
+ d) dflag=1
+ delay="$OPTARG"
+ ;;
+ n) nflag=1
+ numberofhosts="$OPTARG"
+ ;;
+ g) gflag=1
+ numberofgroups="$OPTARG"
+ ;;
+ ?) usage
+ exit 2
+ ;;
+ esac
+done
+
+if [ $zflag$nflag != "11" ]
+then
+ usage
+ exit 2
+fi
+
+numberofpods=$(($numberofhosts/10)) #10 hosts per pod
+tag_one_range=$(($numberofpods*5/13))
+tag_two_range=$(($numberofpods*2/13))
+tag_three_range=$(($numberofpods-$tag_one_range-$tag_two_range))
+
+clusters_per_pod=10 #each cluster has one host
+hosts_per_pod=10
+
+
+declare -a pod_array
+declare -a cluster_array
+
+echo "Split Ratio :: " $tag_one_range":"$tag_two_range":"$tag_three_range
+
+#create the zone
+zone_query="GET http://$host/client/?command=createZone&networktype=Basic&securitygroupenabled=true&name=Zucchini&dns1=4.2.2.2&internaldns1=4.2.2.2 HTTP/1.0\n\n"
+echo -e $zone_query | nc -v -w $delay $host 8096
+
+#Add Secondary Storage
+sstor_query="GET http://$host/client/?command=addSecondaryStorage&zoneid=$zoneid&url=nfs://172.16.15.32/export/share/secondary HTTP/1.0\n\n"
+echo -e $sstor_query | nc -v -w $delay $host 8096
+
+let x=a
+let y=b
+
+echo "[DEBUG] $(date) Starting Creation of $numberofpods Pods"
+for ((name=1;name<=$numberofpods;name++))
+do
+ echo "[DEBUG] $(date) Creating pod[POD$name]"
+ pod_query="GET http://$host/client/?command=createPod&zoneId=$zoneid&name=POD$name&netmask=255.255.255.128&startIp=172.$x.$y.130&endIp=172.$x.$y.189&gateway=172.$x.$y.129 HTTP/1.0\n\n"
+ pod_out=$(echo -e $pod_query | nc -v -w $delay $host 8096)
+ pod_id=$(echo $pod_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ if ! [[ "$pod_id" =~ ^[0-9]+$ ]] ; then
+ exec >&2; echo "[ERROR] $(date) pod [POD$name] creation failed"; continue
+ fi
+ echo "[DEBUG] $(date) Created pod["$pod_id":POD"$name"]"
+ pod_array[$name]=$pod_id
+
+ echo "[DEBUG] $(date) Creating vlan for pod[POD$name]"
+ vlan_query="GET http://$host/client/?command=createVlanIpRange&vlan=untagged&zoneid=$zoneid&podId=$pod_id&forVirtualNetwork=false&gateway=172.$x.$y.129&netmask=255.255.255.128&startip=172.$x.$y.190&endip=172.$x.$y.249 HTTP/1.0\n\n"
+ vlan_out=$(echo -e $vlan_query | nc -v -w $delay $host 8096)
+ vlan_id=$(echo $vlan_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ if ! [[ "$vlan_id" =~ ^[0-9]+$ ]] ; then
+ let y+=1
+ if [ "$y" -eq 256 ]
+ then
+ let x+=1
+ y=1
+ fi
+ exec >&2; echo "[ERROR] $(date) vlan creation for pod[POD$name] failed"; continue
+ fi
+ echo "[DEBUG] $(date) Created vlan for pod[POD$name]"
+
+ #add clusters
+ echo "[DEBUG] $(date) Starting Creation of $clusters_per_pod clusters for pod[POD$name]"
+ for ((cluster=1;cluster<=$clusters_per_pod;cluster++))
+ do
+ echo "[DEBUG] $(date) Creating cluster[POD$name-CLUSTER$cluster] for pod[POD$name]"
+ cluster_query="GET http://$host/client/?command=addCluster&hypervisor=Simulator&clustertype=CloudManaged&zoneId=$zoneid&podId=$pod_id&clustername=POD$name-CLUSTER$cluster HTTP/1.0\n\n"
+ cluster_out=$(echo -e $cluster_query | nc -v -w $delay $host 8096)
+ cluster_id=$(echo $cluster_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ if ! [[ "$cluster_id" =~ ^[0-9]+$ ]] ; then
+ exec >&2; echo "[ERROR] $(date) cluster[POD$name-CLUSTER$cluster] creation for pod[POD$name] failed"; continue
+ fi
+ echo "[DEBUG] $(date) Created cluster["$cluster_id":POD"$name"-CLUSTER"$cluster"]"
+ cluster_array[$(($name*$clusters_per_pod + $cluster))]=$cluster_id
+ done
+ echo "[DEBUG] $(date) Finished Creating clusters for pod[POD$name]"
+ let y+=1
+ if [ "$y" -eq 256 ]
+ then
+ let x+=1
+ y=1
+ fi
+done
+echo "[DEBUG] $(date) Finished Creating $numberofpods Pods"
+
+#echo "DEBUG:Pods and Clusters"
+#echo "PODS:("${#pod_array[@]}")" ${pod_array[@]}
+#echo "CLUSTERS:("${#cluster_array[@]}")" ${cluster_array[@]}
+echo
+echo
+
+
+echo "[DEBUG] $(date) Creating $numberofgroups security groups"
+for ((sg=1;sg<=$numberofgroups;sg++))
+do
+ sg_create_query="GET http://$host/client/?command=createSecurityGroup&name=zGroup$sg&description=zGroup$sg&domainid=1&account=admin HTTP/1.0\n\n"
+ sg_create_out=$(echo -e $sg_create_query | nc -v -w $delay $host 8096)
+ sg_id=$(echo $sg_create_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ if ! [[ "$sg_id" =~ ^[0-9]+$ ]] ; then
+ exec >&2; echo "[ERROR] $(date) security group[zGroup$sg] creation failed"; continue
+ fi
+ echo "[DEBUG] $(date) Created security group[$sg_id:zGroup$sg]"
+
+ echo "[DEBUG] $(date) Adding ingress rule start,end=$((2000 + $sg)), $((2000 + $sg)) to security group[$sg_id:zGroup$sg]"
+ sg_auth_query="GET http://$host/client/?command=authorizeSecurityGroupIngress&domainid=1&account=admin&securitygroupid=$sg_id&protocol=TCP&startport=$((2000 + $sg))&endport=$((2000 + $sg))&usersecuritygrouplist[0].account=admin&usersecuritygrouplist[0].group=zGroup$sg HTTP/1.0\n\n"
+ sg_auth_out=$(echo -e $sg_auth_query | nc -v -w $delay $host 8096)
+done
+echo "[DEBUG] $(date) Finished Creating security groups"
+
+#Add hosts
+#TAG1
+for ((i=1;i<=$tag_one_range;i++))
+do
+ podid=${pod_array[$i]}
+ for ((j=1;j<=$hosts_per_pod;j++))
+ do
+ clusterid=${cluster_array[$(($i*$clusters_per_pod + $j))]}
+ host_query="GET http://$host/client/?command=addHost&zoneId=$zoneid&podId=$podid&username=sim&password=sim&clusterid=$clusterid&url=http%3A%2F%2Fsim&hypervisor=Simulator&clustertype=CloudManaged&hosttags=$tag1 HTTP/1.0\n\n"
+ host_out=$(echo -e $host_query | nc -v -w $delay $host 8096)
+ host_id=$(echo $host_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ if ! [[ "$host_id" =~ ^[0-9]+$ ]] ; then
+ exec >&2; echo "[ERROR] $(date) host addition failed in [pod:$podid,cluster:$clusterid]"; continue
+ fi
+ host_name=$(echo $host_out | sed 's/\(.*\)\(SimulatedAgent.[-0-9a-zA-Z]*\)\(.*\)/\2/g')
+ echo "[DEBUG] $date added host [$host_id:$host_name] to [pod:$podid,cluster:$clusterid] for TAG1"
+ done
+done
+
+#TAG2
+for ((i=$(($tag_one_range + 1));i<=$(($tag_one_range + $tag_two_range));i++))
+do
+ podid=${pod_array[$i]}
+ for ((j=1;j<=$hosts_per_pod;j++))
+ do
+ clusterid=${cluster_array[$(($i*$clusters_per_pod + $j))]}
+ host_query="GET http://$host/client/?command=addHost&zoneId=$zoneid&podId=$podid&username=sim&password=sim&clusterid=$clusterid&url=http%3A%2F%2Fsim&hypervisor=Simulator&clustertype=CloudManaged&hosttags=$tag2 HTTP/1.0\n\n"
+ host_out=$(echo -e $host_query | nc -v -w $delay $host 8096)
+ host_id=$(echo $host_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ if ! [[ "$host_id" =~ ^[0-9]+$ ]] ; then
+ exec >&2; echo "[ERROR] $(date) host addition failed in [pod:$podid,cluster:$clusterid]"; continue
+ fi
+ host_name=$(echo $host_out | sed 's/\(.*\)\(SimulatedAgent.[-0-9a-zA-Z]*\)\(.*\)/\2/g')
+ echo "[DEBUG] $date added host [$host_id:$host_name] to [pod:$podid,cluster:$clusterid] for TAG2"
+ done
+done
+
+#TAG3
+for ((i=$(($tag_two_range + $tag_one_range + 1));i<=$(($tag_three_range + $tag_two_range + $tag_one_range));i++))
+do
+ podid=${pod_array[$i]}
+ for ((j=1;j<=$hosts_per_pod;j++))
+ do
+ clusterid=${cluster_array[$(($i*$clusters_per_pod + $j))]}
+ host_query="GET http://$host/client/?command=addHost&zoneId=$zoneid&podId=$podid&username=sim&password=sim&clusterid=$clusterid&url=http%3A%2F%2Fsim&hypervisor=Simulator&clustertype=CloudManaged&hosttags=$tag3 HTTP/1.0\n\n"
+ host_out=$(echo -e $host_query | nc -v -w $delay $host 8096)
+ host_id=$(echo $host_out | sed 's/\(.*\)\([0-9]*\)\(.*\)/\2/g')
+ if ! [[ "$host_id" =~ ^[0-9]+$ ]] ; then
+ exec >&2; echo "[ERROR] $(date) host addition failed in [pod:$podid,cluster:$clusterid]"; continue
+ fi
+ host_name=$(echo $host_out | sed 's/\(.*\)\(SimulatedAgent.[-0-9a-zA-Z]*\)\(.*\)/\2/g')
+ echo "[DEBUG] $date added host [$host_id:$host_name] to [pod:$podid,cluster:$clusterid] for TAG3"
+ done
+done
+
+echo "Setup complete"
+exit 0
diff --git a/agent-simulator/scripts/zucchini/__old__/small.sh b/agent-simulator/scripts/zucchini/__old__/small.sh
new file mode 100755
index 00000000000..9ffed2322b8
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/small.sh
@@ -0,0 +1,151 @@
+#!/bin/bash
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+############################################################
+#
+# zucchini uses local storage, before setting up make sure
+# * xen.public.network.device is set
+# * use.local.storage and systemvm.use.local.storage are true
+# * optionally turn off stats collector
+# * expunge.delay and expunge.interval are 60s
+# * capacity.skipcounting.hours=0
+
+#Environment
+#1. Small setup for zucchini : 13, 26, 39, 52 hosts only
+#2. Only 3 host tags.
+#3. With in each pod, the host tags are the same.
+#4. The ratio of hosts for the three tags should be 5/2/6
+#5. simulator.properties, workers=1
+############################################################
+
+usage() {
+ printf "Setup Zucchini Like Environment\nUsage: %s: -h management-server -z zoneid [-d delay] -n numberofhosts\n" $(basename $0) >&2
+}
+
+a=1 #CIDR - 16bytes
+b=2 #CIDR - 8 bytes
+
+#options
+hflag=1
+zflag=1
+dflag=1
+nflag=1
+
+host="127.0.0.1" #default localhost
+zoneid=
+delay=300 #default 5 minutes
+numberofhosts=13 #default 13 hosts
+tag1="TAG1"
+tag2="TAG2"
+tag3="TAG3"
+
+while getopts 'h:z:d:n:' OPTION
+do
+ case $OPTION in
+ h) hflag=1
+ host="$OPTARG"
+ ;;
+ z) zflag=1
+ zoneid="$OPTARG"
+ ;;
+ d) dflag=1
+ delay="$OPTARG"
+ ;;
+ n) nflag=1
+ numberofhosts="$OPTARG"
+ ;;
+ ?) usage
+ exit 2
+ ;;
+ esac
+done
+
+if [ $hflag$zflag$dflag$nflag != "1111" ]
+then
+ usage
+ exit 2
+fi
+
+if [ $numberofhosts -gt 52 ]
+then
+ echo "Can't exceed 52 hosts"
+ exit 130
+fi
+
+numberofpods=3 #130 hosts per pod. So need only 3. each pod is homogenous
+tag_one_range=$(($numberofhosts*5/13))
+tag_two_range=$(($numberofhosts*2/13))
+tag_three_range=$(($numberofhosts-$tag_one_range-$tag_two_range))
+
+#create the zone
+zone_query="GET http://$host/client/?command=createZone&networktype=Basic&securitygroupenabled=true&name=Zucchini&dns1=4.2.2.2&internaldns1=4.2.2.2 HTTP/1.0\n\n"
+echo -e $zone_query | nc -v -w $delay $host 8096
+
+sstor_query="GET http://$host/client/?command=addSecondaryStorage&zoneid=$zoneid&url=nfs://172.16.15.32/export/share/secondary HTTP/1.0\n\n"
+echo -e $sstor_query | nc -v -w $delay $host 8096
+
+let x=a
+let y=b
+for name in `seq 1 $numberofpods`
+do
+ pod_query="GET http://$host/client/?command=createPod&zoneId=$zoneid&name=POD$name&netmask=255.255.255.0&startIp=172.$x.$y.2&endIp=172.$x.$y.131&gateway=172.$x.$y.1 HTTP/1.0\n\n"
+ vlan_query="GET http://$host/client/?command=createVlanIpRange&vlan=untagged&zoneid=$zoneid&podId=$name&forVirtualNetwork=false&gateway=172.$y.$x.1&netmask=255.255.255.0&startip=172.$y.$x.2&endip=172.$y.$x.131 HTTP/1.0\n\n"
+ echo -e $pod_query | nc -v -w $delay $host 8096
+ echo -e $vlan_query | nc -v -w $delay $host 8096
+
+ let x+=1
+ let y+=1
+done
+
+#add clusters -
+#for i in `seq 1 10`
+# cluster_query="GET http://$host/client/?command=addCluster&hypervisor=Simulator&clustertype=CloudManaged&zoneId=$zoneid&podId=$podid&clustername=POD$podid-CLUSTER$cluster HTTP/1.0\n\n"
+# echo -e $cluster_query | nc -v -w $delay $host 8096
+#do
+
+clusterid=1
+#TAG1
+for cluster in `seq 1 $tag_one_range`
+do
+ cluster_query="GET http://$host/client/?command=addCluster&hypervisor=Simulator&clustertype=CloudManaged&zoneId=$zoneid&podId=1&clustername=POD1-CLUSTER$cluster HTTP/1.0\n\n"
+ echo -e $cluster_query | nc -v -w $delay $host 8096
+ host_query="GET http://$host/client/?command=addHost&zoneId=$zoneid&podId=1&username=sim&password=sim&clusterid=$clusterid&url=http%3A%2F%2Fsim&hypervisor=Simulator&clustertype=CloudManaged&hosttags=$tag1 HTTP/1.0\n\n"
+ echo -e $host_query | nc -v -w $delay $host 8096
+ let clusterid+=1
+done
+
+#TAG2
+for cluster in `seq $(($tag_one_range + 1)) $(($tag_one_range + $tag_two_range))`
+do
+ cluster_query="GET http://$host/client/?command=addCluster&hypervisor=Simulator&clustertype=CloudManaged&zoneId=$zoneid&podId=2&clustername=POD2-CLUSTER$cluster HTTP/1.0\n\n"
+ echo -e $cluster_query | nc -v -w $delay $host 8096
+ host_query="GET http://$host/client/?command=addHost&zoneId=$zoneid&podId=2&username=sim&password=sim&clusterid=$clusterid&url=http%3A%2F%2Fsim&hypervisor=Simulator&clustertype=CloudManaged&hosttags=$tag2 HTTP/1.0\n\n"
+ echo -e $host_query | nc -v -w $delay $host 8096
+ let clusterid+=1
+done
+
+#TAG3
+for cluster in `seq $(($tag_two_range + $tag_one_range + 1)) $(($tag_three_range + $tag_two_range + $tag_one_range))`
+do
+ cluster_query="GET http://$host/client/?command=addCluster&hypervisor=Simulator&clustertype=CloudManaged&zoneId=$zoneid&podId=3&clustername=POD3-CLUSTER$cluster HTTP/1.0\n\n"
+ echo -e $cluster_query | nc -v -w $delay $host 8096
+ host_query="GET http://$host/client/?command=addHost&zoneId=$zoneid&podId=3&username=sim&password=sim&clusterid=$clusterid&url=http%3A%2F%2Fsim&hypervisor=Simulator&clustertype=CloudManaged&hosttags=$tag3 HTTP/1.0\n\n"
+ echo -e $host_query | nc -v -w $delay $host 8096
+ let clusterid+=1
+
+done
+
+for i in {1..60}
+do
+ sg_create_query="GET http://$host/client/?command=createSecurityGroup&name=TestGroup1&description=Test HTTP/1.0\n\n"
+ echo -e $sg_create_query | nc -v -w $delay $host 8096
+
+ sg_auth_query="GET http://$host/client/?command=authorizeSecurityGroupIngress&domainid=1&account=admin&securitygroupid=$((i+2))&protocol=TCP&startport=2002&endport=2002&usersecuritygrouplist[0].account=admin&usersecuritygrouplist[0].group=TestGroup1 HTTP/1.0\n\n"
+ echo -e $sg_create_query | nc -v -w $delay $host 8096
+done
+
+echo "Setup complete"
+exit 0
diff --git a/agent-simulator/scripts/zucchini/__old__/so_setup.sh b/agent-simulator/scripts/zucchini/__old__/so_setup.sh
new file mode 100755
index 00000000000..97bee1b5339
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/so_setup.sh
@@ -0,0 +1,7 @@
+#setup service offerings with hosttags - TAG1, TAG2, TAG3
+#offering sizes are such that only one VM sits on each host
+host=$1
+
+./setupServiceOffering.sh -h $host -i T1 -l -m 7168 -c 1024 -n 1 -g TAG1
+./setupServiceOffering.sh -h $host -i T2 -l -m 7168 -c 1024 -n 1 -g TAG2
+./setupServiceOffering.sh -h $host -i T3 -l -m 7168 -c 1024 -n 1 -g TAG3
diff --git a/agent-simulator/scripts/zucchini/__old__/startRouter.sh b/agent-simulator/scripts/zucchini/__old__/startRouter.sh
new file mode 100755
index 00000000000..8667d263790
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/startRouter.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+start_router="GET http://10.91.30.226:8096/client/?command=startRouter&id=$x HTTP/1.0\n\n"
+
+
+echo -e $start_router | nc -v -q 60 10.91.30.226 8096
+
diff --git a/agent-simulator/scripts/zucchini/__old__/startVirtualMachine.sh b/agent-simulator/scripts/zucchini/__old__/startVirtualMachine.sh
new file mode 100755
index 00000000000..84fa055ff87
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/startVirtualMachine.sh
@@ -0,0 +1,13 @@
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+x=$1
+
+start_vm="GET http://10.91.30.226:8096/client/?command=startVirtualMachine&id=$x HTTP/1.0\n\n"
+
+
+echo -e $start_vm | nc -v -q 60 10.91.30.226 8096
+
diff --git a/agent-simulator/scripts/zucchini/__old__/stopRouter.sh b/agent-simulator/scripts/zucchini/__old__/stopRouter.sh
new file mode 100755
index 00000000000..51d101cec79
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/stopRouter.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+usage() {
+ printf "Stop Router: %s: -h management-server -i vmid\n" $(basename $0) >&2
+}
+
+iflag=
+hflag=
+
+host="127.0.0.1" #defaults to localhost
+vmid=
+
+while getopts 'h:i:' OPTION
+do
+ case $OPTION in
+ h) hflag=1
+ host="$OPTARG"
+ ;;
+ i) iflag=1
+ vmid="$OPTARG"
+ ;;
+ ?) usage
+ exit 2
+ ;;
+ esac
+done
+
+if [[ $iflag != "1" ]]
+then
+ usage
+ exit 2
+fi
+stop_vm="GET http://$host:8096/client/?command=stopRouter&id=$vmid HTTP/1.0\n\n"
+echo -e $stop_vm | nc -v -w 60 $host 8096
diff --git a/agent-simulator/scripts/zucchini/__old__/stopVirtualMachine.sh b/agent-simulator/scripts/zucchini/__old__/stopVirtualMachine.sh
new file mode 100755
index 00000000000..a0d26c0c62a
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/stopVirtualMachine.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+usage() {
+ printf "Stop Virtual Machine: %s: -h management-server -i vmid\n" $(basename $0) >&2
+}
+
+iflag=
+hflag=
+
+host="127.0.0.1" #defaults to localhost
+vmid=
+
+while getopts 'h:i:' OPTION
+do
+ case $OPTION in
+ h) hflag=1
+ host="$OPTARG"
+ ;;
+ i) iflag=1
+ vmid="$OPTARG"
+ ;;
+ ?) usage
+ exit 2
+ ;;
+ esac
+done
+
+if [[ $iflag != "1" ]]
+then
+ usage
+ exit 2
+fi
+stop_vm="GET http://$host:8096/client/?command=stopVirtualMachine&id=$vmid HTTP/1.0\n\n"
+echo -e $stop_vm | nc -v -w 60 $host 8096
diff --git a/agent-simulator/scripts/zucchini/__old__/zucchini219.sh b/agent-simulator/scripts/zucchini/__old__/zucchini219.sh
new file mode 100755
index 00000000000..424e9fca127
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/__old__/zucchini219.sh
@@ -0,0 +1,110 @@
+#!/bin/bash
+
+
+
+ #
+ # Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
+ #
+
+
+#setup for zucchini hosts in the simulator
+
+#1. Approximately 10 hosts per pod.
+#2. Only 3 host tags.
+#3. With in each pod, the host tags are the same.
+#4. The ratio of hosts for the three tags should be 5/2/6
+
+a=$1 #CIDR - 16bytes
+b=$2 #CIDR - 8 bytes
+host=$3 #MSHOST
+zone=$4
+
+zone_query="GET http://$host/client/?command=createZone&name=Zucchini&dns1=4.2.2.2&internaldns1=4.2.2.2&vlan=10-4000&guestcidraddress=10.1.1.0%2F24 HTTP/1.0\n\n"
+echo -e $zone_query | nc -v -w 120 $host 8096
+
+# Pod Ratio: 38:15:47
+let x=a
+let y=b
+for name in `seq 1 152`
+do
+ pod_query="GET http://$host/client/?command=createPod&zoneId=$zone&name=POD$name&cidr=172.$x.$y.0%2F24&startIp=172.$x.$y.2&endIp=172.$x.$y.252&gateway=172.$x.$y.1 HTTP/1.0\n\n"
+ vlan_query="GET http://$host/client/?command=createVlanIpRange&vlan=untagged&zoneid=$zone&podId=$name&forVirtualNetwork=false&gateway=172.$y.$x.1&netmask=255.255.255.0&startip=172.$y.$x.2&endip=172.$y.$x.252 HTTP/1.0\n\n"
+ echo -e $pod_query | nc -v -w 20 $host 8096
+ echo -e $vlan_query | nc -v -w 20 $host 8096
+
+ let x+=1
+ let y+=1
+done
+
+
+let x=a
+let y=b
+for name in `seq 153 212`
+do
+ pod_query="GET http://$host/client/?command=createPod&zoneId=$zone&name=POD$name&cidr=182.$x.$y.0%2F24&startIp=182.$x.$y.2&endIp=182.$x.$y.252&gateway=182.$x.$y.1 HTTP/1.0\n\n"
+ vlan_query="GET http://$host/client/?command=createVlanIpRange&vlan=untagged&zoneid=$zone&podId=$name&forVirtualNetwork=false&gateway=182.$y.$x.1&netmask=255.255.255.0&startip=182.$y.$x.2&endip=182.$y.$x.252 HTTP/1.0\n\n"
+ echo -e $pod_query | nc -v -w 20 $host 8096
+ echo -e $vlan_query | nc -v -w 20 $host 8096
+
+ let x+=1
+ let y+=1
+done
+
+let x=a
+let y=b
+for name in `seq 213 400`
+do
+
+ pod_query="GET http://$host/client/?command=createPod&zoneId=$zone&name=POD$name&cidr=192.$x.$y.0%2F24&startIp=192.$x.$y.2&endIp=192.$x.$y.252&gateway=192.$x.$y.1 HTTP/1.0\n\n"
+ vlan_query="GET http://$host/client/?command=createVlanIpRange&vlan=untagged&zoneid=$zone&podId=$name&forVirtualNetwork=false&gateway=192.$y.$x.1&netmask=255.255.255.0&startip=192.$y.$x.2&endip=192.$y.$x.252 HTTP/1.0\n\n"
+ echo -e $pod_query | nc -v -w 20 $host 8096
+ echo -e $vlan_query | nc -v -w 20 $host 8096
+
+ let x+=1
+ let y+=1
+done
+
+#add clusters
+#for name in `seq 1 400`
+#do
+# for cluster in `seq 1 10`
+# do
+# cluster_query="GET http://$host/client/?command=addCluster&hypervisor=Simulator&clustertype=CloudManaged&zoneId=$zone&podId=$name&clustername=POD$name-CLUSTER$cluster HTTP/1.0\n\n"
+# echo -e $cluster_query | nc -v -w 120 $host 8096
+# done
+#done
+
+# @ 10 hosts per pod @ 10 clusters per pod
+clusterid=1
+#TAG1
+for podid in `seq 58 152`
+do
+ for i in `seq 1 10`
+ do
+ host_query="GET http://$host/client/?command=addHost&zoneId=$zone&podId=$podid&username=sim&password=sim&clustername=CLUSTER$clusterid&hosttags=TAG1&url=http%3A%2F%2Fsim HTTP/1.0\n\n"
+ echo -e $host_query | nc -v -w 6000 $host 8096
+ done
+ let clusterid+=1
+done
+
+#TAG2
+for podid in `seq 153 212`
+do
+ for i in `seq 1 10`
+ do
+ host_query="GET http://$host/client/?command=addHost&zoneId=$zone&podId=$podid&username=sim&password=sim&clustername=CLUSTER$clusterid&hosttags=TAG2&url=http%3A%2F%2Fsim HTTP/1.0\n\n"
+ echo -e $host_query | nc -v -w 6000 $host 8096
+ done
+ let clusterid+=1
+done
+
+#TAG3
+for podid in `seq 213 400`
+do
+ for i in `seq 1 10`
+ do
+ host_query="GET http://$host/client/?command=addHost&zoneId=$zone&podId=$podid&username=sim&password=sim&cluster=CLUSTER$clusterid&hosttags=TAG3&url=http%3A%2F%2Fsim HTTP/1.0\n\n"
+ echo -e $host_query | nc -v -w 6000 $host 8096
+ done
+ let clusterid+=1
+done
diff --git a/agent-simulator/scripts/zucchini/setup.py b/agent-simulator/scripts/zucchini/setup.py
new file mode 100644
index 00000000000..e3fa849e9bd
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/setup.py
@@ -0,0 +1,208 @@
+#!/usr/bin/env python
+
+'''
+############################################################
+# zucchini uses local storage, before setting up make sure
+# * xen.public.network.device is set
+# * use.local.storage and systemvm.use.local.storage are true
+# * optionally turn off stats collectors
+# * expunge.delay and expunge.interval are 60s
+# * ping.interval is around 3m
+# * turn off dns updates to entire zone, network.dns.basiczone.update=pod
+# * capacity.skipcounting.hours=0
+# * direct.agent.load.size=1000
+# * security groups are enabled
+#
+# This script will only setup an approximate number of hosts. To achieve the ratio
+# of 5:2:6 hosts the total number of hosts is brought close to a number divisible
+# by 13. So if 4000 hosts are added, you might see only 3900 come up
+#
+# 10 hosts per pod @ 1 host per cluster in a single zone
+#
+# Each pod has a /25, so 128 addresses. I think we reserved 5 IP addresses for system VMs in each pod.
+# Then we had something like 60 addresses for hosts and 60 addresses for VMs.
+
+#Environment
+#1. Approximately 10 hosts per pod.
+#2. Only 3 host tags.
+#3. With in each pod, the host tags are the same. Homogenous Pods
+#4. The ratio of hosts for the three tags should be 5/2/6
+#5. In simulator.properties, workers=1
+############################################################
+'''
+
+from optparse import OptionParser
+from configGenerator import *
+import random
+
+def getGlobalSettings():
+ global_settings = {'expunge.delay': '60',
+ 'expunge.interval': '60',
+ 'expunge.workers': '3',
+ 'workers': '10',
+ 'network.dns.basiczone.updates':'pod',
+ 'use.user.concentrated.pod.allocation':'false',
+ 'vm.allocation.algorithm':'firstfit',
+ 'capacity.check.period':'0',
+ 'host.stats.interval':'-1',
+ 'vm.stats.interval':'-1',
+ 'storage.stats.interval':'-1',
+ 'router.stats.interval':'-1',
+ 'vm.op.wait.interval':'5',
+ 'xen.public.network.device':'10.10.10.10', #only a dummy for the simulator
+ 'guest.domain.suffix':'zcloud.simulator',
+ 'instance.name':'ZIM',
+ 'direct.agent.load.size':'1000',
+ 'default.page.size':'10000',
+ 'linkLocalIp.nums':'4',
+ 'systemvm.use.local.storage':'true',
+ 'use.local.storage':'true',
+ 'check.pod.cidrs':'false',
+ }
+ for k,v in global_settings.iteritems():
+ cfg=configuration()
+ cfg.name=k
+ cfg.value=v
+ yield cfg
+
+def podIpRangeGenerator():
+ x=1
+ y=2
+ while 1:
+ if y == 256:
+ x=x+1
+ if x == 256:
+ break
+ y=1
+ y=y+1
+ #pod mangement network
+ yield ('172.'+str(x)+'.'+str(y)+'.129',
+ '172.'+str(x)+'.'+str(y)+'.130',
+ '172.'+str(x)+'.'+str(y)+'.189')
+
+
+def vlanIpRangeGenerator():
+ x=1
+ y=2
+ while 1:
+ if y == 256:
+ x=x+1
+ if x==256:
+ break
+ y=1
+ y=y+1
+ #vlan ip range
+ yield ('172.'+str(x)+'.'+str(y)+'.129',
+ '172.'+str(x)+'.'+str(y)+'.190',
+ '172.'+str(x)+'.'+str(y)+'.249')
+
+
+def describeZucchiniResources(numberOfAgents=1300, dbnode='localhost', mshost='localhost', randomize=False):
+ zs=cloudstackConfiguration()
+ numberofpods=numberOfAgents/10
+ tagOneHosts = numberOfAgents*5/13
+ tagTwoHosts = numberOfAgents*2/13
+ tagThreeHosts = numberOfAgents-tagOneHosts-tagTwoHosts
+
+ clustersPerPod=10
+ hostsPerPod=10
+
+ z = zone()
+ z.dns1 = '4.2.2.2'
+ z.dns2 = '192.168.110.254'
+ z.internaldns1 = '10.91.28.6'
+ z.internaldns2 = '192.168.110.254'
+ z.name = 'Zucchini'
+ z.networktype = 'Basic'
+
+ hosttags=['TAG1' for x in range(tagOneHosts)] + ['TAG2' for x in range(tagTwoHosts)] + ['TAG3' for x in range(tagThreeHosts)]
+ if randomize:
+ random.shuffle(hosttags) #randomize the host distribution
+ curhost=0
+ curpod=0
+ for podRange,vlanRange in zip(podIpRangeGenerator(), vlanIpRangeGenerator()):
+ p = pod()
+ curpod=curpod+1
+ p.name = 'POD'+str(curpod)
+ p.gateway=podRange[0]
+ p.startip=podRange[1]
+ p.endip=podRange[2]
+ p.netmask='255.255.255.128'
+
+ v = iprange()
+ v.gateway=vlanRange[0]
+ v.startip=vlanRange[1]
+ v.endip=vlanRange[2]
+ v.netmask="255.255.255.128"
+ p.guestIpRanges.append(v)
+
+ for i in range(1,clustersPerPod+1):
+ c = cluster()
+ c.clustername = 'POD'+str(curpod)+'-CLUSTER'+str(i)
+ c.hypervisor = 'Simulator'
+ c.clustertype = 'CloudManaged'
+
+ try:
+ h = host()
+ h.username = 'root'
+ h.password = 'password'
+ h.url = "http://sim/%d/cpucore=4&cpuspeed=8000&memory=%d&localstorage=%d"%(i,8*1024*1024*1024,1*1024*1024*1024*1024)
+ h.hosttags = hosttags.pop()
+ c.hosts.append(h)
+ curhost=curhost+1
+ p.clusters.append(c)
+ except IndexError:
+ break
+ #end clusters
+ z.pods.append(p)
+ if curpod == numberofpods or curhost == numberOfAgents:
+ break
+ #end pods
+ secondary = secondaryStorage()
+ secondary.url = 'nfs://172.16.25.32/secondary/path'
+ z.secondaryStorages.append(secondary)
+ zs.zones.append(z)
+
+ '''Add mgt server'''
+ mgt = managementServer()
+ mgt.mgtSvrIp = mshost #could be the LB balancing the cluster of management server as well
+ zs.mgtSvr.append(mgt)
+
+ '''Add a database'''
+ db = dbServer()
+ db.dbSvr = opts.dbnode
+ zs.dbSvr = db
+
+ '''Add some configuration'''
+ [zs.globalConfig.append(cfg) for cfg in getGlobalSettings()]
+
+ ''''add loggers'''
+ testClientLogger = logger()
+ testClientLogger.name = "TestClient"
+ testClientLogger.file = "/var/log/testclient.log"
+
+ testCaseLogger = logger()
+ testCaseLogger.name = "TestCase"
+ testCaseLogger.file = "/var/log/testcase.log"
+
+ zs.logger.append(testClientLogger)
+ zs.logger.append(testCaseLogger)
+ return zs
+
+if __name__=="__main__":
+ parser = OptionParser()
+# parser.add_option('-h','--host',dest='host',help='location of management server(s) or load-balancer')
+ parser.add_option('-n', '--number-of-agents', action='store', dest='agents', help='number of agents in the deployment')
+ parser.add_option('-g', '--enable-security-groups', dest='sgenabled', help='specify if security groups are to be enabled', default=False, action='store_true')
+ parser.add_option('-o', '--output', action='store', default='./zucchiniCfg', dest='output', help='the path where the json config file generated')
+ parser.add_option('-d', '--dbnode', dest='dbnode', help='hostname/ip of the database node', action='store')
+ parser.add_option('-m', '--mshost', dest='mshost', help='hostname/ip of management server', action='store')
+ parser.add_option('-r', '--randomize', dest='randomize', help='randomize the distribution of tags (hetergenous clusters)', action='store_true', default=False)
+
+ (opts, args) = parser.parse_args()
+ mandatories = ['mshost', 'dbnode', 'agents']
+ for m in mandatories:
+ if not opts.__dict__[m]:
+ print "mandatory option missing"
+ cfg = describeZucchiniResources(int(opts.agents), opts.dbnode, opts.mshost, opts.randomize)
+ generate_setup_config(cfg, opts.output)
diff --git a/agent-simulator/scripts/zucchini/tests/testProvision.py b/agent-simulator/scripts/zucchini/tests/testProvision.py
new file mode 100644
index 00000000000..21acb6e33df
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/tests/testProvision.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+'''
+Deploy Virtual Machine tests
+'''
+import unittest
+import random
+from cloudstackAPI import *
+
+class Provision(unittest.case.TestCase):
+ '''
+ This should test basic provisioning of virtual machines
+ 1. Deploy a no-frills VM
+ 2. Deploy with tags - hosttags
+ 3. Deploy with/without security groups
+ '''
+
+ api = self.testClient.getApiClient()
+ solist = {}
+
+ def setUp(self):
+ '''setup service offerings with tags'''
+ for tag in ['TAG1', 'TAG2', 'TAG3']:
+ csocmd = createServiceOffering.createServiceOfferingCmd()
+ csocmd.cpunumber = 1
+ csocmd.cpuspeed = 2048
+ csocmd.displayText = tag
+ csocmd.memory = 7168
+ csocmd.name = tag
+ csocmd.hosttags = tag
+ csocmd.storagetype = 'local'
+ csoresponse = self.api.createServiceOffering(csocmd)
+ self.debug("Created Service Offering: %s", tag)
+ solist[tag]=csoresponse.id
+
+
+ def tearDown(self):
+ ''' Any cleanup post tests '''
+
+ def test_DeployVMWithHostTags(self):
+ '''
+ Deploy 3 virtual machines one with each hosttag
+ '''
+ for k,v in solist:
+ deployVmCmd = deployVirtualMachine.deployVirtualMachineCmd()
+ deployVmCmd.zoneid = 1
+ deployVmCmd.hypervisor='Simulator'
+ deployVmCmd.serviceofferingid=v
+ deployVmCmd.account='admin'
+ deployVmCmd.domainid=1
+ deployVmCmd.templateid=2
+ deployVmResponse = self.api.deployVirtualMachine(deployVmCmd)
+ self.debug("Deployed VM :%d in job: %d",deployVmResponse.id, deployVmResponse.jobid)
+
+
+ def deployCmd(self, tag):
+ deployVmCmd = deployVirtualMachine.deployVirtualMachineCmd()
+ deployVmCmd.zoneid = 1
+ deployVmCmd.hypervisor='Simulator'
+ deployVmCmd.serviceofferingid=solist[tag]
+ deployVmCmd.account='admin'
+ deployVmCmd.domainid=1
+ deployVmCmd.templateid=2
+ return deployVmCmd
+
+ def deployN(self,nargs=300,batchsize=0):
+ '''
+ Deploy Nargs number of VMs concurrently in batches of size {batchsize}.
+ When batchsize is 0 all Vms are deployed in one batch
+ VMs will be deployed in 5:2:6 ratio
+ '''
+ tag1=nargs*5/13
+ tag2=nargs*2/13
+ tag3=nargs-tag1-tag2
+
+ cmds = []
+ [cmds.append(deployCmd('TAG1')) for i in range(tag1)]
+ [cmds.append(deployCmd('TAG2')) for i in range(tag2)]
+ [cmds.append(deployCmd('TAG3')) for i in range(tag3)]
+ random.shuffle(cmds) #with mix-and-match of Tags
+
+ if batchsize == 0:
+ self.testClient.submitCmdsAndWait(cmds)
+ else:
+ while len(z) > 0:
+ try:
+ newbatch = [cmds.pop() for b in range(batchsize)] #pop batchsize items
+ self.testClient.submitCmdsAndWait(newbatch)
+ except IndexError:
+ break
+
+ def test_bulkDeploy(self):
+ deployN(130,0)
+ deployN(nargs=3000,batchsize=100)
+
+
+
+
+
+
+
+
diff --git a/agent-simulator/scripts/zucchini/zucchini.configuration.sql b/agent-simulator/scripts/zucchini/zucchini.configuration.sql
new file mode 100644
index 00000000000..3f81b64d259
--- /dev/null
+++ b/agent-simulator/scripts/zucchini/zucchini.configuration.sql
@@ -0,0 +1,29 @@
+update configuration set value='pod' where name='network.dns.basiczone.updates';
+
+update configuration set value='false' where name='use.user.concentrated.pod.allocation';
+update configuration set value='firstfit' where name='vm.allocation.algorithm';
+
+update configuration set value='60' where name='expunge.delay';
+update configuration set value='60' where name='expunge.interval';
+update configuration set value='3' where name='expunge.workers';
+update configuration set value='10' where name='workers';
+
+update configuration set value='0' where name='capacity.check.period';
+update configuration set value='-1' where name='host.stats.interval';
+update configuration set value='-1' where name='vm.stats.interval';
+update configuration set value='-1' where name='storage.stats.interval';
+update configuration set value='-1' where name='router.stats.interval';
+update configuration set value='5' where name like 'vm.op.wait.interval';
+
+update configuration set value='10.10.10.10' where name='xen.public.network.device';
+update configuration set value='zcloud.simulator' where name='guest.domain.suffix';
+update configuration set value='ZIM' where name='instance.name';
+
+update configuration set value='1000' where name='direct.agent.load.size';
+update configuration set value='10000' where name='default.page.size';
+update configuration set value='4' where name='linkLocalIp.nums';
+update configuration set value='true' where name like '%local.storage%';
+update configuration set value='false' where name like '%check.pod.cidr%';
+
+update configuration set value='100' where name like '%network.security%pool%';
+update configuration set value='120' where name like 'network.securitygroups.work.cleanup.interval';
diff --git a/agent-simulator/src/com/cloud/agent/MetricsCollector.java b/agent-simulator/src/com/cloud/agent/MetricsCollector.java
new file mode 100644
index 00000000000..2bb258e0aca
--- /dev/null
+++ b/agent-simulator/src/com/cloud/agent/MetricsCollector.java
@@ -0,0 +1,110 @@
+/**
+ * * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
+*
+ *
+ * This software is licensed under the GNU General Public License v3 or later.
+ *
+ * It is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package com.cloud.agent;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.utils.concurrency.NamedThreadFactory;
+
+public class MetricsCollector {
+ private static final Logger s_logger = Logger.getLogger(MetricsCollector.class);
+
+ private final Set vmNames = new HashSet();
+ private final Set newVMnames = new HashSet();
+ private final Map metricsMap = new HashMap();
+
+ private final transient ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Metrics"));
+
+ private Set _currentVms;
+
+ public MetricsCollector(Set currentVms) {
+ _currentVms = currentVms;
+ getAllVMNames();
+ }
+
+ public MetricsCollector() {
+
+ }
+
+ public synchronized void getAllVMNames() {
+ Set currentVMs = _currentVms;
+
+ newVMnames.clear();
+ newVMnames.addAll(currentVMs);
+ newVMnames.removeAll(vmNames); //leave only new vms
+
+ vmNames.removeAll(currentVMs); //old vms - current vms --> leave non-running vms;
+ for (String vm: vmNames) {
+ removeVM(vm);
+ }
+
+ vmNames.clear();
+ vmNames.addAll(currentVMs);
+ }
+
+ public synchronized void submitMetricsJobs() {
+ s_logger.debug("Submit Metric Jobs called");
+
+ for (String vm : newVMnames) {
+ MockVmMetrics task = new MockVmMetrics(vm);
+ if (!metricsMap.containsKey(vm)) {
+ metricsMap.put(vm, task);
+ ScheduledFuture> sf = executor.scheduleWithFixedDelay(task, 2, 600, TimeUnit.SECONDS);
+ task.setFuture(sf);
+ }
+ }
+ newVMnames.clear();
+ }
+
+ public synchronized void addVM(String vmName) {
+ newVMnames.add(vmName);
+ s_logger.debug("Added vm name= " + vmName);
+ }
+
+ public synchronized void removeVM(String vmName) {
+ newVMnames.remove(vmName);
+ vmNames.remove(vmName);
+ MockVmMetrics task = metricsMap.get(vmName);
+ if (task != null) {
+ task.stop();
+ boolean r1= task.getFuture().cancel(false);
+ metricsMap.remove(vmName);
+ s_logger.debug("removeVM: cancel returned " + r1 + " for VM " + vmName);
+ } else {
+ s_logger.warn("removeVM called for nonexistent VM " + vmName);
+ }
+ }
+
+ public synchronized Set getVMNames() {
+ return vmNames;
+ }
+
+ public synchronized Map getMetricsMap() {
+ return metricsMap;
+ }
+}
diff --git a/agent-simulator/src/com/cloud/agent/MockVmMetrics.java b/agent-simulator/src/com/cloud/agent/MockVmMetrics.java
new file mode 100644
index 00000000000..49184ea2a0f
--- /dev/null
+++ b/agent-simulator/src/com/cloud/agent/MockVmMetrics.java
@@ -0,0 +1,210 @@
+/**
+ * * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
+*
+ *
+ * This software is licensed under the GNU General Public License v3 or later.
+ *
+ * It is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package com.cloud.agent;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+import java.util.concurrent.ScheduledFuture;
+
+import org.apache.log4j.Logger;
+
+public class MockVmMetrics implements Runnable {
+ private static final Logger s_logger = Logger.getLogger(MockVmMetrics.class);
+
+ private String vmName;
+
+ //the maximum number of network interfaces to a VM (should be 1)
+ public final int MAX_INTERFACES=1;
+
+ //the maximum number of disks to a VM
+ public final int MAX_DISKS=8;
+
+ //the last calculated traffic speed (transmit) per interface
+ private Map netTxKBps = new HashMap();
+
+ //the last calculated traffic speed (receive) per interface
+ private Map netRxKBps = new HashMap();
+
+ //the last calculated disk write speed per disk (Bytes Per Second)
+ private Map diskWriteKBytesPerSec = new HashMap();
+
+ //the last calculated disk read speed per disk (Bytes Per Second)
+ private Map diskReadKBytesPerSec = new HashMap();
+
+ //Total Bytes Transmitted on network interfaces
+ private Map netTxTotalBytes = new HashMap();
+
+ //Total Bytes Received on network interfaces
+ private Map netRxTotalBytes = new HashMap();
+
+ //Total Bytes read per disk
+ private Map diskReadTotalBytes = new HashMap();
+
+ //Total Bytes written per disk
+ private Map diskWriteTotalBytes = new HashMap();
+
+ //CPU time in seconds
+ private Double cpuSeconds = new Double(0.0);
+
+ //CPU percentage
+ private Float cpuPercent = new Float(0.0);
+
+ private Map diskMap = new HashMap();
+
+ private Map vifMap = new HashMap();
+
+ private Map diskStatTimestamp = new HashMap();
+ private Map netStatTimestamp = new HashMap();
+
+ private long cpuStatTimestamp = 0L;
+
+ private ScheduledFuture> future;
+ private boolean stopped = false;
+ private Random randSeed = new Random();
+
+ public MockVmMetrics(String vmName) {
+ this.vmName = vmName;
+ vifMap.put("eth0", "eth0");
+ vifMap.put("eth1", "eth1");
+ vifMap.put("eth2", "eth2");
+
+ Long networkStart = 0L;
+ netTxTotalBytes.put("eth0", networkStart);
+ netRxTotalBytes.put("eth0", networkStart);
+
+ netTxTotalBytes.put("eth1", networkStart);
+ netRxTotalBytes.put("eth1", networkStart);
+
+ netTxTotalBytes.put("eth2", networkStart);
+ netRxTotalBytes.put("eth2", networkStart);
+ }
+
+ private int getIncrementor() {
+ return randSeed.nextInt(100);
+ }
+
+ @Override
+ public void run() {
+ if(s_logger.isDebugEnabled()) {
+ s_logger.debug("Generating MockVM metrics");
+ }
+ for (Map.Entry entry : netRxTotalBytes.entrySet()) {
+ entry.setValue(entry.getValue() + getIncrementor());
+ }
+
+ for (Map.Entry entry : netTxTotalBytes.entrySet()) {
+ entry.setValue(entry.getValue() + getIncrementor());
+ }
+ }
+
+ public String getVmName() {
+ return vmName;
+ }
+
+ public Map getNetTxKBps() {
+ return netTxKBps;
+ }
+
+ public Map getNetRxKBps() {
+ return netRxKBps;
+ }
+
+ public Map getDiskWriteBytesPerSec() {
+ return diskWriteKBytesPerSec;
+ }
+
+ public Map getDiskReadBytesPerSec() {
+ return diskReadKBytesPerSec;
+ }
+
+ public Map getNetTxTotalBytes() {
+ return netTxTotalBytes;
+ }
+
+ public Map getNetRxTotalBytes() {
+ return netRxTotalBytes;
+ }
+
+ public Map getDiskReadTotalBytes() {
+ return diskReadTotalBytes;
+ }
+
+ public Map getDiskWriteTotalBytes() {
+ return diskWriteTotalBytes;
+ }
+
+ public Double getNetTxKBps(String intf) {
+ return netTxKBps.get(intf);
+ }
+
+ public Double getNetRxKBps(String intf) {
+ return netRxKBps.get(intf);
+ }
+
+ public Double getDiskWriteKBytesPerSec(String disk) {
+ return diskWriteKBytesPerSec.get(disk);
+ }
+
+ public Double getDiskReadKBytesPerSec(String disk) {
+ return diskReadKBytesPerSec.get(disk);
+ }
+
+ public Long getNetTxTotalBytes(String intf) {
+ return netTxTotalBytes.get(intf);
+ }
+
+ public Long getNetRxTotalBytes(String intf) {
+ return netRxTotalBytes.get(intf);
+ }
+
+ public Long getDiskReadTotalBytes(String disk) {
+ return diskReadTotalBytes.get(disk);
+ }
+
+ public Long getDiskWriteTotalBytes(String disk) {
+ return diskWriteTotalBytes.get(disk);
+ }
+
+ public Double getCpuSeconds() {
+ return cpuSeconds;
+ }
+
+ public Map getDiskMap() {
+ return diskMap;
+ }
+
+ public Float getCpuPercent() {
+ return cpuPercent;
+ }
+
+ public void setFuture(ScheduledFuture> sf) {
+ this.future = sf;
+ }
+
+ public ScheduledFuture> getFuture() {
+ return future;
+ }
+
+ public void stop() {
+ this.stopped = true;
+ }
+}
+
diff --git a/agent-simulator/src/com/cloud/agent/MultiCaster.java b/agent-simulator/src/com/cloud/agent/MultiCaster.java
new file mode 100644
index 00000000000..f282a2f401e
--- /dev/null
+++ b/agent-simulator/src/com/cloud/agent/MultiCaster.java
@@ -0,0 +1,149 @@
+/**
+ * * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
+*
+ *
+ * This software is licensed under the GNU General Public License v3 or later.
+ *
+ * It is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package com.cloud.agent;
+
+import java.util.*;
+import java.net.*;
+import java.io.*;
+
+import org.apache.log4j.Logger;
+
+public class MultiCaster implements Runnable {
+ private static final Logger s_logger = Logger.getLogger(MultiCaster.class);
+
+ public final int MAX_PACKET_SIZE = 8096;
+
+ private List listeners;
+ private DatagramSocket socket;
+ private byte[] recvBuffer;
+
+ private Thread driver;
+ private volatile boolean stopRequested = false;
+
+ public MultiCaster() {
+ listeners = new ArrayList();
+ recvBuffer = new byte[MAX_PACKET_SIZE];
+ }
+
+ public void addListener(MultiCasterListener listener) {
+ synchronized(listeners) {
+ listeners.add(listener);
+ }
+ }
+
+ public void removeListener(MultiCasterListener listener) {
+ synchronized(listeners) {
+ listeners.remove(listener);
+ }
+ }
+
+ public void cast(byte[] buf, int off, int len,
+ InetAddress toAddress, int nToPort) throws IOException {
+
+ if(socket == null)
+ throw new IOException("multi caster is not started");
+
+ if(len >= MAX_PACKET_SIZE)
+ throw new IOException("packet size exceeds limit of " + MAX_PACKET_SIZE);
+
+ DatagramPacket packet = new DatagramPacket(buf, off,
+ len, toAddress, nToPort);
+
+ socket.send(packet);
+ }
+
+ public void start(String strOutboundAddress,
+ String strClusterAddress, int nPort) throws SocketException {
+ assert(socket == null);
+
+ InetAddress addr = null;
+ try {
+ addr = InetAddress.getByName(strClusterAddress);
+ } catch(IOException e) {
+ s_logger.error("Unexpected exception " , e);
+ }
+
+ if(addr != null && addr.isMulticastAddress()) {
+ try {
+ socket = new MulticastSocket(nPort);
+ socket.setReuseAddress(true);
+
+ if(s_logger.isInfoEnabled())
+ s_logger.info("Join multicast group : " + addr);
+
+ ((MulticastSocket)socket).joinGroup(addr);
+ ((MulticastSocket)socket).setTimeToLive(1);
+
+ if(strOutboundAddress != null) {
+ if(s_logger.isInfoEnabled())
+ s_logger.info("set outgoing interface to : " + strOutboundAddress);
+
+ InetAddress ia = InetAddress.getByName(strOutboundAddress);
+ NetworkInterface ni = NetworkInterface.getByInetAddress(ia);
+ ((MulticastSocket)socket).setNetworkInterface(ni);
+ }
+ } catch(IOException e) {
+ s_logger.error("Unexpected exception " , e);
+ }
+ } else {
+ socket = new DatagramSocket(nPort);
+ socket.setReuseAddress(true);
+ }
+
+ driver = new Thread(this, "Multi-caster");
+ driver.setDaemon(true);
+ driver.start();
+ }
+
+ public void stop() {
+ if(socket != null) {
+ stopRequested = true;
+
+ socket.close();
+ if(driver != null) {
+ try {
+ driver.join();
+ } catch(InterruptedException e) {
+ }
+ driver = null;
+ }
+ }
+
+ socket = null;
+ stopRequested = false;
+ }
+
+ public void run() {
+ while(!stopRequested) {
+ try {
+ DatagramPacket packet = new DatagramPacket(recvBuffer, recvBuffer.length);
+ socket.receive(packet);
+
+ for(Object listener : listeners.toArray()) {
+ ((MultiCasterListener)listener).onMultiCasting(packet.getData(),
+ packet.getOffset(), packet.getLength(), packet.getAddress());
+ }
+ } catch(IOException e) {
+ } catch(Throwable e) {
+ s_logger.error("Unhandled exception : ", e);
+ }
+ }
+ }
+}
diff --git a/agent-simulator/src/com/cloud/agent/MultiCasterListener.java b/agent-simulator/src/com/cloud/agent/MultiCasterListener.java
new file mode 100644
index 00000000000..b42978d8bc9
--- /dev/null
+++ b/agent-simulator/src/com/cloud/agent/MultiCasterListener.java
@@ -0,0 +1,25 @@
+/**
+ * * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
+*
+ *
+ * This software is licensed under the GNU General Public License v3 or later.
+ *
+ * It is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package com.cloud.agent;
+import java.net.*;
+
+public interface MultiCasterListener {
+ public void onMultiCasting(byte[] data, int off, int len, InetAddress addrFrom);
+}
diff --git a/agent-simulator/src/com/cloud/agent/SimulatorCmd.java b/agent-simulator/src/com/cloud/agent/SimulatorCmd.java
new file mode 100644
index 00000000000..61d86ba7818
--- /dev/null
+++ b/agent-simulator/src/com/cloud/agent/SimulatorCmd.java
@@ -0,0 +1,40 @@
+/**
+ * * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
+*
+ *
+ * This software is licensed under the GNU General Public License v3 or later.
+ *
+ * It is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package com.cloud.agent;
+
+import java.io.Serializable;
+
+public class SimulatorCmd implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String testCase = "DEFAULT";
+
+ public SimulatorCmd(String testCase) {
+ this.testCase = testCase;
+ }
+
+ public String getTestCase() {
+ return testCase;
+ }
+
+ public void setTestCase(String testCase) {
+ this.testCase = testCase;
+ }
+}
diff --git a/agent-simulator/src/com/cloud/agent/SimulatorMigrateVmCmd.java b/agent-simulator/src/com/cloud/agent/SimulatorMigrateVmCmd.java
new file mode 100644
index 00000000000..0b1357a1350
--- /dev/null
+++ b/agent-simulator/src/com/cloud/agent/SimulatorMigrateVmCmd.java
@@ -0,0 +1,86 @@
+/**
+ * * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
+*
+ *
+ * This software is licensed under the GNU General Public License v3 or later.
+ *
+ * It is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package com.cloud.agent;
+
+public class SimulatorMigrateVmCmd extends SimulatorCmd {
+
+ private static final long serialVersionUID = 1L;
+
+ private String destIp;
+
+ private String vmName;
+ private long ramSize;
+ private int cpuCount;
+ private int utilization;
+
+ public SimulatorMigrateVmCmd(String testCase) {
+ super(testCase);
+ }
+
+ public String getDestIp() {
+ return destIp;
+ }
+
+ public void setDestIp(String destIp) {
+ this.destIp = destIp;
+ }
+
+ public String getVmName() {
+ return vmName;
+ }
+
+ public void setVmName(String vmName) {
+ this.vmName = vmName;
+ }
+
+ public long getRamSize() {
+ return ramSize;
+ }
+
+ public void setRamSize(long ramSize) {
+ this.ramSize = ramSize;
+ }
+
+ public int getCpuCount() {
+ return cpuCount;
+ }
+
+ public void setCpuCount(int cpuCount) {
+ this.cpuCount = cpuCount;
+ }
+
+ public int getUtilization() {
+ return utilization;
+ }
+
+ public void setUtilization(int utilization) {
+ this.utilization = utilization;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("SimulatorMigrateVmCmd {").append("vm: ").append(getVmName());
+ sb.append(", destIp: ").append(getDestIp()).append(", ramSize: ").append(getRamSize());
+ sb.append(", cpuCount: ").append(getCpuCount()).append(", utilization: ").append(getUtilization());
+ sb.append("}");
+
+ return sb.toString();
+ }
+}
diff --git a/agent-simulator/src/com/cloud/agent/manager/MockAgentManager.java b/agent-simulator/src/com/cloud/agent/manager/MockAgentManager.java
new file mode 100644
index 00000000000..ce2cf58a6c9
--- /dev/null
+++ b/agent-simulator/src/com/cloud/agent/manager/MockAgentManager.java
@@ -0,0 +1,48 @@
+package com.cloud.agent.manager;
+
+import java.util.Map;
+
+import javax.naming.ConfigurationException;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CheckHealthAnswer;
+import com.cloud.agent.api.CheckHealthCommand;
+import com.cloud.agent.api.GetHostStatsAnswer;
+import com.cloud.agent.api.GetHostStatsCommand;
+import com.cloud.agent.api.HostStatsEntry;
+import com.cloud.agent.api.MaintainCommand;
+import com.cloud.agent.api.PingTestCommand;
+import com.cloud.agent.api.PrepareForMigrationAnswer;
+import com.cloud.agent.api.PrepareForMigrationCommand;
+import com.cloud.agent.api.ReadyAnswer;
+import com.cloud.agent.api.ReadyCommand;
+import com.cloud.agent.api.SecurityIngressRulesCmd;
+import com.cloud.agent.api.ShutdownCommand;
+import com.cloud.resource.AgentResourceBase;
+import com.cloud.simulator.MockHost;
+import com.cloud.utils.component.Manager;
+
+public interface MockAgentManager extends Manager {
+ public static final long DEFAULT_HOST_MEM_SIZE = 8 * 1024 * 1024 * 1024L; // 8G, unit of
+ // Mbytes
+ public static final int DEFAULT_HOST_CPU_CORES = 4; // 2 dual core CPUs (2 x
+ // 2)
+ public static final int DEFAULT_HOST_SPEED_MHZ = 8000; // 1 GHz CPUs
+ boolean configure(String name, Map params) throws ConfigurationException;
+
+ Map> createServerResources(Map params);
+
+ boolean handleSystemVMStart(long vmId, String privateIpAddress, String privateMacAddress, String privateNetMask, long dcId, long podId, String name, String vmType, String url);
+
+ boolean handleSystemVMStop(long vmId);
+
+ GetHostStatsAnswer getHostStatistic(GetHostStatsCommand cmd);
+ Answer checkHealth(CheckHealthCommand cmd);
+ Answer pingTest(PingTestCommand cmd);
+
+ Answer PrepareForMigration(PrepareForMigrationCommand cmd);
+
+ MockHost getHost(String guid);
+
+ Answer MaintainCommand(MaintainCommand cmd);
+}
diff --git a/agent-simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java b/agent-simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
new file mode 100644
index 00000000000..5fcdff62648
--- /dev/null
+++ b/agent-simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
@@ -0,0 +1,353 @@
+package com.cloud.agent.manager;
+
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.regex.PatternSyntaxException;
+
+import javax.ejb.Local;
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CheckHealthCommand;
+import com.cloud.agent.api.GetHostStatsAnswer;
+import com.cloud.agent.api.GetHostStatsCommand;
+import com.cloud.agent.api.HostStatsEntry;
+import com.cloud.agent.api.PingTestCommand;
+import com.cloud.agent.api.PrepareForMigrationAnswer;
+import com.cloud.agent.api.PrepareForMigrationCommand;
+import com.cloud.agent.api.SecurityIngressRulesCmd;
+import com.cloud.agent.api.ShutdownCommand;
+import com.cloud.dc.dao.HostPodDao;
+import com.cloud.host.Host.Type;
+import com.cloud.resource.AgentResourceBase;
+import com.cloud.resource.AgentRoutingResource;
+import com.cloud.resource.AgentStorageResource;
+import com.cloud.simulator.MockHost;
+import com.cloud.simulator.MockHostVO;
+import com.cloud.simulator.MockVMVO;
+import com.cloud.simulator.dao.MockHostDao;
+import com.cloud.simulator.dao.MockVMDao;
+
+import com.cloud.utils.Pair;
+
+import com.cloud.utils.component.Inject;
+import com.cloud.utils.concurrency.NamedThreadFactory;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.net.NetUtils;
+
+@Local(value = { MockAgentManager.class })
+public class MockAgentManagerImpl implements MockAgentManager {
+ private static final Logger s_logger = Logger.getLogger(MockAgentManagerImpl.class);
+ @Inject HostPodDao _podDao = null;
+ @Inject MockHostDao _mockHostDao = null;
+ @Inject MockVMDao _mockVmDao = null;
+ @Inject SimulatorManager _simulatorMgr = null;
+ @Inject AgentManager _agentMgr = null;
+ @Inject MockStorageManager _storageMgr = null;
+ private SecureRandom random;
+ private Map _resources = new ConcurrentHashMap();
+ private ThreadPoolExecutor _executor;
+
+ private Pair getPodCidr(long podId, long dcId) {
+ try {
+
+ HashMap> podMap = _podDao
+ .getCurrentPodCidrSubnets(dcId, 0);
+ List