cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [33/50] [abbrv] git commit: updated refs/heads/marvin_refactor to b784012
Date Mon, 18 Nov 2013 08:50:40 GMT
marvin_refactor: security group splits into ingress/egress

@also Include the apiclient as part of the factory instantiation so
there is not redundant parameter when dealing with the object after it
is generated by the factory.

Signed-off-by: Prasanna Santhanam <tsp@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/2bb1533a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/2bb1533a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/2bb1533a

Branch: refs/heads/marvin_refactor
Commit: 2bb1533a8e046e872223a5b3ec04ef2d091e8fd2
Parents: ec09163
Author: Prasanna Santhanam <tsp@apache.org>
Authored: Mon Sep 30 09:53:19 2013 +0530
Committer: Prasanna Santhanam <tsp@apache.org>
Committed: Thu Oct 31 13:54:25 2013 +0530

----------------------------------------------------------------------
 tools/marvin/marvin/generate/entity.py   | 30 +++++++++++++++++++++------
 tools/marvin/marvin/generate/linguist.py | 10 +++++++++
 2 files changed, 34 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2bb1533a/tools/marvin/marvin/generate/entity.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/generate/entity.py b/tools/marvin/marvin/generate/entity.py
index 2d7b627..f9d63dc 100644
--- a/tools/marvin/marvin/generate/entity.py
+++ b/tools/marvin/marvin/generate/entity.py
@@ -103,14 +103,32 @@ class Entity(object):
             #TODO: doc to explain what possible args go into **kwargs
             m.docstring = 'Placeholder for docstring\n' + 'optional arguments (**kwargs):
[%s]"""' % ', '.join(
                 details['optionals'])
-            if not m.is_creator():
-                # remove the id arg as id is the self (object) itself
-                no_id_args = filter(lambda arg: arg != 'id', details['args'])
+            # remove the id arg as id is the self (object) itself
+            no_id_args = filter(lambda arg: arg != 'id', details['args'])
+            if m.is_enumerator():
+                m.signature = 'def %s(cls, apiclient=None, **kwargs):' % (action)
+                m.body.append(self.tabspace + 'cmd = %(module)s.%(command)s()' % {"module":
details["apimodule"],
+                                                                                 "command":
details["apicmd"]})
+                m.body.append(self.tabspace + '[setattr(cmd, key, value) for key, value in
kwargs.iteritems()]')
+                m.body.append(self.tabspace + 'if apiclient:')
+                m.body.append(self.tabspace*2 + '%s = apiclient.%s(cmd)' % (entity.lower(),
details['apimodule']))
+                m.body.append(self.tabspace + 'else:')
+                m.body.append(self.tabspace*2 + '%s = cls.apiclient.%s(cmd)' % (entity.lower(),
details['apimodule']))
+                m.body.append(self.tabspace + '%s = map(lambda e: %s().__update__(e.__dict__),
%s) '
+                                              'if %s and len(%s) > 0 else None' % ( entity.lower(),
+                                                                                    entity,
entity.lower(),
+                                                                                    entity.lower(),
entity.lower()))
+                m.body.append(
+                    self.tabspace + '%s = map(lambda e: e.__update__({\'apiclient\': apiclient
if apiclient else cls.apiclient}), %s) if %s else None' % (
+                    entity.lower(), entity.lower(), entity.lower())
+                                  )
+                m.body.append(self.tabspace + 'return %s' % entity.lower())
+            elif not m.is_creator():
                 if len(no_id_args) > 0: # at least one required non-id argument
-                    m.signature = 'def %s(self, apiclient, %s, **kwargs):'\
+                    m.signature = 'def %s(self, %s, **kwargs):'\
                     % (action, ', '.join(list(set(no_id_args))))
                 else:
-                    m.signature = 'def %s(self, apiclient, **kwargs):' % (action)
+                    m.signature = 'def %s(self, **kwargs):' % (action)
                 m.body.append(self.tabspace + 'cmd = %(module)s.%(command)s()' % {"module":
details["apimodule"],
                                                                                  "command":
details["apicmd"]})
                 if 'id' in details['args']:
@@ -118,7 +136,7 @@ class Entity(object):
                 for arg in no_id_args:
                     m.body.append(self.tabspace + 'cmd.%s = %s' % (arg, arg))
                 m.body.append(self.tabspace + '[setattr(cmd, key, value) for key, value in
kwargs.iteritems()]')
-                m.body.append(self.tabspace + '%s = apiclient.%s(cmd)' % (entity.lower(),
details['apimodule']))
+                m.body.append(self.tabspace + '%s = self.apiclient.%s(cmd)' % (entity.lower(),
details['apimodule']))
                 if m.is_enumerator():
                     m.body.append(self.tabspace +
                                   'return map(lambda e: %s().__update__(e.__dict__), %s)
'

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2bb1533a/tools/marvin/marvin/generate/linguist.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/generate/linguist.py b/tools/marvin/marvin/generate/linguist.py
index ec1f693..5e7b1c3 100644
--- a/tools/marvin/marvin/generate/linguist.py
+++ b/tools/marvin/marvin/generate/linguist.py
@@ -39,6 +39,14 @@ def transform_api(api):
         return 'login', 'CloudStack'
     elif api == 'logout':
         return 'logout', 'CloudStack'
+    elif api == 'authorizeSecurityGroupIngress':
+        return 'authorizeSecurityGroupIngress', 'SecurityGroup'
+    elif api == 'authorizeSecurityGroupEgress':
+        return 'authorizeSecurityGroupEgress', 'SecurityGroup'
+    elif api == 'revokeSecurityGroupIngress':
+        return 'revokeSecurityGroupIngress', 'SecurityGroup'
+    elif api == 'revokeSecurityGroupEgress':
+        return 'revokeSecurityGroupEgress', 'SecurityGroup'
     return api, None
 
 def verb_adjust(api, entity):
@@ -89,6 +97,8 @@ def entity_adjust(entity):
         return 'UserKeys'
     elif entity == 'FirewallRule':
         return 'Firewall'
+    elif entity == 'SecurityGroupRule':
+        return 'SecurityGroup'
     #Cloudstack maintains Template/ISO/Volume as single Image type
     #elif entity in ['Template', 'Volume']:
     #    return 'Image'


Mime
View raw message