# Copyright 2012 Citrix Systems, Inc. Licensed under the # Apache License, Version 2.0 (the "License"); you may not use this # file except in compliance with the License. Citrix Systems, Inc. # reserves all rights not expressly granted by the License. # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Automatically generated by addcopyright.py at 04/03/2012 from cloudstackTestCase import * #@UserName('user', 'LEAF', 0) #@UserName('user0', 'LEAF', 0) #@UserName('user', 'LEAF0', 0) #@UserName('admin', 'ROOT', 1) @UserName('domadmin', 'LEAF0', 2) class TestUserDecorator(cloudstackTestCase): def test_listUserTemplates(self): apiClient = self.testClient.getApiClient() listtmcmd = listTemplates.listTemplatesCmd() listtmcmd.zoneid = 1 listtmcmd.templatefilter = "self" listtmresponse = apiClient.listTemplates(listtmcmd) if listtmresponse is not None: self.assertEqual(len(listtmresponse), 0, "there should be no user created templates") self.debug("%d user templates found"%len(listtmresponse)) def test_listFeaturedTemplates(self): apiClient = self.testClient.getApiClient() listtmcmd = listTemplates.listTemplatesCmd() listtmcmd.zoneid = 1 listtmcmd.templatefilter = "featured" listtmresponse = apiClient.listTemplates(listtmcmd) if listtmresponse is not None: self.assertNotEqual(len(listtmresponse), 0, "there should default featured templates") self.debug("%d featured templates found"%len(listtmresponse)) return listtmresponse[0].id def test_listVirtualMachines(self): apiClient = self.testClient.getApiClient() listvmcmd = listVirtualMachines.listVirtualMachinesCmd() listvmcmd.zoneid = 1 listvmcmd.state = "Running" listvmresponse = apiClient.listVirtualMachines(listvmcmd) if listvmresponse is not None and len(listvmresponse) > 0: self.debug("%d running VMs found"%len(listvmresponse)) else: self.debug("No Vms Found") def test_deployVM(self): apiClient = self.testClient.getApiClient() listzones = listZones.listZonesCmd() listzoneres = apiClient.listZones(listzones) zoneid = listzoneres[0].id listservice = listServiceOfferings.listServiceOfferingsCmd() listserviceres = apiClient.listServiceOfferings(listservice) serviceofferingid = listserviceres[0].id deploycmd = deployVirtualMachine.deployVirtualMachineCmd() deploycmd.displayname = "testVm" deploycmd.templateid = self.test_listFeaturedTemplates() deploycmd.zoneid = zoneid deploycmd.serviceofferingid = serviceofferingid apiClient.deployVirtualMachine(deploycmd)