renamed variables type to cdb_type and version to cdb_version.

This commit is contained in:
Mehul Ved 2015-07-10 16:50:42 +05:30 committed by Matt Clay
parent 217764ba3c
commit 832f251e90

View file

@ -38,11 +38,11 @@ options:
description: description:
- Volume size of the database 1-150GB - Volume size of the database 1-150GB
default: 2 default: 2
type: cdb_type:
description: description:
- type of instance (i.e. MySQL, MariaDB, Percona) - type of instance (i.e. MySQL, MariaDB, Percona)
default: MySQL default: MySQL
version: cdb_version:
description: description:
- version of database (MySQL supports 5.1 and 5.6, MariaDB supports 10, Percona supports 5.6) - version of database (MySQL supports 5.1 and 5.6, MariaDB supports 10, Percona supports 5.6)
choices: ['5.1', '5.6', '10'] choices: ['5.1', '5.6', '10']
@ -76,8 +76,8 @@ EXAMPLES = '''
name: db-server1 name: db-server1
flavor: 1 flavor: 1
volume: 2 volume: 2
type: MySQL cdb_type: MySQL
version: 5.6 cdb_version: 5.6
wait: yes wait: yes
state: present state: present
register: rax_db_server register: rax_db_server
@ -101,11 +101,11 @@ def find_instance(name):
return False return False
def save_instance(module, name, flavor, volume, type, version, wait, def save_instance(module, name, flavor, volume, cdb_type, cdb_version, wait,
wait_timeout): wait_timeout):
for arg, value in dict(name=name, flavor=flavor, for arg, value in dict(name=name, flavor=flavor,
volume=volume, type=type, version=version volume=volume, type=cdb_type, version=cdb_version
).iteritems(): ).iteritems():
if not value: if not value:
module.fail_json(msg='%s is required for the "rax_cdb"' module.fail_json(msg='%s is required for the "rax_cdb"'
@ -131,7 +131,7 @@ def save_instance(module, name, flavor, volume, type, version, wait,
action = 'create' action = 'create'
try: try:
instance = cdb.create(name=name, flavor=flavor, volume=volume, instance = cdb.create(name=name, flavor=flavor, volume=volume,
type=type, version=version) type=cdb_type, version=cdb_version)
except Exception, e: except Exception, e:
module.fail_json(msg='%s' % e.message) module.fail_json(msg='%s' % e.message)
else: else:
@ -202,12 +202,12 @@ def delete_instance(module, name, wait, wait_timeout):
cdb=rax_to_dict(instance)) cdb=rax_to_dict(instance))
def rax_cdb(module, state, name, flavor, volume, type, version, wait, def rax_cdb(module, state, name, flavor, volume, cdb_type, cdb_version, wait,
wait_timeout): wait_timeout):
# act on the state # act on the state
if state == 'present': if state == 'present':
save_instance(module, name, flavor, volume, type, version, wait, save_instance(module, name, flavor, volume, cdb_type, cdb_version, wait,
wait_timeout) wait_timeout)
elif state == 'absent': elif state == 'absent':
delete_instance(module, name, wait, wait_timeout) delete_instance(module, name, wait, wait_timeout)
@ -220,8 +220,8 @@ def main():
name=dict(type='str', required=True), name=dict(type='str', required=True),
flavor=dict(type='int', default=1), flavor=dict(type='int', default=1),
volume=dict(type='int', default=2), volume=dict(type='int', default=2),
type=dict(type='str', default='MySQL'), cdb_type=dict(type='str', default='MySQL'),
version=dict(type='str', default='5.6'), cdb_version=dict(type='str', default='5.6'),
state=dict(default='present', choices=['present', 'absent']), state=dict(default='present', choices=['present', 'absent']),
wait=dict(type='bool', default=False), wait=dict(type='bool', default=False),
wait_timeout=dict(type='int', default=300), wait_timeout=dict(type='int', default=300),
@ -239,14 +239,14 @@ def main():
name = module.params.get('name') name = module.params.get('name')
flavor = module.params.get('flavor') flavor = module.params.get('flavor')
volume = module.params.get('volume') volume = module.params.get('volume')
type = module.params.get('type') cdb_type = module.params.get('type')
version = module.params.get('version') cdb_version = module.params.get('version')
state = module.params.get('state') state = module.params.get('state')
wait = module.params.get('wait') wait = module.params.get('wait')
wait_timeout = module.params.get('wait_timeout') wait_timeout = module.params.get('wait_timeout')
setup_rax_module(module, pyrax) setup_rax_module(module, pyrax)
rax_cdb(module, state, name, flavor, volume, type, version, wait, wait_timeout) rax_cdb(module, state, name, flavor, volume, cdb_type, cdb_version, wait, wait_timeout)
# import module snippets # import module snippets