Merge branch 'devel' of https://github.com/ansible/ansible into devel

This commit is contained in:
James Cammarata 2015-10-12 11:30:03 -04:00
commit 73661d1761

View file

@ -91,6 +91,20 @@ class VcaAnsibleModule(AnsibleModule):
self._vdc = _vdc self._vdc = _vdc
return _vdc return _vdc
def get_vapp(self, vapp_name):
vapp = self.vca.get_vapp(self.vdc, vapp_name)
if not vapp:
raise VcaError('vca instance has no vapp named %s' % vapp_name)
return vapp
def get_vm(self, vapp_name, vm_name):
vapp = self.get_vapp(vapp_name)
vms = [vm for vm in children.get_Vm() if vm.name == vm_name]
try:
return vms[0]
except IndexError:
raise VcaError('vapp has no vm named %s' % vm_name)
def create_instance(self): def create_instance(self):
service_type = self.params.get('service_type', DEFAULT_SERVICE_TYPE) service_type = self.params.get('service_type', DEFAULT_SERVICE_TYPE)
host = self.params.get('host', LOGIN_HOST.get('service_type')) host = self.params.get('host', LOGIN_HOST.get('service_type'))
@ -182,26 +196,26 @@ VCHS_REQ_ARGS = ['service_id']
def _validate_module(module): def _validate_module(module):
if not HAS_PYVCLOUD: if not HAS_PYVCLOUD:
module.fail_json("python module pyvcloud is needed for this module") module.fail_json(msg="python module pyvcloud is needed for this module")
service_type = module.params.get('service_type', DEFAULT_SERVICE_TYPE) service_type = module.params.get('service_type', DEFAULT_SERVICE_TYPE)
if service_type == 'vca': if service_type == 'vca':
for arg in VCA_REQ_ARGS: for arg in VCA_REQ_ARGS:
if module.params.get(arg) is None: if module.params.get(arg) is None:
module.fail_json("argument %s is mandatory when service type " module.fail_json(msg="argument %s is mandatory when service type "
"is vca" % arg) "is vca" % arg)
if service_type == 'vchs': if service_type == 'vchs':
for arg in VCHS_REQ_ARGS: for arg in VCHS_REQ_ARGS:
if module.params.get(arg) is None: if module.params.get(arg) is None:
module.fail_json("argument %s is mandatory when service type " module.fail_json(msg="argument %s is mandatory when service type "
"is vchs" % arg) "is vchs" % arg)
if service_type == 'vcd': if service_type == 'vcd':
for arg in VCD_REQ_ARGS: for arg in VCD_REQ_ARGS:
if module.params.get(arg) is None: if module.params.get(arg) is None:
module.fail_json("argument %s is mandatory when service type " module.fail_json(msg="argument %s is mandatory when service type "
"is vcd" % arg) "is vcd" % arg)