def get_status(self): status = False try: self.get_image_list() status = True LOG.info("Glance connection is established") except Exception as e: LOG.error("Couldn't connect to Glance client " + e) return status
def get_status(self): status = False try: self.get_flavors_list() status = True LOG.info("Nova connection is established") except Exception as e: LOG.error("Couldn't connect to Nova client " + e) return status
def upload_image(self, name, image_location): try: name = str(name).split('.')[0] except: pass LOG.info("Uploading "+name+" image to glance ...") image = self.get_client().images.create(name=name, disk_format='vmdk', container_format='bare') self.get_client().images.upload(image.id, open(image_location)) return image.id
def upload_image(self, name, image_location): try: name = str(name).split('.')[0] except: pass LOG.info("Uploading " + name + " image to glance ...") image = self.get_client().images.create(name=name, disk_format='vmdk', container_format='bare') self.get_client().images.upload(image.id, open(image_location)) return image.id
def get_best_flavor(self, values): LOG.info("Getting the best flavor for virtual machine") best_list = self.get_flavor_map() for i in range(len(values)): initial_list = best_list best_list = {} for flavor in initial_list: if initial_list[flavor][i] >= values[i]: best_list[flavor] = initial_list[flavor] if not best_list: LOG.error("No flavors matched") return get_smallest_flavor(best_list)
def get_image_list(self): LOG.info("Fetching image list ...") return self.get_client().images.list()
def create_stack(self, name, body): LOG.info("Uploading template file to heat endpoint") self.get_client().stacks.create(stack_name=name, template=body) LOG.info("Template is uploaded successfully")