incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [32/42] marvin-refactor: create takes factories not reqd args
Date Fri, 01 Mar 2013 10:06:30 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/TrafficMonitor.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/TrafficMonitor.py b/tools/marvin/marvin/integration/lib/base/TrafficMonitor.py
index 4d6f06d..6c4a8a3 100644
--- a/tools/marvin/marvin/integration/lib/base/TrafficMonitor.py
+++ b/tools/marvin/marvin/integration/lib/base/TrafficMonitor.py
@@ -17,10 +17,15 @@
 from . import CloudStackEntity
 class TrafficMonitor(CloudStackEntity):
 
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
     def add(self, apiclient, url, zoneid, **kwargs):
         pass
 
-    def list(self, apiclient, zoneid, **kwargs):
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 
     def delete(self, apiclient, id, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/TrafficType.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/TrafficType.py b/tools/marvin/marvin/integration/lib/base/TrafficType.py
index facc145..bc4ac2e 100644
--- a/tools/marvin/marvin/integration/lib/base/TrafficType.py
+++ b/tools/marvin/marvin/integration/lib/base/TrafficType.py
@@ -17,10 +17,15 @@
 from . import CloudStackEntity
 class TrafficType(CloudStackEntity):
 
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
     def add(self, apiclient, traffictype, physicalnetworkid, **kwargs):
         pass
 
-    def list(self, apiclient, physicalnetworkid, **kwargs):
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 
     def update(self, apiclient, id, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/TrafficTypeImplementors.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/TrafficTypeImplementors.py b/tools/marvin/marvin/integration/lib/base/TrafficTypeImplementors.py
index 28b1b27..24d6bfe 100644
--- a/tools/marvin/marvin/integration/lib/base/TrafficTypeImplementors.py
+++ b/tools/marvin/marvin/integration/lib/base/TrafficTypeImplementors.py
@@ -17,6 +17,11 @@
 from . import CloudStackEntity
 class TrafficTypeImplementors(CloudStackEntity):
 
-    def list(self, apiclient, **kwargs):
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/UsageRecords.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/UsageRecords.py b/tools/marvin/marvin/integration/lib/base/UsageRecords.py
index 1892519..f7800e2 100644
--- a/tools/marvin/marvin/integration/lib/base/UsageRecords.py
+++ b/tools/marvin/marvin/integration/lib/base/UsageRecords.py
@@ -17,7 +17,12 @@
 from . import CloudStackEntity
 class UsageRecords(CloudStackEntity):
 
-    def list(self, apiclient, startdate, enddate, **kwargs):
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 
     def generate(self, apiclient, startdate, enddate, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/UsageTypes.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/UsageTypes.py b/tools/marvin/marvin/integration/lib/base/UsageTypes.py
index 49dd950..c6585fc 100644
--- a/tools/marvin/marvin/integration/lib/base/UsageTypes.py
+++ b/tools/marvin/marvin/integration/lib/base/UsageTypes.py
@@ -17,6 +17,11 @@
 from . import CloudStackEntity
 class UsageTypes(CloudStackEntity):
 
-    def list(self, apiclient):
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
+    @classmethod
+    def list(cls, apiclient):
         pass
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/User.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/User.py b/tools/marvin/marvin/integration/lib/base/User.py
index f494e2a..7b1dcb5 100644
--- a/tools/marvin/marvin/integration/lib/base/User.py
+++ b/tools/marvin/marvin/integration/lib/base/User.py
@@ -17,6 +17,10 @@
 from . import CloudStackEntity
 class User(CloudStackEntity):
 
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
     def enable(self, apiclient, id, **kwargs):
         pass
 
@@ -26,10 +30,12 @@ class User(CloudStackEntity):
     def lock(self, apiclient, id, **kwargs):
         pass
 
-    def create(self, apiclient, UserFactory, username, account, firstname, lastname, password,
email, **kwargs):
+    @classmethod
+    def create(cls, apiclient, UserFactory, **kwargs):
         pass
 
-    def list(self, apiclient, **kwargs):
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 
     def update(self, apiclient, id, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/UserKeys.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/UserKeys.py b/tools/marvin/marvin/integration/lib/base/UserKeys.py
index d4980ad..560d65b 100644
--- a/tools/marvin/marvin/integration/lib/base/UserKeys.py
+++ b/tools/marvin/marvin/integration/lib/base/UserKeys.py
@@ -17,6 +17,10 @@
 from . import CloudStackEntity
 class UserKeys(CloudStackEntity):
 
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
     def register(self, apiclient, id, **kwargs):
         pass
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/VMPassword.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/VMPassword.py b/tools/marvin/marvin/integration/lib/base/VMPassword.py
index acf6e65..854d309 100644
--- a/tools/marvin/marvin/integration/lib/base/VMPassword.py
+++ b/tools/marvin/marvin/integration/lib/base/VMPassword.py
@@ -17,6 +17,10 @@
 from . import CloudStackEntity
 class VMPassword(CloudStackEntity):
 
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
     def get(self, apiclient, id, **kwargs):
         pass
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/VPC.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/VPC.py b/tools/marvin/marvin/integration/lib/base/VPC.py
index 2661fbf..ef6a470 100644
--- a/tools/marvin/marvin/integration/lib/base/VPC.py
+++ b/tools/marvin/marvin/integration/lib/base/VPC.py
@@ -17,10 +17,16 @@
 from . import CloudStackEntity
 class VPC(CloudStackEntity):
 
-    def create(self, apiclient, VPCFactory, cidr, zoneid, displaytext, name, vpcofferingid,
**kwargs):
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
+    @classmethod
+    def create(cls, apiclient, VPCFactory, **kwargs):
         pass
 
-    def list(self, apiclient, **kwargs):
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 
     def update(self, apiclient, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/VPCOffering.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/VPCOffering.py b/tools/marvin/marvin/integration/lib/base/VPCOffering.py
index bdfd40c..52af1f6 100644
--- a/tools/marvin/marvin/integration/lib/base/VPCOffering.py
+++ b/tools/marvin/marvin/integration/lib/base/VPCOffering.py
@@ -17,10 +17,16 @@
 from . import CloudStackEntity
 class VPCOffering(CloudStackEntity):
 
-    def create(self, apiclient, VPCOfferingFactory, displaytext, name, supportedservices,
**kwargs):
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
+    @classmethod
+    def create(cls, apiclient, VPCOfferingFactory, **kwargs):
         pass
 
-    def list(self, apiclient, **kwargs):
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 
     def update(self, apiclient, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/VirtualMachine.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/VirtualMachine.py b/tools/marvin/marvin/integration/lib/base/VirtualMachine.py
index a8fab46..5479a7e 100644
--- a/tools/marvin/marvin/integration/lib/base/VirtualMachine.py
+++ b/tools/marvin/marvin/integration/lib/base/VirtualMachine.py
@@ -17,16 +17,22 @@
 from . import CloudStackEntity
 class VirtualMachine(CloudStackEntity):
 
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
     def restore(self, apiclient, virtualmachineid, **kwargs):
         pass
 
-    def deploy(self, apiclient, zoneid, serviceofferingid, templateid, **kwargs):
+    @classmethod
+    def deploy(cls, apiclient, VirtualMachineFactory, **kwargs):
         pass
 
     def migrate(self, apiclient, virtualmachineid, **kwargs):
         pass
 
-    def list(self, apiclient, **kwargs):
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 
     def stop(self, apiclient, id, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/VirtualRouterElement.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/VirtualRouterElement.py b/tools/marvin/marvin/integration/lib/base/VirtualRouterElement.py
index 74ba5a5..1012f0d 100644
--- a/tools/marvin/marvin/integration/lib/base/VirtualRouterElement.py
+++ b/tools/marvin/marvin/integration/lib/base/VirtualRouterElement.py
@@ -17,10 +17,16 @@
 from . import CloudStackEntity
 class VirtualRouterElement(CloudStackEntity):
 
-    def create(self, apiclient, VirtualRouterElementFactory, nspid, **kwargs):
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
+    @classmethod
+    def create(cls, apiclient, VirtualRouterElementFactory, **kwargs):
         pass
 
-    def list(self, apiclient, **kwargs):
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 
     def configure(self, apiclient, enabled, id, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/VlanIpRange.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/VlanIpRange.py b/tools/marvin/marvin/integration/lib/base/VlanIpRange.py
index 79f4bcd..5cfb622 100644
--- a/tools/marvin/marvin/integration/lib/base/VlanIpRange.py
+++ b/tools/marvin/marvin/integration/lib/base/VlanIpRange.py
@@ -17,10 +17,16 @@
 from . import CloudStackEntity
 class VlanIpRange(CloudStackEntity):
 
-    def create(self, apiclient, VlanIpRangeFactory, startip, **kwargs):
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
+    @classmethod
+    def create(cls, apiclient, VlanIpRangeFactory, **kwargs):
         pass
 
-    def list(self, apiclient, **kwargs):
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 
     def delete(self, apiclient, id, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/Volume.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/Volume.py b/tools/marvin/marvin/integration/lib/base/Volume.py
index fa3c271..0a4fb4d 100644
--- a/tools/marvin/marvin/integration/lib/base/Volume.py
+++ b/tools/marvin/marvin/integration/lib/base/Volume.py
@@ -17,13 +17,19 @@
 from . import CloudStackEntity
 class Volume(CloudStackEntity):
 
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
     def migrate(self, apiclient, storageid, volumeid, **kwargs):
         pass
 
-    def create(self, apiclient, VolumeFactory, name, **kwargs):
+    @classmethod
+    def create(cls, apiclient, VolumeFactory, **kwargs):
         pass
 
-    def list(self, apiclient, **kwargs):
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 
     def upload(self, apiclient, url, zoneid, name, format, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/VpnConnection.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/VpnConnection.py b/tools/marvin/marvin/integration/lib/base/VpnConnection.py
index 95eba9c..0bf2df4 100644
--- a/tools/marvin/marvin/integration/lib/base/VpnConnection.py
+++ b/tools/marvin/marvin/integration/lib/base/VpnConnection.py
@@ -17,13 +17,19 @@
 from . import CloudStackEntity
 class VpnConnection(CloudStackEntity):
 
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
     def reset(self, apiclient, id, **kwargs):
         pass
 
-    def create(self, apiclient, VpnConnectionFactory, s2scustomergatewayid, s2svpngatewayid,
**kwargs):
+    @classmethod
+    def create(cls, apiclient, VpnConnectionFactory, **kwargs):
         pass
 
-    def list(self, apiclient, **kwargs):
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 
     def delete(self, apiclient, id, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/VpnCustomerGateway.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/VpnCustomerGateway.py b/tools/marvin/marvin/integration/lib/base/VpnCustomerGateway.py
index 40c661e..ad76f8c 100644
--- a/tools/marvin/marvin/integration/lib/base/VpnCustomerGateway.py
+++ b/tools/marvin/marvin/integration/lib/base/VpnCustomerGateway.py
@@ -17,10 +17,16 @@
 from . import CloudStackEntity
 class VpnCustomerGateway(CloudStackEntity):
 
-    def create(self, apiclient, VpnCustomerGatewayFactory, ipsecpsk, cidrlist, esppolicy,
ikepolicy, gateway, **kwargs):
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
+    @classmethod
+    def create(cls, apiclient, VpnCustomerGatewayFactory, **kwargs):
         pass
 
-    def list(self, apiclient, **kwargs):
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 
     def update(self, apiclient, ikepolicy, cidrlist, gateway, ipsecpsk, esppolicy, id, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/VpnGateway.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/VpnGateway.py b/tools/marvin/marvin/integration/lib/base/VpnGateway.py
index 2ba149f..974a3da 100644
--- a/tools/marvin/marvin/integration/lib/base/VpnGateway.py
+++ b/tools/marvin/marvin/integration/lib/base/VpnGateway.py
@@ -17,10 +17,16 @@
 from . import CloudStackEntity
 class VpnGateway(CloudStackEntity):
 
-    def create(self, apiclient, VpnGatewayFactory, vpcid, **kwargs):
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
+    @classmethod
+    def create(cls, apiclient, VpnGatewayFactory, **kwargs):
         pass
 
-    def list(self, apiclient, **kwargs):
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 
     def delete(self, apiclient, id, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/VpnUser.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/VpnUser.py b/tools/marvin/marvin/integration/lib/base/VpnUser.py
index 7f8a260..a277ab0 100644
--- a/tools/marvin/marvin/integration/lib/base/VpnUser.py
+++ b/tools/marvin/marvin/integration/lib/base/VpnUser.py
@@ -17,10 +17,15 @@
 from . import CloudStackEntity
 class VpnUser(CloudStackEntity):
 
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
     def add(self, apiclient, username, password, **kwargs):
         pass
 
-    def list(self, apiclient, **kwargs):
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 
     def remove(self, apiclient, username, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/base/Zone.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base/Zone.py b/tools/marvin/marvin/integration/lib/base/Zone.py
index d663eec..530c5b6 100644
--- a/tools/marvin/marvin/integration/lib/base/Zone.py
+++ b/tools/marvin/marvin/integration/lib/base/Zone.py
@@ -17,10 +17,16 @@
 from . import CloudStackEntity
 class Zone(CloudStackEntity):
 
-    def create(self, apiclient, ZoneFactory, networktype, dns1, internaldns1, name, **kwargs):
+    def __init__(self, items):
+        self.__dict__.update(items)
+
+
+    @classmethod
+    def create(cls, apiclient, ZoneFactory, **kwargs):
         pass
 
-    def list(self, apiclient, **kwargs):
+    @classmethod
+    def list(cls, apiclient, **kwargs):
         pass
 
     def update(self, apiclient, id, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/factory/AccountFactory.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/factory/AccountFactory.py b/tools/marvin/marvin/integration/lib/factory/AccountFactory.py
index f32979b..0e5428f 100644
--- a/tools/marvin/marvin/integration/lib/factory/AccountFactory.py
+++ b/tools/marvin/marvin/integration/lib/factory/AccountFactory.py
@@ -15,14 +15,31 @@
 # specific language governing permissions and limitations
 # under the License.
 import factory
+import hashlib
 from marvin.integration.lib.base import Account
+from marvin.integration.lib.utils import random_gen
+
 class AccountFactory(factory.Factory):
 
     FACTORY_FOR = Account
 
-    accounttype = None
-    email = None
-    firstname = None
-    lastname = None
-    password = None
+    #0 - User, 1 - Root Admin, 2 - Domain Admin
+    accounttype = 0
+    email = factory.LazyAttribute(lambda e: '{0}.{1}@cloudstack.org'.format(e.firstname,
e.lastname)).lower()
+    firstname = 'fname-'+random_gen()
+    lastname = 'lname-'+random_gen()
     username = None
+
+    # Password Encoding
+    mdf = hashlib.md5()
+    mdf.update('password')
+    password = mdf.hexdigest()
+
+
+class AdminAccountFactory(AccountFactory):
+    accounttype = 1
+
+
+class DomainAdminFactory(AccountFactory):
+    accounttype = 2
+    domainid = None

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d4124c5/tools/marvin/marvin/integration/lib/generateBase.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/generateBase.py b/tools/marvin/marvin/integration/lib/generateBase.py
index 3e3dc79..d4f718c 100644
--- a/tools/marvin/marvin/integration/lib/generateBase.py
+++ b/tools/marvin/marvin/integration/lib/generateBase.py
@@ -110,15 +110,22 @@ def write_entity_classes(entities):
     for entity, actions in entities.iteritems():
         code = 'from . import CloudStackEntity\n'
         code += 'class %s(CloudStackEntity):'%entity
+        code += '\n\n'
+        code += tabspace + 'def __init__(self, items):\n'
+        code += tabspace*2 + 'self.__dict__.update(items)\n'
         for action, args in actions.iteritems():
             code += '\n\n'
+            if action in ['create', 'list', 'deploy']:
+                code += tabspace + '@classmethod\n'
             code += tabspace
-            if action.startswith('create'):
-                code += 'def %s(self, apiclient, %sFactory'%(action, entity)
+            if action in ['create', 'deploy']:
+                code += 'def %s(cls, apiclient, %sFactory'%(action, entity)
+            elif action in ['list']:
+                code += 'def %s(cls, apiclient'%(action)
             else:
                 code += 'def %s(self, apiclient'%(action)
-            if len(args[0]) > 0:
-                code += ', ' + ', '.join(list(set(args[0])))
+                if len(args[0]) > 0:
+                    code += ', ' + ', '.join(list(set(args[0])))
             if len(args[1]) > 0:
                 code += ', **kwargs):\n'
             else:


Mime
View raw message