def the_networks_are_connected_to_instance(step): # Get Server list from Nova raw_response = world.nova_request.get_server_list() assert_equal(raw_response.status, 200, "Error to obtain Server list. HTTP status code is not the expected") server_list = raw_httplib_request_to_python_dic(raw_response) # For each tier, check Networks for tier in world.tiers: # Get Server id sub_instance_name = "{}-{}".format(world.instance_name, tier.name) server_id = get_server_id_by_partial_name(server_list, sub_instance_name) # Get Server details raw_response = world.nova_request.get_server_details(server_id) assert_equal(raw_response.status, 200, "Error to obtain Server details. HTTP status code is not the expected") server_details = raw_httplib_request_to_python_dic(raw_response) connected_networks_list = get_network_name_list(server_details) if tier.networks is None or tier.networks == []: assert_equal(len(connected_networks_list), 1, "The number of connected networks is not the expected one") assert_equal(connected_networks_list[0], world.config[PAAS][REGION_DEFAULT_SHAREDNET_PROPERTY], "The connected network is not the configured as Shared-Net") else: assert_equal(len(connected_networks_list), len(tier.networks), "The number of connected networks is not the expected one") for network in tier.networks: assert_in(network.network_name, connected_networks_list, "The network '%s' is not connected to the instance".format(network.network_name))
def the_product_is_installed(step, product_name, product_version, tier_name, installator): tier = None for tier_world in world.tiers: if tier_world.name == tier_name: tier = tier_world assert_is_not_none(tier, "Tier with name '{}' not found in created tier list.".format(tier_name)) # > Get from Nova the IP of the Floating VM # >> Get Server list from Nova raw_response = world.nova_request.get_server_list() assert_equal(raw_response.status, 200, "Error to obtain Server list. HTTP status code is not the expected") server_list = raw_httplib_request_to_python_dic(raw_response) sub_instance_name = "{}-{}".format(world.instance_name, tier.name) server_id = get_server_id_by_partial_name(server_list, sub_instance_name) # Get Server details raw_response = world.nova_request.get_server_details(server_id) assert_equal(raw_response.status, 200, "Error to obtain Server details. HTTP status code is not the expected") server_details = raw_httplib_request_to_python_dic(raw_response) connected_networks_list = get_network_name_list(server_details) shared_net = world.config[PAAS][REGION_DEFAULT_SHAREDNET_PROPERTY] assert_in(shared_net, connected_networks_list, "The connected network is not the configured as Shared-Net") ip_internet = get_floating_ip(server_details, shared_net) assert_is_not_none(ip_internet, "Floating IP not found Shared-Net. Is the Internet network added to tier conf?") # Create new Fabric connection fabric_client = FabricUtils(host_name=ip_internet, host_username=world.config[PAAS][CONFIG_SUPPORT_USER], host_password="******", host_ssh_key=world.config[PAAS][CONFIG_SUPPORT_KEY_FILE]) file_name = PRODUCT_FILE_NAME_FORMAT.format(product_name=product_name, product_version=product_version, installator=installator) # Wait for software installation. time.sleep(SLEEP_TIME_CHECKS) # Retry SSH 5 times response = False for i in range(MAX_CHECKS_SSH_CONNECTION): try: response = fabric_client.file_exist(INSTALLATION_PRODUCT_DIR, file_name) print "Connected!" break except Exception as e: print "SSH Connection #%d: %s" % (i, e.message) time.sleep(SLEEP_TIME_CHECKS) assert_true(response, "Softwer is not installed. File not found: '{}/{}".format(INSTALLATION_PRODUCT_DIR, file_name))