首页 > 编程语言 > 详细

openstack python sdk list tenants get token get servers

时间:2016-01-06 20:02:12      阅读:189      评论:0      收藏:0      [点我收藏+]

1,openstack python sdk 获取token 获取租户tenants projects

#!/bin/bash
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=admin
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=yidesk321
export OS_AUTH_URL=http://controller-test:35357/v2.0
export OS_IMAGE_API_VERSION=2

#!/usr/bin/python
from os import environ as env
import keystoneclient.v2_0.client as ksclient
keystone = ksclient.Client(auth_url=env[OS_AUTH_URL],
                           username=env[OS_USERNAME],
                           password=env[OS_PASSWORD],
                           tenant_name=env[OS_TENANT_NAME])
print keystone.auth_token
print keystone.tenants.list()

2.获取指定project 下的servers

#!/usr/bin/env python
#import os
from credentials import get_nova_credentials_v2
from novaclient.client import Client

credentials = get_nova_credentials_v2()
nova_client = Client(**credentials)

print(nova_client.servers.list())

 

openstack python sdk list tenants get token get servers

原文:http://www.cnblogs.com/ruiy/p/5106585.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!