Merge pull request #11226 from resmo/for-ansible

cloudstack: cleanup, remove unused parts
This commit is contained in:
Brian Coca 2015-06-10 14:44:49 -04:00
commit f2934eeb0a
2 changed files with 22 additions and 54 deletions

View file

@ -77,8 +77,12 @@ class AnsibleCloudStack:
else:
self.cs = CloudStack(**read_config())
# TODO: rename to has_changed()
# TODO: for backward compatibility only, remove if not used anymore
def _has_changed(self, want_dict, current_dict, only_keys=None):
return self.has_changed(want_dict=want_dict, current_dict=current_dict, only_keys=only_keys)
def has_changed(self, want_dict, current_dict, only_keys=None):
for key, value in want_dict.iteritems():
# Optionally limit by a list of keys
@ -111,11 +115,6 @@ class AnsibleCloudStack:
return my_dict
# TODO: for backward compatibility only, remove if not used anymore
def get_project_id(self):
return self.get_project(key='id')
def get_project(self, key=None):
if self.project:
return self._get_by_key(key, self.project)
@ -135,11 +134,6 @@ class AnsibleCloudStack:
self.module.fail_json(msg="project '%s' not found" % project)
# TODO: for backward compatibility only, remove if not used anymore
def get_ip_address_id(self):
return self.get_ip_address(key='id')
def get_ip_address(self, key=None):
if self.ip_address:
return self._get_by_key(key, self.ip_address)
@ -162,11 +156,6 @@ class AnsibleCloudStack:
return self._get_by_key(key, self.ip_address)
# TODO: for backward compatibility only, remove if not used anymore
def get_vm_id(self):
return self.get_vm(key='id')
def get_vm(self, key=None):
if self.vm:
return self._get_by_key(key, self.vm)
@ -189,11 +178,6 @@ class AnsibleCloudStack:
self.module.fail_json(msg="Virtual machine '%s' not found" % vm)
# TODO: for backward compatibility only, remove if not used anymore
def get_zone_id(self):
return self.get_zone(key='id')
def get_zone(self, key=None):
if self.zone:
return self._get_by_key(key, self.zone)
@ -214,11 +198,6 @@ class AnsibleCloudStack:
self.module.fail_json(msg="zone '%s' not found" % zone)
# TODO: for backward compatibility only, remove if not used anymore
def get_os_type_id(self):
return self.get_os_type(key='id')
def get_os_type(self, key=None):
if self.os_type:
return self._get_by_key(key, self.zone)
@ -361,8 +340,12 @@ class AnsibleCloudStack:
return self._get_by_key(key, self.capabilities)
# TODO: rename to poll_job()
# TODO: for backward compatibility only, remove if not used anymore
def _poll_job(self, job=None, key=None):
return self.poll_job(job=job, key=key)
def poll_job(self, job=None, key=None):
if 'jobid' in job:
while True:
res = self.cs.queryAsyncJobResult(jobid=job['jobid'])

View file

@ -64,19 +64,25 @@ class AnsibleCloudStack:
api_secret = self.module.params.get('secret_key')
api_url = self.module.params.get('api_url')
api_http_method = self.module.params.get('api_http_method')
api_timeout = self.module.params.get('api_timeout')
if api_key and api_secret and api_url:
self.cs = CloudStack(
endpoint=api_url,
key=api_key,
secret=api_secret,
timeout=api_timeout,
method=api_http_method
)
else:
self.cs = CloudStack(**read_config())
# TODO: rename to has_changed()
# TODO: for backward compatibility only, remove if not used anymore
def _has_changed(self, want_dict, current_dict, only_keys=None):
return self.has_changed(want_dict=want_dict, current_dict=current_dict, only_keys=only_keys)
def has_changed(self, want_dict, current_dict, only_keys=None):
for key, value in want_dict.iteritems():
# Optionally limit by a list of keys
@ -109,11 +115,6 @@ class AnsibleCloudStack:
return my_dict
# TODO: for backward compatibility only, remove if not used anymore
def get_project_id(self):
return self.get_project(key='id')
def get_project(self, key=None):
if self.project:
return self._get_by_key(key, self.project)
@ -133,11 +134,6 @@ class AnsibleCloudStack:
self.module.fail_json(msg="project '%s' not found" % project)
# TODO: for backward compatibility only, remove if not used anymore
def get_ip_address_id(self):
return self.get_ip_address(key='id')
def get_ip_address(self, key=None):
if self.ip_address:
return self._get_by_key(key, self.ip_address)
@ -160,11 +156,6 @@ class AnsibleCloudStack:
return self._get_by_key(key, self.ip_address)
# TODO: for backward compatibility only, remove if not used anymore
def get_vm_id(self):
return self.get_vm(key='id')
def get_vm(self, key=None):
if self.vm:
return self._get_by_key(key, self.vm)
@ -187,11 +178,6 @@ class AnsibleCloudStack:
self.module.fail_json(msg="Virtual machine '%s' not found" % vm)
# TODO: for backward compatibility only, remove if not used anymore
def get_zone_id(self):
return self.get_zone(key='id')
def get_zone(self, key=None):
if self.zone:
return self._get_by_key(key, self.zone)
@ -212,11 +198,6 @@ class AnsibleCloudStack:
self.module.fail_json(msg="zone '%s' not found" % zone)
# TODO: for backward compatibility only, remove if not used anymore
def get_os_type_id(self):
return self.get_os_type(key='id')
def get_os_type(self, key=None):
if self.os_type:
return self._get_by_key(key, self.zone)
@ -359,8 +340,12 @@ class AnsibleCloudStack:
return self._get_by_key(key, self.capabilities)
# TODO: rename to poll_job()
# TODO: for backward compatibility only, remove if not used anymore
def _poll_job(self, job=None, key=None):
return self.poll_job(job=job, key=key)
def poll_job(self, job=None, key=None):
if 'jobid' in job:
while True:
res = self.cs.queryAsyncJobResult(jobid=job['jobid'])