Merge pull request #11213 from resmo/for-ansible

cloudstack: prevent getting the wrong project.
pull/11251/head
Brian Coca 10 years ago
commit f1e4ae5fc3

@ -124,13 +124,12 @@ class AnsibleCloudStack:
if not project: if not project:
return None return None
args = {} args = {}
args['listall'] = True
args['account'] = self.get_account(key='name') args['account'] = self.get_account(key='name')
args['domainid'] = self.get_domain(key='id') args['domainid'] = self.get_domain(key='id')
projects = self.cs.listProjects(**args) projects = self.cs.listProjects(**args)
if projects: if projects:
for p in projects['project']: for p in projects['project']:
if project in [ p['name'], p['displaytext'], p['id'] ]: if project.lower() in [ p['name'].lower(), p['id'] ]:
self.project = p self.project = p
return self._get_by_key(key, self.project) return self._get_by_key(key, self.project)
self.module.fail_json(msg="project '%s' not found" % project) self.module.fail_json(msg="project '%s' not found" % project)
@ -361,6 +360,7 @@ class AnsibleCloudStack:
self.capabilities = capabilities['capability'] self.capabilities = capabilities['capability']
return self._get_by_key(key, self.capabilities) return self._get_by_key(key, self.capabilities)
# TODO: rename to poll_job() # TODO: rename to poll_job()
def _poll_job(self, job=None, key=None): def _poll_job(self, job=None, key=None):
if 'jobid' in job: if 'jobid' in job:

@ -122,13 +122,12 @@ class AnsibleCloudStack:
if not project: if not project:
return None return None
args = {} args = {}
args['listall'] = True
args['account'] = self.get_account(key='name') args['account'] = self.get_account(key='name')
args['domainid'] = self.get_domain(key='id') args['domainid'] = self.get_domain(key='id')
projects = self.cs.listProjects(**args) projects = self.cs.listProjects(**args)
if projects: if projects:
for p in projects['project']: for p in projects['project']:
if project in [ p['name'], p['displaytext'], p['id'] ]: if project.lower() in [ p['name'].lower(), p['id'] ]:
self.project = p self.project = p
return self._get_by_key(key, self.project) return self._get_by_key(key, self.project)
self.module.fail_json(msg="project '%s' not found" % project) self.module.fail_json(msg="project '%s' not found" % project)
@ -359,6 +358,7 @@ class AnsibleCloudStack:
self.capabilities = capabilities['capability'] self.capabilities = capabilities['capability']
return self._get_by_key(key, self.capabilities) return self._get_by_key(key, self.capabilities)
# TODO: rename to poll_job() # TODO: rename to poll_job()
def _poll_job(self, job=None, key=None): def _poll_job(self, job=None, key=None):
if 'jobid' in job: if 'jobid' in job:

Loading…
Cancel
Save