Pass the keystone creds to resource.py so usable from run-parser and heat

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
Angus Salkeld 2012-04-02 12:00:21 +10:00
parent 7d11d4abf6
commit 8d372fcb16
3 changed files with 17 additions and 9 deletions

View File

@ -49,5 +49,17 @@ with open(filename) as f:
setparam(params_dict, 'DBRootPassword', 'admone')
setparam(params_dict, 'LinuxDistribution', 'F16')
# set the keystone auth environs up
username = os.environ['OS_USERNAME']
password = os.environ['OS_PASSWORD']
tenant = os.environ['OS_TENANT_NAME']
auth_url = os.environ['OS_AUTH_URL']
params_dict['KeyStoneCreds'] = dict(username=username,
password=password,
tenant=tenant,
auth_url=auth_url,
strategy='keystone')
stack = parser.Stack(stack_name, json_blob, params_dict)
stack.start()

View File

@ -42,6 +42,7 @@ class Stack:
if parms != None:
self._apply_user_parameters(parms)
self.creds = parms['KeyStoneCreds']
self.resources = {}
for r in self.t['Resources']:

View File

@ -289,16 +289,11 @@ class Instance(Resource):
distro_name = self.stack.parameter_get('LinuxDistribution')
key_name = self.t['Properties']['KeyName']
image_name = self.t['Properties']['ImageId']
# TODO(sdake)
# self.stack.parameter_get('KeyStoneCreds')
# parse the keystone credentials and set the os variables
# note this works with bin/run-parser.py ;)
username = os.environ['OS_USERNAME']
password = os.environ['OS_PASSWORD']
tenant = os.environ['OS_TENANT_NAME']
auth_url = os.environ['OS_AUTH_URL']
username = self.stack.creds['username']
password = self.stack.creds['password']
tenant = self.stack.creds['tenant']
auth_url = self.stack.creds['auth_url']
nova_client = client.Client(username, password, tenant, auth_url, service_type='compute', service_name='nova')
image_list = nova_client.images.list()