-
Notifications
You must be signed in to change notification settings - Fork 19
/
minitest.py
78 lines (63 loc) · 2.37 KB
/
minitest.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import openstack.admin
import openstack.compute
import openstack.auth
import openstack.extras
import random
import sys
if len(sys.argv) > 1:
host = sys.argv[1]
else:
host = 'localhost'
auth = openstack.auth.Auth(management_url='http://%s:8080/v2.0/' % host)
token = auth.tokens.create('1234', 'admin', 'secrete')
print token.serviceCatalog
admin_token = auth.tokens.create('1234', 'admin', 'secrete')
accounts = openstack.extras.Account(auth_token=admin_token.id,
management_url='http://%s:8081/v2.0' % host)
extras = openstack.extras.Extras(auth_token=token.id,
auth_url='http://%s:8774/v1.1/' % host,
management_url='http://%s:8774/v1.1/' % host)
admin = openstack.admin.Admin(auth_token=token.id,
auth_url='http://%s:8774/v1.1/' % host,
management_url='http://%s:8774/v1.1/' % host)
compute = openstack.compute.Compute(auth_token=token.id,
auth_url='http://%s:8774/v1.1/' % host,
management_url='http://%s:8774/v1.1/' % host)
print "-----"
print extras.keypairs.list()
#print extras.keypairs.delete('test')
print extras.keypairs.create('test')
print extras.keypairs.create('test2')
#print extras.servers.list()[0]._info['attrs']['description']
#print extras.servers.list()[0].update('my server', None, 'description')
print "-----"
#flavors = admin.flavors.list()
#services = admin.services.list()
#print services
#for s in services:
# print s._info
# s.update(False)
#admin.flavors.delete(405)
#flavor = admin.flavors.create('', '', '', '', '')
#flavor.delete(True)
if True:
print "%d users" % len(accounts.users.list())
t = accounts.users.create('jesse', '[email protected]', 'asdf', '1234', True)
print 'created %s' % t
print "%d users" % len(accounts.users.list())
t.delete()
print "after delete: %d users" % len(accounts.users.list())
#console = extras.consoles.create(servers[0].id, 'vnc')
#print console.output
#print compute.servers.list()
if False:
try:
project = admin.projects.create('test', 'joeuser', 'desc')
except:
admin.projects.delete('test')
pass
project.update('joeuser', 'desc2')
for p in admin.projects.list():
print p._info
admin.projects.delete('test')
#print compute.images.list()