openstack Ocata版本 python
程序员文章站
2022-09-03 08:28:05
from keystoneauth1.identity import v3 from keystoneauth1 import session from nova... ......
from keystoneauth1.identity import v3
from keystoneauth1 import session
from novaclient import client
from neutronclient.v2_0 import client as neutron_client
from cinderclient.v1 import client as cinder_client
def get_cloud2_creds():
d = dict(
auth_url= 'http://172.28.14.254:35357/v3',
username= "admin",
password= "password",
project_name= "admin",
user_domain_id= "default",
project_domain_id= "default"
)
return d
auth = v3.password(**get_cloud2_creds())
sess = session.session(auth=auth)
nova = client.client("2", session=sess)
print nova.servers.list()
neutron = neutron_client.client(session=sess)
#print neutron.list_networks()
#print neutron.list_subnets()
#print neutron.list_ports(**{'network_id':'73688ff6-e0fc-42a4-ab1d-8e5faaa2cf2f'})
cinder = cinder_client.client(session=sess)
print cinder.volumes.list()
print cinder.volumes.get("eea1e3c5-93f8-4939-978e-a459e6da5d0f")
推荐阅读
-
ubuntu16.04使用Anaconda创建对应python版本的虚拟环境
-
详解如何管理多个Python版本和虚拟环境
-
Python2.x版本中基本的中文编码问题解决
-
mac下pycharm设置python版本的图文教程
-
Python3.x版本中新的字符串格式化方法
-
Python3.0与2.X版本的区别实例分析
-
详解Python3.1版本带来的核心变化
-
windows系统中Python多版本与jupyter notebook使用虚拟环境的过程
-
Python2.6版本中实现字典推导 PEP 274(Dict Comprehensions)
-
Python2.x版本中maketrans()方法的使用介绍