__date__ = "$05-nov-2021 12:00:00$"
-class TestGCPOperations():
+class TestGCPOperations:
gcp_conn = None
- time_id = datetime.today().strftime('%Y%m%d%H%M%S')
+ time_id = datetime.today().strftime("%Y%m%d%H%M%S")
vim_id = "gcp-test-" + time_id
vim_name = vim_id
vm_name = "gcp-test-vm-" + time_id
credentials_file,
image_id,
image_connector_id,
- flavor_id
+ flavor_id,
):
self.config["project_name"] = project_name
self.config["region_name"] = region_name
self.config["credentials"] = json.load(file)
except ValueError:
raise Exception(
- "Not possible to read credentials JSON file %s", self.config["credentials"]
+ "Not possible to read credentials JSON file %s",
+ self.config["credentials"],
)
self.image_id = image_id
self.image_connector_id = image_connector_id
)
def test_networks(self):
- net_id_1 = self.gcp_conn.new_network(self.net_name, None, {"subnet_address": "10.0.0.0/25"})
- net_id_2 = self.gcp_conn.new_network(self.net_name, None, {"subnet_address": "10.9.0.0/25"})
+ net_id_1 = self.gcp_conn.new_network(
+ self.net_name, None, {"subnet_address": "10.0.0.0/25"}
+ )
+ net_id_2 = self.gcp_conn.new_network(
+ self.net_name, None, {"subnet_address": "10.9.0.0/25"}
+ )
_ = self.gcp_conn.delete_network(net_id_1[0])
_ = self.gcp_conn.delete_network(net_id_2[0])
_ = self.gcp_conn.delete_vminstance(vm_id_1[0])
def test_vminstances_2_nets(self):
- net_id_1 = self.gcp_conn.new_network(self.net_name, None, {"subnet_address": "10.0.0.0/25"})
- net_id_2 = self.gcp_conn.new_network(self.net_name, None, {"subnet_address": "10.9.0.0/25"})
+ net_id_1 = self.gcp_conn.new_network(
+ self.net_name, None, {"subnet_address": "10.0.0.0/25"}
+ )
+ net_id_2 = self.gcp_conn.new_network(
+ self.net_name, None, {"subnet_address": "10.9.0.0/25"}
+ )
vm_id_1 = self.gcp_conn.new_vminstance(
name=self.vm_name,
start=True,
image_id=self.image_id,
flavor_id=self.flavor_id,
- net_list=[{"net_id": net_id_1[0], "use": "mgmt"}, {"net_id": net_id_2[0], "use": "internal"}],
+ net_list=[
+ {"net_id": net_id_1[0], "use": "mgmt"},
+ {"net_id": net_id_2[0], "use": "internal"},
+ ],
cloud_config=self.cloud_config,
)
_ = self.gcp_conn.delete_vminstance(vm_id_1[0])
_ = self.gcp_conn.delete_network(net_id_1[0])
_ = self.gcp_conn.delete_network(net_id_2[0])
-
def test_vminstances_image_connector_id(self):
image_id = self.gcp_conn.get_image_list({"name": self.image_connector_id})
vm_id_1 = self.gcp_conn.new_vminstance(
def test_vminstances_flavor(self):
machine_type = self.gcp_conn.get_flavor_id_from_data(
- {'disk': 10, 'ram': 2048, 'vcpus': 1, 'extended': {'mempage-size': 'LARGE', 'numas': [{'threads': 1}]}}
+ {
+ "disk": 10,
+ "ram": 2048,
+ "vcpus": 1,
+ "extended": {"mempage-size": "LARGE", "numas": [{"threads": 1}]},
+ }
)
vm_id_1 = self.gcp_conn.new_vminstance(
name=self.vm_name,
try:
with open(gcp_env_file) as f:
for line in f:
- var, value = line.replace('\n', '').split("=")
+ var, value = line.replace("\n", "").split("=")
if var == "GCP_PROJECT":
project_name = value
elif var == "GCP_REGION":
elif var == "GCP_FLAVOR":
flavor_id = value
except ValueError:
- raise Exception(
- "Wrong format of GCP test environment file"
- )
+ raise Exception("Wrong format of GCP test environment file")
if (
project_name is None
credentials_file,
image_id,
image_connector_id,
- flavor_id
+ flavor_id,
)
test_gcp.test_networks()
test_gcp.test_vminstances_default()
test_gcp.test_vminstances_2_nets()
test_gcp.test_vminstances_connector_id()
test_gcp.test_vminstances_flavor()
-