def volume_refresh(self, print_objs): """ List all the successfuly created volumes :returns: volumes object :rtype: NoneType """ driver = self._get_driver() volumes = driver.list_volumes() db_client = Evemongo_client() db_client.delete(VOLUME) e = {} n = 1 for vol in volumes: #print(vol) data = {} data['id'] = vol.id data['name'] = vol.name data['size'] = vol.size data['driver'] = vol.driver.name e[n] = data n = n + 1 db_client.post(VOLUME, data) if print_objs == True : Console.ok(str(Printer.dict_table(e, order=['id','name', 'size','driver']))) return volumes
def location_refresh(self, print_location): """ List all available locations :returns: location objects :rtype: NoneType """ driver = self._get_driver() locations = driver.list_locations() db_client = Evemongo_client() db_client.delete(LOCATION) n = 1 e = {} #<EC2NodeLocation: id=0, name=us-west-1a, country=USA, availability_zone=<ExEC2AvailabilityZone: name=us-west-1a, # zone_state=available, region_name=us-west-1> driver=Amazon EC2>, for location in locations: data = {} data['id'] = location.id data['name'] = location.name data['country'] = location.country data['availability_zone'] = location.availability_zone.name data['zone_state'] = location.availability_zone.zone_state data['region_name'] = location.availability_zone.region_name #data['provider'] = location.driver.name e[n] = data n = n + 1 db_client.post(LOCATION, data) if print_location == True: Console.ok(str(Printer.dict_table(e, order=['id','name','country', 'availability_zone', 'zone_state','region_name','provider']))) return locations
def node_refresh(self, show_list): """ List the all instance of node :returns: nodes object :rtype: NoneType """ # get driver driver = self._get_driver() #List the running vm's nodes = driver.list_nodes() db_client = Evemongo_client() db_client.delete(NODE) n = 0 ; e = {} for node in nodes: # parse flavors data = {} data['uuid'] = str(node.uuid) data['name'] = str(node.name) data['state'] = str(node.state) data['provider'] = str(node.driver.name) e[n] = data n = n + 1 db_client.post(NODE, data) if show_list: Console.ok(str(Printer.dict_table(e, order=['uuid', 'name', 'state', 'provider']))) return nodes
def keypair_refresh(self): """ List all the available key pair associated with account :returns: None :rtype: NoneType """ driver = self._get_driver() db_client = Evemongo_client() db_client.delete(KEYPAIR) key_pair_objs = driver.list_key_pairs() n =1 e = {} for kp in key_pair_objs: data = {} data['name'] = kp.name data['fingerprint'] = kp.fingerprint e[n] = data n = n + 1 db_client.post(KEYPAIR, data) Console.ok(str(Printer.dict_table(e, order=['name', 'fingerprint']))) return
def flavor_refresh(self): """ List all the flavor list available on Amazon EC2 :returns: None :rtype: NoneType """ #get driver driver = self._get_driver() # get flavor list and print sizes = driver.list_sizes() #print(sizes) n = 1 e = {} db_client = Evemongo_client() db_client.delete(FLAVOR) for size in sizes: # parse flavors data = {} data['id'] = size .id data['name'] = size.name data['ram'] = size.ram data['disk'] = size.disk data['price'] = size.price e[n] = data n = n + 1 # store it in mongodb db_client.post(FLAVOR, data) #print(data) Console.ok(str(Printer.dict_table(e, order=['id', 'name', 'ram', 'disk', 'bandwidth', 'price']))) #print("successfully stored in db", r) return