openstack kilo python cinderclient

➜  ~ python
Python 2.7.5 (default, Oct 30 2018, 23:45:53)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from cinderclient import client
>>> cinder = client.Client('1', "admin", "312", "admin", "http://localhost:35357/v2.0")
>>> cinder.volumes.list()
[<Volume: 38d52a5d-ee13-4ea3-b370-e80d41ada1f2>, <Volume: 046a2b6c-72a0-4a1d-9874-121afe1557a7>, <Volume: eeb23bf0-f53e-4062-8162-e261c4774fe4>]

使用下面的参数内容,但是不能用$OS_USER_NAME, 会报invalid syntax
cinder = client.Client('1', $OS_USER_NAME, $OS_PASSWORD, $OS_TENANT_NAME, $OS_AUTH_URL)

猜你喜欢

转载自www.cnblogs.com/longchang/p/10767489.html