Add VMs to the database even with HUB_MODE=mock

Closes ~cyberia/services#83
This commit is contained in:
3wc 2021-07-21 22:06:30 +02:00
parent 8f2becb9ee
commit 9f23638959
1 changed files with 10 additions and 2 deletions

View File

@ -40,6 +40,16 @@ class MockHub(VirtualizationInterface):
validate_capsul_id(id)
current_app.logger.info(f"mock create: {id} for {email}")
sleep(1)
get_model().create_vm(
email=email,
id=id,
size=size,
os=os,
host=host_id,
network_name=network_name,
public_ipv4=public_ipv4,
ssh_authorized_keys=list(map(lambda x: x["name"], ssh_authorized_keys)),
)
def destroy(self, email: str, id: str):
current_app.logger.info(f"mock destroy: {id} for {email}")
@ -49,7 +59,6 @@ class MockHub(VirtualizationInterface):
class CapsulFlaskHub(VirtualizationInterface):
def synchronous_operation(self, hosts: List[OnlineHost], email: str, payload: str) -> List[HTTPResult]:
return self.generic_operation(hosts, email, payload, True)[1]
@ -262,4 +271,3 @@ class CapsulFlaskHub(VirtualizationInterface):
if not result_status == "success":
raise ValueError(f"""failed to {command} vm "{id}" on host "{host.id}" for {email}: {result_json_string}""")