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:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,6 +11,7 @@ tests/__pycache__
|
|||||||
**/tests/*.pyc
|
**/tests/*.pyc
|
||||||
.venv/
|
.venv/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
/installer/.venv/
|
||||||
/installer/**/__pycache__
|
/installer/**/__pycache__
|
||||||
/installer/dist/
|
/installer/dist/
|
||||||
/installer/build/
|
/installer/build/
|
||||||
|
|||||||
1
installer/.gitignore
vendored
1
installer/.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
.venv/
|
||||||
bin/
|
bin/
|
||||||
lib/
|
lib/
|
||||||
lib64
|
lib64
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ def cli(ctx, help):
|
|||||||
elif ctx.args[0] == "uninstall":
|
elif ctx.args[0] == "uninstall":
|
||||||
uninstall()
|
uninstall()
|
||||||
exit(0)
|
exit(0)
|
||||||
|
elif ctx.args[0] == "start":
|
||||||
|
start()
|
||||||
|
run(ctx.args)
|
||||||
|
exit(0)
|
||||||
elif ctx.args[0] == "stop":
|
elif ctx.args[0] == "stop":
|
||||||
run(ctx.args)
|
run(ctx.args)
|
||||||
stop()
|
stop()
|
||||||
@@ -261,6 +265,16 @@ def dashboard_proxy() -> None:
|
|||||||
return 1
|
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:
|
def stop() -> None:
|
||||||
vm_provider_name = "multipass"
|
vm_provider_name = "multipass"
|
||||||
vm_provider_class = get_provider_for(vm_provider_name)
|
vm_provider_class = get_provider_for(vm_provider_name)
|
||||||
@@ -278,7 +292,10 @@ def run(cmd) -> None:
|
|||||||
try:
|
try:
|
||||||
vm_provider_class.ensure_provider()
|
vm_provider_class.ensure_provider()
|
||||||
instance = vm_provider_class(echoer=echo)
|
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]
|
command = cmd[0]
|
||||||
cmd[0] = "microk8s.{}".format(command)
|
cmd[0] = "microk8s.{}".format(command)
|
||||||
instance.run(cmd)
|
instance.run(cmd)
|
||||||
|
|||||||
@@ -173,6 +173,13 @@ class Multipass(Provider):
|
|||||||
instance_name=self.instance_name, json_info=instance_info_raw.decode()
|
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:
|
def stop(self) -> None:
|
||||||
instance_info = self._instance_info = self._get_instance_info()
|
instance_info = self._instance_info = self._get_instance_info()
|
||||||
if instance_info.is_stopped():
|
if instance_info.is_stopped():
|
||||||
|
|||||||
Reference in New Issue
Block a user