mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* rax_scaling_group: fix sanity check
* add changelog fragment
* added missing call to expanduser()
(cherry picked from commit 6a03108609
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
d6d9f84b0a
commit
2435fb3f30
8 changed files with 26 additions and 20 deletions
2
changelogs/fragments/5563-rax-scaling-group-sanity.yml
Normal file
2
changelogs/fragments/5563-rax-scaling-group-sanity.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- rax_scaling_group - refactored out code to the ``rax`` module utils to clear the sanity check (https://github.com/ansible-collections/community.general/pull/5563).
|
|
@ -314,3 +314,21 @@ def setup_rax_module(module, rax_module, region_required=True):
|
||||||
(region, ','.join(rax_module.regions)))
|
(region, ','.join(rax_module.regions)))
|
||||||
|
|
||||||
return rax_module
|
return rax_module
|
||||||
|
|
||||||
|
|
||||||
|
def rax_scaling_group_personality_file(module, files):
|
||||||
|
if not files:
|
||||||
|
return []
|
||||||
|
|
||||||
|
results = []
|
||||||
|
for rpath, lpath in files.items():
|
||||||
|
lpath = os.path.expanduser(lpath)
|
||||||
|
try:
|
||||||
|
with open(lpath, 'r') as f:
|
||||||
|
results.append({
|
||||||
|
'path': rpath,
|
||||||
|
'contents': f.read(),
|
||||||
|
})
|
||||||
|
except Exception as e:
|
||||||
|
module.fail_json(msg='Failed to load %s: %s' % (lpath, str(e)))
|
||||||
|
return results
|
||||||
|
|
|
@ -161,8 +161,11 @@ except ImportError:
|
||||||
HAS_PYRAX = False
|
HAS_PYRAX = False
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible_collections.community.general.plugins.module_utils.rax import (rax_argument_spec, rax_find_image, rax_find_network,
|
from ansible_collections.community.general.plugins.module_utils.rax import (
|
||||||
rax_required_together, rax_to_dict, setup_rax_module)
|
rax_argument_spec, rax_find_image, rax_find_network,
|
||||||
|
rax_required_together, rax_to_dict, setup_rax_module,
|
||||||
|
rax_scaling_group_personality_file,
|
||||||
|
)
|
||||||
from ansible.module_utils.six import string_types
|
from ansible.module_utils.six import string_types
|
||||||
|
|
||||||
|
|
||||||
|
@ -223,19 +226,7 @@ def rax_asg(module, cooldown=300, disk_config=None, files=None, flavor=None,
|
||||||
del nic['net-id']
|
del nic['net-id']
|
||||||
|
|
||||||
# Handle the file contents
|
# Handle the file contents
|
||||||
personality = []
|
personality = rax_scaling_group_personality_file(module, files)
|
||||||
if files:
|
|
||||||
for rpath in files.keys():
|
|
||||||
lpath = os.path.expanduser(files[rpath])
|
|
||||||
try:
|
|
||||||
f = open(lpath, 'r')
|
|
||||||
personality.append({
|
|
||||||
'path': rpath,
|
|
||||||
'contents': f.read()
|
|
||||||
})
|
|
||||||
f.close()
|
|
||||||
except Exception as e:
|
|
||||||
module.fail_json(msg='Failed to load %s' % lpath)
|
|
||||||
|
|
||||||
lbs = []
|
lbs = []
|
||||||
if loadbalancers:
|
if loadbalancers:
|
||||||
|
|
|
@ -25,7 +25,6 @@ plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias -
|
||||||
plugins/modules/rax_files_objects.py use-argspec-type-path
|
plugins/modules/rax_files_objects.py use-argspec-type-path
|
||||||
plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice
|
||||||
plugins/modules/rax.py use-argspec-type-path # fix needed
|
plugins/modules/rax.py use-argspec-type-path # fix needed
|
||||||
plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values
|
|
||||||
plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice
|
||||||
plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path
|
plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path
|
||||||
plugins/modules/udm_share.py validate-modules:parameter-list-no-elements
|
plugins/modules/udm_share.py validate-modules:parameter-list-no-elements
|
||||||
|
|
|
@ -20,7 +20,6 @@ plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias -
|
||||||
plugins/modules/rax_files_objects.py use-argspec-type-path
|
plugins/modules/rax_files_objects.py use-argspec-type-path
|
||||||
plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice
|
||||||
plugins/modules/rax.py use-argspec-type-path # fix needed
|
plugins/modules/rax.py use-argspec-type-path # fix needed
|
||||||
plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values
|
|
||||||
plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice
|
||||||
plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path
|
plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path
|
||||||
plugins/modules/udm_share.py validate-modules:parameter-list-no-elements
|
plugins/modules/udm_share.py validate-modules:parameter-list-no-elements
|
||||||
|
|
|
@ -20,7 +20,6 @@ plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias -
|
||||||
plugins/modules/rax_files_objects.py use-argspec-type-path
|
plugins/modules/rax_files_objects.py use-argspec-type-path
|
||||||
plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice
|
||||||
plugins/modules/rax.py use-argspec-type-path # fix needed
|
plugins/modules/rax.py use-argspec-type-path # fix needed
|
||||||
plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values
|
|
||||||
plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice
|
||||||
plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path
|
plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path
|
||||||
plugins/modules/udm_share.py validate-modules:parameter-list-no-elements
|
plugins/modules/udm_share.py validate-modules:parameter-list-no-elements
|
||||||
|
|
|
@ -21,7 +21,6 @@ plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias -
|
||||||
plugins/modules/rax_files_objects.py use-argspec-type-path
|
plugins/modules/rax_files_objects.py use-argspec-type-path
|
||||||
plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice
|
||||||
plugins/modules/rax.py use-argspec-type-path # fix needed
|
plugins/modules/rax.py use-argspec-type-path # fix needed
|
||||||
plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values
|
|
||||||
plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice
|
||||||
plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path
|
plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path
|
||||||
plugins/modules/udm_share.py validate-modules:parameter-list-no-elements
|
plugins/modules/udm_share.py validate-modules:parameter-list-no-elements
|
||||||
|
|
|
@ -21,7 +21,6 @@ plugins/modules/puppet.py validate-modules:parameter-invalid # invalid alias -
|
||||||
plugins/modules/rax_files_objects.py use-argspec-type-path
|
plugins/modules/rax_files_objects.py use-argspec-type-path
|
||||||
plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/rax_files.py validate-modules:parameter-state-invalid-choice
|
||||||
plugins/modules/rax.py use-argspec-type-path # fix needed
|
plugins/modules/rax.py use-argspec-type-path # fix needed
|
||||||
plugins/modules/rax_scaling_group.py use-argspec-type-path # fix needed, expanduser() applied to dict values
|
|
||||||
plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice
|
||||||
plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path
|
plugins/modules/ssh_config.py use-argspec-type-path # Required since module uses other methods to specify path
|
||||||
plugins/modules/udm_share.py validate-modules:parameter-list-no-elements
|
plugins/modules/udm_share.py validate-modules:parameter-list-no-elements
|
||||||
|
|
Loading…
Reference in a new issue