Compare commits
4 Commits
9435a46fbd
...
288ccd7357
Author | SHA1 | Date | |
---|---|---|---|
288ccd7357 | |||
94953ccf16 | |||
2446a74b76 | |||
e84f13161a |
40
twvdscli.py
40
twvdscli.py
@ -429,12 +429,15 @@ def dbs_create(passwd: str = typer.Option(..., help="DB password"),
|
||||
|
||||
|
||||
@dbs_app.command("list")
|
||||
def dbs_list():
|
||||
def dbs_list(raw: bool = typer.Option(False, help="Get result as raw json")):
|
||||
"""
|
||||
Show list of DBs:
|
||||
ID, State, Name, IP, local IP, Password, Type
|
||||
"""
|
||||
list_of_dbaas = Dbaas.list()
|
||||
if raw:
|
||||
print(list_of_dbaas)
|
||||
return
|
||||
x = PrettyTable()
|
||||
x.field_names = ['id', 'state', 'name', 'ip', 'local_ip', 'password', 'type']
|
||||
if list_of_dbaas is None:
|
||||
@ -509,18 +512,27 @@ def vds_goto(vds_id: Optional[int] = typer.Argument(None),
|
||||
|
||||
|
||||
@servers_app.command("start")
|
||||
def vds_start(vds_id: Optional[int] = typer.Argument(None)):
|
||||
def vds_start(vds_id: Optional[int] = typer.Argument(None), raw: bool = typer.Option(False, help="Get result as raw json")):
|
||||
"""
|
||||
Start VDS
|
||||
"""
|
||||
if vds_id is None:
|
||||
if raw:
|
||||
print(
|
||||
dict(
|
||||
error="No VDS ID provided"
|
||||
)
|
||||
)
|
||||
return 1
|
||||
vds_list()
|
||||
vds_id = input("Enter VDS ID: ")
|
||||
result = Server.start(vds_id)
|
||||
if result is None:
|
||||
print(typer.style("Error", fg=typer.colors.RED))
|
||||
sys.exit(1)
|
||||
|
||||
if raw:
|
||||
print(result)
|
||||
return
|
||||
for frame in cycle(r'-\|/'):
|
||||
state = Server.get_vds(vds_id)
|
||||
if state:
|
||||
@ -532,18 +544,26 @@ def vds_start(vds_id: Optional[int] = typer.Argument(None)):
|
||||
|
||||
|
||||
@servers_app.command("stop")
|
||||
def vds_stop(vds_id: Optional[int] = typer.Argument(None)):
|
||||
def vds_stop(vds_id: Optional[int] = typer.Argument(None), raw: bool = typer.Option(False, help="Get result as raw json")):
|
||||
"""
|
||||
Stop VDS
|
||||
"""
|
||||
if vds_id is None:
|
||||
if raw:
|
||||
print(
|
||||
dict(
|
||||
error="No VDS ID provided"
|
||||
)
|
||||
)
|
||||
return 1
|
||||
vds_list()
|
||||
vds_id = input("Enter VDS ID: ")
|
||||
result = Server.stop(vds_id)
|
||||
if result is None:
|
||||
print(typer.style("Error", fg=typer.colors.RED))
|
||||
sys.exit(1)
|
||||
|
||||
if raw:
|
||||
print(result)
|
||||
for frame in cycle(r'-\|/'):
|
||||
state = Server.get_vds(vds_id)
|
||||
if state:
|
||||
@ -561,6 +581,13 @@ def vds_clone(vds_id: Optional[int] = typer.Argument(None),
|
||||
Clone VDS
|
||||
"""
|
||||
if vds_id is None:
|
||||
if raw:
|
||||
print(
|
||||
dict(
|
||||
error="No VDS ID provided"
|
||||
)
|
||||
)
|
||||
return 1
|
||||
vds_list()
|
||||
vds_id = input("Enter VDS ID: ")
|
||||
new_vds = Server.clone(vds_id)
|
||||
@ -568,6 +595,9 @@ def vds_clone(vds_id: Optional[int] = typer.Argument(None),
|
||||
print(typer.style("Error", fg=typer.colors.RED))
|
||||
sys.exit(1)
|
||||
else:
|
||||
if raw:
|
||||
print(new_vds)
|
||||
return
|
||||
new_vds = new_vds['server']
|
||||
|
||||
for frame in cycle(r'-\|/'):
|
||||
|
Loading…
Reference in New Issue
Block a user