From 3e5987acb272bef1e8a9d2fb7e29e6fd8b900dc4 Mon Sep 17 00:00:00 2001 From: Chiradeep Vittal Date: Wed, 6 Oct 2010 13:25:13 -0700 Subject: [PATCH] current state of rsyslog.conf --- test.sh | 63 +++++++++++++++++++++++++++++++++++++++++++ test/addhosts.sh | 13 +++++++++ test/admincookie.txt | 5 ++++ test/cleanup.sh | 34 +++++++++++++++++++++++ test/createlogin.sh | 5 ++++ test/hosts.properties | 1 + test/setupzone.sh | 25 +++++++++++++++++ test/test.sh | 5 ++++ 8 files changed, 151 insertions(+) create mode 100644 test.sh create mode 100755 test/addhosts.sh create mode 100644 test/admincookie.txt create mode 100755 test/cleanup.sh create mode 100755 test/createlogin.sh create mode 100644 test/hosts.properties create mode 100755 test/setupzone.sh create mode 100755 test/test.sh diff --git a/test.sh b/test.sh new file mode 100644 index 00000000000..3ebe9129a05 --- /dev/null +++ b/test.sh @@ -0,0 +1,63 @@ +#!/bin/bash +MGMT_SERVER=$MGMT_SERVER + +#login +curl -c admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=login&username=admin&password=password&response=json" + +#delete service offerings +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=deleteServiceOffering&id=1&response=json" +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=deleteServiceOffering&id=2&response=json" +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=deleteServiceOffering&id=3&response=json" + +#delete service offerings +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=deleteDiskOffering&id=1&response=json" +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=deleteDiskOffering&id=2&response=json" +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=deleteDiskOffering&id=3&response=json" + +#create service offerings +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=createServiceOffering&cpuNumber=2&cpuSpeed=2400&memory=2400&displayText=Memcached%20Node&name=Memcached%20Node&storageType=local&response=json" +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=createServiceOffering&cpuNumber=2&cpuSpeed=2400&memory=2400&displayText=Web%20Node&name=Web%20Node&storageType=local&response=json" +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=createServiceOffering&cpuNumber=2&cpuSpeed=2400&memory=2400&displayText=Database%20Node&name=Database%20Node&storageType=local&response=json" + +#create disk offerings +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=createDiskOffering&diskSize=20&displayText=Small%20Size&name=Volume%20#1&isMirrored=false&response=json" +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=createDiskOffering&diskSize=40&displayText=Volume%20Medium%20Size&name=Volume%20#2&isMirrored=false&response=json" +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=createDiskOffering&diskSize=80&displayText=Volume%20Large%20Size&name=Volume%20#3&isMirrored=false&response=json" + +#add secondary storage +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=addSecondaryStorage&zoneId=1&url=nfs%3A//192.168.151.16/export/secondary-storage&response=json" + +#register template +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=registerTemplate&displayText=Rightscale%20%ami-ccb35ea5&format=VHD&isPublic=true&name=Rightscale%20ami-ccb35ea5&osTypeId=11&passwordEnabled=false&url=http%3A//nfs1.lab.vmops.com/templates/ami-ccb35ea5/ami-ccb35ea5.vhd.bz2&response=json" + +#add primary storage +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=createStoragePool&zoneId=1&podId=1&url=nfs%3A//192.168.151.16/export/primary-storage&response=json" + +#add hosts here + +#check if templates are ready (DomR and Rightscale AMI) +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=listTemplates&isReady=true&showAll=true&response=json" + +#add user +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=createUser&username=tester&email=tester&firstname=tester&accounttype=0&password=&lastname=tester&response=json" + +#login user +curl -c usercookie.txt -sS "http://$MGMT_SERVER/client/api?command=login&username=tester&password=tester&response=json" + +#create VMs +curl -b usercookie.txt -sS "http://$MGMT_SERVER/client/api?command=deployVirtualMachine&zoneId=1&serviceofferingId=4&diskOfferingId=4&templateId=201&displayName=Farmville2&group=Farmville%20Group&response=json" + +#get IP (n times) +curl -b usercookie.txt -sS "http://$MGMT_SERVER/client/api?command=associateIpAddress&zoneId=1&response=json" + +#list IP addresses +curl -b usercookie.txt -sS "http://$MGMT_SERVER/client/api?command=listPublicIpAddresses&zoneId=1&response=json" + +#create security group and add rule +curl -b usercookie.txt -sS "http://$MGMT_SERVER/client/api?command=createSecurityGroup&name=ssh1&description=ssh1&response=json" +curl -b usercookie.txt -sS "http://$MGMT_SERVER/client/api?command=createNetworkRule&privateport=22&protocol=TCP&publicport=22&securitygroupid=1&response=json" +curl -b usercookie.txt -sS "http://$MGMT_SERVER/client/api?command=queryAsyncJobResult&jobId=8&response=json" + +#assign security group +curl -b usercookie.txt -sS "http://$MGMT_SERVER/client/api?command=assignSecurityGroup&groupids=1&publicip=172.24.0.102&virtualmachineid=5&response=json" | awk '{print $(NF-1)}' +curl -b usercookie.txt -sS "http://$MGMT_SERVER/client/api?command=queryAsyncJobResult&jobId=8&response=json" diff --git a/test/addhosts.sh b/test/addhosts.sh new file mode 100755 index 00000000000..bda305d7db0 --- /dev/null +++ b/test/addhosts.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +MGMT_SERVER=localhost +PASSWORD=password +USERNAME=root +sessionkey=$1 + +zoneId=5 +podId=5 +ip=192.168.140.11 +cluster=CV +err=$(curl -sS "http://${MGMT_SERVER}:8096/?command=addHost&zoneId=$zoneId&cluster=$clustername&podId=$podId&url=http://$ip&username=$USERNAME&password=$PASSWORD&sessionkey=$sessionkey&response=json") + diff --git a/test/admincookie.txt b/test/admincookie.txt new file mode 100644 index 00000000000..a9c17affde9 --- /dev/null +++ b/test/admincookie.txt @@ -0,0 +1,5 @@ +# Netscape HTTP Cookie File +# http://curl.haxx.se/rfc/cookie_spec.html +# This file was generated by libcurl! Edit at your own risk. + +localhost FALSE /client FALSE 0 JSESSIONID 71E3FBC27B8B647B09FFAABB458D1E20 diff --git a/test/cleanup.sh b/test/cleanup.sh new file mode 100755 index 00000000000..9e50d70990d --- /dev/null +++ b/test/cleanup.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +. /etc/rc.d/init.d/functions +source $(dirname $0)/hosts.properties + +set -x + + + +cleanup_xen_host(){ +ssh root@$1 "for vm in \`xe vm-list | grep name-label | grep -v Control | awk '{print \$4}'\`; do uuid=\`xe vm-list name-label=\$vm | grep uuid | awk '{print \$5}'\`; echo \$uuid; xe vm-shutdown --force uuid=\$uuid; xe vm-destroy uuid=\$uuid; done" +ssh root@$1 "for vlan in \`xe vlan-list | grep uuid | awk '{print \$5}'\`; do echo \$vlan; xe vlan-destroy uuid=\$vlan; done" +ssh root@$1 "for vlan in \`xe network-list | grep name-label | grep VLAN| awk '{print \$4}'\`; do echo \$vlan; uuid=\`xe network-list name-label=\$vlan | grep uuid | awk '{print \$5}'\`; xe network-destroy uuid=\$uuid; done" +ssh root@$1 "for sr in \`xe sr-list type=nfs name-description=storage | grep uuid | awk '{print \$5}'\`; do pbd=\`xe pbd-list sr-uuid=\$sr | grep ^uuid | awk '{ print \$5}'\` ; echo \$pbd; xe pbd-unplug uuid=\$pbd; xe pbd-destroy uuid=\$pbd; xe sr-forget uuid=\$sr; done" +ssh root@$1 "for sr in \`xe sr-list type=nfs | grep uuid | awk '{print \$5}'\`; do pbd=\`xe pbd-list sr-uuid=\$sr | grep ^uuid | awk '{ print \$5}'\` ; echo \$pbd; xe pbd-unplug uuid=\$pbd; xe pbd-destroy uuid=\$pbd; xe sr-forget uuid=\$sr; done" +ssh root@$1 "sr=\`xe sr-list type=lvm | grep uuid | awk '{print \$5}'\`; for vdi in \`xe vdi-list sr-uuid=\$sr | grep ^uuid | awk '{ print \$5}'\` ; do echo \$vdi; xe vdi-destroy uuid=\$vdi; done" +} + +cleanup_primary() { + ssh root@nfs1.lab.vmops.com 'rm -vf /export/home/chiradeep/primary/*.vhd' +} + +dir=$(dirname "$0") +if [ -f $dir/../deploy.properties ]; then + . "$dir/../deploy.properties" +fi + +#Kill vms and delete vlans on all computing hosts +for i in $COMPUTE +do + cleanup_xen_host $i +done + +cleanup_primary diff --git a/test/createlogin.sh b/test/createlogin.sh new file mode 100755 index 00000000000..603a306200c --- /dev/null +++ b/test/createlogin.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +sessionkey=$(curl -c admincookie.txt -sS "http://localhost:8080/client/api?command=login&username=admin&password=5f4dcc3b5aa765d61d8327deb882cf99&response=json" | awk -F "," '{print $13}' | awk -F":" '{print $2}' | tr -d '[:space:]' | tr -d '"') + +echo $sessionkey diff --git a/test/hosts.properties b/test/hosts.properties new file mode 100644 index 00000000000..8bf9d859596 --- /dev/null +++ b/test/hosts.properties @@ -0,0 +1 @@ +COMPUTE=192.168.140.11 diff --git a/test/setupzone.sh b/test/setupzone.sh new file mode 100755 index 00000000000..d7c9c19fd34 --- /dev/null +++ b/test/setupzone.sh @@ -0,0 +1,25 @@ +#!/bin/bash +MGMT_SERVER=localhost:8080 + +set -x +sessionkey=$1 +#create zone +# curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=createZone&name=$ZONENAME&dns1=$EXTDNS1&internaldns1=8.8.8.8&guestcidraddress=10.1.1.1/24&vlan=1000-1100&response=json" +echo +#update zone +#curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=updateZone&id=1&name=$ZONENAME&DNS1=$EXTDNS1&internaldns1=$INTDNS1&guestcidraddress=10.1.1.1/24&vlan=1000-1100&response=json" +echo + +#add pods +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=updatePod&id=5&name=CV&gateway=192.168.140.1&cidr=192.168.140.0%2F24&startip=192.168.140.150&endip=192.168.140.155&sessionkey=$sessionkey&response=json" +echo +#curl -b admincookie.txt -sS "http://localhost:8080/client/api?command=createPod&name=POD2&zoneid=1&gateway=192.168.203.1&cidr=192.168.203.0%2F24&startip=192.168.203.65&endip=192.168.203.72&response=json" +echo + +#add secondary storage +curl -b admincookie.txt -sS "http://$MGMT_SERVER/client/api?command=addSecondaryStorage&zoneId=5&url=nfs%3A//nfs1.lab.vmops.com/export/home/chiradeep/secondary/&sessionkey=$sessionkey&response=json" +echo + +#register template + +#curl -b admincookie.txt -sS "http://localhost:8080/client/api?command=registerTemplate&displayText=Rightscale%20%ami-ccb35ea5&format=VHD&isPublic=true&name=Rightscale%20ami-ccb35ea5&osTypeId=11&passwordEnabled=false&url=http%3A//192.168.90.243/templates/zynga/ami-ccb35ea5.vhd.bz2&displayText=ZyngaRSTemplate&zoneId=1&ostypeid=12&sessionkey=$sessionkey&response=json" diff --git a/test/test.sh b/test/test.sh new file mode 100755 index 00000000000..830dd5634b6 --- /dev/null +++ b/test/test.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +sessionkey=$($(dirname $0)/createlogin.sh) +$(dirname $0)/setupzone.sh $sessionkey +$(dirname $0)/addhosts.sh $sessionkey