nova3 使用控制台nova启动器7.0引擎

1453人阅读
Openstack(61)
&&& 这段时间进行openstack控制台界面的开发有2个多月,感觉学到了不少东西。
&&& 首先是前端的技术,之前只知道简单的html语法,对CSS,JS,JQUERY等一窍不通。年后,小组开发人手不是很够,果断转行去开发,记得刚开始,搞个练手的界面,搞了两天才实现。而且前提是别人写好的结构,拿过来修改使用。熟读唐诗三百首,不会做诗也会吟的境界。但是一旦碰到没有样例的界面,那就头疼了,因为很多标签都是不认识的。但只能问人,搜索用法,记得有几天,写几个界面,搞得有点喘不过气来。但事实证明一句老话,当你感觉到难受的时候,是你学东西最多的时候。因为不懂,所以觉得很难,因为一直坚持,所以特别难受,中途多次想不做前端了,让其他人做,只写后端好了,但还是一直坚持。截止本稿时间,终于学到了一些基本前端,现在做OPensack的控制台界面开发勉强够用。
开发后端直接使用各个服务的client,因为Horizon就是这么干的。
通过实例化一个通过授权认证的客户端对象,然后可以进行后续的操作
nova操作,
import novaclient.v1_1.client as nvclient
nova = nvclient.Client(auth_url=auth_dict[&--os-auth-url&],\
username=auth_dict[&--os-username&],\
api_key=auth_dict[&--os-password&],\
project_id=auth_dict[&--os-tenant-name&])
可以进行的操作,经常用到的:
2.2 keystone
import keystoneclient.v2_0.client as ksclient
keystone = ksclient.Client(auth_url = auth_dict[&--os-auth-url&], \
username = auth_dict[&--os-username&], \
password = auth_dict[&--os-password&], \
tenant_name = auth_dict[&--os-tenant-name&])
2.3 neutron
import neutronclient.v2_0.client as neutronclient
neutron = neutronclient.Client(auth_url=auth_dict[&--os-auth-url&],\
username=auth_dict[&--os-username&],\
password=auth_dict[&--os-password&],\
tenant_name=auth_dict[&--os-tenant-name&])
import neutronclient.v2_0.client as neutronclient
import keystoneclient.v2_0.client as ksclient
keystone = ksclient.Client(auth_url = auth_dict[&--os-auth-url&], \
username = auth_dict[&--os-username&], \
password = auth_dict[&--os-password&], \
tenant_name = auth_dict[&--os-tenant-name&])
endpoint_url = keystone.service_catalog.url_for(service_type='network')
token = keystone.auth_token
neutron2 = neutronclient.Client(endpoint_url=endpoint_url, token=token)
neutron = neutronclient.Client(auth_url=auth_dict[&--os-auth-url&],\
&username=auth_dict[&--os-username&],\
password=auth_dict[&--os-password&],\
tenant_name=auth_dict[&--os-tenant-name&])
2.4 Cinder:
import cinderclient.v1.client as cinderclient
cinder = cinderclient.Client(auth_url=auth_dict[&--os-auth-url&], \
username=auth_dict[&--os-username&], \
api_key=auth_dict[&--os-password&], \
project_id=auth_dict[&--os-tenant-name&])
2.5 Glance:
import glanceclient.v2.client as glclient
import keystoneclient.v2_0.client as ksclient
keystone = ksclient.Client(auth_url=auth_dict[&--os-auth-url&],\
username=auth_dict[&--os-username&],\
password=auth_dict[&--os-password&],\
tenant_name=auth_dict[&--os-tenant-name&])
glance_endpoint = keystone.service_catalog.url_for(service_type='image')
glance = glclient.Client(glance_endpoint, token=keystone.auth_token)
很多操作返回的都是一个对象,比如:
users=keystone.users.list()
print(type(users))
print(users[0].__dict__)
输出如下:
users type: &type 'list'&
user type: &class 'keystoneclient.v2_0.users.User'&
&&& 'name': u'cinder',
&&& 'enabled': True,
&&& 'tenantId': u'1b0a62cad3ddcb61e8ff78a',
&&& 'manager': &keystoneclient.v2_0.users.UserManagerobjectat0x2a3a950&,
&&& 'id': u'b3e76dabe',
&&& '_info': {
&&&&&&& u'id': u'b3e76dabe',
&&&&&&& u'enabled': True,
&&&&&&& u'email': u'cinder@localhost',
&&&&&&& u'name': u'cinder',
&&&&&&& u'tenantId': u'1b0a62cad3ddcb61e8ff78a'
&&& 'email': u'cinder@localhost',
&&& '_loaded': True
发现__dict__包含的_info字段的内容已经是这个对象的我们要用到的属性了,所以可以直接用这个_info的内容。
&&相关文章推荐
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:227864次
积分:4965
积分:4965
排名:第5146名
原创:242篇
评论:27条
阅读:8090
阅读:111312
阅读:4122
(1)(1)(3)(1)(4)(1)(1)(3)(2)(1)(1)(4)(2)(1)(1)(11)(217)}

我要回帖

更多关于 nova3第三关引擎室 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信