mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-04 15:29:10 -07:00
Python 3 fixes for CloudStack modules and tests. (#24400)
This commit is contained in:
parent
6aa32d3e9d
commit
d999d613cb
23 changed files with 25 additions and 29 deletions
|
@ -28,7 +28,11 @@
|
||||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from ansible.module_utils._text import to_text
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from cs import CloudStack, CloudStackException, read_config
|
from cs import CloudStack, CloudStackException, read_config
|
||||||
HAS_LIB_CS = True
|
HAS_LIB_CS = True
|
||||||
|
@ -47,6 +51,9 @@ CS_HYPERVISORS = [
|
||||||
'Simulator', 'simulator',
|
'Simulator', 'simulator',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if sys.version_info > (3,):
|
||||||
|
long = int
|
||||||
|
|
||||||
|
|
||||||
def cs_argument_spec():
|
def cs_argument_spec():
|
||||||
return dict(
|
return dict(
|
||||||
|
@ -184,20 +191,23 @@ class AnsibleCloudStack(object):
|
||||||
self.result['diff']['after'][key] = value
|
self.result['diff']['after'][key] = value
|
||||||
result = True
|
result = True
|
||||||
else:
|
else:
|
||||||
|
before_value = to_text(current_dict[key])
|
||||||
|
after_value = to_text(value)
|
||||||
|
|
||||||
if self.case_sensitive_keys and key in self.case_sensitive_keys:
|
if self.case_sensitive_keys and key in self.case_sensitive_keys:
|
||||||
if value != current_dict[key].encode('utf-8'):
|
if before_value != after_value:
|
||||||
self.result['diff']['before'][key] = current_dict[key].encode('utf-8')
|
self.result['diff']['before'][key] = before_value
|
||||||
self.result['diff']['after'][key] = value
|
self.result['diff']['after'][key] = after_value
|
||||||
result = True
|
result = True
|
||||||
|
|
||||||
# Test for diff in case insensitive way
|
# Test for diff in case insensitive way
|
||||||
elif value.lower() != current_dict[key].encode('utf-8').lower():
|
elif before_value.lower() != after_value.lower():
|
||||||
self.result['diff']['before'][key] = current_dict[key].encode('utf-8')
|
self.result['diff']['before'][key] = before_value
|
||||||
self.result['diff']['after'][key] = value
|
self.result['diff']['after'][key] = after_value
|
||||||
result = True
|
result = True
|
||||||
else:
|
else:
|
||||||
self.result['diff']['before'][key] = None
|
self.result['diff']['before'][key] = None
|
||||||
self.result['diff']['after'][key] = value
|
self.result['diff']['after'][key] = to_text(value)
|
||||||
result = True
|
result = True
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,7 @@ except ImportError:
|
||||||
HAS_LIB_SSHPUBKEYS = False
|
HAS_LIB_SSHPUBKEYS = False
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible.module_utils._text import to_native
|
||||||
from ansible.module_utils.cloudstack import (
|
from ansible.module_utils.cloudstack import (
|
||||||
AnsibleCloudStack,
|
AnsibleCloudStack,
|
||||||
CloudStackException,
|
CloudStackException,
|
||||||
|
@ -232,6 +233,8 @@ class AnsibleCloudStackSshKey(AnsibleCloudStack):
|
||||||
|
|
||||||
def _get_ssh_fingerprint(self, public_key):
|
def _get_ssh_fingerprint(self, public_key):
|
||||||
key = sshpubkeys.SSHKey(public_key)
|
key = sshpubkeys.SSHKey(public_key)
|
||||||
|
if hasattr(key, 'hash_md5'):
|
||||||
|
return key.hash_md5().replace(to_native('MD5:'), to_native(''))
|
||||||
return key.hash()
|
return key.hash()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- config|failed
|
- config|failed
|
||||||
- "config.msg == 'missing required arguments: value,name'"
|
- "config.msg.startswith('missing required arguments: ')"
|
||||||
|
|
||||||
- name: test configuration
|
- name: test configuration
|
||||||
cs_configuration:
|
cs_configuration:
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- lb|failed
|
- lb|failed
|
||||||
- "'ip_address,name' in lb.msg"
|
- "lb.msg.startswith('missing required arguments: ')"
|
||||||
|
|
||||||
- name: test create rule
|
- name: test create rule
|
||||||
cs_loadbalancer_rule:
|
cs_loadbalancer_rule:
|
||||||
|
@ -143,7 +143,7 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- lb|failed
|
- lb|failed
|
||||||
- "'vms,name' in lb.msg"
|
- "lb.msg.startswith('missing required arguments: ')"
|
||||||
|
|
||||||
- name: test add members to rule
|
- name: test add members to rule
|
||||||
cs_loadbalancer_rule_member:
|
cs_loadbalancer_rule_member:
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- pf|failed
|
- pf|failed
|
||||||
- 'pf.msg == "missing required arguments: private_port,ip_address,public_port"'
|
- 'pf.msg.startswith("missing required arguments: ")'
|
||||||
|
|
||||||
- name: test present port forwarding
|
- name: test present port forwarding
|
||||||
cs_portforward:
|
cs_portforward:
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- snap|failed
|
- snap|failed
|
||||||
- 'snap.msg == "missing required arguments: vm,name"'
|
- 'snap.msg.startswith("missing required arguments: ")'
|
||||||
|
|
||||||
- name: test create snapshot
|
- name: test create snapshot
|
||||||
cs_vmsnapshot:
|
cs_vmsnapshot:
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
cloud/cs
|
cloud/cs
|
||||||
posix/ci/cloud/cs
|
posix/ci/cloud/cs
|
||||||
skip/python3
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue