1
0
mirror of https://github.com/ubuntu/microk8s.git synced 2021-05-23 02:23:41 +03:00

Adding start wrapper (#1529)

This commit is contained in:
Joe Borg
2020-09-01 03:52:31 -04:00
committed by GitHub
parent 00f57dfc84
commit 6acd4820b4
4 changed files with 27 additions and 1 deletions

1
.gitignore vendored
View File

@@ -11,6 +11,7 @@ tests/__pycache__
**/tests/*.pyc
.venv/
.vscode/
/installer/.venv/
/installer/**/__pycache__
/installer/dist/
/installer/build/

View File

@@ -1,3 +1,4 @@
.venv/
bin/
lib/
lib64

View File

@@ -42,6 +42,10 @@ def cli(ctx, help):
elif ctx.args[0] == "uninstall":
uninstall()
exit(0)
elif ctx.args[0] == "start":
start()
run(ctx.args)
exit(0)
elif ctx.args[0] == "stop":
run(ctx.args)
stop()
@@ -261,6 +265,16 @@ def dashboard_proxy() -> None:
return 1
def start() -> None:
vm_provider_name = "multipass"
vm_provider_class = get_provider_for(vm_provider_name)
vm_provider_class.ensure_provider()
instance = vm_provider_class(echoer=Echo())
instance_info = instance.get_instance_info()
if not instance_info.is_running():
instance.start()
def stop() -> None:
vm_provider_name = "multipass"
vm_provider_class = get_provider_for(vm_provider_name)
@@ -278,7 +292,10 @@ def run(cmd) -> None:
try:
vm_provider_class.ensure_provider()
instance = vm_provider_class(echoer=echo)
instance.get_instance_info()
instance_info = instance.get_instance_info()
if not instance_info.is_running():
instance.start()
instance.run(["microk8s.start"])
command = cmd[0]
cmd[0] = "microk8s.{}".format(command)
instance.run(cmd)

View File

@@ -173,6 +173,13 @@ class Multipass(Provider):
instance_name=self.instance_name, json_info=instance_info_raw.decode()
)
def start(self) -> None:
instance_info = self._instance_info = self._get_instance_info()
if not instance_info.is_stopped():
return
self._multipass_cmd.start(instance_name=self.instance_name)
def stop(self) -> None:
instance_info = self._instance_info = self._get_instance_info()
if instance_info.is_stopped():