1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Rename nova filters to include and exclude

jeblair says: "having 'flavor_filter' be inclusive, and 'image_filter'
be exclusive is kind of mind blowing" and I agree. Let's be more
explicit.
This commit is contained in:
Monty Taylor 2014-08-03 09:21:14 -07:00
parent 38beae3b19
commit b81a37ad9b

View file

@ -83,9 +83,9 @@ options:
required: true required: true
default: None default: None
version_added: "1.7" version_added: "1.7"
image_filter: image_exclude:
description: description:
- Text to use to filter image names, for the case, such as HP, where there are multiple image names matching the common identifying portions. image_filter is a negative match filter - it is text that may not exist in the image name. Defaults to "(deprecated)" - Text to use to filter image names, for the case, such as HP, where there are multiple image names matching the common identifying portions. image_exclude is a negative match filter - it is text that may not exist in the image name. Defaults to "(deprecated)"
version_added: "1.7" version_added: "1.7"
flavor_id: flavor_id:
description: description:
@ -98,9 +98,9 @@ options:
required: false required: false
default: 1 default: 1
version_added: "1.7" version_added: "1.7"
flavor_filter: flavor_include:
description: description:
- Text to use to filter flavor names, for the case, such as Rackspace, where there are multiple flavors that have the same ram count. flavor_filter is a positive match filter - it must exist in the flavor name. - Text to use to filter flavor names, for the case, such as Rackspace, where there are multiple flavors that have the same ram count. flavor_include is a positive match filter - it must exist in the flavor name.
version_added: "1.7" version_added: "1.7"
key_name: key_name:
description: description:
@ -244,7 +244,7 @@ EXAMPLES = '''
auth_url: https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/ auth_url: https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/
region_name: region-b.geo-1 region_name: region-b.geo-1
image_name: Ubuntu Server 14.04 image_name: Ubuntu Server 14.04
image_filter: deprecated image_exclude: deprecated
flavor_ram: 4096 flavor_ram: 4096
# Creates a new VM with 4G of RAM on Ubuntu Trusty on a Rackspace Performance node in DFW # Creates a new VM with 4G of RAM on Ubuntu Trusty on a Rackspace Performance node in DFW
@ -262,7 +262,7 @@ EXAMPLES = '''
region_name: DFW region_name: DFW
image_name: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM) image_name: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)
flavor_ram: 4096 flavor_ram: 4096
flavor_filter: Performance flavor_include: Performance
''' '''
@ -391,8 +391,8 @@ def _get_image_id(module, nova):
if module.params['image_name']: if module.params['image_name']:
for image in nova.images.list(): for image in nova.images.list():
if (module.params['image_name'] in image.name and ( if (module.params['image_name'] in image.name and (
not module.params['image_filter'] not module.params['image_exclude']
or module.params['image_filter'] not in image.name)): or module.params['image_exclude'] not in image.name)):
return image.id return image.id
module.fail_json(msg = "Error finding image id from name(%s)" % module.params['image_name']) module.fail_json(msg = "Error finding image id from name(%s)" % module.params['image_name'])
return module.params['image_id'] return module.params['image_id']
@ -402,7 +402,7 @@ def _get_flavor_id(module, nova):
if module.params['flavor_ram']: if module.params['flavor_ram']:
for flavor in sorted(nova.flavors.list(), key=operator.attrgetter('ram')): for flavor in sorted(nova.flavors.list(), key=operator.attrgetter('ram')):
if (flavor.ram >= module.params['flavor_ram'] and if (flavor.ram >= module.params['flavor_ram'] and
(not module.params['flavor_filter'] or module.params['flavor_filter'] in flavor.name)): (not module.params['flavor_include'] or module.params['flavor_include'] in flavor.name)):
return flavor.id return flavor.id
module.fail_json(msg = "Error finding flavor with %sMB of RAM" % module.params['flavor_ram']) module.fail_json(msg = "Error finding flavor with %sMB of RAM" % module.params['flavor_ram'])
return module.params['flavor_id'] return module.params['flavor_id']
@ -526,10 +526,10 @@ def main():
name = dict(required=True), name = dict(required=True),
image_id = dict(default=None), image_id = dict(default=None),
image_name = dict(default=None), image_name = dict(default=None),
image_filter = dict(default='(deprecated)'), image_exclude = dict(default='(deprecated)'),
flavor_id = dict(default=1), flavor_id = dict(default=1),
flavor_ram = dict(default=None, type='int'), flavor_ram = dict(default=None, type='int'),
flavor_filter = dict(default=None), flavor_include = dict(default=None),
key_name = dict(default=None), key_name = dict(default=None),
security_groups = dict(default='default'), security_groups = dict(default='default'),
nics = dict(default=None), nics = dict(default=None),