Merge pull request #11226 from resmo/for-ansible
cloudstack: cleanup, remove unused parts
This commit is contained in:
commit
f2934eeb0a
2 changed files with 22 additions and 54 deletions
|
@ -77,8 +77,12 @@ class AnsibleCloudStack:
|
||||||
else:
|
else:
|
||||||
self.cs = CloudStack(**read_config())
|
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):
|
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():
|
for key, value in want_dict.iteritems():
|
||||||
|
|
||||||
# Optionally limit by a list of keys
|
# Optionally limit by a list of keys
|
||||||
|
@ -111,11 +115,6 @@ class AnsibleCloudStack:
|
||||||
return my_dict
|
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):
|
def get_project(self, key=None):
|
||||||
if self.project:
|
if self.project:
|
||||||
return self._get_by_key(key, 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)
|
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):
|
def get_ip_address(self, key=None):
|
||||||
if self.ip_address:
|
if self.ip_address:
|
||||||
return self._get_by_key(key, 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)
|
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):
|
def get_vm(self, key=None):
|
||||||
if self.vm:
|
if self.vm:
|
||||||
return self._get_by_key(key, 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)
|
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):
|
def get_zone(self, key=None):
|
||||||
if self.zone:
|
if self.zone:
|
||||||
return self._get_by_key(key, 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)
|
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):
|
def get_os_type(self, key=None):
|
||||||
if self.os_type:
|
if self.os_type:
|
||||||
return self._get_by_key(key, self.zone)
|
return self._get_by_key(key, self.zone)
|
||||||
|
@ -361,8 +340,12 @@ class AnsibleCloudStack:
|
||||||
return self._get_by_key(key, self.capabilities)
|
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):
|
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:
|
if 'jobid' in job:
|
||||||
while True:
|
while True:
|
||||||
res = self.cs.queryAsyncJobResult(jobid=job['jobid'])
|
res = self.cs.queryAsyncJobResult(jobid=job['jobid'])
|
||||||
|
|
|
@ -64,19 +64,25 @@ class AnsibleCloudStack:
|
||||||
api_secret = self.module.params.get('secret_key')
|
api_secret = self.module.params.get('secret_key')
|
||||||
api_url = self.module.params.get('api_url')
|
api_url = self.module.params.get('api_url')
|
||||||
api_http_method = self.module.params.get('api_http_method')
|
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:
|
if api_key and api_secret and api_url:
|
||||||
self.cs = CloudStack(
|
self.cs = CloudStack(
|
||||||
endpoint=api_url,
|
endpoint=api_url,
|
||||||
key=api_key,
|
key=api_key,
|
||||||
secret=api_secret,
|
secret=api_secret,
|
||||||
|
timeout=api_timeout,
|
||||||
method=api_http_method
|
method=api_http_method
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.cs = CloudStack(**read_config())
|
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):
|
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():
|
for key, value in want_dict.iteritems():
|
||||||
|
|
||||||
# Optionally limit by a list of keys
|
# Optionally limit by a list of keys
|
||||||
|
@ -109,11 +115,6 @@ class AnsibleCloudStack:
|
||||||
return my_dict
|
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):
|
def get_project(self, key=None):
|
||||||
if self.project:
|
if self.project:
|
||||||
return self._get_by_key(key, 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)
|
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):
|
def get_ip_address(self, key=None):
|
||||||
if self.ip_address:
|
if self.ip_address:
|
||||||
return self._get_by_key(key, 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)
|
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):
|
def get_vm(self, key=None):
|
||||||
if self.vm:
|
if self.vm:
|
||||||
return self._get_by_key(key, 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)
|
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):
|
def get_zone(self, key=None):
|
||||||
if self.zone:
|
if self.zone:
|
||||||
return self._get_by_key(key, 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)
|
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):
|
def get_os_type(self, key=None):
|
||||||
if self.os_type:
|
if self.os_type:
|
||||||
return self._get_by_key(key, self.zone)
|
return self._get_by_key(key, self.zone)
|
||||||
|
@ -359,8 +340,12 @@ class AnsibleCloudStack:
|
||||||
return self._get_by_key(key, self.capabilities)
|
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):
|
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:
|
if 'jobid' in job:
|
||||||
while True:
|
while True:
|
||||||
res = self.cs.queryAsyncJobResult(jobid=job['jobid'])
|
res = self.cs.queryAsyncJobResult(jobid=job['jobid'])
|
||||||
|
|
Loading…
Reference in a new issue