This repository was archived by the owner on Feb 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi_interpreter.py
More file actions
1996 lines (1651 loc) · 141 KB
/
Copy pathapi_interpreter.py
File metadata and controls
1996 lines (1651 loc) · 141 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> import os
>>> os.environ['OS_USERNAME']
'demo'
>>> os.environ['OS_PASSWD']
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
os.environ['OS_PASSWD']
File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__
raise KeyError(key)
KeyError: 'OS_PASSWD'
>>> os.environ['OS_PASSWORD']
'nomoresecrete'
>>> os.environ['OS_AUTH_URL']
'http://192.168.80.130:5000/v2.0'
>>> def get_keystone_creds():
d = {}
d['username'] = os.environ['OS_USERNAME']
d['password'] = os.environ['OS_PASSWORD']
d['auth_url'] = os.environ['OS_AUTH_URL']
d['tenant_name'] = os.environ['OS_TENANT_NAME']
return d
>>>
>>> def get_keystone_admin_creds():
d = {}
d['username'] = 'admin'
d['password'] = 'nomoresecrete'
d['auth_url'] = 'http://192.168.80.130:5000/v2.0'
d['tenant_name'] = 'admin'
return d
>>> import keystoneclient.v2_0.client as ksclient
>>> creds = get_keystone_admin_creds()
>>> creds
{'username': 'admin', 'tenant_name': 'admin', 'password': 'nomoresecrete', 'auth_url': 'http://192.168.80.130:5000/v2.0'}
>>> keystone = ksclient.Client(**creds)
>>> keystone.auth_token
u'9eceeb2176e440128d0459864752e733'
>>> keystone.tenants.list()
[<Tenant {u'enabled': True, u'description': None, u'name': u'service', u'id': u'42a758197838431ea8d23aa3792ea9f6'}>, <Tenant {u'enabled': True, u'description': None, u'name': u'invisible_to_admin', u'id': u'9de40b4a9e4d4fae9a2010879e4c4e24'}>, <Tenant {u'enabled': True, u'description': None, u'name': u'admin', u'id': u'd60b5c7ed1a449efb4dab22162da0cb8'}>, <Tenant {u'enabled': True, u'description': None, u'name': u'demo', u'id': u'd8f42a85e023411080a86768fa0e4692'}>]
>>> dir(keystone)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattr__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_adapter', '_auth_token', '_build_keyring_key', '_cs_request', '_endpoint', '_management_url', '_process_management_url', 'auth_domain_id', 'auth_ref', 'auth_tenant_id', 'auth_token', 'auth_token_from_user', 'auth_url', 'auth_user_id', 'authenticate', 'certificates', 'debug_log', 'delete', 'deprecated_adapter_variables', 'deprecated_session_variables', 'domain', 'domain_id', 'domain_name', 'ec2', 'endpoints', 'extensions', 'force_new_token', 'get', 'get_auth_ref_from_keyring', 'get_endpoint', 'get_headers', 'get_options', 'get_project_id', 'get_raw_token_from_identity_service', 'get_token', 'get_user_id', 'has_service_catalog', 'head', 'invalidate', 'load_from_argparse_arguments', 'load_from_conf_options', 'load_from_options', 'load_from_options_getter', 'management_url', 'password', 'patch', 'post', 'process_token', 'project_domain_id', 'project_domain_name', 'project_id', 'project_name', 'put', 'register_argparse_arguments', 'register_conf_options', 'request', 'roles', 'serialize', 'service_catalog', 'services', 'session', 'stale_duration', 'store_auth_ref_into_keyring', 'tenant_id', 'tenant_name', 'tenants', 'tokens', 'trust_id', 'use_keyring', 'user_domain_id', 'user_domain_name', 'user_id', 'username', 'users', 'version']
>>> keystone.services.list()
[<Service {u'type': u'cloudformation', u'description': u'Heat CloudFormation Service', u'enabled': True, u'id': u'1601c35405454cdd8a935c492c2dfe66', u'name': u'heat-cfn'}>, <Service {u'type': u'volumev2', u'description': u'Cinder Volume Service V2', u'enabled': True, u'id': u'1daebc2a4ea74ae5bb0878bc04e63fed', u'name': u'cinderv2'}>, <Service {u'type': u'network', u'description': u'Neutron Service', u'enabled': True, u'id': u'28f5d5bbbc7f4b11b54cf7ddb81ea637', u'name': u'neutron'}>, <Service {u'type': u'volume', u'description': u'Cinder Volume Service', u'enabled': True, u'id': u'4c9ac854ec094f12b6b3a88275c5ca14', u'name': u'cinder'}>, <Service {u'type': u'identity', u'description': u'Keystone Identity Service', u'enabled': True, u'id': u'5c97d29cffb24f4aa5f1d3bf439a71eb', u'name': u'keystone'}>, <Service {u'type': u'computev21', u'description': u'Nova Compute Service V2.1', u'enabled': True, u'id': u'74152f778c794c3582c2d418f4fe62f4', u'name': u'novav21'}>, <Service {u'type': u'orchestration', u'description': u'Heat Orchestration Service', u'enabled': True, u'id': u'76e54b792a6d4287817de2f982add4fd', u'name': u'heat'}>, <Service {u'type': u'compute', u'description': u'Nova Compute Service', u'enabled': True, u'id': u'a5717708347648c19306ddb197cc7b9f', u'name': u'nova'}>, <Service {u'type': u'image', u'description': u'Glance Image Service', u'enabled': True, u'id': u'f0ae91766045456a9e19fa36f52fdd9d', u'name': u'glance'}>, <Service {u'type': u'ec2', u'description': u'EC2 Compatibility Layer', u'enabled': True, u'id': u'f9f040f16b3f42e780e29ee4f506a1bd', u'name': u'ec2'}>]
>>> keystone.users.list()
[<User {u'username': u'heat', u'id': u'126452eda45e47549d8c7e75f355c76e', u'enabled': True, u'name': u'heat', u'email': None}>, <User {u'username': u'admin', u'id': u'5651e750923546e695e06ca9a810c759', u'enabled': True, u'name': u'admin', u'email': None}>, <User {u'username': u'neutron', u'id': u'81758bbaec0c420fbe97e5fbdbb52152', u'enabled': True, u'name': u'neutron', u'email': None}>, <User {u'username': u'cinder', u'id': u'934ff7c1dc1845a48244a3232d67c86a', u'enabled': True, u'name': u'cinder', u'email': None}>, <User {u'username': u'nova', u'id': u'c457ef7813c149eca1c6b1b02da394ca', u'enabled': True, u'name': u'nova', u'email': None}>, <User {u'username': u'glance', u'id': u'ccfa207f5b33407699ed3d39b96319d8', u'enabled': True, u'name': u'glance', u'email': None}>, <User {u'username': u'demo', u'id': u'f2e0e944388943e389e5f50f0de1ade3', u'enabled': True, u'name': u'demo', u'email': u'demo@example.com'}>]
>>> len(keystone.users.list())
7
>>> users = keystone.users.list()
>>> for u in users:
print u
print "\n"
<User {u'username': u'heat', u'id': u'126452eda45e47549d8c7e75f355c76e', u'enabled': True, u'name': u'heat', u'email': None}>
<User {u'username': u'admin', u'id': u'5651e750923546e695e06ca9a810c759', u'enabled': True, u'name': u'admin', u'email': None}>
<User {u'username': u'neutron', u'id': u'81758bbaec0c420fbe97e5fbdbb52152', u'enabled': True, u'name': u'neutron', u'email': None}>
<User {u'username': u'cinder', u'id': u'934ff7c1dc1845a48244a3232d67c86a', u'enabled': True, u'name': u'cinder', u'email': None}>
<User {u'username': u'nova', u'id': u'c457ef7813c149eca1c6b1b02da394ca', u'enabled': True, u'name': u'nova', u'email': None}>
<User {u'username': u'glance', u'id': u'ccfa207f5b33407699ed3d39b96319d8', u'enabled': True, u'name': u'glance', u'email': None}>
<User {u'username': u'demo', u'id': u'f2e0e944388943e389e5f50f0de1ade3', u'enabled': True, u'name': u'demo', u'email': u'demo@example.com'}>
>>> services = keystone.services.list()
>>> for s in services:
print s
<Service {u'type': u'cloudformation', u'description': u'Heat CloudFormation Service', u'enabled': True, u'id': u'1601c35405454cdd8a935c492c2dfe66', u'name': u'heat-cfn'}>
<Service {u'type': u'volumev2', u'description': u'Cinder Volume Service V2', u'enabled': True, u'id': u'1daebc2a4ea74ae5bb0878bc04e63fed', u'name': u'cinderv2'}>
<Service {u'type': u'network', u'description': u'Neutron Service', u'enabled': True, u'id': u'28f5d5bbbc7f4b11b54cf7ddb81ea637', u'name': u'neutron'}>
<Service {u'type': u'volume', u'description': u'Cinder Volume Service', u'enabled': True, u'id': u'4c9ac854ec094f12b6b3a88275c5ca14', u'name': u'cinder'}>
<Service {u'type': u'identity', u'description': u'Keystone Identity Service', u'enabled': True, u'id': u'5c97d29cffb24f4aa5f1d3bf439a71eb', u'name': u'keystone'}>
<Service {u'type': u'computev21', u'description': u'Nova Compute Service V2.1', u'enabled': True, u'id': u'74152f778c794c3582c2d418f4fe62f4', u'name': u'novav21'}>
<Service {u'type': u'orchestration', u'description': u'Heat Orchestration Service', u'enabled': True, u'id': u'76e54b792a6d4287817de2f982add4fd', u'name': u'heat'}>
<Service {u'type': u'compute', u'description': u'Nova Compute Service', u'enabled': True, u'id': u'a5717708347648c19306ddb197cc7b9f', u'name': u'nova'}>
<Service {u'type': u'image', u'description': u'Glance Image Service', u'enabled': True, u'id': u'f0ae91766045456a9e19fa36f52fdd9d', u'name': u'glance'}>
<Service {u'type': u'ec2', u'description': u'EC2 Compatibility Layer', u'enabled': True, u'id': u'f9f040f16b3f42e780e29ee4f506a1bd', u'name': u'ec2'}>
>>> for s in services:
print s + "\n"
Traceback (most recent call last):
File "<pyshell#32>", line 2, in <module>
print s + "\n"
TypeError: unsupported operand type(s) for +: 'Service' and 'str'
>>> for s in services:
print s
print "\n"
<Service {u'type': u'cloudformation', u'description': u'Heat CloudFormation Service', u'enabled': True, u'id': u'1601c35405454cdd8a935c492c2dfe66', u'name': u'heat-cfn'}>
<Service {u'type': u'volumev2', u'description': u'Cinder Volume Service V2', u'enabled': True, u'id': u'1daebc2a4ea74ae5bb0878bc04e63fed', u'name': u'cinderv2'}>
<Service {u'type': u'network', u'description': u'Neutron Service', u'enabled': True, u'id': u'28f5d5bbbc7f4b11b54cf7ddb81ea637', u'name': u'neutron'}>
<Service {u'type': u'volume', u'description': u'Cinder Volume Service', u'enabled': True, u'id': u'4c9ac854ec094f12b6b3a88275c5ca14', u'name': u'cinder'}>
<Service {u'type': u'identity', u'description': u'Keystone Identity Service', u'enabled': True, u'id': u'5c97d29cffb24f4aa5f1d3bf439a71eb', u'name': u'keystone'}>
<Service {u'type': u'computev21', u'description': u'Nova Compute Service V2.1', u'enabled': True, u'id': u'74152f778c794c3582c2d418f4fe62f4', u'name': u'novav21'}>
<Service {u'type': u'orchestration', u'description': u'Heat Orchestration Service', u'enabled': True, u'id': u'76e54b792a6d4287817de2f982add4fd', u'name': u'heat'}>
<Service {u'type': u'compute', u'description': u'Nova Compute Service', u'enabled': True, u'id': u'a5717708347648c19306ddb197cc7b9f', u'name': u'nova'}>
<Service {u'type': u'image', u'description': u'Glance Image Service', u'enabled': True, u'id': u'f0ae91766045456a9e19fa36f52fdd9d', u'name': u'glance'}>
<Service {u'type': u'ec2', u'description': u'EC2 Compatibility Layer', u'enabled': True, u'id': u'f9f040f16b3f42e780e29ee4f506a1bd', u'name': u'ec2'}>
>>> s1 = services[1]
>>> s1
<Service {u'type': u'volumev2', u'description': u'Cinder Volume Service V2', u'enabled': True, u'id': u'1daebc2a4ea74ae5bb0878bc04e63fed', u'name': u'cinderv2'}>
>>> dir(s1)
['HUMAN_ID', 'NAME_ATTR', '__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattr__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_add_details', '_info', '_loaded', 'delete', 'description', 'enabled', 'get', 'human_id', 'id', 'is_loaded', 'manager', 'name', 'set_loaded', 'to_dict', 'type']
>>> s1.name
u'cinderv2'
>>> s1.description
u'Cinder Volume Service V2'
>>> keystone.session
<keystoneclient.session.Session object at 0x7f141db26c50>
>>>
>>> ksclient.endpoints.list()
Traceback (most recent call last):
File "<pyshell#43>", line 1, in <module>
ksclient.endpoints.list()
AttributeError: 'module' object has no attribute 'list'
>>>
>>> dir(ksclient.endpoints)
['Endpoint', 'EndpointManager', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 'base']
>>>
>>> ksclient.users.list()
Traceback (most recent call last):
File "<pyshell#47>", line 1, in <module>
ksclient.users.list()
AttributeError: 'module' object has no attribute 'list'
>>>
>>> keystone.endpoints.list()
[<Endpoint {u'adminurl': u'http://192.168.80.130:9696/', u'region': u'RegionOne', u'enabled': True, u'id': u'9a1764a2ecfd4890a5d80edb03365d99', u'service_id': u'28f5d5bbbc7f4b11b54cf7ddb81ea637', u'internalurl': u'http://192.168.80.130:9696/', u'publicurl': u'http://192.168.80.130:9696/'}>, <Endpoint {u'adminurl': u'http://192.168.80.130:8004/v1/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'internalurl': u'http://192.168.80.130:8004/v1/$(tenant_id)s', u'service_id': u'76e54b792a6d4287817de2f982add4fd', u'id': u'4654524b478c4eac923fb3570f4b7e5e', u'publicurl': u'http://192.168.80.130:8004/v1/$(tenant_id)s'}>, <Endpoint {u'adminurl': u'http://192.168.80.130:8774/v2/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'id': u'71c0c32a001848e98d62ef44df238633', u'service_id': u'a5717708347648c19306ddb197cc7b9f', u'internalurl': u'http://192.168.80.130:8774/v2/$(tenant_id)s', u'publicurl': u'http://192.168.80.130:8774/v2/$(tenant_id)s'}>, <Endpoint {u'adminurl': u'http://192.168.80.130:8773/', u'region': u'RegionOne', u'enabled': True, u'id': u'e48968c44dfc4724a3cd96365531b585', u'service_id': u'f9f040f16b3f42e780e29ee4f506a1bd', u'internalurl': u'http://192.168.80.130:8773/', u'publicurl': u'http://192.168.80.130:8773/'}>, <Endpoint {u'adminurl': u'http://192.168.80.130:9292', u'region': u'RegionOne', u'enabled': True, u'id': u'a53a05b0c1ee49dfae3f03f7aaf97721', u'service_id': u'f0ae91766045456a9e19fa36f52fdd9d', u'internalurl': u'http://192.168.80.130:9292', u'publicurl': u'http://192.168.80.130:9292'}>, <Endpoint {u'adminurl': u'http://192.168.80.130:35357/v2.0', u'region': u'RegionOne', u'enabled': True, u'internalurl': u'http://192.168.80.130:5000/v2.0', u'service_id': u'5c97d29cffb24f4aa5f1d3bf439a71eb', u'id': u'a61044ddcefa4df283e79184ebea3cd4', u'publicurl': u'http://192.168.80.130:5000/v2.0'}>, <Endpoint {u'adminurl': u'http://192.168.80.130:8000/v1', u'region': u'RegionOne', u'enabled': True, u'id': u'94d0e7eafa244ed49485ac0b82361ffe', u'service_id': u'1601c35405454cdd8a935c492c2dfe66', u'internalurl': u'http://192.168.80.130:8000/v1', u'publicurl': u'http://192.168.80.130:8000/v1'}>, <Endpoint {u'adminurl': u'http://192.168.80.130:8774/v2.1/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'id': u'8755e2c0681b44e28a98097ba8935f8b', u'service_id': u'74152f778c794c3582c2d418f4fe62f4', u'internalurl': u'http://192.168.80.130:8774/v2.1/$(tenant_id)s', u'publicurl': u'http://192.168.80.130:8774/v2.1/$(tenant_id)s'}>, <Endpoint {u'adminurl': u'http://192.168.80.130:8776/v1/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'id': u'25e18edad644455d828020d89a937976', u'service_id': u'4c9ac854ec094f12b6b3a88275c5ca14', u'internalurl': u'http://192.168.80.130:8776/v1/$(tenant_id)s', u'publicurl': u'http://192.168.80.130:8776/v1/$(tenant_id)s'}>, <Endpoint {u'adminurl': u'http://192.168.80.130:8776/v2/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'id': u'8b64ac979eef4064988315e1596ecac0', u'service_id': u'1daebc2a4ea74ae5bb0878bc04e63fed', u'internalurl': u'http://192.168.80.130:8776/v2/$(tenant_id)s', u'publicurl': u'http://192.168.80.130:8776/v2/$(tenant_id)s'}>]
>>> for x in keystone.endpoints.list():
print x
print "\n"
<Endpoint {u'adminurl': u'http://192.168.80.130:9696/', u'region': u'RegionOne', u'enabled': True, u'id': u'9a1764a2ecfd4890a5d80edb03365d99', u'service_id': u'28f5d5bbbc7f4b11b54cf7ddb81ea637', u'internalurl': u'http://192.168.80.130:9696/', u'publicurl': u'http://192.168.80.130:9696/'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:8004/v1/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'internalurl': u'http://192.168.80.130:8004/v1/$(tenant_id)s', u'service_id': u'76e54b792a6d4287817de2f982add4fd', u'id': u'4654524b478c4eac923fb3570f4b7e5e', u'publicurl': u'http://192.168.80.130:8004/v1/$(tenant_id)s'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:8774/v2/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'id': u'71c0c32a001848e98d62ef44df238633', u'service_id': u'a5717708347648c19306ddb197cc7b9f', u'internalurl': u'http://192.168.80.130:8774/v2/$(tenant_id)s', u'publicurl': u'http://192.168.80.130:8774/v2/$(tenant_id)s'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:8773/', u'region': u'RegionOne', u'enabled': True, u'id': u'e48968c44dfc4724a3cd96365531b585', u'service_id': u'f9f040f16b3f42e780e29ee4f506a1bd', u'internalurl': u'http://192.168.80.130:8773/', u'publicurl': u'http://192.168.80.130:8773/'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:9292', u'region': u'RegionOne', u'enabled': True, u'id': u'a53a05b0c1ee49dfae3f03f7aaf97721', u'service_id': u'f0ae91766045456a9e19fa36f52fdd9d', u'internalurl': u'http://192.168.80.130:9292', u'publicurl': u'http://192.168.80.130:9292'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:35357/v2.0', u'region': u'RegionOne', u'enabled': True, u'internalurl': u'http://192.168.80.130:5000/v2.0', u'service_id': u'5c97d29cffb24f4aa5f1d3bf439a71eb', u'id': u'a61044ddcefa4df283e79184ebea3cd4', u'publicurl': u'http://192.168.80.130:5000/v2.0'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:8000/v1', u'region': u'RegionOne', u'enabled': True, u'id': u'94d0e7eafa244ed49485ac0b82361ffe', u'service_id': u'1601c35405454cdd8a935c492c2dfe66', u'internalurl': u'http://192.168.80.130:8000/v1', u'publicurl': u'http://192.168.80.130:8000/v1'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:8774/v2.1/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'id': u'8755e2c0681b44e28a98097ba8935f8b', u'service_id': u'74152f778c794c3582c2d418f4fe62f4', u'internalurl': u'http://192.168.80.130:8774/v2.1/$(tenant_id)s', u'publicurl': u'http://192.168.80.130:8774/v2.1/$(tenant_id)s'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:8776/v1/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'id': u'25e18edad644455d828020d89a937976', u'service_id': u'4c9ac854ec094f12b6b3a88275c5ca14', u'internalurl': u'http://192.168.80.130:8776/v1/$(tenant_id)s', u'publicurl': u'http://192.168.80.130:8776/v1/$(tenant_id)s'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:8776/v2/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'id': u'8b64ac979eef4064988315e1596ecac0', u'service_id': u'1daebc2a4ea74ae5bb0878bc04e63fed', u'internalurl': u'http://192.168.80.130:8776/v2/$(tenant_id)s', u'publicurl': u'http://192.168.80.130:8776/v2/$(tenant_id)s'}>
>>> x1 = keystone.endpoints.list()[1]
>>> x1
<Endpoint {u'adminurl': u'http://192.168.80.130:8004/v1/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'internalurl': u'http://192.168.80.130:8004/v1/$(tenant_id)s', u'service_id': u'76e54b792a6d4287817de2f982add4fd', u'id': u'4654524b478c4eac923fb3570f4b7e5e', u'publicurl': u'http://192.168.80.130:8004/v1/$(tenant_id)s'}>
>>>
>>> dir(x1)
['HUMAN_ID', 'NAME_ATTR', '__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattr__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_add_details', '_info', '_loaded', 'adminurl', 'delete', 'enabled', 'get', 'human_id', 'id', 'internalurl', 'is_loaded', 'manager', 'publicurl', 'region', 'service_id', 'set_loaded', 'to_dict']
>>> x1.HUMAN_ID
False
>>> x1.NAME_ATTR
'name'
>>> x1.adminurl
u'http://192.168.80.130:8004/v1/$(tenant_id)s'
>>> x1.manager
<keystoneclient.v2_0.endpoints.EndpointManager object at 0x7f141db26c10>
>>>
>>> import retrying
>>> dir(retrying)
['Attempt', 'MAX_WAIT', 'RetryError', 'Retrying', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 'random', 'retry', 'six', 'sys', 'time', 'traceback']
>>>
>>>
>>> from heatclient.v1 import client as heatclient
>>>
>>>
>>> demo_creds = get_keystone_creds()
>>> demo_creds
{'username': 'demo', 'tenant_name': 'demo', 'password': 'nomoresecrete', 'auth_url': 'http://192.168.80.130:5000/v2.0'}
>>>
>>> hc = heatclient.Client(**demo_creds)
Traceback (most recent call last):
File "<pyshell#73>", line 1, in <module>
hc = heatclient.Client(**demo_creds)
File "/usr/local/lib/python2.7/dist-packages/heatclient/v1/client.py", line 40, in __init__
self.http_client = http._construct_http_client(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 389, in _construct_http_client
return HTTPClient(*args, **kwargs)
TypeError: __init__() takes exactly 2 arguments (1 given)
>>> import novaclient.v1_1.client as nvclient
Warning (from warnings module):
File "/usr/local/lib/python2.7/dist-packages/novaclient/v1_1/__init__.py", line 30
warnings.warn("Module novaclient.v1_1 is deprecated (taken as a basis for "
UserWarning: Module novaclient.v1_1 is deprecated (taken as a basis for novaclient.v2). The preferable way to get client class or object you can find in novaclient.client module.
>>> import novaclient.v2.client as nvclient
>>>
>>> nova = nvclient.Client(**demo_creds)
Traceback (most recent call last):
File "<pyshell#77>", line 1, in <module>
nova = nvclient.Client(**demo_creds)
File "/usr/local/lib/python2.7/dist-packages/novaclient/v2/client.py", line 227, in __init__
**kwargs)
TypeError: _construct_http_client() got multiple values for keyword argument 'password'
>>>
>>> demo_creds
{'username': 'demo', 'tenant_name': 'demo', 'password': 'nomoresecrete', 'auth_url': 'http://192.168.80.130:5000/v2.0'}
>>> hc = heatclient.Client(**demo_creds)
Traceback (most recent call last):
File "<pyshell#80>", line 1, in <module>
hc = heatclient.Client(**demo_creds)
File "/usr/local/lib/python2.7/dist-packages/heatclient/v1/client.py", line 40, in __init__
self.http_client = http._construct_http_client(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 389, in _construct_http_client
return HTTPClient(*args, **kwargs)
TypeError: __init__() takes exactly 2 arguments (1 given)
>>> hc = heatclient.Client(demo_creds)
Traceback (most recent call last):
File "<pyshell#81>", line 1, in <module>
hc = heatclient.Client(demo_creds)
File "/usr/local/lib/python2.7/dist-packages/heatclient/v1/client.py", line 40, in __init__
self.http_client = http._construct_http_client(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 389, in _construct_http_client
return HTTPClient(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 83, in __init__
if parse.urlparse(endpoint).scheme == "https":
File "/usr/lib/python2.7/urlparse.py", line 143, in urlparse
tuple = urlsplit(url, scheme, allow_fragments)
File "/usr/lib/python2.7/urlparse.py", line 176, in urlsplit
cached = _parse_cache.get(key, None)
TypeError: unhashable type: 'dict'
>>>
>>> hc = heatclient.Client(**demo_creds)
Traceback (most recent call last):
File "<pyshell#83>", line 1, in <module>
hc = heatclient.Client(**demo_creds)
File "/usr/local/lib/python2.7/dist-packages/heatclient/v1/client.py", line 40, in __init__
self.http_client = http._construct_http_client(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 389, in _construct_http_client
return HTTPClient(*args, **kwargs)
TypeError: __init__() takes exactly 2 arguments (1 given)
>>>
>>> os.environ['HEAT_URL']
Traceback (most recent call last):
File "<pyshell#85>", line 1, in <module>
os.environ['HEAT_URL']
File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__
raise KeyError(key)
KeyError: 'HEAT_URL'
>>> ksclient.tenants.list()
Traceback (most recent call last):
File "<pyshell#86>", line 1, in <module>
ksclient.tenants.list()
AttributeError: 'module' object has no attribute 'list'
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__', 'creds', 'demo_creds', 'get_keystone_admin_creds', 'get_keystone_creds', 'heatclient', 'keystone', 'ksclient', 'nvclient', 'os', 'retrying', 's', 's1', 'services', 'u', 'users', 'x', 'x1']
>>> keystone.tenants.list()
[<Tenant {u'enabled': True, u'description': None, u'name': u'service', u'id': u'42a758197838431ea8d23aa3792ea9f6'}>, <Tenant {u'enabled': True, u'description': None, u'name': u'invisible_to_admin', u'id': u'9de40b4a9e4d4fae9a2010879e4c4e24'}>, <Tenant {u'enabled': True, u'description': None, u'name': u'admin', u'id': u'd60b5c7ed1a449efb4dab22162da0cb8'}>, <Tenant {u'enabled': True, u'description': None, u'name': u'demo', u'id': u'd8f42a85e023411080a86768fa0e4692'}>]
>>>
>>> for t in keystone.tenants.list():
print t
print "\n"
<Tenant {u'enabled': True, u'description': None, u'name': u'service', u'id': u'42a758197838431ea8d23aa3792ea9f6'}>
<Tenant {u'enabled': True, u'description': None, u'name': u'invisible_to_admin', u'id': u'9de40b4a9e4d4fae9a2010879e4c4e24'}>
<Tenant {u'enabled': True, u'description': None, u'name': u'admin', u'id': u'd60b5c7ed1a449efb4dab22162da0cb8'}>
<Tenant {u'enabled': True, u'description': None, u'name': u'demo', u'id': u'd8f42a85e023411080a86768fa0e4692'}>
>>> for e in keystone.endpoints.list():
print e
print "\n"
<Endpoint {u'adminurl': u'http://192.168.80.130:9696/', u'region': u'RegionOne', u'enabled': True, u'id': u'9a1764a2ecfd4890a5d80edb03365d99', u'service_id': u'28f5d5bbbc7f4b11b54cf7ddb81ea637', u'internalurl': u'http://192.168.80.130:9696/', u'publicurl': u'http://192.168.80.130:9696/'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:8004/v1/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'internalurl': u'http://192.168.80.130:8004/v1/$(tenant_id)s', u'service_id': u'76e54b792a6d4287817de2f982add4fd', u'id': u'4654524b478c4eac923fb3570f4b7e5e', u'publicurl': u'http://192.168.80.130:8004/v1/$(tenant_id)s'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:8774/v2/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'id': u'71c0c32a001848e98d62ef44df238633', u'service_id': u'a5717708347648c19306ddb197cc7b9f', u'internalurl': u'http://192.168.80.130:8774/v2/$(tenant_id)s', u'publicurl': u'http://192.168.80.130:8774/v2/$(tenant_id)s'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:8773/', u'region': u'RegionOne', u'enabled': True, u'id': u'e48968c44dfc4724a3cd96365531b585', u'service_id': u'f9f040f16b3f42e780e29ee4f506a1bd', u'internalurl': u'http://192.168.80.130:8773/', u'publicurl': u'http://192.168.80.130:8773/'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:9292', u'region': u'RegionOne', u'enabled': True, u'id': u'a53a05b0c1ee49dfae3f03f7aaf97721', u'service_id': u'f0ae91766045456a9e19fa36f52fdd9d', u'internalurl': u'http://192.168.80.130:9292', u'publicurl': u'http://192.168.80.130:9292'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:35357/v2.0', u'region': u'RegionOne', u'enabled': True, u'internalurl': u'http://192.168.80.130:5000/v2.0', u'service_id': u'5c97d29cffb24f4aa5f1d3bf439a71eb', u'id': u'a61044ddcefa4df283e79184ebea3cd4', u'publicurl': u'http://192.168.80.130:5000/v2.0'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:8000/v1', u'region': u'RegionOne', u'enabled': True, u'id': u'94d0e7eafa244ed49485ac0b82361ffe', u'service_id': u'1601c35405454cdd8a935c492c2dfe66', u'internalurl': u'http://192.168.80.130:8000/v1', u'publicurl': u'http://192.168.80.130:8000/v1'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:8774/v2.1/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'id': u'8755e2c0681b44e28a98097ba8935f8b', u'service_id': u'74152f778c794c3582c2d418f4fe62f4', u'internalurl': u'http://192.168.80.130:8774/v2.1/$(tenant_id)s', u'publicurl': u'http://192.168.80.130:8774/v2.1/$(tenant_id)s'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:8776/v1/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'id': u'25e18edad644455d828020d89a937976', u'service_id': u'4c9ac854ec094f12b6b3a88275c5ca14', u'internalurl': u'http://192.168.80.130:8776/v1/$(tenant_id)s', u'publicurl': u'http://192.168.80.130:8776/v1/$(tenant_id)s'}>
<Endpoint {u'adminurl': u'http://192.168.80.130:8776/v2/$(tenant_id)s', u'region': u'RegionOne', u'enabled': True, u'id': u'8b64ac979eef4064988315e1596ecac0', u'service_id': u'1daebc2a4ea74ae5bb0878bc04e63fed', u'internalurl': u'http://192.168.80.130:8776/v2/$(tenant_id)s', u'publicurl': u'http://192.168.80.130:8776/v2/$(tenant_id)s'}>
>>>
>>> [<Tenant {u'enabled': True, u'description': None, u'name': u'service', u'id': u'42a758197838431ea8d23aa3792ea9f6'}>, <Tenant {u'enabled': True, u'description': None, u'name': u'invisible_to_admin', u'id': u'9de40b4a9e4d4fae9a2010879e4c4e24'}>, <Tenant {u'enabled': True, u'description': None, u'name': u'admin', u'id': u'd60b5c7ed1a449efb4dab22162da0cb8'}>, <Tenant {u'enabled': True, u'description': None, u'name': u'demo', u'id': u'd8f42a85e023411080a86768fa0e4692'}>]
SyntaxError: invalid syntax
>>>
>>> heat_endpoint = "http://192.168.80.130:8004/v1/"
>>> heat_endpoint += "d8f42a85e023411080a86768fa0e4692"
>>> heat_endpoint
'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692'
>>> demo_creds
{'username': 'demo', 'tenant_name': 'demo', 'password': 'nomoresecrete', 'auth_url': 'http://192.168.80.130:5000/v2.0'}
>>> demo_creds['endpoint'] = heat_endpoint
>>>
>>> demo_creds
{'username': 'demo', 'tenant_name': 'demo', 'password': 'nomoresecrete', 'auth_url': 'http://192.168.80.130:5000/v2.0', 'endpoint': 'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692'}
>>>
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__', 'creds', 'demo_creds', 'e', 'get_keystone_admin_creds', 'get_keystone_creds', 'heat_endpoint', 'heatclient', 'keystone', 'ksclient', 'nvclient', 'os', 'retrying', 's', 's1', 'services', 't', 'u', 'users', 'x', 'x1']
>>> heat = heatclient.Client(**demo_creds)
>>>
>>> heat.stacks.list()
<generator object paginate at 0x7f141d6b9e60>
>>> for s in heat.stacks.list():
print s
Traceback (most recent call last):
File "<pyshell#115>", line 1, in <module>
for s in heat.stacks.list():
File "/usr/local/lib/python2.7/dist-packages/heatclient/v1/stacks.py", line 100, in paginate
stacks = self._list(url, 'stacks')
File "/usr/local/lib/python2.7/dist-packages/heatclient/openstack/common/apiclient/base.py", line 131, in _list
body = self.client.get(url).json()
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 291, in get
return self.client_request("GET", url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 284, in client_request
resp, body = self.json_request(method, url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 265, in json_request
resp = self._http_request(url, method, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 220, in _http_request
raise exc.from_response(resp)
HTTPUnauthorized: ERROR: Authentication required
>>>
>>> heat.http_client
<heatclient.common.http.HTTPClient object at 0x7f141d6ae610>
>>> heat.http_client.auth_token
>>>
>>> print heat.http_client.auth_token
None
>>> dir(heat.stacks)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_delete', '_get', '_head', '_hooks_map', '_list', '_patch', '_post', '_put', 'abandon', 'add_hook', 'client', 'create', 'delete', 'get', 'list', 'preview', 'resource_class', 'restore', 'run_hooks', 'snapshot', 'snapshot_delete', 'snapshot_list', 'snapshot_show', 'template', 'update', 'validate']
>>>
>>> dir(heat)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'actions', 'build_info', 'events', 'http_client', 'resource_types', 'resources', 'services', 'software_configs', 'software_deployments', 'stacks']
>>>
>>> demo_creds
{'username': 'demo', 'tenant_name': 'demo', 'password': 'nomoresecrete', 'auth_url': 'http://192.168.80.130:5000/v2.0', 'endpoint': 'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692'}
>>> heat = heatclient.Cl
Traceback (most recent call last):
File "<pyshell#126>", line 1, in <module>
heat = heatclient.Cl
AttributeError: 'module' object has no attribute 'Cl'
>>>
>>> dir(heatclient)
['Client', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 'actions', 'build_info', 'events', 'http', 'resource_types', 'resources', 'services', 'software_configs', 'software_deployments', 'stacks']
>>> type(heatclient)
<type 'module'>
>>>
>>> keystone.auth_token
u'cb7d4d2ab474410fbb03f98a8059da58'
>>> keystone.services.list()
[<Service {u'type': u'cloudformation', u'description': u'Heat CloudFormation Service', u'enabled': True, u'id': u'1601c35405454cdd8a935c492c2dfe66', u'name': u'heat-cfn'}>, <Service {u'type': u'volumev2', u'description': u'Cinder Volume Service V2', u'enabled': True, u'id': u'1daebc2a4ea74ae5bb0878bc04e63fed', u'name': u'cinderv2'}>, <Service {u'type': u'network', u'description': u'Neutron Service', u'enabled': True, u'id': u'28f5d5bbbc7f4b11b54cf7ddb81ea637', u'name': u'neutron'}>, <Service {u'type': u'volume', u'description': u'Cinder Volume Service', u'enabled': True, u'id': u'4c9ac854ec094f12b6b3a88275c5ca14', u'name': u'cinder'}>, <Service {u'type': u'identity', u'description': u'Keystone Identity Service', u'enabled': True, u'id': u'5c97d29cffb24f4aa5f1d3bf439a71eb', u'name': u'keystone'}>, <Service {u'type': u'computev21', u'description': u'Nova Compute Service V2.1', u'enabled': True, u'id': u'74152f778c794c3582c2d418f4fe62f4', u'name': u'novav21'}>, <Service {u'type': u'orchestration', u'description': u'Heat Orchestration Service', u'enabled': True, u'id': u'76e54b792a6d4287817de2f982add4fd', u'name': u'heat'}>, <Service {u'type': u'compute', u'description': u'Nova Compute Service', u'enabled': True, u'id': u'a5717708347648c19306ddb197cc7b9f', u'name': u'nova'}>, <Service {u'type': u'image', u'description': u'Glance Image Service', u'enabled': True, u'id': u'f0ae91766045456a9e19fa36f52fdd9d', u'name': u'glance'}>, <Service {u'type': u'ec2', u'description': u'EC2 Compatibility Layer', u'enabled': True, u'id': u'f9f040f16b3f42e780e29ee4f506a1bd', u'name': u'ec2'}>]
>>>
>>> keystone.auth_token
u'cb7d4d2ab474410fbb03f98a8059da58'
>>>
>>>
>>> del demo_creds['endpoint']
>>> demo_creds
{'username': 'demo', 'tenant_name': 'demo', 'password': 'nomoresecrete', 'auth_url': 'http://192.168.80.130:5000/v2.0'}
>>>
>>> heat = heatclient.Client(heat_endpoint, **demo_creds)
>>> heat.stacks.list()
<generator object paginate at 0x7f141d6b9e60>
>>> heat.s
Traceback (most recent call last):
File "<pyshell#142>", line 1, in <module>
heat.s
AttributeError: 'Client' object has no attribute 's'
>>> for x in heat.stacks.list():
print x
Traceback (most recent call last):
File "<pyshell#145>", line 1, in <module>
for x in heat.stacks.list():
File "/usr/local/lib/python2.7/dist-packages/heatclient/v1/stacks.py", line 100, in paginate
stacks = self._list(url, 'stacks')
File "/usr/local/lib/python2.7/dist-packages/heatclient/openstack/common/apiclient/base.py", line 131, in _list
body = self.client.get(url).json()
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 291, in get
return self.client_request("GET", url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 284, in client_request
resp, body = self.json_request(method, url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 265, in json_request
resp = self._http_request(url, method, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 220, in _http_request
raise exc.from_response(resp)
HTTPUnauthorized: ERROR: Authentication required
>>> heat.stacks.get('s')
Traceback (most recent call last):
File "<pyshell#146>", line 1, in <module>
heat.stacks.get('s')
File "/usr/local/lib/python2.7/dist-packages/heatclient/v1/stacks.py", line 202, in get
resp, body = self.client.json_request('GET', '/stacks/%s' % stack_id)
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 265, in json_request
resp = self._http_request(url, method, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 220, in _http_request
raise exc.from_response(resp)
HTTPUnauthorized: ERROR: Authentication required
>>>
>>> demo_creds
{'username': 'demo', 'tenant_name': 'demo', 'password': 'nomoresecrete', 'auth_url': 'http://192.168.80.130:5000/v2.0'}
>>> heat = heatclient.Client(heat_endpoint, **demo_creds)
>>> token = keystone.auth_token
>>> token
u'cb7d4d2ab474410fbb03f98a8059da58'
>>> heat = heatclient.Client(heat_endpoint, token=token, **demo_creds)
>>> heat.stacks.get('s')
Traceback (most recent call last):
File "<pyshell#153>", line 1, in <module>
heat.stacks.get('s')
File "/usr/local/lib/python2.7/dist-packages/heatclient/v1/stacks.py", line 202, in get
resp, body = self.client.json_request('GET', '/stacks/%s' % stack_id)
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 265, in json_request
resp = self._http_request(url, method, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/heatclient/common/http.py", line 220, in _http_request
raise exc.from_response(resp)
HTTPForbidden: ERROR: Access was denied to this resource.
>>>
>>>
>>>
>>> keystone = ksclient.Client(**demo_creds)
>>> keystone.services.list()
Traceback (most recent call last):
File "<pyshell#158>", line 1, in <module>
keystone.services.list()
File "/usr/local/lib/python2.7/dist-packages/keystoneclient/v2_0/services.py", line 32, in list
return self._list("/OS-KSADM/services", "OS-KSADM:services")
File "/usr/local/lib/python2.7/dist-packages/keystoneclient/base.py", line 113, in _list
resp, body = self.client.get(url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keystoneclient/adapter.py", line 170, in get
return self.request(url, 'GET', **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keystoneclient/adapter.py", line 206, in request
resp = super(LegacyJsonAdapter, self).request(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keystoneclient/adapter.py", line 95, in request
return self.session.request(url, method, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keystoneclient/utils.py", line 336, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keystoneclient/session.py", line 397, in request
raise exceptions.from_response(resp, method, url)
Forbidden: You are not authorized to perform the requested action: admin_required (Disable debug mode to suppress these details.) (HTTP 403) (Request-ID: req-becd4247-358c-410d-b0ca-1df3004c40b5)
>>>
>>> keystone.auth_token
u'81a536e331644a6bb80d5de04579478b'
>>>
>>> heat = heatclient.Client(heat_endpoint, token=token, **demo_creds)
>>> token = keystone.auth_token
>>> token
u'81a536e331644a6bb80d5de04579478b'
>>> heat = heatclient.Client(heat_endpoint, token=token, **demo_creds)
>>> heat.stacks.get('s')
<Stack {u'disable_rollback': True, u'description': u'Heat WordPress template to support F18, using only Heat OpenStack-native resource types, and without the requirement for heat-cfntools in the image. WordPress is web software you can use to create a beautiful website or blog. This template installs a single-instance WordPress deployment using a local MySQL database to store the data.\n', u'parent': None, u'tags': None, u'stack_name': u's', u'stack_user_project_id': u'27d984f4753b4f76b195e52060ac7af9', u'stack_status_reason': u'Stack CREATE completed successfully', u'creation_time': u'2015-06-08T10:24:47', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'self'}], u'capabilities': [], u'notification_topics': [], u'parameters': {u'OS::project_id': u'd8f42a85e023411080a86768fa0e4692', u'OS::stack_id': u'8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'OS::stack_name': u's', u'instance_type': u'm1.tiny', u'key_name': u'heat_key', u'image_id': u'cirros-0.3.4-x86_64-uec'}, u'timeout_mins': None, u'stack_status': u'CREATE_COMPLETE', u'stack_owner': u'demo', u'updated_time': None, u'id': u'8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'outputs': [], u'template_description': u'Heat WordPress template to support F18, using only Heat OpenStack-native resource types, and without the requirement for heat-cfntools in the image. WordPress is web software you can use to create a beautiful website or blog. This template installs a single-instance WordPress deployment using a local MySQL database to store the data.\n'}>
>>> for s in heat.stacks.list():
print s
<Stack {u'description': u'Heat WordPress template to support F18, using only Heat OpenStack-native resource types, and without the requirement for heat-cfntools in the image. WordPress is web software you can use to create a beautiful website or blog. This template installs a single-instance WordPress deployment using a local MySQL database to store the data.\n', u'parent': None, u'tags': None, u'stack_name': u's', u'stack_user_project_id': u'27d984f4753b4f76b195e52060ac7af9', u'stack_status_reason': u'Stack CREATE completed successfully', u'creation_time': u'2015-06-08T10:24:47', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'self'}], u'updated_time': None, u'stack_owner': u'demo', u'stack_status': u'CREATE_COMPLETE', u'id': u'8f2d5f57-d5c5-4eed-b09b-feaf04779431'}>
>>>
>>> s = heat.stacks.get('s')
>>> s.outputs
[]
>>>
>>> heat.resources.list('s)
SyntaxError: EOL while scanning string literal
>>> heat.resources.list('s')
[<Resource {u'resource_name': u'myserver1', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver1', u'rel': u'self'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'stack'}], u'logical_resource_id': u'myserver1', u'creation_time': u'2015-06-08T10:24:48', u'resource_status': u'CREATE_COMPLETE', u'updated_time': u'2015-06-08T10:24:48', u'required_by': [], u'resource_status_reason': u'state changed', u'physical_resource_id': u'd92e0280-f1e9-46c9-9397-565c0ca003a0', u'resource_type': u'OS::Nova::Server'}>, <Resource {u'resource_name': u'myserver', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver', u'rel': u'self'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'stack'}], u'logical_resource_id': u'myserver', u'creation_time': u'2015-06-08T10:24:48', u'resource_status': u'CREATE_COMPLETE', u'updated_time': u'2015-06-08T10:24:48', u'required_by': [u'myserver1'], u'resource_status_reason': u'state changed', u'physical_resource_id': u'a59ec336-1e3b-43e6-9cb4-2ef839a76fa4', u'resource_type': u'OS::Nova::Server'}>]
>>> r = heat.resources.list('s')
>>> len(r)
2
>>> for x in r:
print x.name
Traceback (most recent call last):
File "<pyshell#180>", line 2, in <module>
print x.name
File "/usr/local/lib/python2.7/dist-packages/heatclient/openstack/common/apiclient/base.py", line 494, in __getattr__
raise AttributeError(k)
AttributeError: name
>>> for x in r:
print x.resource_name
myserver1
myserver
>>>
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__', 'creds', 'demo_creds', 'e', 'get_keystone_admin_creds', 'get_keystone_creds', 'heat', 'heat_endpoint', 'heatclient', 'keystone', 'ksclient', 'nvclient', 'os', 'r', 'retrying', 's', 's1', 'services', 't', 'token', 'u', 'users', 'x', 'x1']
>>> type(heat)
<class 'heatclient.v1.client.Client'>
>>> heat.events.list('s')
[<Event {u'resource_name': u's', u'event_time': u'2015-06-08T10:25:44', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/s/events/82e42593-ce39-4129-b2fc-85d9e7730de2', u'rel': u'self'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/s', u'rel': u'resource'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'stack'}], u'logical_resource_id': u's', u'resource_status': u'CREATE_COMPLETE', u'resource_status_reason': u'Stack CREATE completed successfully', u'physical_resource_id': u'8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'id': u'82e42593-ce39-4129-b2fc-85d9e7730de2'}>, <Event {u'resource_name': u'myserver1', u'event_time': u'2015-06-08T10:25:44', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver1/events/cea7a505-63f6-4534-873f-1b23b773de58', u'rel': u'self'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver1', u'rel': u'resource'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'stack'}], u'logical_resource_id': u'myserver1', u'resource_status': u'CREATE_COMPLETE', u'resource_status_reason': u'state changed', u'physical_resource_id': u'd92e0280-f1e9-46c9-9397-565c0ca003a0', u'id': u'cea7a505-63f6-4534-873f-1b23b773de58'}>, <Event {u'resource_name': u'myserver1', u'event_time': u'2015-06-08T10:25:34', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver1/events/a812b9fd-8c66-4ee3-ad88-b93d19e6983f', u'rel': u'self'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver1', u'rel': u'resource'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'stack'}], u'logical_resource_id': u'myserver1', u'resource_status': u'CREATE_IN_PROGRESS', u'resource_status_reason': u'state changed', u'physical_resource_id': None, u'id': u'a812b9fd-8c66-4ee3-ad88-b93d19e6983f'}>, <Event {u'resource_name': u'myserver', u'event_time': u'2015-06-08T10:24:57', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver/events/db86280d-818f-4f2b-8b9d-a56341ab3cc6', u'rel': u'self'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver', u'rel': u'resource'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'stack'}], u'logical_resource_id': u'myserver', u'resource_status': u'CREATE_COMPLETE', u'resource_status_reason': u'state changed', u'physical_resource_id': u'a59ec336-1e3b-43e6-9cb4-2ef839a76fa4', u'id': u'db86280d-818f-4f2b-8b9d-a56341ab3cc6'}>, <Event {u'resource_name': u'myserver', u'event_time': u'2015-06-08T10:24:48', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver/events/b09bc00d-09b1-4763-b29f-5f459b0b53a4', u'rel': u'self'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver', u'rel': u'resource'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'stack'}], u'logical_resource_id': u'myserver', u'resource_status': u'CREATE_IN_PROGRESS', u'resource_status_reason': u'state changed', u'physical_resource_id': None, u'id': u'b09bc00d-09b1-4763-b29f-5f459b0b53a4'}>, <Event {u'resource_name': u's', u'event_time': u'2015-06-08T10:24:48', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/s/events/ad3ebf05-eb1e-46c9-82d7-030ec9532748', u'rel': u'self'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/s', u'rel': u'resource'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'stack'}], u'logical_resource_id': u's', u'resource_status': u'CREATE_IN_PROGRESS', u'resource_status_reason': u'Stack CREATE started', u'physical_resource_id': u'8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'id': u'ad3ebf05-eb1e-46c9-82d7-030ec9532748'}>]
>>> len(heat.events.list('s'))
6
>>> for e in heat.events.list('s'):
print e
print "\n"
<Event {u'resource_name': u's', u'event_time': u'2015-06-08T10:25:44', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/s/events/82e42593-ce39-4129-b2fc-85d9e7730de2', u'rel': u'self'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/s', u'rel': u'resource'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'stack'}], u'logical_resource_id': u's', u'resource_status': u'CREATE_COMPLETE', u'resource_status_reason': u'Stack CREATE completed successfully', u'physical_resource_id': u'8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'id': u'82e42593-ce39-4129-b2fc-85d9e7730de2'}>
<Event {u'resource_name': u'myserver1', u'event_time': u'2015-06-08T10:25:44', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver1/events/cea7a505-63f6-4534-873f-1b23b773de58', u'rel': u'self'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver1', u'rel': u'resource'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'stack'}], u'logical_resource_id': u'myserver1', u'resource_status': u'CREATE_COMPLETE', u'resource_status_reason': u'state changed', u'physical_resource_id': u'd92e0280-f1e9-46c9-9397-565c0ca003a0', u'id': u'cea7a505-63f6-4534-873f-1b23b773de58'}>
<Event {u'resource_name': u'myserver1', u'event_time': u'2015-06-08T10:25:34', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver1/events/a812b9fd-8c66-4ee3-ad88-b93d19e6983f', u'rel': u'self'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver1', u'rel': u'resource'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'stack'}], u'logical_resource_id': u'myserver1', u'resource_status': u'CREATE_IN_PROGRESS', u'resource_status_reason': u'state changed', u'physical_resource_id': None, u'id': u'a812b9fd-8c66-4ee3-ad88-b93d19e6983f'}>
<Event {u'resource_name': u'myserver', u'event_time': u'2015-06-08T10:24:57', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver/events/db86280d-818f-4f2b-8b9d-a56341ab3cc6', u'rel': u'self'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver', u'rel': u'resource'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'stack'}], u'logical_resource_id': u'myserver', u'resource_status': u'CREATE_COMPLETE', u'resource_status_reason': u'state changed', u'physical_resource_id': u'a59ec336-1e3b-43e6-9cb4-2ef839a76fa4', u'id': u'db86280d-818f-4f2b-8b9d-a56341ab3cc6'}>
<Event {u'resource_name': u'myserver', u'event_time': u'2015-06-08T10:24:48', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver/events/b09bc00d-09b1-4763-b29f-5f459b0b53a4', u'rel': u'self'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/myserver', u'rel': u'resource'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'stack'}], u'logical_resource_id': u'myserver', u'resource_status': u'CREATE_IN_PROGRESS', u'resource_status_reason': u'state changed', u'physical_resource_id': None, u'id': u'b09bc00d-09b1-4763-b29f-5f459b0b53a4'}>
<Event {u'resource_name': u's', u'event_time': u'2015-06-08T10:24:48', u'links': [{u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/s/events/ad3ebf05-eb1e-46c9-82d7-030ec9532748', u'rel': u'self'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431/resources/s', u'rel': u'resource'}, {u'href': u'http://192.168.80.130:8004/v1/d8f42a85e023411080a86768fa0e4692/stacks/s/8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'rel': u'stack'}], u'logical_resource_id': u's', u'resource_status': u'CREATE_IN_PROGRESS', u'resource_status_reason': u'Stack CREATE started', u'physical_resource_id': u'8f2d5f57-d5c5-4eed-b09b-feaf04779431', u'id': u'ad3ebf05-eb1e-46c9-82d7-030ec9532748'}>
>>> demo_creds
{'username': 'demo', 'tenant_name': 'demo', 'password': 'nomoresecrete', 'auth_url': 'http://192.168.80.130:5000/v2.0'}
>>> keystone.users.list()
Traceback (most recent call last):
File "<pyshell#193>", line 1, in <module>
keystone.users.list()
File "/usr/local/lib/python2.7/dist-packages/keystoneclient/v2_0/users.py", line 125, in list
return self._list("/users%s" % query, "users")
File "/usr/local/lib/python2.7/dist-packages/keystoneclient/base.py", line 113, in _list
resp, body = self.client.get(url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keystoneclient/adapter.py", line 170, in get
return self.request(url, 'GET', **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keystoneclient/adapter.py", line 206, in request
resp = super(LegacyJsonAdapter, self).request(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keystoneclient/adapter.py", line 95, in request
return self.session.request(url, method, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keystoneclient/utils.py", line 336, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keystoneclient/session.py", line 397, in request
raise exceptions.from_response(resp, method, url)
Forbidden: You are not authorized to perform the requested action: admin_required (Disable debug mode to suppress these details.) (HTTP 403) (Request-ID: req-56626733-9701-4503-b4da-58e4ac814f49)
>>> creds
{'username': 'admin', 'tenant_name': 'admin', 'password': 'nomoresecrete', 'auth_url': 'http://192.168.80.130:5000/v2.0'}
>>> keystone = ksclient.Client(**creds)
>>> for u in keystone.users.list():
print u
print "\N
SyntaxError: EOL while scanning string literal
>>> for u in keystone.users.list():
print u
print "\n"
<User {u'username': u'heat', u'id': u'126452eda45e47549d8c7e75f355c76e', u'enabled': True, u'name': u'heat', u'email': None}>
<User {u'username': u'admin', u'id': u'5651e750923546e695e06ca9a810c759', u'enabled': True, u'name': u'admin', u'email': None}>
<User {u'username': u'neutron', u'id': u'81758bbaec0c420fbe97e5fbdbb52152', u'enabled': True, u'name': u'neutron', u'email': None}>
<User {u'username': u'cinder', u'id': u'934ff7c1dc1845a48244a3232d67c86a', u'enabled': True, u'name': u'cinder', u'email': None}>
<User {u'username': u'nova', u'id': u'c457ef7813c149eca1c6b1b02da394ca', u'enabled': True, u'name': u'nova', u'email': None}>
<User {u'username': u'glance', u'id': u'ccfa207f5b33407699ed3d39b96319d8', u'enabled': True, u'name': u'glance', u'email': None}>
<User {u'username': u'demo', u'id': u'f2e0e944388943e389e5f50f0de1ade3', u'enabled': True, u'name': u'demo', u'email': u'demo@example.com'}>
>>>
>>> demo_creds
{'username': 'demo', 'tenant_name': 'demo', 'password': 'nomoresecrete', 'auth_url': 'http://192.168.80.130:5000/v2.0'}
>>> del demo_creds['username']
>>> demo_creds
{'tenant_name': 'demo', 'password': 'nomoresecrete', 'auth_url': 'http://192.168.80.130:5000/v2.0'}
>>> demo_creds['user_id']='f2e0e944388943e389e5f50f0de1ade3'
>>> help(ksclient.Client)
Help on class Client in module keystoneclient.v2_0.client:
class Client(keystoneclient.httpclient.HTTPClient)
| Client for the OpenStack Keystone v2.0 API.
|
| :param string username: Username for authentication. (optional)
| :param string password: Password for authentication. (optional)
| :param string token: Token for authentication. (optional)
| :param string tenant_id: Tenant id. (optional)
| :param string tenant_name: Tenant name. (optional)
| :param string auth_url: Keystone service endpoint for authorization.
| :param string region_name: Name of a region to select when choosing an
| endpoint from the service catalog.
| :param string endpoint: A user-supplied endpoint URL for the keystone
| service. Lazy-authentication is possible for API
| service calls if endpoint is set at
| instantiation.(optional)
| :param integer timeout: Allows customization of the timeout for client
| http requests. (optional)
| :param string original_ip: The original IP of the requesting user
| which will be sent to Keystone in a
| 'Forwarded' header. (optional)
| :param string cert: Path to the Privacy Enhanced Mail (PEM) file which
| contains the corresponding X.509 client certificate
| needed to established two-way SSL connection with
| the identity service. (optional)
| :param string key: Path to the Privacy Enhanced Mail (PEM) file which
| contains the unencrypted client private key needed
| to established two-way SSL connection with the
| identity service. (optional)
| :param string cacert: Path to the Privacy Enhanced Mail (PEM) file which
| contains the trusted authority X.509 certificates
| needed to established SSL connection with the
| identity service. (optional)
| :param boolean insecure: Does not perform X.509 certificate validation
| when establishing SSL connection with identity
| service. default: False (optional)
| :param dict auth_ref: To allow for consumers of the client to manage their
| own caching strategy, you may initialize a client
| with a previously captured auth_reference (token)
| :param boolean debug: Enables debug logging of all request and responses
| to keystone. default False (option)
|
| .. warning::
|
| If debug is enabled, it may show passwords in plain text as a part of
| its output.
|
|
| The client can be created and used like a user or in a strictly
| bootstrap mode. Normal operation expects a username, password, auth_url,
| and tenant_name or id to be provided. Other values will be lazily loaded
| as needed from the service catalog.
|
| Example::
|
| >>> from keystoneclient.v2_0 import client
| >>> keystone = client.Client(username=USER,
| ... password=PASS,
| ... tenant_name=TENANT_NAME,
| ... auth_url=KEYSTONE_URL)
| >>> keystone.tenants.list()
| ...
| >>> user = keystone.users.get(USER_ID)
| >>> user.delete()
|
| Once authenticated, you can store and attempt to re-use the
| authenticated token. the auth_ref property on the client
| returns as a dictionary-like-object so that you can export and
| cache it, re-using it when initiating another client::
|
| >>> from keystoneclient.v2_0 import client
| >>> keystone = client.Client(username=USER,
| ... password=PASS,
| ... tenant_name=TENANT_NAME,
| ... auth_url=KEYSTONE_URL)
| >>> auth_ref = keystone.auth_ref
| >>> # pickle or whatever you like here
| >>> new_client = client.Client(auth_ref=auth_ref)
|
| Alternatively, you can provide the administrative token configured in
| keystone and an endpoint to communicate with directly. See
| (``admin_token`` in ``keystone.conf``) In this case, authenticate()
| is not needed, and no service catalog will be loaded.
|
| Example::
|
| >>> from keystoneclient.v2_0 import client
| >>> admin_client = client.Client(
| ... token='12345secret7890',
| ... endpoint='http://localhost:35357/v2.0')
| >>> admin_client.tenants.list()
|
| Method resolution order:
| Client
| keystoneclient.httpclient.HTTPClient
| keystoneclient.baseclient.Client
| keystoneclient.auth.base.BaseAuthPlugin
| __builtin__.object
|
| Methods defined here:
|
| __init__(self, **kwargs)
| Initialize a new client for the Keystone v2.0 API.
|
| get_raw_token_from_identity_service(self, auth_url, username=None, password=None, tenant_name=None, tenant_id=None, token=None, project_name=None, project_id=None, trust_id=None, **kwargs)
| Authenticate against the v2 Identity API.
|
| If a token is provided it will be used in preference over username and
| password.
|
| :returns: access.AccessInfo if authentication was successful.
| :raises keystoneclient.exceptions.AuthorizationFailure: if unable to
| authenticate or validate the existing authorization token
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| version = 'v2.0'
|
| ----------------------------------------------------------------------
| Methods inherited from keystoneclient.httpclient.HTTPClient:
|
| __getattr__(self, name)
|
| __setattr__(self, name, val)
|
| authenticate(*args, **kwargs)
| Authenticate user.
|
| Uses the data provided at instantiation to authenticate against
| the Identity server. This may use either a username and password
| or token for authentication. If a tenant name or id was provided
| then the resulting authenticated client will be scoped to that
| tenant and contain a service catalog of available endpoints.
|
| With the v2.0 API, if a tenant name or ID is not provided, the
| authentication token returned will be 'unscoped' and limited in
| capabilities until a fully-scoped token is acquired.
|
| With the v3 API, if a domain name or id was provided then the resulting
| authenticated client will be scoped to that domain. If a project name
| or ID is not provided, and the authenticating user has a default
| project configured, the authentication token returned will be 'scoped'
| to the default project. Otherwise, the authentication token returned
| will be 'unscoped' and limited in capabilities until a fully-scoped
| token is acquired.
|
| With the v3 API, with the OS-TRUST extension enabled, the trust_id can
| be provided to allow project-specific role delegation between users
|
| If successful, sets the self.auth_ref and self.auth_token with
| the returned token. If not already set, will also set
| self.management_url from the details provided in the token.
|
| :returns: ``True`` if authentication was successful.
| :raises keystoneclient.exceptions.AuthorizationFailure: if unable to
| authenticate or validate the existing authorization token
| :raises keystoneclient.exceptions.ValueError: if insufficient
| parameters are used.
|
| If keyring is used, token is retrieved from keyring instead.
| Authentication will only be necessary if any of the following
| conditions are met:
|
| * keyring is not used
| * if token is not found in keyring
| * if token retrieved from keyring is expired or about to
| expired (as determined by stale_duration)
| * if force_new_token is true
|
| delete(self, url, **kwargs)
| Perform an authenticate DELETE request.
|
| This calls :py:meth:`.request()` with ``method`` set to ``DELETE`` and
| an authentication token if one is available.
|
| .. warning::
| *DEPRECATED*: This function is no longer used. It was designed to
| be used by the managers and the managers now receive an adapter so
| this function is no longer on the standard request path.
|
| get(self, url, **kwargs)
| Perform an authenticated GET request.
|
| This calls :py:meth:`.request()` with ``method`` set to ``GET`` and an
| authentication token if one is available.
|
| .. warning::
| *DEPRECATED*: This function is no longer used. It was designed to
| be used by the managers and the managers now receive an adapter so
| this function is no longer on the standard request path.
|
| get_auth_ref_from_keyring(self, **kwargs)
| Retrieve auth_ref from keyring.
|
| If auth_ref is found in keyring, (keyring_key, auth_ref) is returned.
| Otherwise, (keyring_key, None) is returned.
|
| :returns: (keyring_key, auth_ref) or (keyring_key, None)
| :returns: or (None, None) if use_keyring is not set in the object
|
| get_endpoint(self, session, interface=None, **kwargs)
|
| get_project_id(self, session, **kwargs)
|
| get_token(self, session, **kwargs)
|
| get_user_id(self, session, **kwargs)
|
| has_service_catalog(self)
| Returns True if this client provides a service catalog.
|
| head(self, url, **kwargs)
| Perform an authenticated HEAD request.
|
| This calls :py:meth:`.request()` with ``method`` set to ``HEAD`` and an
| authentication token if one is available.
|
| .. warning::
| *DEPRECATED*: This function is no longer used. It was designed to
| be used by the managers and the managers now receive an adapter so
| this function is no longer on the standard request path.
|
| patch(self, url, **kwargs)
| Perform an authenticate PATCH request.
|
| This calls :py:meth:`.request()` with ``method`` set to ``PATCH`` and
| an authentication token if one is available.
|
| .. warning::
| *DEPRECATED*: This function is no longer used. It was designed to
| be used by the managers and the managers now receive an adapter so
| this function is no longer on the standard request path.
|
| post(self, url, **kwargs)
| Perform an authenticate POST request.
|
| This calls :py:meth:`.request()` with ``method`` set to ``POST`` and an
| authentication token if one is available.
|
| .. warning::
| *DEPRECATED*: This function is no longer used. It was designed to
| be used by the managers and the managers now receive an adapter so
| this function is no longer on the standard request path.
|
| process_token(self, region_name=None)
| Extract and process information from the new auth_ref.
|
| And set the relevant authentication information.
|
| put(self, url, **kwargs)
| Perform an authenticate PUT request.
|
| This calls :py:meth:`.request()` with ``method`` set to ``PUT`` and an
| authentication token if one is available.
|
| .. warning::
| *DEPRECATED*: This function is no longer used. It was designed to
| be used by the managers and the managers now receive an adapter so
| this function is no longer on the standard request path.
|
| request(self, *args, **kwargs)
| Send an http request with the specified characteristics.
|
| Wrapper around requests.request to handle tasks such as
| setting headers, JSON encoding/decoding, and error handling.
|
| .. warning::
| *DEPRECATED*: This function is no longer used. It was designed to
| be used only by the managers and the managers now receive an
| adapter so this function is no longer on the standard request path.
|
| serialize(self, entity)
|
| store_auth_ref_into_keyring(self, keyring_key)
| Store auth_ref into keyring.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from keystoneclient.httpclient.HTTPClient:
|
| auth_token
|
| management_url
|
| service_catalog
| Returns this client's service catalog.
|
| tenant_id
| Provide read-only backwards compatibility for tenant_id.
| This is deprecated, use project_id instead.
|
| tenant_name
| Provide read-only backwards compatibility for tenant_name.
| This is deprecated, use project_name instead.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from keystoneclient.httpclient.HTTPClient:
|
| deprecated_adapter_variables = {'region_name': None}
|
| deprecated_session_variables = {'cert': None, 'original_ip': None, 'ti...
|
| ----------------------------------------------------------------------
| Data descriptors inherited from keystoneclient.baseclient.Client:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Methods inherited from keystoneclient.auth.base.BaseAuthPlugin:
|
| get_headers(self, session, **kwargs)
| Fetch authentication headers for message.
|
| This is a more generalized replacement of the older get_token to allow
| plugins to specify different or additional authentication headers to
| the OpenStack standard 'X-Auth-Token' header.