forked from ironcamel/openstack.api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
minitest.py
110 lines (89 loc) · 3.35 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
from datetime import datetime
import openstackx.admin
import openstackx.compute
import openstackx.auth
import openstackx.extras
import random
import sys
if len(sys.argv) > 1:
host = sys.argv[1]
else:
host = 'localhost'
auth = openstackx.auth.Auth(management_url='http://%s:8080/v2.0/' % host)
token = auth.tokens.create('1234', 'admin', 'secrete')
print token._info
admin_token = auth.tokens.create('1234', 'admin', 'secrete')
accounts = openstackx.extras.Account(auth_token=admin_token.id,
management_url='http://%s:8081/v2.0' % host)
extras = openstackx.extras.Extras(auth_token=token.id,
auth_url='http://%s:8774/v1.1/' % host,
management_url='http://%s:8774/v1.1/' % host)
admin = openstackx.admin.Admin(auth_token=token.id,
auth_url='http://%s:8774/v1.1/' % host,
management_url='http://%s:8774/v1.1/' % host)
compute = openstackx.compute.Compute(auth_token=token.id,
auth_url='http://%s:8774/v1.1/' % host,
management_url='http://%s:8774/v1.1/' % host)
#services = admin.services.list()
print "#####################################################################"
print admin.quota_sets.list(True)
print "#####################################################################"
print "-----"
print "-----"
#print accounts.tenants.get('1234')
#print accounts.tenants.add_tenant_user('1234', 'joeuser')
print accounts.role_refs.get_for_user('joeadmin')
print accounts.role_refs.get_for_user('joeuser')
print "hooray"
print "-----"
print accounts.role_refs.add_for_tenant_user('1234', 'joeuser', 'Admin')
print accounts.role_refs.delete_for_tenant_user('1234', 'joeuser', 'Admin')
print "-----"
#print accounts.tenants.get_tenant_users('1234')
print "-----"
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']
#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)
print admin.flavors.list()
#admin.flavors.delete(405)
#flavor = admin.flavors.create('', '', '', '', '')
#flavor.delete(True)
if False:
print accounts.tenants.get('1234')
print "%d tenants" % len(accounts.tenants.list())
t = accounts.tenants.create('project:%d' % random.randint(0, 10000))
t.update("test", False)
print t.enabled
print t.description
if False:
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()