mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
move simulator/test to opensource
This commit is contained in:
parent
4b6d072490
commit
d36a988d84
28
agent-simulator/.classpath
Normal file
28
agent-simulator/.classpath
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="/deps/cloud-log4j.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/api"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/server"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/utils"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/agent"/>
|
||||
<classpathentry kind="lib" path="/deps/cloud-gson.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/core-premium"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/premium"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/agent-premium"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/console"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/console-proxy"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/console-viewer"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/deps"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/setup"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/test"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/thirdparty"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/tools"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/ui"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/usage"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/vmopsClient"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/vmware-base"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
17
agent-simulator/.project
Normal file
17
agent-simulator/.project
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>agent-simulator</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
73
agent-simulator/db/create-schema-simulator.sql
Normal file
73
agent-simulator/db/create-schema-simulator.sql
Normal file
@ -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;
|
||||
|
||||
13
agent-simulator/scripts/__old__/deletePod.sh
Executable file
13
agent-simulator/scripts/__old__/deletePod.sh
Executable file
@ -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
|
||||
|
||||
12
agent-simulator/scripts/__old__/deleteServiceOffering.sh
Executable file
12
agent-simulator/scripts/__old__/deleteServiceOffering.sh
Executable file
@ -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
|
||||
|
||||
13
agent-simulator/scripts/__old__/deleteVlan.sh
Executable file
13
agent-simulator/scripts/__old__/deleteVlan.sh
Executable file
@ -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
|
||||
|
||||
13
agent-simulator/scripts/__old__/deployVirtualMachine.sh
Executable file
13
agent-simulator/scripts/__old__/deployVirtualMachine.sh
Executable file
@ -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
|
||||
9
agent-simulator/scripts/__old__/listRouters.sh
Executable file
9
agent-simulator/scripts/__old__/listRouters.sh
Executable file
@ -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
|
||||
9
agent-simulator/scripts/__old__/listVirtualMachine.sh
Executable file
9
agent-simulator/scripts/__old__/listVirtualMachine.sh
Executable file
@ -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
|
||||
56
agent-simulator/scripts/__old__/queryAsyncJobResult.sh
Executable file
56
agent-simulator/scripts/__old__/queryAsyncJobResult.sh
Executable file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
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
|
||||
13
agent-simulator/scripts/__old__/run.sh
Normal file
13
agent-simulator/scripts/__old__/run.sh
Normal file
@ -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 $@
|
||||
|
||||
|
||||
18
agent-simulator/scripts/__old__/setupDirectPods.sh
Executable file
18
agent-simulator/scripts/__old__/setupDirectPods.sh
Executable file
@ -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
|
||||
25
agent-simulator/scripts/__old__/setupHosts.sh
Executable file
25
agent-simulator/scripts/__old__/setupHosts.sh
Executable file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
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
|
||||
41
agent-simulator/scripts/__old__/setupPodAndNetwork.sh
Executable file
41
agent-simulator/scripts/__old__/setupPodAndNetwork.sh
Executable file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
11
agent-simulator/scripts/__old__/setupServiceOffering.sh
Executable file
11
agent-simulator/scripts/__old__/setupServiceOffering.sh
Executable file
@ -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
|
||||
13
agent-simulator/scripts/__old__/setupVlan.sh
Executable file
13
agent-simulator/scripts/__old__/setupVlan.sh
Executable file
@ -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
|
||||
40
agent-simulator/scripts/__old__/simulator_advanced.sh
Executable file
40
agent-simulator/scripts/__old__/simulator_advanced.sh
Executable file
@ -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
|
||||
38
agent-simulator/scripts/__old__/simulator_basic.sh
Executable file
38
agent-simulator/scripts/__old__/simulator_basic.sh
Executable file
@ -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
|
||||
13
agent-simulator/scripts/__old__/startRouter.sh
Executable file
13
agent-simulator/scripts/__old__/startRouter.sh
Executable file
@ -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
|
||||
|
||||
9
agent-simulator/scripts/__old__/testQuery.sh
Executable file
9
agent-simulator/scripts/__old__/testQuery.sh
Executable file
@ -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
|
||||
|
||||
37
agent-simulator/scripts/addHostStats.py
Normal file
37
agent-simulator/scripts/addHostStats.py
Normal file
@ -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)
|
||||
|
||||
|
||||
|
||||
BIN
agent-simulator/scripts/addHosts.png
Normal file
BIN
agent-simulator/scripts/addHosts.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
24
agent-simulator/scripts/guava/__old__/1000routers.sh
Executable file
24
agent-simulator/scripts/guava/__old__/1000routers.sh
Executable file
@ -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
|
||||
11
agent-simulator/scripts/guava/__old__/createAdminAccount.sh
Executable file
11
agent-simulator/scripts/guava/__old__/createAdminAccount.sh
Executable file
@ -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
|
||||
7
agent-simulator/scripts/guava/__old__/createStoragePool.sh
Executable file
7
agent-simulator/scripts/guava/__old__/createStoragePool.sh
Executable file
@ -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
|
||||
11
agent-simulator/scripts/guava/__old__/createUserAccount.sh
Executable file
11
agent-simulator/scripts/guava/__old__/createUserAccount.sh
Executable file
@ -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
|
||||
12
agent-simulator/scripts/guava/__old__/deleteAccount.sh
Executable file
12
agent-simulator/scripts/guava/__old__/deleteAccount.sh
Executable file
@ -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
|
||||
|
||||
13
agent-simulator/scripts/guava/__old__/deletePod.sh
Executable file
13
agent-simulator/scripts/guava/__old__/deletePod.sh
Executable file
@ -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
|
||||
|
||||
12
agent-simulator/scripts/guava/__old__/deleteServiceOffering.sh
Executable file
12
agent-simulator/scripts/guava/__old__/deleteServiceOffering.sh
Executable file
@ -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
|
||||
|
||||
13
agent-simulator/scripts/guava/__old__/deleteVlan.sh
Executable file
13
agent-simulator/scripts/guava/__old__/deleteVlan.sh
Executable file
@ -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
|
||||
|
||||
14
agent-simulator/scripts/guava/__old__/deployVirtualMachine.sh
Executable file
14
agent-simulator/scripts/guava/__old__/deployVirtualMachine.sh
Executable file
@ -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
|
||||
12
agent-simulator/scripts/guava/__old__/destroyVirtualMachine.sh
Executable file
12
agent-simulator/scripts/guava/__old__/destroyVirtualMachine.sh
Executable file
@ -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
|
||||
|
||||
9
agent-simulator/scripts/guava/__old__/listCapacity.sh
Executable file
9
agent-simulator/scripts/guava/__old__/listCapacity.sh
Executable file
@ -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
|
||||
9
agent-simulator/scripts/guava/__old__/listEvents.sh
Executable file
9
agent-simulator/scripts/guava/__old__/listEvents.sh
Executable file
@ -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
|
||||
|
||||
9
agent-simulator/scripts/guava/__old__/listHosts.sh
Executable file
9
agent-simulator/scripts/guava/__old__/listHosts.sh
Executable file
@ -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
|
||||
9
agent-simulator/scripts/guava/__old__/listRouters.sh
Executable file
9
agent-simulator/scripts/guava/__old__/listRouters.sh
Executable file
@ -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
|
||||
9
agent-simulator/scripts/guava/__old__/listTemplates.sh
Executable file
9
agent-simulator/scripts/guava/__old__/listTemplates.sh
Executable file
@ -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
|
||||
9
agent-simulator/scripts/guava/__old__/listVirtualMachine.sh
Executable file
9
agent-simulator/scripts/guava/__old__/listVirtualMachine.sh
Executable file
@ -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
|
||||
15
agent-simulator/scripts/guava/__old__/load.sh
Executable file
15
agent-simulator/scripts/guava/__old__/load.sh
Executable file
@ -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
|
||||
8
agent-simulator/scripts/guava/__old__/networkShutDown.sh
Executable file
8
agent-simulator/scripts/guava/__old__/networkShutDown.sh
Executable file
@ -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
|
||||
8
agent-simulator/scripts/guava/__old__/networkStart.sh
Executable file
8
agent-simulator/scripts/guava/__old__/networkStart.sh
Executable file
@ -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
|
||||
16
agent-simulator/scripts/guava/__old__/reconnectStats.sh
Executable file
16
agent-simulator/scripts/guava/__old__/reconnectStats.sh
Executable file
@ -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
|
||||
34
agent-simulator/scripts/guava/__old__/setup.sh
Executable file
34
agent-simulator/scripts/guava/__old__/setup.sh
Executable file
@ -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
|
||||
18
agent-simulator/scripts/guava/__old__/setupDirectPods.sh
Executable file
18
agent-simulator/scripts/guava/__old__/setupDirectPods.sh
Executable file
@ -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
|
||||
10
agent-simulator/scripts/guava/__old__/setupHosts.sh
Executable file
10
agent-simulator/scripts/guava/__old__/setupHosts.sh
Executable file
@ -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
|
||||
26
agent-simulator/scripts/guava/__old__/setupPodAndNetwork.sh
Executable file
26
agent-simulator/scripts/guava/__old__/setupPodAndNetwork.sh
Executable file
@ -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
|
||||
|
||||
|
||||
|
||||
11
agent-simulator/scripts/guava/__old__/setupServiceOffering.sh
Executable file
11
agent-simulator/scripts/guava/__old__/setupServiceOffering.sh
Executable file
@ -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
|
||||
13
agent-simulator/scripts/guava/__old__/setupVlan.sh
Executable file
13
agent-simulator/scripts/guava/__old__/setupVlan.sh
Executable file
@ -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
|
||||
13
agent-simulator/scripts/guava/__old__/startRouter.sh
Executable file
13
agent-simulator/scripts/guava/__old__/startRouter.sh
Executable file
@ -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
|
||||
|
||||
13
agent-simulator/scripts/guava/__old__/startVirtualMachine.sh
Executable file
13
agent-simulator/scripts/guava/__old__/startVirtualMachine.sh
Executable file
@ -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
|
||||
|
||||
13
agent-simulator/scripts/guava/__old__/stopVirtualMachine.sh
Executable file
13
agent-simulator/scripts/guava/__old__/stopVirtualMachine.sh
Executable file
@ -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
|
||||
|
||||
39
agent-simulator/scripts/guava/__old__/stress.sh
Executable file
39
agent-simulator/scripts/guava/__old__/stress.sh
Executable file
@ -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
|
||||
120
agent-simulator/scripts/guava/__old__/stress2.sh
Executable file
120
agent-simulator/scripts/guava/__old__/stress2.sh
Executable file
@ -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/\(.*<id>\)\([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
|
||||
2
agent-simulator/scripts/run.bat
Normal file
2
agent-simulator/scripts/run.bat
Normal file
@ -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 %*
|
||||
|
||||
13
agent-simulator/scripts/zucchini/__old__/deletePod.sh
Executable file
13
agent-simulator/scripts/zucchini/__old__/deletePod.sh
Executable file
@ -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
|
||||
|
||||
12
agent-simulator/scripts/zucchini/__old__/deleteServiceOffering.sh
Executable file
12
agent-simulator/scripts/zucchini/__old__/deleteServiceOffering.sh
Executable file
@ -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
|
||||
|
||||
13
agent-simulator/scripts/zucchini/__old__/deleteVlan.sh
Executable file
13
agent-simulator/scripts/zucchini/__old__/deleteVlan.sh
Executable file
@ -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
|
||||
|
||||
194
agent-simulator/scripts/zucchini/__old__/deployBulk-sg.sh
Executable file
194
agent-simulator/scripts/zucchini/__old__/deployBulk-sg.sh
Executable file
@ -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/\(.*<count>\)\([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/\(.*<jobid>\)\([0-9]*\)\(.*\)/\2/g')
|
||||
vmid=$(echo $job_out | sed 's/\(.*<id>\)\([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/\(.*<jobid>\)\([0-9]*\)\(.*\)/\2/g')
|
||||
vmid=$(echo $job_out | sed 's/\(.*<id>\)\([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/\(.*<jobid>\)\([0-9]*\)\(.*\)/\2/g')
|
||||
vmid=$(echo $job_out | sed 's/\(.*<id>\)\([0-9]*\)\(.*\)/\2/g')
|
||||
echo "[DEBUG] $(date) deployed vm: " $vmid " in job: " $job_id
|
||||
|
||||
vmcount=$((vmcount+1))
|
||||
done
|
||||
147
agent-simulator/scripts/zucchini/__old__/deployBulk.sh
Executable file
147
agent-simulator/scripts/zucchini/__old__/deployBulk.sh
Executable file
@ -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/\(.*<jobid>\)\([0-9]*\)\(.*\)/\2/g')
|
||||
vmid=$(echo $job_out | sed 's/\(.*<id>\)\([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/\(.*<jobid>\)\([0-9]*\)\(.*\)/\2/g')
|
||||
vmid=$(echo $job_out | sed 's/\(.*<id>\)\([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/\(.*<jobid>\)\([0-9]*\)\(.*\)/\2/g')
|
||||
vmid=$(echo $job_out | sed 's/\(.*<id>\)\([0-9]*\)\(.*\)/\2/g')
|
||||
echo "[DEBUG] $(date) deployed vm: " $vmid " in job: " $job_id
|
||||
vmcount=$((vmcount+1))
|
||||
done
|
||||
13
agent-simulator/scripts/zucchini/__old__/deployVirtualMachine.sh
Executable file
13
agent-simulator/scripts/zucchini/__old__/deployVirtualMachine.sh
Executable file
@ -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
|
||||
40
agent-simulator/scripts/zucchini/__old__/destroySystemVm.sh
Executable file
40
agent-simulator/scripts/zucchini/__old__/destroySystemVm.sh
Executable file
@ -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
|
||||
|
||||
12
agent-simulator/scripts/zucchini/__old__/destroyVirtualMachine.sh
Executable file
12
agent-simulator/scripts/zucchini/__old__/destroyVirtualMachine.sh
Executable file
@ -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
|
||||
|
||||
9
agent-simulator/scripts/zucchini/__old__/listCapacity.sh
Executable file
9
agent-simulator/scripts/zucchini/__old__/listCapacity.sh
Executable file
@ -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
|
||||
9
agent-simulator/scripts/zucchini/__old__/listEvents.sh
Executable file
9
agent-simulator/scripts/zucchini/__old__/listEvents.sh
Executable file
@ -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
|
||||
|
||||
9
agent-simulator/scripts/zucchini/__old__/listHosts.sh
Executable file
9
agent-simulator/scripts/zucchini/__old__/listHosts.sh
Executable file
@ -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
|
||||
9
agent-simulator/scripts/zucchini/__old__/listRouters.sh
Executable file
9
agent-simulator/scripts/zucchini/__old__/listRouters.sh
Executable file
@ -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
|
||||
9
agent-simulator/scripts/zucchini/__old__/listTemplates.sh
Executable file
9
agent-simulator/scripts/zucchini/__old__/listTemplates.sh
Executable file
@ -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
|
||||
9
agent-simulator/scripts/zucchini/__old__/listVirtualMachine.sh
Executable file
9
agent-simulator/scripts/zucchini/__old__/listVirtualMachine.sh
Executable file
@ -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
|
||||
21
agent-simulator/scripts/zucchini/__old__/monitor.sh
Executable file
21
agent-simulator/scripts/zucchini/__old__/monitor.sh
Executable file
@ -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
|
||||
224
agent-simulator/scripts/zucchini/__old__/newsetup.sh
Executable file
224
agent-simulator/scripts/zucchini/__old__/newsetup.sh
Executable file
@ -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/\(.*<id>\)\([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/\(.*<id>\)\([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/\(.*<id>\)\([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/\(.*<id>\)\([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/\(.*<name>\)\(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/\(.*<id>\)\([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/\(.*<name>\)\(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/\(.*<id>\)\([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/\(.*<name>\)\(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
|
||||
16
agent-simulator/scripts/zucchini/__old__/reconnectStats.sh
Executable file
16
agent-simulator/scripts/zucchini/__old__/reconnectStats.sh
Executable file
@ -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
|
||||
81
agent-simulator/scripts/zucchini/__old__/setup.sh
Executable file
81
agent-simulator/scripts/zucchini/__old__/setup.sh
Executable file
@ -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
|
||||
18
agent-simulator/scripts/zucchini/__old__/setupDirectPods.sh
Executable file
18
agent-simulator/scripts/zucchini/__old__/setupDirectPods.sh
Executable file
@ -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
|
||||
10
agent-simulator/scripts/zucchini/__old__/setupHosts.sh
Executable file
10
agent-simulator/scripts/zucchini/__old__/setupHosts.sh
Executable file
@ -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
|
||||
26
agent-simulator/scripts/zucchini/__old__/setupPodAndNetwork.sh
Executable file
26
agent-simulator/scripts/zucchini/__old__/setupPodAndNetwork.sh
Executable file
@ -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
|
||||
|
||||
|
||||
|
||||
11
agent-simulator/scripts/zucchini/__old__/setupServiceOffering.sh
Executable file
11
agent-simulator/scripts/zucchini/__old__/setupServiceOffering.sh
Executable file
@ -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
|
||||
13
agent-simulator/scripts/zucchini/__old__/setupVlan.sh
Executable file
13
agent-simulator/scripts/zucchini/__old__/setupVlan.sh
Executable file
@ -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
|
||||
248
agent-simulator/scripts/zucchini/__old__/setup_sg.sh
Executable file
248
agent-simulator/scripts/zucchini/__old__/setup_sg.sh
Executable file
@ -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/\(.*<id>\)\([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/\(.*<id>\)\([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/\(.*<id>\)\([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/\(.*<id>\)\([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/\(.*<id>\)\([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/\(.*<name>\)\(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/\(.*<id>\)\([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/\(.*<name>\)\(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/\(.*<id>\)\([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/\(.*<name>\)\(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
|
||||
151
agent-simulator/scripts/zucchini/__old__/small.sh
Executable file
151
agent-simulator/scripts/zucchini/__old__/small.sh
Executable file
@ -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
|
||||
7
agent-simulator/scripts/zucchini/__old__/so_setup.sh
Executable file
7
agent-simulator/scripts/zucchini/__old__/so_setup.sh
Executable file
@ -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
|
||||
13
agent-simulator/scripts/zucchini/__old__/startRouter.sh
Executable file
13
agent-simulator/scripts/zucchini/__old__/startRouter.sh
Executable file
@ -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
|
||||
|
||||
13
agent-simulator/scripts/zucchini/__old__/startVirtualMachine.sh
Executable file
13
agent-simulator/scripts/zucchini/__old__/startVirtualMachine.sh
Executable file
@ -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
|
||||
|
||||
37
agent-simulator/scripts/zucchini/__old__/stopRouter.sh
Executable file
37
agent-simulator/scripts/zucchini/__old__/stopRouter.sh
Executable file
@ -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
|
||||
37
agent-simulator/scripts/zucchini/__old__/stopVirtualMachine.sh
Executable file
37
agent-simulator/scripts/zucchini/__old__/stopVirtualMachine.sh
Executable file
@ -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
|
||||
110
agent-simulator/scripts/zucchini/__old__/zucchini219.sh
Executable file
110
agent-simulator/scripts/zucchini/__old__/zucchini219.sh
Executable file
@ -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
|
||||
208
agent-simulator/scripts/zucchini/setup.py
Normal file
208
agent-simulator/scripts/zucchini/setup.py
Normal file
@ -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)
|
||||
101
agent-simulator/scripts/zucchini/tests/testProvision.py
Normal file
101
agent-simulator/scripts/zucchini/tests/testProvision.py
Normal file
@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
29
agent-simulator/scripts/zucchini/zucchini.configuration.sql
Normal file
29
agent-simulator/scripts/zucchini/zucchini.configuration.sql
Normal file
@ -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';
|
||||
110
agent-simulator/src/com/cloud/agent/MetricsCollector.java
Normal file
110
agent-simulator/src/com/cloud/agent/MetricsCollector.java
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
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<String> vmNames = new HashSet<String>();
|
||||
private final Set<String> newVMnames = new HashSet<String>();
|
||||
private final Map<String, MockVmMetrics> metricsMap = new HashMap<String, MockVmMetrics>();
|
||||
|
||||
private final transient ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Metrics"));
|
||||
|
||||
private Set<String> _currentVms;
|
||||
|
||||
public MetricsCollector(Set<String> currentVms) {
|
||||
_currentVms = currentVms;
|
||||
getAllVMNames();
|
||||
}
|
||||
|
||||
public MetricsCollector() {
|
||||
|
||||
}
|
||||
|
||||
public synchronized void getAllVMNames() {
|
||||
Set<String> 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<String> getVMNames() {
|
||||
return vmNames;
|
||||
}
|
||||
|
||||
public synchronized Map<String, MockVmMetrics> getMetricsMap() {
|
||||
return metricsMap;
|
||||
}
|
||||
}
|
||||
210
agent-simulator/src/com/cloud/agent/MockVmMetrics.java
Normal file
210
agent-simulator/src/com/cloud/agent/MockVmMetrics.java
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
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<String, Double> netTxKBps = new HashMap<String, Double>();
|
||||
|
||||
//the last calculated traffic speed (receive) per interface
|
||||
private Map<String, Double> netRxKBps = new HashMap<String, Double>();
|
||||
|
||||
//the last calculated disk write speed per disk (Bytes Per Second)
|
||||
private Map<String, Double> diskWriteKBytesPerSec = new HashMap<String, Double>();
|
||||
|
||||
//the last calculated disk read speed per disk (Bytes Per Second)
|
||||
private Map<String, Double> diskReadKBytesPerSec = new HashMap<String, Double>();
|
||||
|
||||
//Total Bytes Transmitted on network interfaces
|
||||
private Map<String, Long> netTxTotalBytes = new HashMap<String, Long>();
|
||||
|
||||
//Total Bytes Received on network interfaces
|
||||
private Map<String, Long> netRxTotalBytes = new HashMap<String, Long>();
|
||||
|
||||
//Total Bytes read per disk
|
||||
private Map<String, Long> diskReadTotalBytes = new HashMap<String, Long>();
|
||||
|
||||
//Total Bytes written per disk
|
||||
private Map<String, Long> diskWriteTotalBytes = new HashMap<String, Long>();
|
||||
|
||||
//CPU time in seconds
|
||||
private Double cpuSeconds = new Double(0.0);
|
||||
|
||||
//CPU percentage
|
||||
private Float cpuPercent = new Float(0.0);
|
||||
|
||||
private Map<String, String> diskMap = new HashMap<String, String>();
|
||||
|
||||
private Map<String, String> vifMap = new HashMap<String, String>();
|
||||
|
||||
private Map<String, Long> diskStatTimestamp = new HashMap<String, Long>();
|
||||
private Map<String, Long> netStatTimestamp = new HashMap<String, Long>();
|
||||
|
||||
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<String, Long> entry : netRxTotalBytes.entrySet()) {
|
||||
entry.setValue(entry.getValue() + getIncrementor());
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Long> entry : netTxTotalBytes.entrySet()) {
|
||||
entry.setValue(entry.getValue() + getIncrementor());
|
||||
}
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
public Map<String, Double> getNetTxKBps() {
|
||||
return netTxKBps;
|
||||
}
|
||||
|
||||
public Map<String, Double> getNetRxKBps() {
|
||||
return netRxKBps;
|
||||
}
|
||||
|
||||
public Map<String, Double> getDiskWriteBytesPerSec() {
|
||||
return diskWriteKBytesPerSec;
|
||||
}
|
||||
|
||||
public Map<String, Double> getDiskReadBytesPerSec() {
|
||||
return diskReadKBytesPerSec;
|
||||
}
|
||||
|
||||
public Map<String, Long> getNetTxTotalBytes() {
|
||||
return netTxTotalBytes;
|
||||
}
|
||||
|
||||
public Map<String, Long> getNetRxTotalBytes() {
|
||||
return netRxTotalBytes;
|
||||
}
|
||||
|
||||
public Map<String, Long> getDiskReadTotalBytes() {
|
||||
return diskReadTotalBytes;
|
||||
}
|
||||
|
||||
public Map<String, Long> 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<String, String> 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;
|
||||
}
|
||||
}
|
||||
|
||||
149
agent-simulator/src/com/cloud/agent/MultiCaster.java
Normal file
149
agent-simulator/src/com/cloud/agent/MultiCaster.java
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
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<MultiCasterListener> listeners;
|
||||
private DatagramSocket socket;
|
||||
private byte[] recvBuffer;
|
||||
|
||||
private Thread driver;
|
||||
private volatile boolean stopRequested = false;
|
||||
|
||||
public MultiCaster() {
|
||||
listeners = new ArrayList<MultiCasterListener>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
agent-simulator/src/com/cloud/agent/MultiCasterListener.java
Normal file
25
agent-simulator/src/com/cloud/agent/MultiCasterListener.java
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.agent;
|
||||
import java.net.*;
|
||||
|
||||
public interface MultiCasterListener {
|
||||
public void onMultiCasting(byte[] data, int off, int len, InetAddress addrFrom);
|
||||
}
|
||||
40
agent-simulator/src/com/cloud/agent/SimulatorCmd.java
Normal file
40
agent-simulator/src/com/cloud/agent/SimulatorCmd.java
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -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<String, Object> params) throws ConfigurationException;
|
||||
|
||||
Map<AgentResourceBase, Map<String, String>> createServerResources(Map<String, Object> 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);
|
||||
}
|
||||
@ -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<String, AgentResourceBase> _resources = new ConcurrentHashMap<String, AgentResourceBase>();
|
||||
private ThreadPoolExecutor _executor;
|
||||
|
||||
private Pair<String, Long> getPodCidr(long podId, long dcId) {
|
||||
try {
|
||||
|
||||
HashMap<Long, List<Object>> podMap = _podDao
|
||||
.getCurrentPodCidrSubnets(dcId, 0);
|
||||
List<Object> cidrPair = podMap.get(podId);
|
||||
String cidrAddress = (String) cidrPair.get(0);
|
||||
Long cidrSize = (Long)cidrPair.get(1);
|
||||
return new Pair<String, Long>(cidrAddress, cidrSize);
|
||||
} catch (PatternSyntaxException e) {
|
||||
s_logger.error("Exception while splitting pod cidr");
|
||||
return null;
|
||||
} catch(IndexOutOfBoundsException e) {
|
||||
s_logger.error("Invalid pod cidr. Please check");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getIpAddress(long instanceId, long dcId, long podId) {
|
||||
Pair<String, Long> cidr = this.getPodCidr(podId, dcId);
|
||||
return NetUtils.long2Ip(NetUtils.ip2Long(cidr.first()) + instanceId);
|
||||
}
|
||||
|
||||
private String getMacAddress(long dcId, long podId, long clusterId, int instanceId) {
|
||||
return NetUtils.long2Mac((dcId << 40 + podId << 32 + clusterId << 24 + instanceId));
|
||||
}
|
||||
public synchronized int getNextAgentId(long cidrSize) {
|
||||
return random.nextInt((int)cidrSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public Map<AgentResourceBase, Map<String, String>> createServerResources(
|
||||
Map<String, Object> params) {
|
||||
|
||||
Map<String, String> args = new HashMap<String, String>();
|
||||
Map<AgentResourceBase, Map<String,String>> newResources = new HashMap<AgentResourceBase, Map<String,String>>();
|
||||
AgentResourceBase agentResource;
|
||||
long cpuCore = Long.parseLong((String)params.get("cpucore"));
|
||||
long cpuSpeed = Long.parseLong((String)params.get("cpuspeed"));
|
||||
long memory = Long.parseLong((String)params.get("memory"));
|
||||
long localStorageSize = Long.parseLong((String)params.get("localstorage"));
|
||||
synchronized (this) {
|
||||
long dataCenterId = Long.parseLong((String)params.get("zone"));
|
||||
long podId = Long.parseLong((String)params.get("pod"));
|
||||
long clusterId = Long.parseLong((String)params.get("cluster"));
|
||||
long cidrSize = getPodCidr(podId, dataCenterId).second();
|
||||
|
||||
int agentId = getNextAgentId(cidrSize);
|
||||
String ipAddress = getIpAddress(agentId, dataCenterId, podId);
|
||||
String macAddress = getMacAddress(dataCenterId, podId, clusterId, agentId);
|
||||
MockHostVO mockHost = new MockHostVO();
|
||||
mockHost.setDataCenterId(dataCenterId);
|
||||
mockHost.setPodId(podId);
|
||||
mockHost.setClusterId(clusterId);
|
||||
mockHost.setCapabilities("hvm");
|
||||
mockHost.setCpuCount(cpuCore);
|
||||
mockHost.setCpuSpeed(cpuSpeed);
|
||||
mockHost.setMemorySize(memory);
|
||||
String guid = UUID.randomUUID().toString();
|
||||
mockHost.setGuid(guid);
|
||||
mockHost.setName("SimulatedAgent." + guid);
|
||||
mockHost.setPrivateIpAddress(ipAddress);
|
||||
mockHost.setPublicIpAddress(ipAddress);
|
||||
mockHost.setStorageIpAddress(ipAddress);
|
||||
mockHost.setPrivateMacAddress(macAddress);
|
||||
mockHost.setPublicMacAddress(macAddress);
|
||||
mockHost.setStorageMacAddress(macAddress);
|
||||
mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
|
||||
mockHost.setResource("com.cloud.agent.AgentRoutingResource");
|
||||
mockHost = _mockHostDao.persist(mockHost);
|
||||
|
||||
_storageMgr.getLocalStorage(guid, localStorageSize);
|
||||
|
||||
agentResource = new AgentRoutingResource();
|
||||
if (agentResource != null) {
|
||||
try {
|
||||
params.put("guid", mockHost.getGuid());
|
||||
agentResource.start();
|
||||
agentResource.configure(mockHost.getName(),
|
||||
params);
|
||||
|
||||
newResources.put(agentResource, args);
|
||||
} catch (ConfigurationException e) {
|
||||
s_logger
|
||||
.error("error while configuring server resource"
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
return newResources;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
try {
|
||||
random = SecureRandom.getInstance("SHA1PRNG");
|
||||
_executor = new ThreadPoolExecutor(1, 5, 1, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory("Simulator-Agent-Mgr"));
|
||||
//ComponentLocator locator = ComponentLocator.getCurrentLocator();
|
||||
//_simulatorMgr = (SimulatorManager) locator.getComponent(SimulatorManager.Name);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
s_logger.debug("Failed to initialize random:" + e.toString());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleSystemVMStart(long vmId, String privateIpAddress, String privateMacAddress, String privateNetMask, long dcId, long podId, String name, String vmType, String url) {
|
||||
_executor.execute(new SystemVMHandler(vmId, privateIpAddress, privateMacAddress, privateNetMask, dcId, podId, name, vmType, _simulatorMgr, url));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleSystemVMStop(long vmId) {
|
||||
_executor.execute(new SystemVMHandler(vmId));
|
||||
return true;
|
||||
}
|
||||
|
||||
private class SystemVMHandler implements Runnable {
|
||||
private long vmId;
|
||||
private String privateIpAddress;
|
||||
private String privateMacAddress;
|
||||
private String privateNetMask;
|
||||
private long dcId;
|
||||
private long podId;
|
||||
private String guid;
|
||||
private String name;
|
||||
private String vmType;
|
||||
private SimulatorManager mgr;
|
||||
private String mode;
|
||||
private String url;
|
||||
public SystemVMHandler(long vmId, String privateIpAddress, String privateMacAddress, String privateNetMask, long dcId, long podId, String name, String vmType,
|
||||
SimulatorManager mgr, String url) {
|
||||
this.vmId = vmId;
|
||||
this.privateIpAddress = privateIpAddress;
|
||||
this.privateMacAddress = privateMacAddress;
|
||||
this.privateNetMask = privateNetMask;
|
||||
this.dcId = dcId;
|
||||
this.guid = "SystemVM-" + UUID.randomUUID().toString();
|
||||
this.name = name;
|
||||
this.vmType = vmType;
|
||||
this.mgr = mgr;
|
||||
this.mode = "Start";
|
||||
this.url = url;
|
||||
this.podId = podId;
|
||||
}
|
||||
|
||||
public SystemVMHandler(long vmId) {
|
||||
this.vmId = vmId;
|
||||
this.mode = "Stop";
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public void run() {
|
||||
if (this.mode.equalsIgnoreCase("Stop")) {
|
||||
MockHost host = _mockHostDao.findByVmId(this.vmId);
|
||||
if (host != null) {
|
||||
String guid = host.getGuid();
|
||||
if (guid != null) {
|
||||
AgentResourceBase res = _resources.get(guid);
|
||||
if (res != null) {
|
||||
res.stop();
|
||||
_resources.remove(guid);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
String resource = null;
|
||||
if (vmType.equalsIgnoreCase("secstorage")) {
|
||||
resource = "com.cloud.agent.AgentStorageResource";
|
||||
}
|
||||
MockHostVO mockHost = new MockHostVO();
|
||||
mockHost.setDataCenterId(this.dcId);
|
||||
mockHost.setPodId(this.podId);
|
||||
mockHost.setCpuCount(DEFAULT_HOST_CPU_CORES);
|
||||
mockHost.setCpuSpeed(DEFAULT_HOST_SPEED_MHZ);
|
||||
mockHost.setMemorySize(DEFAULT_HOST_MEM_SIZE);
|
||||
mockHost.setGuid(this.guid);
|
||||
mockHost.setName(name);
|
||||
mockHost.setPrivateIpAddress(this.privateIpAddress);
|
||||
mockHost.setPublicIpAddress(this.privateIpAddress);
|
||||
mockHost.setStorageIpAddress(this.privateIpAddress);
|
||||
mockHost.setPrivateMacAddress(this.privateMacAddress);
|
||||
mockHost.setPublicMacAddress(this.privateMacAddress);
|
||||
mockHost.setStorageMacAddress(this.privateMacAddress);
|
||||
mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
|
||||
mockHost.setResource(resource);
|
||||
mockHost.setVmId(vmId);
|
||||
mockHost = _mockHostDao.persist(mockHost);
|
||||
|
||||
if (vmType.equalsIgnoreCase("secstorage")) {
|
||||
AgentStorageResource storageResource = new AgentStorageResource();
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("guid", this.guid);
|
||||
storageResource.configure("secondaryStorage", params);
|
||||
storageResource.start();
|
||||
} catch (ConfigurationException e) {
|
||||
s_logger.debug("Failed to load secondary storage resource: " + e.toString());
|
||||
return;
|
||||
}
|
||||
Map<String, String> details = new HashMap<String, String>();
|
||||
|
||||
_agentMgr.addHost(this.dcId, storageResource, Type.SecondaryStorageVM, details);
|
||||
_resources.put(this.guid, storageResource);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public MockHost getHost(String guid) {
|
||||
return _mockHostDao.findByGuid(guid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetHostStatsAnswer getHostStatistic(GetHostStatsCommand cmd) {
|
||||
String hostGuid = cmd.getHostGuid();
|
||||
MockHost host = _mockHostDao.findByGuid(hostGuid);
|
||||
if (host == null) {
|
||||
return null;
|
||||
}
|
||||
List<MockVMVO> vms = _mockVmDao.findByHostId(host.getId());
|
||||
double usedMem = 0.0;
|
||||
double usedCpu = 0.0;
|
||||
for (MockVMVO vm : vms) {
|
||||
usedMem += vm.getMemory();
|
||||
usedCpu += vm.getCpu();
|
||||
}
|
||||
|
||||
HostStatsEntry hostStats = new HostStatsEntry();
|
||||
hostStats.setTotalMemoryKBs(host.getMemorySize());
|
||||
hostStats.setFreeMemoryKBs(host.getMemorySize() - usedMem);
|
||||
hostStats.setNetworkReadKBs(32768);
|
||||
hostStats.setNetworkWriteKBs(16384);
|
||||
hostStats.setCpuUtilization(usedCpu/(host.getCpuCount() * host.getCpuSpeed()));
|
||||
hostStats.setEntityType("simulator-host");
|
||||
hostStats.setHostId(cmd.getHostId());
|
||||
return new GetHostStatsAnswer(cmd, hostStats);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Answer checkHealth(CheckHealthCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Answer pingTest(PingTestCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PrepareForMigrationAnswer PrepareForMigration(PrepareForMigrationCommand cmd) {
|
||||
return new PrepareForMigrationAnswer(cmd);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Answer MaintainCommand(com.cloud.agent.api.MaintainCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
package com.cloud.agent.manager;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.AttachIsoCommand;
|
||||
import com.cloud.agent.api.AttachVolumeAnswer;
|
||||
import com.cloud.agent.api.AttachVolumeCommand;
|
||||
import com.cloud.agent.api.BackupSnapshotAnswer;
|
||||
import com.cloud.agent.api.BackupSnapshotCommand;
|
||||
import com.cloud.agent.api.ComputeChecksumCommand;
|
||||
import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
|
||||
import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
|
||||
import com.cloud.agent.api.CreateStoragePoolCommand;
|
||||
import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer;
|
||||
import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
|
||||
import com.cloud.agent.api.DeleteSnapshotBackupAnswer;
|
||||
import com.cloud.agent.api.DeleteSnapshotBackupCommand;
|
||||
import com.cloud.agent.api.DeleteStoragePoolCommand;
|
||||
import com.cloud.agent.api.GetStorageStatsAnswer;
|
||||
import com.cloud.agent.api.GetStorageStatsCommand;
|
||||
import com.cloud.agent.api.ManageSnapshotAnswer;
|
||||
import com.cloud.agent.api.ManageSnapshotCommand;
|
||||
import com.cloud.agent.api.ModifyStoragePoolCommand;
|
||||
import com.cloud.agent.api.SecStorageSetupCommand;
|
||||
import com.cloud.agent.api.SecStorageVMSetupCommand;
|
||||
import com.cloud.agent.api.StoragePoolInfo;
|
||||
import com.cloud.agent.api.storage.CreateAnswer;
|
||||
import com.cloud.agent.api.storage.CreateCommand;
|
||||
import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
|
||||
import com.cloud.agent.api.storage.CreatePrivateTemplateCommand;
|
||||
import com.cloud.agent.api.storage.DeleteTemplateCommand;
|
||||
import com.cloud.agent.api.storage.DestroyCommand;
|
||||
import com.cloud.agent.api.storage.DownloadCommand;
|
||||
import com.cloud.agent.api.storage.DownloadProgressCommand;
|
||||
import com.cloud.agent.api.storage.ListTemplateCommand;
|
||||
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
|
||||
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
||||
public interface MockStorageManager extends Manager {
|
||||
public static final long DEFAULT_HOST_STORAGE_SIZE = 1 * 1024 * 1024 * 1024 * 1024L; //1T
|
||||
public static final long DEFAULT_TEMPLATE_SIZE = 1 * 1000 * 1000 * 1000L; //1G
|
||||
|
||||
public PrimaryStorageDownloadAnswer primaryStorageDownload(PrimaryStorageDownloadCommand cmd);
|
||||
|
||||
public CreateAnswer createVolume(CreateCommand cmd);
|
||||
public AttachVolumeAnswer AttachVolume(AttachVolumeCommand cmd);
|
||||
public Answer AttachIso(AttachIsoCommand cmd);
|
||||
|
||||
public Answer DeleteStoragePool(DeleteStoragePoolCommand cmd);
|
||||
public Answer ModifyStoragePool(ModifyStoragePoolCommand cmd);
|
||||
public Answer CreateStoragePool(CreateStoragePoolCommand cmd);
|
||||
|
||||
public Answer SecStorageSetup(SecStorageSetupCommand cmd);
|
||||
public Answer ListTemplates(ListTemplateCommand cmd);
|
||||
public Answer Destroy(DestroyCommand cmd);
|
||||
public Answer Download(DownloadCommand cmd);
|
||||
public Answer DownloadProcess(DownloadProgressCommand cmd);
|
||||
public GetStorageStatsAnswer GetStorageStats(GetStorageStatsCommand cmd);
|
||||
public Answer ManageSnapshot(ManageSnapshotCommand cmd);
|
||||
public Answer BackupSnapshot(BackupSnapshotCommand cmd);
|
||||
public Answer DeleteSnapshotBackup(DeleteSnapshotBackupCommand cmd);
|
||||
public Answer CreateVolumeFromSnapshot(CreateVolumeFromSnapshotCommand cmd);
|
||||
public Answer DeleteTemplate(DeleteTemplateCommand cmd);
|
||||
public Answer SecStorageVMSetup(SecStorageVMSetupCommand cmd);
|
||||
|
||||
public void preinstallTemplates(String url, long zoneId);
|
||||
|
||||
StoragePoolInfo getLocalStorage(String hostGuid);
|
||||
|
||||
public Answer CreatePrivateTemplateFromSnapshot(CreatePrivateTemplateFromSnapshotCommand cmd);
|
||||
|
||||
public Answer ComputeChecksum(ComputeChecksumCommand cmd);
|
||||
|
||||
public Answer CreatePrivateTemplateFromVolume(CreatePrivateTemplateFromVolumeCommand cmd);
|
||||
|
||||
StoragePoolInfo getLocalStorage(String hostGuid, Long storageSize);
|
||||
}
|
||||
@ -0,0 +1,658 @@
|
||||
/**
|
||||
* Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
package com.cloud.agent.manager;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.AttachIsoCommand;
|
||||
import com.cloud.agent.api.AttachVolumeAnswer;
|
||||
import com.cloud.agent.api.AttachVolumeCommand;
|
||||
import com.cloud.agent.api.BackupSnapshotAnswer;
|
||||
import com.cloud.agent.api.BackupSnapshotCommand;
|
||||
import com.cloud.agent.api.ComputeChecksumCommand;
|
||||
import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
|
||||
import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
|
||||
import com.cloud.agent.api.CreateStoragePoolCommand;
|
||||
import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer;
|
||||
import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
|
||||
import com.cloud.agent.api.DeleteSnapshotBackupCommand;
|
||||
import com.cloud.agent.api.DeleteStoragePoolCommand;
|
||||
import com.cloud.agent.api.GetStorageStatsAnswer;
|
||||
import com.cloud.agent.api.GetStorageStatsCommand;
|
||||
import com.cloud.agent.api.ManageSnapshotAnswer;
|
||||
import com.cloud.agent.api.ManageSnapshotCommand;
|
||||
import com.cloud.agent.api.ModifyStoragePoolAnswer;
|
||||
import com.cloud.agent.api.ModifyStoragePoolCommand;
|
||||
import com.cloud.agent.api.SecStorageSetupAnswer;
|
||||
import com.cloud.agent.api.SecStorageSetupCommand;
|
||||
import com.cloud.agent.api.SecStorageVMSetupCommand;
|
||||
import com.cloud.agent.api.StoragePoolInfo;
|
||||
import com.cloud.agent.api.storage.CreateAnswer;
|
||||
import com.cloud.agent.api.storage.CreateCommand;
|
||||
import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
|
||||
import com.cloud.agent.api.storage.DeleteTemplateCommand;
|
||||
import com.cloud.agent.api.storage.DestroyCommand;
|
||||
import com.cloud.agent.api.storage.DownloadAnswer;
|
||||
import com.cloud.agent.api.storage.DownloadCommand;
|
||||
import com.cloud.agent.api.storage.DownloadProgressCommand;
|
||||
import com.cloud.agent.api.storage.ListTemplateAnswer;
|
||||
import com.cloud.agent.api.storage.ListTemplateCommand;
|
||||
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
|
||||
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
|
||||
import com.cloud.agent.api.to.StorageFilerTO;
|
||||
import com.cloud.agent.api.to.VolumeTO;
|
||||
import com.cloud.simulator.MockHost;
|
||||
import com.cloud.simulator.MockSecStorageVO;
|
||||
import com.cloud.simulator.MockStoragePoolVO;
|
||||
import com.cloud.simulator.MockVMVO;
|
||||
import com.cloud.simulator.MockVolumeVO;
|
||||
import com.cloud.simulator.MockVolumeVO.MockVolumeType;
|
||||
import com.cloud.simulator.dao.MockHostDao;
|
||||
import com.cloud.simulator.dao.MockSecStorageDao;
|
||||
import com.cloud.simulator.dao.MockStoragePoolDao;
|
||||
import com.cloud.simulator.dao.MockVMDao;
|
||||
import com.cloud.simulator.dao.MockVolumeDao;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.storage.template.TemplateInfo;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.DiskProfile;
|
||||
|
||||
|
||||
@Local(value = { MockStorageManager.class })
|
||||
public class MockStorageManagerImpl implements MockStorageManager {
|
||||
private static final Logger s_logger = Logger.getLogger(MockStorageManagerImpl.class);
|
||||
@Inject MockStoragePoolDao _mockStoragePoolDao = null;
|
||||
@Inject MockSecStorageDao _mockSecStorageDao = null;
|
||||
@Inject MockVolumeDao _mockVolumeDao = null;
|
||||
@Inject MockVMDao _mockVMDao = null;
|
||||
@Inject MockHostDao _mockHostDao = null;
|
||||
|
||||
private MockVolumeVO findVolumeFromSecondary(String path, String ssUrl, MockVolumeType type) {
|
||||
|
||||
String volumePath = path.replaceAll(ssUrl, "");
|
||||
|
||||
MockSecStorageVO secStorage = _mockSecStorageDao.findByUrl(ssUrl);
|
||||
if (secStorage == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
volumePath = secStorage.getMountPoint() + volumePath;
|
||||
volumePath = volumePath.replaceAll("//", "/");
|
||||
|
||||
MockVolumeVO volume = _mockVolumeDao.findByStoragePathAndType(volumePath);
|
||||
if (volume == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return volume;
|
||||
}
|
||||
@Override
|
||||
public PrimaryStorageDownloadAnswer primaryStorageDownload(PrimaryStorageDownloadCommand cmd) {
|
||||
MockVolumeVO template = findVolumeFromSecondary(cmd.getUrl(),cmd.getSecondaryStorageUrl(), MockVolumeType.TEMPLATE);
|
||||
if (template == null) {
|
||||
return new PrimaryStorageDownloadAnswer("Can't find primary storage");
|
||||
}
|
||||
|
||||
MockStoragePoolVO primaryStorage = _mockStoragePoolDao.findByUuid(cmd.getPoolUuid());
|
||||
if (primaryStorage == null) {
|
||||
return new PrimaryStorageDownloadAnswer("Can't find primary storage");
|
||||
}
|
||||
|
||||
String volumeName = UUID.randomUUID().toString();
|
||||
MockVolumeVO newVolume = new MockVolumeVO();
|
||||
newVolume.setName(volumeName);
|
||||
newVolume.setPath(primaryStorage.getMountPoint() + volumeName);
|
||||
newVolume.setPoolId(primaryStorage.getId());
|
||||
newVolume.setSize(template.getSize());
|
||||
newVolume.setType(MockVolumeType.VOLUME);
|
||||
_mockVolumeDao.persist(newVolume);
|
||||
|
||||
|
||||
return new PrimaryStorageDownloadAnswer(newVolume.getPath(), newVolume.getSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateAnswer createVolume(CreateCommand cmd) {
|
||||
StorageFilerTO sf = cmd.getPool();
|
||||
DiskProfile dskch = cmd.getDiskCharacteristics();
|
||||
MockStoragePoolVO storagePool = _mockStoragePoolDao.findByUuid(sf.getUuid());
|
||||
if (storagePool == null) {
|
||||
return new CreateAnswer(cmd, "Failed to find storage pool: " + sf.getUuid());
|
||||
}
|
||||
|
||||
String volumeName = UUID.randomUUID().toString();
|
||||
MockVolumeVO volume = new MockVolumeVO();
|
||||
volume.setPoolId(storagePool.getId());
|
||||
volume.setName(volumeName);
|
||||
volume.setPath(storagePool.getMountPoint() + volumeName);
|
||||
volume.setSize(dskch.getSize());
|
||||
volume.setType(MockVolumeType.VOLUME);
|
||||
volume = _mockVolumeDao.persist(volume);
|
||||
|
||||
VolumeTO volumeTo = new VolumeTO(cmd.getVolumeId(), dskch.getType(), sf.getType(), sf.getUuid(),
|
||||
volume.getName(), storagePool.getMountPoint(), volume.getPath(), volume.getSize(), null);
|
||||
|
||||
return new CreateAnswer(cmd, volumeTo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttachVolumeAnswer AttachVolume(AttachVolumeCommand cmd) {
|
||||
String poolid = cmd.getPoolUuid();
|
||||
String volumeName = cmd.getVolumeName();
|
||||
MockVolumeVO volume = _mockVolumeDao.findByStoragePathAndType(cmd.getVolumePath());
|
||||
if (volume == null) {
|
||||
return new AttachVolumeAnswer(cmd, "Can't find volume:" + volumeName + "on pool:" + poolid);
|
||||
}
|
||||
|
||||
String vmName = cmd.getVmName();
|
||||
MockVMVO vm = _mockVMDao.findByVmName(vmName);
|
||||
if (vm == null) {
|
||||
return new AttachVolumeAnswer(cmd, "can't vm :" + vmName);
|
||||
}
|
||||
|
||||
return new AttachVolumeAnswer(cmd, cmd.getDeviceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer AttachIso(AttachIsoCommand cmd) {
|
||||
MockVolumeVO iso = findVolumeFromSecondary(cmd.getIsoPath(), cmd.getStoreUrl(), MockVolumeType.ISO);
|
||||
if (iso == null) {
|
||||
return new Answer(cmd, false, "Failed to find the iso: " + cmd.getIsoPath() + "on secondary storage " + cmd.getStoreUrl());
|
||||
}
|
||||
|
||||
String vmName = cmd.getVmName();
|
||||
MockVMVO vm = _mockVMDao.findByVmName(vmName);
|
||||
if (vm == null) {
|
||||
return new Answer(cmd, false, "can't vm :" + vmName);
|
||||
}
|
||||
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer DeleteStoragePool(DeleteStoragePoolCommand cmd) {
|
||||
MockStoragePoolVO storage = _mockStoragePoolDao.findByUuid(cmd.getPool().getUuid());
|
||||
if (storage == null) {
|
||||
return new Answer(cmd, false, "can't find storage pool:" + cmd.getPool().getUuid());
|
||||
}
|
||||
_mockStoragePoolDao.remove(storage.getId());
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModifyStoragePoolAnswer ModifyStoragePool(ModifyStoragePoolCommand cmd) {
|
||||
StorageFilerTO sf = cmd.getPool();
|
||||
MockStoragePoolVO storagePool = _mockStoragePoolDao.findByUuid(sf.getUuid());
|
||||
if (storagePool == null) {
|
||||
storagePool = new MockStoragePoolVO();
|
||||
storagePool.setUuid(sf.getUuid());
|
||||
storagePool.setMountPoint("/mnt/" + sf.getUuid() + File.separator);
|
||||
|
||||
Long size = DEFAULT_HOST_STORAGE_SIZE;
|
||||
String path = sf.getPath();
|
||||
int index = path.lastIndexOf("/");
|
||||
if (index != -1) {
|
||||
path = path.substring(index+1);
|
||||
if (path != null) {
|
||||
String values[] = path.split("=");
|
||||
if (values.length > 1 && values[0].equalsIgnoreCase("size")) {
|
||||
size = Long.parseLong(values[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
storagePool.setCapacity(size);
|
||||
|
||||
storagePool.setStorageType(sf.getType());
|
||||
storagePool = _mockStoragePoolDao.persist(storagePool);
|
||||
}
|
||||
|
||||
return new ModifyStoragePoolAnswer(cmd, storagePool.getCapacity(), 0, new HashMap<String, TemplateInfo>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer CreateStoragePool(CreateStoragePoolCommand cmd) {
|
||||
StorageFilerTO sf = cmd.getPool();
|
||||
MockStoragePoolVO storagePool = _mockStoragePoolDao.findByUuid(sf.getUuid());
|
||||
if (storagePool == null) {
|
||||
storagePool = new MockStoragePoolVO();
|
||||
storagePool.setUuid(sf.getUuid());
|
||||
storagePool.setMountPoint("/mnt/" + sf.getUuid() + File.separator);
|
||||
|
||||
Long size = DEFAULT_HOST_STORAGE_SIZE;
|
||||
String path = sf.getPath();
|
||||
int index = path.lastIndexOf("/");
|
||||
if (index != -1) {
|
||||
path = path.substring(index+1);
|
||||
if (path != null) {
|
||||
String values[] = path.split("=");
|
||||
if (values.length > 1 && values[0].equalsIgnoreCase("size")) {
|
||||
size = Long.parseLong(values[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
storagePool.setCapacity(size);
|
||||
|
||||
storagePool.setStorageType(sf.getType());
|
||||
storagePool = _mockStoragePoolDao.persist(storagePool);
|
||||
}
|
||||
|
||||
return new ModifyStoragePoolAnswer(cmd, storagePool.getCapacity(), 0, new HashMap<String, TemplateInfo>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer SecStorageSetup(SecStorageSetupCommand cmd) {
|
||||
MockSecStorageVO storage = _mockSecStorageDao.findByUrl(cmd.getSecUrl());
|
||||
if (storage == null) {
|
||||
return new Answer(cmd, false, "can't find the storage");
|
||||
}
|
||||
return new SecStorageSetupAnswer(storage.getMountPoint());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer ListTemplates(ListTemplateCommand cmd) {
|
||||
MockSecStorageVO storage = _mockSecStorageDao.findByUrl(cmd.getSecUrl());
|
||||
if (storage == null) {
|
||||
return new Answer(cmd, false, "Failed to get secondary storage");
|
||||
}
|
||||
|
||||
List<MockVolumeVO> templates = _mockVolumeDao.findByStorageIdAndType(storage.getId(), MockVolumeType.TEMPLATE);
|
||||
Map<String, TemplateInfo> templateInfos = new HashMap<String, TemplateInfo>();
|
||||
for (MockVolumeVO template : templates) {
|
||||
templateInfos.put(template.getName(), new TemplateInfo(template.getName(), template.getPath().replaceAll(storage.getMountPoint(), ""), template.getSize(), template.getSize(), true, false));
|
||||
}
|
||||
|
||||
return new ListTemplateAnswer(cmd.getSecUrl(), templateInfos);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer Destroy(DestroyCommand cmd) {
|
||||
|
||||
MockVolumeVO volume = _mockVolumeDao.findByStoragePathAndType(cmd.getVolume().getPath());
|
||||
if (volume != null) {
|
||||
_mockVolumeDao.remove(volume.getId());
|
||||
}
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DownloadAnswer Download(DownloadCommand cmd) {
|
||||
MockSecStorageVO ssvo = _mockSecStorageDao.findByUrl(cmd.getSecUrl());
|
||||
if (ssvo == null) {
|
||||
return new DownloadAnswer("can't find secondary storage", VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR);
|
||||
}
|
||||
|
||||
MockVolumeVO volume = new MockVolumeVO();
|
||||
volume.setPoolId(ssvo.getId());
|
||||
volume.setName(cmd.getName());
|
||||
volume.setPath(ssvo.getMountPoint() + cmd.getName());
|
||||
volume.setSize(0);
|
||||
volume.setType(MockVolumeType.TEMPLATE);
|
||||
volume.setStatus(Status.DOWNLOAD_IN_PROGRESS);
|
||||
volume = _mockVolumeDao.persist(volume);
|
||||
|
||||
return new DownloadAnswer(String.valueOf(volume.getId()), 0, "Downloading", Status.DOWNLOAD_IN_PROGRESS, cmd.getName(), cmd.getName(), volume.getSize(), volume.getSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DownloadAnswer DownloadProcess(DownloadProgressCommand cmd) {
|
||||
String volumeId = cmd.getJobId();
|
||||
MockVolumeVO volume = _mockVolumeDao.findById(Long.parseLong(volumeId));
|
||||
if (volume == null) {
|
||||
return new DownloadAnswer("Can't find the downloading volume", Status.ABANDONED);
|
||||
}
|
||||
|
||||
long size = Math.min(volume.getSize() + DEFAULT_TEMPLATE_SIZE/5, DEFAULT_TEMPLATE_SIZE);
|
||||
volume.setSize(size);
|
||||
|
||||
double volumeSize = volume.getSize();
|
||||
double pct = volumeSize/DEFAULT_TEMPLATE_SIZE;
|
||||
if (pct >= 1.0) {
|
||||
volume.setStatus(Status.DOWNLOADED);
|
||||
_mockVolumeDao.update(volume.getId(), volume);
|
||||
return new DownloadAnswer(cmd.getJobId(), 100, cmd, com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOADED, volume.getPath(), volume.getName());
|
||||
} else {
|
||||
_mockVolumeDao.update(volume.getId(), volume);
|
||||
return new DownloadAnswer(cmd.getJobId(), (int)(pct*100.0) , cmd, com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOAD_IN_PROGRESS, volume.getPath(), volume.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetStorageStatsAnswer GetStorageStats(GetStorageStatsCommand cmd) {
|
||||
String uuid = cmd.getStorageId();
|
||||
if (uuid == null) {
|
||||
String secUrl = cmd.getSecUrl();
|
||||
MockSecStorageVO secondary = _mockSecStorageDao.findByUrl(secUrl);
|
||||
if (secondary == null) {
|
||||
return new GetStorageStatsAnswer(cmd, "Can't find the secondary storage:" + secUrl);
|
||||
}
|
||||
Long totalUsed = _mockVolumeDao.findTotalStorageId(secondary.getId());
|
||||
return new GetStorageStatsAnswer(cmd, secondary.getCapacity(), totalUsed);
|
||||
} else {
|
||||
MockStoragePoolVO pool = _mockStoragePoolDao.findByUuid(uuid);
|
||||
if (pool == null) {
|
||||
return new GetStorageStatsAnswer(cmd, "Can't find the pool");
|
||||
}
|
||||
Long totalUsed = _mockVolumeDao.findTotalStorageId(pool.getId());
|
||||
if (totalUsed == null) {
|
||||
totalUsed = 0L;
|
||||
}
|
||||
return new GetStorageStatsAnswer(cmd, pool.getCapacity(), totalUsed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManageSnapshotAnswer ManageSnapshot(ManageSnapshotCommand cmd) {
|
||||
String volPath = cmd.getVolumePath();
|
||||
|
||||
MockVolumeVO volume = _mockVolumeDao.findByStoragePathAndType(volPath);
|
||||
if (volume == null) {
|
||||
return new ManageSnapshotAnswer(cmd, false, "Can't find the volume");
|
||||
}
|
||||
MockStoragePoolVO storagePool = _mockStoragePoolDao.findById(volume.getPoolId());
|
||||
if (storagePool == null) {
|
||||
return new ManageSnapshotAnswer(cmd, false, "Can't find the storage pooll");
|
||||
}
|
||||
|
||||
String mountPoint = storagePool.getMountPoint();
|
||||
MockVolumeVO snapshot = new MockVolumeVO();
|
||||
|
||||
snapshot.setName(cmd.getSnapshotName());
|
||||
snapshot.setPath(mountPoint + cmd.getSnapshotName());
|
||||
snapshot.setSize(volume.getSize());
|
||||
snapshot.setPoolId(storagePool.getId());
|
||||
snapshot.setType(MockVolumeType.SNAPSHOT);
|
||||
snapshot.setStatus(Status.DOWNLOADED);
|
||||
|
||||
snapshot = _mockVolumeDao.persist(snapshot);
|
||||
|
||||
return new ManageSnapshotAnswer(cmd, snapshot.getId(), snapshot.getPath(), true, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackupSnapshotAnswer BackupSnapshot(BackupSnapshotCommand cmd) {
|
||||
String snapshotPath = cmd.getSnapshotUuid();
|
||||
MockVolumeVO snapshot = _mockVolumeDao.findByStoragePathAndType(snapshotPath);
|
||||
if (snapshot == null) {
|
||||
return new BackupSnapshotAnswer(cmd, false, "can't find snapshot" + snapshotPath, null, true);
|
||||
}
|
||||
|
||||
String secStorageUrl = cmd.getSecondaryStoragePoolURL();
|
||||
MockSecStorageVO secStorage = _mockSecStorageDao.findByUrl(secStorageUrl);
|
||||
if (secStorage == null) {
|
||||
return new BackupSnapshotAnswer(cmd, false, "can't find sec storage" + snapshotPath, null, true);
|
||||
}
|
||||
MockVolumeVO newsnapshot = new MockVolumeVO();
|
||||
String name = UUID.randomUUID().toString();
|
||||
newsnapshot.setName(name);
|
||||
newsnapshot.setPath(secStorage.getMountPoint() + name);
|
||||
newsnapshot.setPoolId(secStorage.getId());
|
||||
newsnapshot.setSize(snapshot.getSize());
|
||||
newsnapshot.setStatus(Status.DOWNLOADED);
|
||||
newsnapshot.setType(MockVolumeType.SNAPSHOT);
|
||||
newsnapshot = _mockVolumeDao.persist(newsnapshot);
|
||||
|
||||
return new BackupSnapshotAnswer(cmd, true, null, newsnapshot.getName(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer DeleteSnapshotBackup(DeleteSnapshotBackupCommand cmd) {
|
||||
|
||||
MockVolumeVO backSnapshot = _mockVolumeDao.findByName(cmd.getSnapshotUuid());
|
||||
if (backSnapshot == null) {
|
||||
return new Answer(cmd, false, "can't find the backupsnapshot: " + cmd.getSnapshotUuid());
|
||||
}
|
||||
|
||||
_mockVolumeDao.remove(backSnapshot.getId());
|
||||
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateVolumeFromSnapshotAnswer CreateVolumeFromSnapshot(CreateVolumeFromSnapshotCommand cmd) {
|
||||
MockVolumeVO backSnapshot = _mockVolumeDao.findByName(cmd.getSnapshotUuid());
|
||||
if (backSnapshot == null) {
|
||||
return new CreateVolumeFromSnapshotAnswer(cmd, false, "can't find the backupsnapshot: " + cmd.getSnapshotUuid(), null);
|
||||
}
|
||||
|
||||
MockStoragePoolVO primary = _mockStoragePoolDao.findByUuid(cmd.getPrimaryStoragePoolNameLabel());
|
||||
if (primary == null) {
|
||||
return new CreateVolumeFromSnapshotAnswer(cmd, false, "can't find the primary storage: " + cmd.getPrimaryStoragePoolNameLabel(), null);
|
||||
}
|
||||
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
MockVolumeVO volume = new MockVolumeVO();
|
||||
|
||||
volume.setName(uuid);
|
||||
volume.setPath(primary.getMountPoint() + uuid);
|
||||
volume.setPoolId(primary.getId());
|
||||
volume.setSize(backSnapshot.getSize());
|
||||
volume.setStatus(Status.DOWNLOADED);
|
||||
volume.setType(MockVolumeType.VOLUME);
|
||||
_mockVolumeDao.persist(volume);
|
||||
|
||||
return new CreateVolumeFromSnapshotAnswer(cmd, true, null, volume.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer DeleteTemplate(DeleteTemplateCommand cmd) {
|
||||
MockVolumeVO template = _mockVolumeDao.findByStoragePathAndType(cmd.getTemplatePath());
|
||||
if (template == null) {
|
||||
return new Answer(cmd, false, "can't find template:" + cmd.getTemplatePath());
|
||||
}
|
||||
|
||||
_mockVolumeDao.remove(template.getId());
|
||||
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer SecStorageVMSetup(SecStorageVMSetupCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preinstallTemplates(String url, long zoneId) {
|
||||
MockSecStorageVO storage = _mockSecStorageDao.findByUrl(url);
|
||||
if (storage == null) {
|
||||
storage = new MockSecStorageVO();
|
||||
URI uri;
|
||||
try {
|
||||
uri = new URI(url);
|
||||
} catch (URISyntaxException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
String nfsHost = uri.getHost();
|
||||
String nfsPath = uri.getPath();
|
||||
String path = nfsHost + ":" + nfsPath;
|
||||
String dir = "/mnt/" + UUID.nameUUIDFromBytes(path.getBytes()).toString() + File.separator;
|
||||
|
||||
storage.setUrl(url);
|
||||
storage.setCapacity(DEFAULT_HOST_STORAGE_SIZE);
|
||||
|
||||
storage.setMountPoint(dir);
|
||||
|
||||
storage = _mockSecStorageDao.persist(storage);
|
||||
|
||||
//preinstall default templates into secondary storage
|
||||
long defaultTemplateSize = 2 * 1024 * 1024 * 1024L;
|
||||
MockVolumeVO template = new MockVolumeVO();
|
||||
template.setName("simulator-domR");
|
||||
template.setPath(storage.getMountPoint() + "template/tmpl/1/9/" + UUID.randomUUID().toString());
|
||||
template.setPoolId(storage.getId());
|
||||
template.setSize(defaultTemplateSize);
|
||||
template.setType(MockVolumeType.TEMPLATE);
|
||||
template.setStatus(Status.DOWNLOADED);
|
||||
_mockVolumeDao.persist(template);
|
||||
|
||||
template = new MockVolumeVO();
|
||||
template.setName("simulator-Centos");
|
||||
template.setPath(storage.getMountPoint() + "template/tmpl/1/10/" + UUID.randomUUID().toString());
|
||||
template.setPoolId(storage.getId());
|
||||
template.setSize(defaultTemplateSize);
|
||||
template.setType(MockVolumeType.TEMPLATE);
|
||||
_mockVolumeDao.persist(template);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoragePoolInfo getLocalStorage(String hostGuid) {
|
||||
MockHost host = _mockHostDao.findByGuid(hostGuid);
|
||||
|
||||
MockStoragePoolVO storagePool = _mockStoragePoolDao.findByHost(hostGuid);
|
||||
if (storagePool == null) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
storagePool = new MockStoragePoolVO();
|
||||
storagePool.setUuid(uuid);
|
||||
storagePool.setMountPoint("/mnt/" + uuid + File.separator);
|
||||
storagePool.setCapacity(DEFAULT_HOST_STORAGE_SIZE);
|
||||
storagePool.setHostGuid(hostGuid);
|
||||
storagePool.setStorageType(StoragePoolType.Filesystem);
|
||||
storagePool = _mockStoragePoolDao.persist(storagePool);
|
||||
}
|
||||
|
||||
|
||||
return new StoragePoolInfo(storagePool.getUuid(), host.getPrivateIpAddress(), storagePool.getMountPoint(), storagePool.getMountPoint(), storagePool.getPoolType(), storagePool.getCapacity(), 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoragePoolInfo getLocalStorage(String hostGuid, Long storageSize) {
|
||||
MockHost host = _mockHostDao.findByGuid(hostGuid);
|
||||
if (storageSize == null) {
|
||||
storageSize = DEFAULT_HOST_STORAGE_SIZE;
|
||||
}
|
||||
MockStoragePoolVO storagePool = _mockStoragePoolDao.findByHost(hostGuid);
|
||||
if (storagePool == null) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
storagePool = new MockStoragePoolVO();
|
||||
storagePool.setUuid(uuid);
|
||||
storagePool.setMountPoint("/mnt/" + uuid + File.separator);
|
||||
storagePool.setCapacity(storageSize);
|
||||
storagePool.setHostGuid(hostGuid);
|
||||
storagePool.setStorageType(StoragePoolType.Filesystem);
|
||||
storagePool = _mockStoragePoolDao.persist(storagePool);
|
||||
}
|
||||
|
||||
|
||||
return new StoragePoolInfo(storagePool.getUuid(), host.getPrivateIpAddress(), storagePool.getMountPoint(), storagePool.getMountPoint(), storagePool.getPoolType(), storagePool.getCapacity(), 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatePrivateTemplateAnswer CreatePrivateTemplateFromSnapshot(CreatePrivateTemplateFromSnapshotCommand cmd) {
|
||||
String snapshotUUId = cmd.getSnapshotUuid();
|
||||
MockVolumeVO snapshot = _mockVolumeDao.findByName(snapshotUUId);
|
||||
if (snapshot == null) {
|
||||
snapshotUUId = cmd.getSnapshotName();
|
||||
snapshot = _mockVolumeDao.findByName(snapshotUUId);
|
||||
if (snapshot == null) {
|
||||
return new CreatePrivateTemplateAnswer(cmd, false, "can't find snapshot:" + snapshotUUId);
|
||||
}
|
||||
}
|
||||
|
||||
MockSecStorageVO sec = _mockSecStorageDao.findByUrl(cmd.getSecondaryStoragePoolURL());
|
||||
if (sec == null) {
|
||||
return new CreatePrivateTemplateAnswer(cmd, false, "can't find secondary storage");
|
||||
}
|
||||
|
||||
MockVolumeVO template = new MockVolumeVO();
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
template.setName(uuid);
|
||||
template.setPath(sec.getMountPoint() + uuid);
|
||||
template.setPoolId(sec.getId());
|
||||
template.setSize(snapshot.getSize());
|
||||
template.setStatus(Status.DOWNLOADED);
|
||||
template.setType(MockVolumeType.TEMPLATE);
|
||||
template = _mockVolumeDao.persist(template);
|
||||
|
||||
return new CreatePrivateTemplateAnswer(cmd, true, "", template.getName(), template.getSize(), template.getSize(), template.getName(), ImageFormat.QCOW2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer ComputeChecksum(ComputeChecksumCommand cmd) {
|
||||
MockVolumeVO volume = _mockVolumeDao.findByName(cmd.getTemplatePath());
|
||||
if (volume == null) {
|
||||
return new Answer(cmd, false, "cant' find volume:" + cmd.getTemplatePath());
|
||||
}
|
||||
String md5 = null;
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("md5");
|
||||
md5 = String.format("%032x", new BigInteger(1, md.digest(cmd.getTemplatePath().getBytes())));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
s_logger.debug("failed to gernerate md5:" + e.toString());
|
||||
}
|
||||
|
||||
return new Answer(cmd, true, md5);
|
||||
}
|
||||
@Override
|
||||
public CreatePrivateTemplateAnswer CreatePrivateTemplateFromVolume(CreatePrivateTemplateFromVolumeCommand cmd) {
|
||||
MockVolumeVO volume = _mockVolumeDao.findByStoragePathAndType(cmd.getVolumePath());
|
||||
if (volume == null) {
|
||||
return new CreatePrivateTemplateAnswer(cmd, false, "cant' find volume" + cmd.getVolumePath());
|
||||
}
|
||||
|
||||
MockSecStorageVO sec = _mockSecStorageDao.findByUrl(cmd.getSecondaryStoragePoolURL());
|
||||
if (sec == null) {
|
||||
return new CreatePrivateTemplateAnswer(cmd, false, "can't find secondary storage");
|
||||
}
|
||||
|
||||
MockVolumeVO template = new MockVolumeVO();
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
template.setName(uuid);
|
||||
template.setPath(sec.getMountPoint() + uuid);
|
||||
template.setPoolId(sec.getId());
|
||||
template.setSize(volume.getSize());
|
||||
template.setStatus(Status.DOWNLOADED);
|
||||
template.setType(MockVolumeType.TEMPLATE);
|
||||
template = _mockVolumeDao.persist(template);
|
||||
|
||||
return new CreatePrivateTemplateAnswer(cmd, true, "", template.getName(), template.getSize(), template.getSize(), template.getName(), ImageFormat.QCOW2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,86 @@
|
||||
/**
|
||||
* Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
package com.cloud.agent.manager;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.CheckVirtualMachineCommand;
|
||||
import com.cloud.agent.api.CleanupNetworkRulesCmd;
|
||||
import com.cloud.agent.api.GetVmStatsCommand;
|
||||
import com.cloud.agent.api.GetVncPortCommand;
|
||||
import com.cloud.agent.api.MigrateAnswer;
|
||||
import com.cloud.agent.api.MigrateCommand;
|
||||
import com.cloud.agent.api.NetworkUsageAnswer;
|
||||
import com.cloud.agent.api.NetworkUsageCommand;
|
||||
import com.cloud.agent.api.RebootCommand;
|
||||
import com.cloud.agent.api.SecurityIngressRulesCmd;
|
||||
import com.cloud.agent.api.StartCommand;
|
||||
import com.cloud.agent.api.StopCommand;
|
||||
import com.cloud.agent.api.VmStatsEntry;
|
||||
import com.cloud.agent.api.check.CheckSshAnswer;
|
||||
import com.cloud.agent.api.check.CheckSshCommand;
|
||||
import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand;
|
||||
import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand;
|
||||
import com.cloud.agent.api.routing.DhcpEntryCommand;
|
||||
import com.cloud.agent.api.routing.IpAssocCommand;
|
||||
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
|
||||
import com.cloud.agent.api.routing.SavePasswordCommand;
|
||||
import com.cloud.agent.api.routing.SetPortForwardingRulesAnswer;
|
||||
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesAnswer;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
|
||||
import com.cloud.agent.api.routing.VmDataCommand;
|
||||
import com.cloud.agent.api.storage.DestroyCommand;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.simulator.MockVm;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
public interface MockVmManager extends Manager {
|
||||
public Answer stopVM(StopCommand cmd);
|
||||
public Answer rebootVM(RebootCommand cmd);
|
||||
|
||||
public boolean migrate(String vmName, String params);
|
||||
|
||||
public Answer checkVmState(CheckVirtualMachineCommand cmd, String hostGuid);
|
||||
public Map<String, State> getVmStates(String hostGuid);
|
||||
public Answer getVncPort(GetVncPortCommand cmd);
|
||||
|
||||
Answer startVM(StartCommand cmd, String hostGuid);
|
||||
|
||||
Answer getVmStats(GetVmStatsCommand cmd);
|
||||
public CheckSshAnswer checkSshCommand(CheckSshCommand cmd);
|
||||
|
||||
Answer SetStaticNatRules(SetStaticNatRulesCommand cmd);
|
||||
|
||||
Answer SetPortForwardingRules(SetPortForwardingRulesCommand cmd);
|
||||
|
||||
Answer getNetworkUsage(NetworkUsageCommand cmd);
|
||||
|
||||
Answer Migrate(MigrateCommand cmd, String hostGuid);
|
||||
|
||||
Answer IpAssoc(IpAssocCommand cmd);
|
||||
|
||||
Answer LoadBalancerConfig(LoadBalancerConfigCommand cmd);
|
||||
|
||||
Answer AddDhcpEntry(DhcpEntryCommand cmd);
|
||||
|
||||
Answer setVmData(VmDataCommand cmd);
|
||||
Answer CleanupNetworkRules(CleanupNetworkRulesCmd cmd, String hostGuid);
|
||||
|
||||
Answer CheckConsoleProxyLoad(CheckConsoleProxyLoadCommand cmd);
|
||||
Answer WatchConsoleProxyLoad(WatchConsoleProxyLoadCommand cmd);
|
||||
|
||||
Answer AddSecurityIngressRules(SecurityIngressRulesCmd cmd);
|
||||
Answer SavePassword(SavePasswordCommand cmd);
|
||||
HashMap<String, Pair<Long, Long>> syncNetworkGroups(String hostGuid);
|
||||
|
||||
}
|
||||
@ -0,0 +1,398 @@
|
||||
/**
|
||||
* Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
package com.cloud.agent.manager;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.CheckVirtualMachineAnswer;
|
||||
import com.cloud.agent.api.CheckVirtualMachineCommand;
|
||||
import com.cloud.agent.api.CleanupNetworkRulesCmd;
|
||||
import com.cloud.agent.api.GetVmStatsAnswer;
|
||||
import com.cloud.agent.api.GetVmStatsCommand;
|
||||
import com.cloud.agent.api.GetVncPortAnswer;
|
||||
import com.cloud.agent.api.GetVncPortCommand;
|
||||
import com.cloud.agent.api.MigrateAnswer;
|
||||
import com.cloud.agent.api.MigrateCommand;
|
||||
import com.cloud.agent.api.NetworkUsageAnswer;
|
||||
import com.cloud.agent.api.NetworkUsageCommand;
|
||||
import com.cloud.agent.api.RebootCommand;
|
||||
import com.cloud.agent.api.SecurityIngressRuleAnswer;
|
||||
import com.cloud.agent.api.SecurityIngressRulesCmd;
|
||||
import com.cloud.agent.api.StartAnswer;
|
||||
import com.cloud.agent.api.StartCommand;
|
||||
import com.cloud.agent.api.StopAnswer;
|
||||
import com.cloud.agent.api.StopCommand;
|
||||
import com.cloud.agent.api.VmStatsEntry;
|
||||
import com.cloud.agent.api.check.CheckSshAnswer;
|
||||
import com.cloud.agent.api.check.CheckSshCommand;
|
||||
import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand;
|
||||
import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand;
|
||||
import com.cloud.agent.api.routing.DhcpEntryCommand;
|
||||
import com.cloud.agent.api.routing.IpAssocCommand;
|
||||
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
|
||||
import com.cloud.agent.api.routing.SavePasswordCommand;
|
||||
import com.cloud.agent.api.routing.SetPortForwardingRulesAnswer;
|
||||
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesAnswer;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
|
||||
import com.cloud.agent.api.routing.VmDataCommand;
|
||||
import com.cloud.agent.api.storage.DestroyCommand;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
|
||||
import com.cloud.simulator.MockHost;
|
||||
import com.cloud.simulator.MockHostVO;
|
||||
import com.cloud.simulator.MockSecurityRulesVO;
|
||||
import com.cloud.simulator.MockVMVO;
|
||||
import com.cloud.simulator.MockVm;
|
||||
import com.cloud.simulator.dao.MockHostDao;
|
||||
import com.cloud.simulator.dao.MockSecurityRulesDao;
|
||||
import com.cloud.simulator.dao.MockVMDao;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Inject;
|
||||
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
@Local(value = { MockVmManager.class })
|
||||
public class MockVmManagerImpl implements MockVmManager {
|
||||
private static final Logger s_logger = Logger.getLogger(MockVmManagerImpl.class);
|
||||
|
||||
@Inject MockVMDao _mockVmDao = null;
|
||||
@Inject MockAgentManager _mockAgentMgr = null;
|
||||
@Inject MockHostDao _mockHostDao = null;
|
||||
@Inject MockSecurityRulesDao _mockSecurityDao = null;
|
||||
|
||||
public MockVmManagerImpl() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String startVM(String vmName, NicTO[] nics,
|
||||
int cpuHz, long ramSize,
|
||||
String bootArgs, String hostGuid) {
|
||||
|
||||
MockHost host = _mockHostDao.findByGuid(hostGuid);
|
||||
if (host == null) {
|
||||
return "can't find host";
|
||||
}
|
||||
|
||||
MockVm vm = _mockVmDao.findByVmName(vmName);
|
||||
if(vm == null) {
|
||||
int vncPort = 0;
|
||||
if(vncPort < 0)
|
||||
return "Unable to allocate VNC port";
|
||||
vm = new MockVMVO();
|
||||
vm.setCpu(cpuHz);
|
||||
vm.setMemory(ramSize);
|
||||
vm.setState(State.Running);
|
||||
vm.setName(vmName);
|
||||
vm.setVncPort(vncPort);
|
||||
vm.setHostId(host.getId());
|
||||
vm = _mockVmDao.persist((MockVMVO)vm);
|
||||
} else {
|
||||
if(vm.getState() == State.Stopped) {
|
||||
vm.setState(State.Running);
|
||||
_mockVmDao.update(vm.getId(), (MockVMVO)vm);
|
||||
}
|
||||
}
|
||||
|
||||
if (vm.getState() == State.Running && vmName.startsWith("s-")) {
|
||||
String prvIp = null;
|
||||
String prvMac = null;
|
||||
String prvNetMask = null;
|
||||
|
||||
for (NicTO nic : nics) {
|
||||
if (nic.getType() == TrafficType.Management) {
|
||||
prvIp = nic.getIp();
|
||||
prvMac = nic.getMac();
|
||||
prvNetMask = nic.getNetmask();
|
||||
}
|
||||
}
|
||||
long dcId = 0;
|
||||
long podId = 0;
|
||||
String name = null;
|
||||
String vmType = null;
|
||||
String url = null;
|
||||
String[] args = bootArgs.trim().split(" ");
|
||||
for (String arg : args) {
|
||||
String[] params = arg.split("=");
|
||||
if (params.length < 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (params[0].equalsIgnoreCase("zone")) {
|
||||
dcId = Long.parseLong(params[1]);
|
||||
} else if (params[0].equalsIgnoreCase("name")) {
|
||||
name = params[1];
|
||||
} else if (params[0].equalsIgnoreCase("type")) {
|
||||
vmType = params[1];
|
||||
} else if (params[0].equalsIgnoreCase("url")) {
|
||||
url = params[1];
|
||||
} else if (params[0].equalsIgnoreCase("pod")) {
|
||||
podId = Long.parseLong(params[1]);
|
||||
}
|
||||
}
|
||||
|
||||
_mockAgentMgr.handleSystemVMStart(vm.getId(), prvIp, prvMac, prvNetMask, dcId, podId, name, vmType, url);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean rebootVM(String vmName) {
|
||||
MockVm vm = _mockVmDao.findByVmName(vmName);
|
||||
if(vm != null) {
|
||||
vm.setState(State.Running);
|
||||
_mockVmDao.update(vm.getId(), (MockVMVO)vm);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean migrate(String vmName, String params) {
|
||||
MockVm vm = _mockVmDao.findByVmName(vmName);
|
||||
if(vm != null) {
|
||||
vm.setState(State.Stopped);
|
||||
_mockVmDao.remove(vm.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, State> getVmStates(String hostGuid) {
|
||||
Map<String, State> states = new HashMap<String, State>();
|
||||
List<MockVMVO> vms = _mockVmDao.findByHostGuid(hostGuid);
|
||||
if (vms.isEmpty()) {
|
||||
return states;
|
||||
}
|
||||
|
||||
for(MockVm vm : vms) {
|
||||
states.put(vm.getName(), vm.getState());
|
||||
}
|
||||
|
||||
return states;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer getVmStats(GetVmStatsCommand cmd) {
|
||||
HashMap<String, VmStatsEntry> vmStatsNameMap = new HashMap<String, VmStatsEntry>();
|
||||
List<String> vmNames = cmd.getVmNames();
|
||||
for (String vmName : vmNames) {
|
||||
VmStatsEntry entry = new VmStatsEntry(0, 0, 0, 0, "vm");
|
||||
entry.setNetworkReadKBs(32768); // default values 256 KBps
|
||||
entry.setNetworkWriteKBs(16384);
|
||||
entry.setCPUUtilization(10);
|
||||
entry.setNumCPUs(1);
|
||||
vmStatsNameMap.put(vmName, entry);
|
||||
}
|
||||
return new GetVmStatsAnswer(cmd, vmStatsNameMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckVirtualMachineAnswer checkVmState(CheckVirtualMachineCommand cmd, String hostGuid) {
|
||||
MockVMVO vm = _mockVmDao.findByVmNameAndHost(cmd.getVmName(), hostGuid);
|
||||
if (vm == null) {
|
||||
return new CheckVirtualMachineAnswer(cmd, "can't find vm:" + cmd.getVmName());
|
||||
}
|
||||
|
||||
return new CheckVirtualMachineAnswer(cmd, vm.getState(), vm.getVncPort());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer startVM(StartCommand cmd, String hostGuid) {
|
||||
VirtualMachineTO vm = cmd.getVirtualMachine();
|
||||
String result = startVM(vm.getName(), vm.getNics(), vm.getCpus()* vm.getSpeed(), vm.getMaxRam(), vm.getBootArgs(), hostGuid);
|
||||
if (result != null) {
|
||||
return new StartAnswer(cmd, result);
|
||||
} else {
|
||||
return new StartAnswer(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckSshAnswer checkSshCommand(CheckSshCommand cmd) {
|
||||
return new CheckSshAnswer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer SetStaticNatRules(SetStaticNatRulesCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer SetPortForwardingRules(SetPortForwardingRulesCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkUsageAnswer getNetworkUsage(NetworkUsageCommand cmd) {
|
||||
return new NetworkUsageAnswer(cmd, null, 100L, 100L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MigrateAnswer Migrate(MigrateCommand cmd, String hostGuid) {
|
||||
String vmName = cmd.getVmName();
|
||||
String destGuid = cmd.getHostGuid();
|
||||
MockVMVO vm = _mockVmDao.findByVmNameAndHost(vmName, hostGuid);
|
||||
if (vm == null) {
|
||||
return new MigrateAnswer(cmd, false, "can;t find vm:" + vmName + " on host:" + hostGuid, null);
|
||||
}
|
||||
|
||||
MockHost destHost = _mockHostDao.findByGuid(destGuid);
|
||||
if (destHost == null) {
|
||||
return new MigrateAnswer(cmd, false, "can;t find host:" + hostGuid, null);
|
||||
}
|
||||
vm.setHostId(destHost.getId());
|
||||
_mockVmDao.update(vm.getId(), vm);
|
||||
return new MigrateAnswer(cmd, true,null, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer IpAssoc(IpAssocCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer LoadBalancerConfig(LoadBalancerConfigCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer AddDhcpEntry(DhcpEntryCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer setVmData(VmDataCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer CleanupNetworkRules(CleanupNetworkRulesCmd cmd, String hostGuid) {
|
||||
List<MockSecurityRulesVO> rules = _mockSecurityDao.findByHost(hostGuid);
|
||||
for (MockSecurityRulesVO rule : rules) {
|
||||
MockVMVO vm = _mockVmDao.findByVmNameAndHost(rule.getVmName(), hostGuid);
|
||||
if (vm == null) {
|
||||
_mockSecurityDao.remove(rule.getId());
|
||||
}
|
||||
}
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer stopVM(StopCommand cmd) {
|
||||
String vmName = cmd.getVmName();
|
||||
MockVm vm = _mockVmDao.findByVmName(vmName);
|
||||
if(vm != null) {
|
||||
vm.setState(State.Stopped);
|
||||
_mockVmDao.update(vm.getId(), (MockVMVO)vm);
|
||||
}
|
||||
|
||||
if (vmName.startsWith("s-")) {
|
||||
_mockAgentMgr.handleSystemVMStop(vm.getId());
|
||||
}
|
||||
|
||||
return new StopAnswer(cmd, null, new Integer(0), new Long(100), new Long(200));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer rebootVM(RebootCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer getVncPort(GetVncPortCommand cmd) {
|
||||
return new GetVncPortAnswer(cmd, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer CheckConsoleProxyLoad(CheckConsoleProxyLoadCommand cmd) {
|
||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer WatchConsoleProxyLoad(WatchConsoleProxyLoadCommand cmd) {
|
||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityIngressRuleAnswer AddSecurityIngressRules(SecurityIngressRulesCmd cmd) {
|
||||
MockVMVO vm = _mockVmDao.findByVmName(cmd.getVmName());
|
||||
if (vm == null) {
|
||||
return new SecurityIngressRuleAnswer(cmd, false, "cant' find the vm: " + cmd.getVmName());
|
||||
}
|
||||
|
||||
MockSecurityRulesVO rules = _mockSecurityDao.findByVmId(cmd.getVmId());
|
||||
if (rules == null) {
|
||||
rules = new MockSecurityRulesVO();
|
||||
rules.setRuleSet(cmd.stringifyRules());
|
||||
rules.setSeqNum(cmd.getSeqNum());
|
||||
rules.setSignature(cmd.getSignature());
|
||||
rules.setVmId(vm.getId());
|
||||
rules.setHostId(vm.getHostId());
|
||||
|
||||
_mockSecurityDao.persist(rules);
|
||||
} else {
|
||||
rules.setSeqNum(cmd.getSeqNum());
|
||||
rules.setSignature(cmd.getSignature());
|
||||
rules.setRuleSet(cmd.stringifyRules());
|
||||
rules.setVmId(cmd.getVmId());
|
||||
rules.setHostId(vm.getHostId());
|
||||
_mockSecurityDao.update(rules.getId(), rules);
|
||||
}
|
||||
|
||||
return new SecurityIngressRuleAnswer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer SavePassword(SavePasswordCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, Pair<Long, Long>> syncNetworkGroups(String hostGuid) {
|
||||
HashMap<String, Pair<Long, Long>> maps = new HashMap<String, Pair<Long, Long>>();
|
||||
List<MockSecurityRulesVO> rules = _mockSecurityDao.findByHost(hostGuid);
|
||||
for (MockSecurityRulesVO rule : rules) {
|
||||
maps.put(rule.getVmName(), new Pair<Long, Long>(rule.getVmId(), rule.getSeqNum()));
|
||||
}
|
||||
return maps;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user