-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrant_CLI.py
59 lines (53 loc) · 1.57 KB
/
Vagrant_CLI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import click
import subprocess
import search
@click.group()
def CLI():
pass
@CLI.command()
@click.argument('name')
def init(name):
'''Enter a name for creating a vagrant machine from vagrant cloud'''
subprocess.run(f'vagrant init {name}', shell=True)
@CLI.command()
@click.argument('name')
def up(name):
'''Enter the name for running the vagrant machine'''
if search.search(name) == True:
subprocess.run(f'vagrant up {name}', shell=True)
else:
click.echo('There is no machine named: {name}!')
@CLI.command()
@click.argument('name')
def halt(name):
'''Enter the name for stopping the vagrant machine'''
if search.search(name) == True:
subprocess.run(f'vagrant halt {name}', shell=True)
else:
click.echo(f'There is no machine named: {name}!')
@CLI.command()
@click.argument('name')
def suspend(name):
'''Enter the name for suspending the vagrant machine'''
if search.search(name) == True:
subprocess.run(f'vagrant suspend {name}', shell=True)
else:
click.echo('There is no machine named: {name}!')
@CLI.command()
@click.argument('name')
def resume(name):
'''Enter the name for resuming the vagrant machine'''
if search.search(name) == True:
subprocess.run(f'vagrant halt {name}', shell=True)
else:
click.echo('There is no machine named: {name}!')
@CLI.command()
def list():
'''Listing all machines'''
click.echo(search.check())
@CLI.command()
def status():
'''Status of all machines'''
subprocess.run(f'vagrant status', shell=True)
if __name__ == '__main__':
CLI()