def the_product_instance_is_returned_in_the_list(step): instance_id = generate_product_instance_id(world.vm_fqn, world.product_name, world.product_version) assert_true(world.response.ok, 'RESPONSE: {}'.format(world.response)) response_body = response_body_to_dict( world.response, world.headers[ACCEPT_HEADER], xml_root_element_name=PRODUCT_INSTANCE_LIST) response_body = response_body assert_true(len(response_body) != 0) product_instance = None for product_ins in response_body: if instance_id in product_ins[PRODUCT_INSTANCE_NAME]: product_instance = product_ins break assert_true(product_instance is not None) assert_equals(product_instance[PRODUCT_INSTANCE_NAME], instance_id) assert_true(product_instance[PRODUCT_INSTANCE_STATUS] != "") assert_equals( product_instance[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_IP], world.vm_ip) assert_equals( product_instance[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_FQN], world.vm_fqn) assert_equals( product_instance[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_HOSTNAME], world.vm_hostname) assert_equals(product_instance[PRODUCT][VERSION], world.product_version) assert_equals(product_instance[PRODUCT][PRODUCT_NAME], world.product_name)
def the_product_is_instantiated(self, step): """ Checks if the product is instantiated with the correct data (values from world) :param step: Lettuce step data :return: world.instance_status with the installation status """ world.instance_id = generate_product_instance_id(world.vm_fqn, world.product_name, world.product_version) response = self.api_utils.retrieve_product_instance(headers=world.headers, vdc_id=world.tenant_id, product_instance_id=world.instance_id) assert_true(response.ok, 'RESPONSE: {}'.format(response)) response_body = response_body_to_dict(response, world.headers[ACCEPT_HEADER], xml_root_element_name=PRODUCT_INSTANCE_RES) assert_equals(response_body[PRODUCT_INSTANCE_NAME], world.instance_id) assert_true(response_body[PRODUCT_INSTANCE_STATUS] != "") assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_FQN], world.vm_fqn) assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_HOSTNAME], world.vm_hostname) ip_aux = "" if world.vm_ip is None else world.vm_ip assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_IP], ip_aux) assert_equals(response_body[PRODUCT_RELEASE][VERSION], world.product_version) assert_equals(response_body[PRODUCT_RELEASE][PRODUCT][PRODUCT_NAME], world.product_name) world.instance_status = response_body[PRODUCT_INSTANCE_STATUS]
def the_product_instance_is_returned_in_the_list(step): instance_id = generate_product_instance_id(world.vm_fqn, world.product_name, world.product_version) assert_true(world.response.ok, 'RESPONSE: {}'.format(world.response)) #response_body = xml_to_dict(world.response.content)[PRODUCT_INSTANCE_LIST][PRODUCT_INSTANCE_RES] response_body = response_body_to_dict(world.response, world.headers[ACCEPT_HEADER], xml_root_element_name=PRODUCT_INSTANCE_LIST) response_body = response_body assert_true(len(response_body) != 0) product_instance = None for product_ins in response_body: if instance_id in product_ins[PRODUCT_INSTANCE_NAME]: product_instance = product_ins break assert_true(product_instance is not None) assert_equals(product_instance[PRODUCT_INSTANCE_NAME], instance_id) assert_true(product_instance[PRODUCT_INSTANCE_STATUS] != "") assert_equals(product_instance[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_IP], world.vm_ip) assert_equals(product_instance[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_FQN], world.vm_fqn) assert_equals(product_instance[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_HOSTNAME], world.vm_hostname) assert_equals(product_instance[PRODUCT_RELEASE][VERSION], world.product_version) assert_equals(product_instance[PRODUCT_RELEASE][PRODUCT][PRODUCT_NAME], world.product_name)
def i_get_the_product_instance_details(step): world.instance_id = generate_product_instance_id(world.vm_fqn, world.product_name, world.product_version) world.response = api_utils.retrieve_product_instance( headers=world.headers, vdc_id=world.tenant_id, product_instance_id=world.instance_id)
def i_uninstall_a_installed_product_and_release(self, step): """ Uninstal a product. Use data from world world.vm_fqn, world.product_name, world.product_version, world.tenant_id :return: Response in world.response and instance_id in world.instance_id """ world.instance_id = generate_product_instance_id(world.vm_fqn, world.product_name, world.product_version) world.response = self.api_utils.uninstall_product_by_product_instance_id(headers=world.headers, vdc_id=world.tenant_id, product_instance_id=world.instance_id)
def the_product_is_instantiated(self, step): """ Checks if the product is instantiated with the correct data (values from world) :param step: Lettuce step data :return: world.instance_status with the installation status """ world.instance_id = generate_product_instance_id(world.vm_fqn, world.product_name, world.product_version) response = self.api_utils.retrieve_product_instance(headers=world.headers, vdc_id=world.tenant_id, product_instance_id=world.instance_id) assert_true(response.ok, 'RESPONSE: {}'.format(response)) response_body = response_body_to_dict(response, world.headers[ACCEPT_HEADER], xml_root_element_name=PRODUCT_INSTANCE) assert_equals(response_body[PRODUCT_INSTANCE_NAME], world.instance_id) assert_true(response_body[PRODUCT_INSTANCE_STATUS] != "") assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_FQN], world.vm_fqn) assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_HOSTNAME], world.vm_hostname) ip_aux = "" if world.vm_ip is None else world.vm_ip assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_IP], ip_aux) assert_equals(response_body[PRODUCT][VERSION], world.product_version) assert_equals(response_body[PRODUCT][PRODUCT_NAME], world.product_name) # If the instance has been created with attributes, check it. if world.instance_attributes is not None: # Check if attributes have got type. # Else, add plain type before check it (default type) for attribute in world.instance_attributes: if ATTRIBUTE_TYPE not in attribute: attribute.update({ATTRIBUTE_TYPE: ATTRIBUTE_TYPE_PLAIN}) world.instance_attributes = world.instance_attributes[0] \ if len(world.instance_attributes) == 1 else world.instance_attributes assert_equals(response_body[PRODUCT_INSTANCE_ATTRIBUTES], world.instance_attributes) world.instance_status = response_body[PRODUCT_INSTANCE_STATUS]
def i_get_the_product_instance_details(step): world.instance_id = generate_product_instance_id(world.vm_fqn, world.product_name, world.product_version) world.response = api_utils.retrieve_product_instance(headers=world.headers, vdc_id=world.tenant_id, product_instance_id=world.instance_id)