def cluster(self, *args): args = list(args) if not len(args) or not args[0]: print "cluster command requires an action. Valid actions are: " print " list\n status" return action = args.pop(0) if action == 'list': cluster.list() else: # actions that require a cluster name if not len(args) or not args[0]: print "cluster name required for {}".format(action) return cluster_name = args.pop(0) cl = cluster.Cluster(cluster_name) if action == 'status': print "{} status: {}".format(cluster_name, cl.status()) elif action == 'create': if not cl.create(): print "Failed to bring up {} cluster".format(cluster_name) else: print "Unknown cluster command: {}".format(action)
#!/usr/bin/python #coding:utf-8 #http://download.cloud.com/releases/3.0.3/api_3.0.3/TOC_Root_Admin.html import api import output import domain, user, host, vm, network, zone, cluster, pod, volumn #import template, iso, router, firewall, pool, systemvm, nat, serviceoffering, vlan, diskoffering, address, event, capacity, alert cs = api.client() domains = domain.list(cs) zones = zone.list(cs) pods = pod.list(cs) clusters = cluster.list(cs) hosts = host.list(cs) vms = vm.list(cs) users = user.list(cs) networks = network.list(cs) #output.pprinter(vms) output.csv_objectip(vms)