def get_allproductandrelease(self): """ Get All ProductAndReleases :return: A duple: All product and Releses from SDC Catalog as a dict, the 'Request' response """ logger.info("Get all ProductAndReleases") response = self.get(PRODUCTANDRELEASE_RESOURCE_ROOT_URI, headers=self.headers) sr_response = response_body_to_dict(response, self.headers[HEADER_CONTENT_TYPE], xml_root_element_name=PRODUCTANDRELEASE_BODY_ROOT) return sr_response, response
def delete_environment_instance(self, name): """ Delete an environemnt instance(Tenant) :param name: Name of the environment instance to be deleted :return: A duple : The task (asynchronous method) as a dict, the 'Request' response """ logger.info("Deleting environment instance " + name) response = self.delete(ENVIRONMENT_INSTANCE_RESOURCE_DETAIL_URI, headers=self.headers, parameters=None, tenant_id=self.tenant_id, environment_instance_name=name) task_dict = response_body_to_dict(response,self.headers[HEADER_ACCEPT], xml_root_element_name=TASK_BODY_ROOT ) return task_dict, response
def get_environment(self, name): """ Get an environment (Tenant) :return: A duple: The environment as a dict, , the 'Request' response """ logger.info("Get environment") response = self.get(ENVIRONMENT_RESOURCE_DETAIL_URI, headers=self.headers, parameters=None, tenant_id=self.tenant_id, environment_name=name) dict_environment = response_body_to_dict(response, self.headers[HEADER_ACCEPT], xml_root_element_name=ENVIRONMENT_BODY_ROOT) return dict_environment, response
def get_task(self, task_id): """ Get a PaasManager Task (Tenant) :param task_id: ID of the task to obtain :return: A duple: The corresponding task, , the 'Request' response """ logger.info("Get task") response = self.get(TASK_RESOURCE_DETAIL_URI, headers=self.headers, parameters=None, tenant_id=self.tenant_id, task_id=task_id) task_dict = response_body_to_dict(response, self.headers[HEADER_ACCEPT], xml_root_element_name=TASK_BODY_ROOT) return task_dict, response
def get_allproductandrelease(self): """ Get All ProductAndReleases :return: A duple: All product and Releses from SDC Catalog as a dict, the 'Request' response """ logger.info("Get all ProductAndReleases") response = self.get(PRODUCTANDRELEASE_RESOURCE_ROOT_URI, headers=self.headers) sr_response = response_body_to_dict( response, self.headers[HEADER_CONTENT_TYPE], xml_root_element_name=PRODUCTANDRELEASE_BODY_ROOT) return sr_response, response
def get_tier(self, environment_name, name): """ Get a Tier of a Environment (Tenant) :param environment_name: Name of the environment to which tier belongs :param name: Name of the tier to be deleted :return: Aduple: the corresponding Tier as a dict, , the 'Request' response """ logger.info("Get tier") response = self.get(TIER_RESOURCE_DETAIL_URI, headers=self.headers, parameters=None, tenant_id=self.tenant_id, environment_name=environment_name, tier_name=name) dict_tier = response_body_to_dict(response, self.headers[HEADER_ACCEPT], xml_root_element_name=TIER_BODY_ROOT) return dict_tier, response
def get_environment(self, name): """ Get an environment (Tenant) :return: A duple: The environment as a dict, , the 'Request' response """ logger.info("Get environment") response = self.get(ENVIRONMENT_RESOURCE_DETAIL_URI, headers=self.headers, parameters=None, tenant_id=self.tenant_id, environment_name=name) dict_environment = response_body_to_dict( response, self.headers[HEADER_ACCEPT], xml_root_element_name=ENVIRONMENT_BODY_ROOT) return dict_environment, response
def create_environment_instance(self, name, description, environment_name, environment_description, tier_name, image, region_name, keypair=None, product_name=None, product_version=None, network_name=None, subnetwork_name=None): """ Create a new environment (Tenant) :param name: Name of the environment instance (blueprint) :param description: Description of the environment instance (blueprint) :param environment_name: Name of the environment :param tier_name: Name of the tier :param image: image to deploy a VM from :param keypair: keypair of the user to enter the deployed VM :param product_name: Name of the product :param product_version: Product version :param network_name: Name of the network :param subnetwork_name: Name of the subnetwork :return: A duple : The task (asynchronous method) as a dict, the 'Request' response """ logger.info("Creating new environment instance") env_model = {ENVIRONMENT_INSTANCE_BODY_ROOT: { ENVIRONMENT_INSTANCE_BODY_NAME: name, ENVIRONMENT_BODY_DESCRIPTION: description, ENVIRONMENT_BODY_ROOT: { ENVIRONMENT_BODY_NAME: environment_name, ENVIRONMENT_BODY_DESCRIPTION: environment_description, TIER_BODY_ROOT: { TIER_BODY_NAME: tier_name, TIER_BODY_INITIAL_INSTANCES: "1", TIER_BODY_MAXIMUM_INSTANCES: "1", TIER_BODY_MINIMUM_INSTANCES: "1", TIER_BODY_IMAGE: image, TIER_BODY_FLAVOUR: "2", TIER_BODY_KEYPAIR: keypair, TIER_BODY_FLOATINGIP: "False", TIER_BODY_REGION: region_name, TIER_BODY_PRODUCTRELEASE : { TIER_BODY_PRODUCTRELEASE_NAME : product_name, TIER_BODY_PRODUCTRELEASE_VERSION : product_version }, TIER_BODY_NETWORK : { TIER_BODY_NETWORK_NAME : network_name, TIER_BODY_SUBNETWORK : { TIER_BODY_SUBNETWORK_NAME: subnetwork_name } } } } } } #Removing keys whose values are None delete_element_when_value_none(env_model) #Converting json to body request body = model_to_request_body(env_model, self.headers[HEADER_CONTENT_TYPE]) response = self.post(ENVIRONMENT_INSTANCE_RESOURCE_ROOT_URI, body, self.headers, parameters=None, tenant_id=self.tenant_id) task_dict = response_body_to_dict(response,self.headers[HEADER_ACCEPT], xml_root_element_name=TASK_BODY_ROOT ) return task_dict, response