Compare commits
No commits in common. "cd950292ac9a45e4868260e5b9088c0d3798308c" and "ceeddaca7d06da886b58c607aafd0a622054622c" have entirely different histories.
cd950292ac
...
ceeddaca7d
42
twvdscli.py
42
twvdscli.py
@ -84,21 +84,6 @@ class Server:
|
|||||||
else:
|
else:
|
||||||
return result.json()
|
return result.json()
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def clone(vds_id):
|
|
||||||
"""
|
|
||||||
Clone VDS
|
|
||||||
"""
|
|
||||||
uri = "https://public-api.timeweb.com/api/v1/vds/{id}/{action}"
|
|
||||||
result = requests.post(
|
|
||||||
uri.format(id=vds_id, action='clone'),
|
|
||||||
headers=reqHeader
|
|
||||||
)
|
|
||||||
if not result.ok:
|
|
||||||
return None
|
|
||||||
else:
|
|
||||||
return result.json()
|
|
||||||
|
|
||||||
|
|
||||||
@app.command("balance")
|
@app.command("balance")
|
||||||
def get_balance():
|
def get_balance():
|
||||||
@ -163,31 +148,6 @@ def vds_stop(vds_id: Optional[int] = typer.Argument(None)):
|
|||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
|
|
||||||
|
|
||||||
@servers_app.command("clone")
|
|
||||||
def vds_clone(vds_id: Optional[int] = typer.Argument(None)):
|
|
||||||
"""
|
|
||||||
Clone VDS, show cute spinner until VDS stops
|
|
||||||
"""
|
|
||||||
if vds_id is None:
|
|
||||||
vds_list()
|
|
||||||
vds_id = input("Enter VDS ID: ")
|
|
||||||
new_vds = Server.clone(vds_id)
|
|
||||||
if new_vds is None:
|
|
||||||
print(typer.style("Error", fg=typer.colors.RED))
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
new_vds = new_vds['server']
|
|
||||||
|
|
||||||
for frame in cycle(r'-\|/'):
|
|
||||||
state = Server.get_vds(new_vds['id'])
|
|
||||||
if state:
|
|
||||||
if state['server']['status'] == 'on':
|
|
||||||
print(typer.style("\nCloned: " + new_vds['configuration']['caption'], fg=typer.colors.GREEN))
|
|
||||||
break
|
|
||||||
print('\r', frame, sep='', end='', flush=True)
|
|
||||||
sleep(0.1)
|
|
||||||
|
|
||||||
|
|
||||||
@servers_app.command("list")
|
@servers_app.command("list")
|
||||||
def vds_list():
|
def vds_list():
|
||||||
"""
|
"""
|
||||||
@ -208,7 +168,7 @@ def vds_list():
|
|||||||
else:
|
else:
|
||||||
state = i['status']
|
state = i['status']
|
||||||
x.add_row([i['id'], state, i['name'], i['ip'], i['configuration']['cpu'], i['configuration']['ram'], i['configuration']['disk_size']])
|
x.add_row([i['id'], state, i['name'], i['ip'], i['configuration']['cpu'], i['configuration']['ram'], i['configuration']['disk_size']])
|
||||||
print(x)
|
print(x)
|
||||||
|
|
||||||
|
|
||||||
def auth(based):
|
def auth(based):
|
||||||
|
Loading…
Reference in New Issue
Block a user