def get_vm(self, vm_id): """ Obtain data about a vm @param vm_id: the id of the VM @return: the info or None if cannot find the VM """ the_url = "%s/%s/%s" % (self.url_openstack, "servers", vm_id) response = http.get(the_url, self.header) if response.status is not 200 and response.status is not 202: loggers.set_error_log( str(response.status) + ': error to add the product') return None else: info = response.read() loggers.set_info_log(info) return info
def get_pool(self): """ Obtain the pools of the tenant @rtype : list @return: a list of pools """ my_url = "%s/%s" % (self.url_openstack, "os-floating-ip-pools") response = http.get(my_url, self.header) if response.status != 200: return None var = response.read() pool = json.loads(var) pools = [] for my_pool in pool['floating_ip_pools']: pools.append(my_pool['name']) if len(pools) < 1: return None return pools
def get_product_info(self, product_name): """ return the information from a product @param product_name: the product name @return: the product description """ the_url = "%s/%s/%s" % (self.sdc_url, "catalog/product", product_name) response = http.get(the_url, self.header) if response.status() != 200: loggers.set_error_log('error to get the product ' + product_name + ' ' + str(response.status())) return None else: data = json.loads(response.read()) loggers.set_info_log(data) try: description = data['description'] except Exception: return None return description
def get_product_release(self, product_name): """ Obtain the product release from a product @param product_name: the name of the product @return: The version of the software """ my_url = "%s/%s/%s/%s" % (self.sdc_url, "catalog/product", product_name, "release") response = http.get(my_url, self.header) if response.status() != 200: error = 'error to get the product ' + product_name + ' ' + str( response.status()) loggers.set_error_log(error) return None else: data = json.loads(response.read()) loggers.set_info_log(data) if data is None: return None return data['productRelease']['version']
def get_products(self): """ Obtain a list of the product's name @return:List od products """ my_url = "%s/%s" % (self.sdc_url, "catalog/product") loggers.set_info_log(my_url) response = http.get(my_url, self.header) if response.status() != 200: msg = "Error obtaining the token" loggers.set_error_log(msg) return "Error", msg else: data = json.loads(response.read()) products = data["product"] my_products = [] for product in products: var = product['name'] my_products.append(var) loggers.set_info_log(my_products) return None, my_products
def get_product_release_info(self, product_name, product_version): """ Obtain the information from a product release @param product_name: the product version @param product_version: the product release @return: The description of the product release """ my_url = "%s/%s/%s/%s/%s" % (self.sdc_url, "catalog/product", product_name, "release", product_version) response = http.get(my_url, self.header) if response.status() != 200: error = 'error to get the product ' + product_name + ' ' + str( response.status()) loggers.set_error_log(error) return None else: data = json.loads(response.read()) try: description = data['productRelease']['product']['description'] except Exception: return None return description