mirror of https://github.com/apache/cloudstack.git
marvin_refactor: working virtulmachine test
Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
parent
dcd96afd16
commit
cb35216f80
|
|
@ -16,10 +16,17 @@
|
|||
# under the License.
|
||||
import factory
|
||||
from marvin.integration.lib.base import Template
|
||||
class TemplateFactory(factory.Factory):
|
||||
from marvin.integration.lib.factory.CloudStackBaseFactory import CloudStackBaseFactory
|
||||
|
||||
FACTORY_FOR = Template
|
||||
class TemplateFactory(CloudStackBaseFactory):
|
||||
|
||||
FACTORY_FOR = Template.Template
|
||||
|
||||
displaytext = None
|
||||
name = None
|
||||
ostypeid = None
|
||||
|
||||
class DefaultBuiltInTemplateFactory(TemplateFactory):
|
||||
ostype = 'CentOS 5.3 (64-bit)'
|
||||
displaytext = 'CentOS 5.3 (64-bit)'
|
||||
name = 'CentOS 5.3 (64-bit)'
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
# under the License.
|
||||
import factory
|
||||
from marvin.integration.lib.base import User
|
||||
|
||||
class UserFactory(factory.Factory):
|
||||
|
||||
FACTORY_FOR = User
|
||||
|
|
|
|||
|
|
@ -14,11 +14,14 @@
|
|||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import factory
|
||||
from marvin.integration.lib.base import VirtualMachine
|
||||
class VirtualMachineFactory(factory.Factory):
|
||||
from marvin.integration.lib.factory.CloudStackBaseFactory import CloudStackBaseFactory
|
||||
|
||||
FACTORY_FOR = VirtualMachine
|
||||
class VirtualMachineFactory(CloudStackBaseFactory):
|
||||
|
||||
FACTORY_FOR = VirtualMachine.VirtualMachine
|
||||
|
||||
serviceofferingid = None
|
||||
templateid = None
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
import unittest
|
||||
from marvin.cloudstackTestClient import cloudstackTestClient
|
||||
from marvin.integration.lib.common import get_template
|
||||
|
||||
from marvin.integration.lib.factory.AccountFactory import *
|
||||
from marvin.integration.lib.base.Account import Account
|
||||
|
|
@ -27,6 +28,13 @@ from marvin.integration.lib.base.ServiceOffering import ServiceOffering
|
|||
from marvin.integration.lib.factory.NetworkOfferingFactory import *
|
||||
from marvin.integration.lib.base.NetworkOffering import NetworkOffering
|
||||
|
||||
from marvin.integration.lib.base.Zone import Zone
|
||||
|
||||
from marvin.integration.lib.factory.TemplateFactory import *
|
||||
|
||||
from marvin.integration.lib.factory.VirtualMachineFactory import *
|
||||
from marvin.integration.lib.base.VirtualMachine import VirtualMachine
|
||||
|
||||
class AccountFactoryTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.apiClient = cloudstackTestClient(mgtSvr='localhost').getApiClient()
|
||||
|
|
@ -92,4 +100,20 @@ class NetworkOfferingFactoryTest(unittest.TestCase):
|
|||
sgOffering.update(self.apiClient, state='Enabled')
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
pass
|
||||
|
||||
class VirtualMachineFactoryTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.apiClient = cloudstackTestClient(mgtSvr='localhost').getApiClient()
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_virtualMachineDeploy(self):
|
||||
sf = ServiceOfferingFactory()
|
||||
tf = DefaultBuiltInTemplateFactory()
|
||||
zones = Zone.list(apiclient=self.apiClient)
|
||||
template = get_template(apiclient=self.apiClient, zoneid = zones[0].id, ostype=tf.ostype)
|
||||
vmf = VirtualMachineFactory(serviceofferingid = sf.id, templateid = template.id, zoneid = zones[0].id)
|
||||
|
||||
vm = VirtualMachine.create(apiclient=self.apiClient, VirtualMachineFactory=vmf)
|
||||
|
|
@ -137,7 +137,8 @@ def write_entity_classes(entities):
|
|||
else:
|
||||
body.append(tabspace + 'def %s(self, apiclient, **kwargs):'%(action))
|
||||
body.append(tabspace*2 + 'cmd = %(module)s.%(command)s()'%{"module": details["apimodule"], "command": details["apicmd"]})
|
||||
body.append(tabspace*2 + 'cmd.id = self.id')
|
||||
if action not in ['create', 'list', 'deploy']:
|
||||
body.append(tabspace*2 + 'cmd.id = self.id')
|
||||
for arg in details['args']:
|
||||
body.append(tabspace*2 + 'cmd.%s = %s'%(arg, arg))
|
||||
body.append(tabspace*2 + '[setattr(cmd, key, value) for key,value in kwargs.iteritems()]')
|
||||
|
|
|
|||
Loading…
Reference in New Issue