-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
executable file
·64 lines (46 loc) · 1.32 KB
/
cli.py
File metadata and controls
executable file
·64 lines (46 loc) · 1.32 KB
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
60
61
62
63
64
#!/usr/bin/env python
# Our helper
import pyos_connect
# bpython
import bpdb
# To see errors from the libraries
import logging
# To handle CLI args
import argparse
welcome_text = 'OpenStack bpython CLI. Type help_me() for examples and usage'
help_text = '''OpenStack bpython CLI
Helper methods:
help_me() - This message
debug() - Enable debug logging
exit() or CTRL+d - exit
varibles:
nova
cinder
glance
keysone
neutron
Use the above varibles to explor the API's. Simple examples:
nova.services.list()
nova.quotas.get('demo')
nova.servers.list(search_opts={'all_tenants': True})
'''
def debug(level=logging.DEBUG):
logging.basicConfig(level=level)
logging.captureWarnings(True)
def help_me():
print(help_text)
parser = argparse.ArgumentParser(description='Connect to OpenStack and explore the python API bindings')
parser.add_argument('--insecure', dest='insecure', action='store_true')
parser.add_argument('--debug', '-d', dest='debug', action='store_true')
args = parser.parse_args()
if args.debug: debug()
# Connect and get handles to all services
os = pyos_connect.pyos_connect(verify=not args.insecure)
nova = os.get_nova()
glance = os.get_glance()
keystone = os.get_keystone()
cinder = os.get_cinder()
neutron = os.get_neutron()
print welcome_text
# Break out to the bpython interpretor
bpdb.set_trace()