[pkg-eucalyptus-commits] [SCM] managing cloud instances for Eucalyptus branch, master, updated. 3.0.0-alpha3-257-g1da8e3a

Garrett Holmstrom gholms at fedoraproject.org
Sun Jun 16 02:30:21 UTC 2013


The following commit has been merged in the master branch:
commit 13d3ac907584603bcfc2e46358a8648dc95c0bf6
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date:   Tue Feb 19 17:30:01 2013 -0800

    Port GetAccountPolicy

diff --git a/bin/euare-accountgetpolicy b/bin/euare-accountgetpolicy
index c4b4203..2d854cb 100755
--- a/bin/euare-accountgetpolicy
+++ b/bin/euare-accountgetpolicy
@@ -1,7 +1,6 @@
-#!/usr/bin/python
+#!/usr/bin/python -tt
 
 import euca2ools.commands.euare.getaccountpolicy
 
 if __name__ == '__main__':
-    r = euca2ools.commands.euare.getaccountpolicy.GetAccountPolicy()
-    r.main_cli()
+    euca2ools.commands.euare.getaccountpolicy.GetAccountPolicy.run()
diff --git a/euca2ools/commands/euare/getaccountpolicy.py b/euca2ools/commands/euare/getaccountpolicy.py
index 139f00a..75623c7 100644
--- a/euca2ools/commands/euare/getaccountpolicy.py
+++ b/euca2ools/commands/euare/getaccountpolicy.py
@@ -1,6 +1,6 @@
 # Software License Agreement (BSD License)
 #
-# Copyright (c) 2009-2011, Eucalyptus Systems, Inc.
+# Copyright (c) 2009-2013, Eucalyptus Systems, Inc.
 # All rights reserved.
 #
 # Redistribution and use of this software in source and binary forms, with or
@@ -27,43 +27,26 @@
 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
-#
-# Author: Neil Soman neil at eucalyptus.com
-#         Mitch Garnaat mgarnaat at eucalyptus.com
-
-from boto.roboto.awsqueryrequest import AWSQueryRequest
-from boto.roboto.param import Param
-import euca2ools.commands.euare
-import euca2ools.utils
-
-
-class GetAccountPolicy(AWSQueryRequest):
-
-    ServiceClass = euca2ools.commands.euare.Euare
-
-    Description = """GetAccountPolicy"""
-    Params = [Param(
-        name='AccountName',
-        short_name='a',
-        long_name='account-name',
-        ptype='string',
-        optional=False,
-        doc=""" Name of the account the policy is associated with. """,
-        ), Param(
-        name='PolicyName',
-        short_name='p',
-        long_name='policy-name',
-        ptype='string',
-        optional=False,
-        doc=""" Name of the policy document to get. """,
-        )]
-
-    def cli_formatter(self, data):
-        print data.PolicyDocument
-
-    def main(self, **args):
-        return self.send(**args)
 
-    def main_cli(self):
-        euca2ools.utils.print_version_if_necessary()
-        self.do_cli()
+import json
+from requestbuilder import Arg
+import urllib
+from . import EuareRequest
+
+
+class GetAccountPolicy(EuareRequest):
+    DESCRIPTION = "Display an account's policy"
+    ARGS = [Arg('-a', '--account-name', dest='AccountName', metavar='ACCOUNT',
+                required=True,
+                help='account the policy is attached to (required)'),
+            Arg('-p', '--policy-name', dest='PolicyName', metavar='POLICY',
+                required=True, help='name of the policy to show (required)'),
+            Arg('--pretty-print', action='store_true', route_to=None,
+                help='reformat the policy for easier reading')]
+
+    def print_result(self, result):
+        policy_content = urllib.unquote(result['PolicyDocument'])
+        if self.args['pretty_print']:
+            policy_json = json.loads(policy_content)
+            policy_content = json.dumps(policy_json, indent=4)
+        print policy_content

-- 
managing cloud instances for Eucalyptus



More information about the pkg-eucalyptus-commits mailing list