Skip to content

Commit

Permalink
Topic/quickfix vpc failures (#155)
Browse files Browse the repository at this point in the history
* fixing vpc enabled check

* fixing vpc enabled check

* format and fix vpc tests

* added missing test file

* fixing vpc project query

* black formatting

(cherry picked from commit 9a193d949c06342e0e9b32db0aba4a6459f1a2f7)
(cherry picked from commit a804977)
  • Loading branch information
abhijeetkaurav1st committed Jul 25, 2022
1 parent 049d8df commit 18d1337
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
15 changes: 12 additions & 3 deletions tests/cli/runtime_helpers/ahv/app_edit_overlay_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@
SUBNET = DSL_CONFIG["ACCOUNTS"]["NUTANIX_PC"][0]["SUBNETS"][0]["NAME"]
CLUSTER = DSL_CONFIG["ACCOUNTS"]["NUTANIX_PC"][0]["SUBNETS"][0]["CLUSTER"]
NETWORK1 = DSL_CONFIG["AHV"]["NETWORK"]["VLAN1211"]
VPC_PROJECT = (
DSL_CONFIG.get("VPC_PROJECTS", {}).get("PROJECT1", {}).get("NAME", "default")
)


def get_vpc_project(config):
project_name = "default"
vpc_enabled = config.get("IS_VPC_ENABLED", False)
if not vpc_enabled:
return project_name

project_name = (
config.get("VPC_PROJECTS", {}).get("PROJECT1", {}).get("NAME", "default")
)


def get_local_az_overlay_details_from_dsl_config(config):
Expand Down Expand Up @@ -51,6 +59,7 @@ def get_local_az_overlay_details_from_dsl_config(config):


NETWORK1, VPC1, CLUSTER1 = get_local_az_overlay_details_from_dsl_config(DSL_CONFIG)
VPC_PROJECT = get_vpc_project(DSL_CONFIG)

DefaultCred = basic_cred(
CRED_USERNAME,
Expand Down
29 changes: 25 additions & 4 deletions tests/testprep.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,36 @@ def add_tunnel_details(config):
config["VPC_TUNNELS"] = config_tunnels_dict


def check_project_exists(project_name="default"):
client = get_api_client()

payload = {
"length": 200,
"offset": 0,
"filter": "name=={}".format(project_name),
}
project_name_uuid_map = client.project.get_name_uuid_map(payload)

if not project_name_uuid_map:
print("Project {} not found".format(project_name))
return False

return True


def add_vpc_details(config):
config["IS_VPC_ENABLED"] = False

add_project_details(config, "VPC_PROJECTS", "test_vpc_project")

# UUID gets populated if the project actually exists
config_projects = (
config.get("VPC_PROJECTS", {}).get("PROJECT1", {}).get("UUID", None)
)
if config_projects:
# config_projects = (
# config.get("VPC_PROJECTS", {}).get("PROJECT1", {}).get("UUID", None)
# )
# if config_projects:
# config["IS_VPC_ENABLED"] = True
project_exists = check_project_exists("test_vpc_project")
if project_exists:
config["IS_VPC_ENABLED"] = True

add_tunnel_details(config)
Expand Down

0 comments on commit 18d1337

Please sign in to comment.