diff --git a/patches/systemvm/debian/config/root/edithosts.sh b/patches/systemvm/debian/config/root/edithosts.sh index 478ce4ba552..506c5e68b48 100755 --- a/patches/systemvm/debian/config/root/edithosts.sh +++ b/patches/systemvm/debian/config/root/edithosts.sh @@ -67,6 +67,33 @@ sed -i /"$2 "/d /etc/hosts sed -i /"$3"/d /etc/hosts echo "$2 $3" >> /etc/hosts +locked=0 +if [ $no_redundant -eq 0 ] +then +#for redundant router, grap the lock to prevent racy with keepalived process +LOCK=/tmp/rrouter.lock + +# Wait the lock +for i in `seq 1 5` +do + if [ ! -e $LOCK ] + then + touch $LOCK + locked=1 + break + fi + sleep 1 + logger -t cloud "edithosts: sleep 1 second wait for the redundant router lock" +done + +if [ $locked -eq 0 ] +then + logger -t cloud "edithosts: fail to get the redundant router lock" + logger -t cloud "edithosts: keepalived should able to handle the dnsmasq restart" + exit +fi +fi + # make dnsmasq re-read files pid=$(pidof dnsmasq) if [ "$pid" != "" ] @@ -81,4 +108,10 @@ else fi fi -exit $? +ret=$? +if [ $locked -eq 1 ] +then + rm $LOCK +fi + +exit $ret diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index dde0e29703b..a8341fa0b0e 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -486,7 +486,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager } // Check that the volume is stored on shared storage - if (!_storageMgr.volumeOnSharedStoragePool(volume)) { + if (!(Volume.State.Allocated.equals(volume.getState())) && !_storageMgr.volumeOnSharedStoragePool(volume)) { throw new InvalidParameterValueException("Please specify a volume that has been created on a shared storage pool."); } diff --git a/tools/testClient/cloudstackTestCase.py b/tools/testClient/cloudstackTestCase.py new file mode 100644 index 00000000000..39696b2ca9f --- /dev/null +++ b/tools/testClient/cloudstackTestCase.py @@ -0,0 +1,7 @@ +from cloudstackAPI import * +import unittest +import cloudstackTestClient +class cloudstackTestCase(unittest.case.TestCase): + def __init__(self, args): + unittest.case.TestCase.__init__(self, args) + self.testClient = cloudstackTestClient.cloudstackTestClient() diff --git a/tools/testClient/cloudstackTestClient.py b/tools/testClient/cloudstackTestClient.py index 1c2aad5ee49..28aef44b4bd 100644 --- a/tools/testClient/cloudstackTestClient.py +++ b/tools/testClient/cloudstackTestClient.py @@ -4,7 +4,7 @@ import dbConnection from cloudstackAPI import * class cloudstackTestClient(object): - def __init__(self, mgtSvr, port=8096, apiKey = None, securityKey = None, asyncTimeout=3600, defaultWorkerThreads=10, logging=None): + def __init__(self, mgtSvr=None, port=8096, apiKey = None, securityKey = None, asyncTimeout=3600, defaultWorkerThreads=10, logging=None): self.connection = cloudstackConnection.cloudConnection(mgtSvr, port, apiKey, securityKey, asyncTimeout, logging) self.apiClient = cloudstackAPIClient.CloudStackAPIClient(self.connection) self.dbConnection = None @@ -15,7 +15,7 @@ class cloudstackTestClient(object): def dbConfigure(self, host="localhost", port=3306, user='cloud', passwd='cloud', db='cloud'): self.dbConnection = dbConnection.dbConnection(host, port, user, passwd, db) - self.asyncJobMgr = asyncJobMgr.asyncJobMgr(self.apiClient, self.dbConnection) + def getDbConnection(self): return self.dbConnection @@ -36,10 +36,10 @@ class cloudstackTestClient(object): def submitCmdsAndWait(self, cmds): if self.asyncJobMgr is None: - return None + self.asyncJobMgr = asyncJobMgr.asyncJobMgr(self.apiClient, self.dbConnection) return self.asyncJobMgr.submitCmdsAndWait(cmds) def submitJobs(self, job, ntimes=1, nums_threads=10, interval=1): if self.asyncJobMgr is None: - return None + self.asyncJobMgr = asyncJobMgr.asyncJobMgr(self.apiClient, self.dbConnection) self.asyncJobMgr.submitJobs(job, ntimes, nums_threads, interval) \ No newline at end of file diff --git a/tools/testClient/testcase/test_1.py b/tools/testClient/testcase/test_1.py index a2f7a0305fb..a97bbb3b916 100644 --- a/tools/testClient/testcase/test_1.py +++ b/tools/testClient/testcase/test_1.py @@ -1,8 +1,6 @@ -import unittest -import random -from cloudstackAPI import * +from cloudstackTestCase import * -class TestCase1(unittest.case.TestCase): +class TestCase1(cloudstackTestCase): def test_cloudstackapi(self): apiClient = self.testClient.getApiClient() diff --git a/tools/testClient/testcase/test_2.py b/tools/testClient/testcase/test_2.py index c86cf1158a9..f9937b83e72 100644 --- a/tools/testClient/testcase/test_2.py +++ b/tools/testClient/testcase/test_2.py @@ -1,7 +1,5 @@ -import unittest -import random -from cloudstackAPI import * -class TestCase2(unittest.case.TestCase): +from cloudstackTestCase import * +class TestCase2(cloudstackTestCase): def test_cloudstackapi1(self): apiClient = self.testClient.getApiClient() diff --git a/tools/testClient/testcase/test_3.py b/tools/testClient/testcase/test_3.py new file mode 100644 index 00000000000..676bf7a5fae --- /dev/null +++ b/tools/testClient/testcase/test_3.py @@ -0,0 +1,49 @@ +from cloudstackTestCase import * +import uuid +class TestCase1(cloudstackTestCase): + def setUp(self): + '''get a small service offering id''' + listsocmd = listServiceOfferings.listServiceOfferingsCmd() + listsocmd.name = "Small Instance" + listsocmd.issystem = "false" + sos = self.testClient.getApiClient().listServiceOfferings(listsocmd) + if sos is not None and len(sos) > 0: + self.svid = sos[0].id + listdiskovcmd = listDiskOfferings.listDiskOfferingsCmd() + listdiskovcmd.name = "Small" + disoov = self.testClient.getApiClient().listDiskOfferings(listdiskovcmd) + if disoov is not None and len(disoov) > 0: + self.diskov = disoov[0].id + + '''get user vm template id''' + listtmplcmd = listTemplates.listTemplatesCmd() + listtmplcmd.templatefilter = "featured" + tmpls = self.testClient.getApiClient().listTemplates(listtmplcmd) + if tmpls is not None: + for tmpl in tmpls: + if tmpl.isready == "true": + self.templateId = tmpl.id + self.zoneId = tmpl.zoneid + break + + def test_cloudstackapi(self): + apiClient = self.testClient.getApiClient() + + createvm = deployVirtualMachine.deployVirtualMachineCmd() + createvm.serviceofferingid = self.svid + createvm.templateid = self.templateId + createvm.zoneid = self.zoneId + vm = apiClient.deployVirtualMachine(createvm) + vmId = vm.id + + creatvolume = createVolume.createVolumeCmd() + creatvolume.name = "tetst" + str(uuid.uuid4()) + creatvolume.diskofferingid = self.diskov + creatvolume.zoneid = self.zoneId + createvolumeresponse = apiClient.createVolume(creatvolume) + volumeId = createvolumeresponse.id + attach = attachVolume.attachVolumeCmd() + + attach.id = volumeId + attach.virtualmachineid = vmId + apiClient.attachVolume(attach) \ No newline at end of file diff --git a/ui/scripts/cloud.core.volume.js b/ui/scripts/cloud.core.volume.js index 7be56e135c5..84057143a79 100644 --- a/ui/scripts/cloud.core.volume.js +++ b/ui/scripts/cloud.core.volume.js @@ -433,7 +433,7 @@ function volumeJsonToDetailsTab(){ $thisTab.find("#vm_name").text(getVmName(jsonObj.vmname, jsonObj.vmdisplayname) + " (" + fromdb(jsonObj.vmstate) + ")"); setDateField(jsonObj.created, $thisTab.find("#created")); - if(isAdmin() || isDomainAdmin()) { + if(isAdmin()) { $thisTab.find("#storage").text(fromdb(jsonObj.storage)); $thisTab.find("#storage_container").show(); }