libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erjoh...@apache.org
Subject libcloud git commit: [google] flip logic on GCE demo script flags and add clean-up arg
Date Wed, 15 Jul 2015 20:27:12 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 2b01bc369 -> 0efa5b783


[google] flip logic on GCE demo script flags and add clean-up arg


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/0efa5b78
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/0efa5b78
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/0efa5b78

Branch: refs/heads/trunk
Commit: 0efa5b783a376b415458976d8a8e6813111048b2
Parents: 2b01bc3
Author: Eric Johnson <erjohnso@google.com>
Authored: Wed Jul 15 20:26:50 2015 +0000
Committer: Eric Johnson <erjohnso@google.com>
Committed: Wed Jul 15 20:26:50 2015 +0000

----------------------------------------------------------------------
 demos/gce_demo.py | 90 +++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 75 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/0efa5b78/demos/gce_demo.py
----------------------------------------------------------------------
diff --git a/demos/gce_demo.py b/demos/gce_demo.py
index 6c15907..790d7d6 100755
--- a/demos/gce_demo.py
+++ b/demos/gce_demo.py
@@ -170,6 +170,60 @@ def display(title, resource_list=[]):
                 print('     %s' % item)
 
 
+def cleanup_only():
+    start_time = datetime.datetime.now()
+    display('Clean-up start time: %s' % str(start_time))
+    gce = get_gce_driver()
+    # Get project info and print name
+    project = gce.ex_get_project()
+    display('Project: %s' % project.name)
+
+    # == Get Lists of Everything and Display the lists (up to 10) ==
+    # These can either just return values for the current datacenter (zone)
+    # or for everything.
+    all_nodes = gce.list_nodes(ex_zone='all')
+    display('Nodes:', all_nodes)
+
+    all_addresses = gce.ex_list_addresses(region='all')
+    display('Addresses:', all_addresses)
+
+    all_volumes = gce.list_volumes(ex_zone='all')
+    display('Volumes:', all_volumes)
+
+    # This can return everything, but there is a large amount of overlap,
+    # so we'll just get the sizes from the current zone.
+    sizes = gce.list_sizes()
+    display('Sizes:', sizes)
+
+    # These are global
+    firewalls = gce.ex_list_firewalls()
+    display('Firewalls:', firewalls)
+
+    networks = gce.ex_list_networks()
+    display('Networks:', networks)
+
+    images = gce.list_images()
+    display('Images:', images)
+
+    locations = gce.list_locations()
+    display('Locations:', locations)
+
+    zones = gce.ex_list_zones()
+    display('Zones:', zones)
+
+    snapshots = gce.ex_list_snapshots()
+    display('Snapshots:', snapshots)
+
+    # == Clean up any old demo resources ==
+    display('Cleaning up any "%s" resources' % DEMO_BASE_NAME)
+    clean_up(gce, DEMO_BASE_NAME, all_nodes,
+             all_addresses + all_volumes + firewalls + networks + snapshots)
+    volumes = gce.list_volumes()
+    clean_up(gce, DEMO_BASE_NAME, None, volumes)
+    end_time = datetime.datetime.now()
+    display('Total runtime: %s' % str(end_time - start_time))
+
+
 def clean_up(gce, base_name, node_list=None, resource_list=None):
     """
     Destroy all resources that have a name beginning with 'base_name'.
@@ -617,20 +671,26 @@ def main_dns():
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(
         description='Google Cloud Platform Demo / Live Test Script')
-    parser.add_argument("--skip-compute",
-                        help="skip compute demo / live tests",
-                        dest="compute", action="store_false")
-    parser.add_argument("--skip-load-balancer",
-                        help="skip load-balancer demo / live tests",
-                        dest="lb", action="store_false")
-    parser.add_argument("--skip-dns",
-                        help="skip DNS demo / live tests",
-                        dest="dns", action="store_false")
+    parser.add_argument("--compute",
+                        help="perform compute demo / live tests",
+                        dest="compute", action="store_true")
+    parser.add_argument("--load-balancer",
+                        help="perform load-balancer demo / live tests",
+                        dest="lb", action="store_true")
+    parser.add_argument("--dns",
+                        help="perform DNS demo / live tests",
+                        dest="dns", action="store_true")
+    parser.add_argument("--cleanup-only",
+                        help="perform clean-up (skips all tests)",
+                        dest="cleanup", action="store_true")
     cl_args = parser.parse_args()
 
-    if cl_args.compute:
-        main_compute()
-    if cl_args.lb:
-        main_load_balancer()
-    if cl_args.dns:
-        main_dns()
+    if cl_args.cleanup:
+        cleanup_only()
+    else:
+        if cl_args.compute:
+            main_compute()
+        if cl_args.lb:
+            main_load_balancer()
+        if cl_args.dns:
+            main_dns()


Mime
View raw message