You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ts...@apache.org on 2013/10/02 18:42:07 UTC
[37/50] [abbrv] git commit: updated refs/heads/marvin-refactor to
bbaf354
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 <ts...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9f759a8a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9f759a8a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9f759a8a
Branch: refs/heads/marvin-refactor
Commit: 9f759a8ae9ba5fc3757d111618117d5e348b8333
Parents: 7d4b35d
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Mon Sep 30 09:53:19 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Wed Oct 2 20:28:00 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/9f759a8a/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/9f759a8a/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'