def build_entity(self): affinity_group = otypes.AffinityGroup( name=self._module.params['name'], description=self._module.params['description'], positive=(self._module.params['vm_rule'] == 'positive') if self._module.params['vm_rule'] is not None else None, enforcing=(self._module.params['vm_enforcing']) if self._module.params['vm_enforcing'] is not None else None, ) # Those attributes are Supported since 4.1: if not engine_supported(self._connection, '4.1'): return affinity_group affinity_group.hosts_rule = otypes.AffinityRule( positive=(self.param('host_rule') == 'positive') if self.param('host_rule') is not None else None, enforcing=self.param('host_enforcing'), ) if (self.param('host_enforcing') is not None or self.param('host_rule') is not None) else None affinity_group.vms_rule = otypes.AffinityRule( positive=(self.param('vm_rule') == 'positive') if self.param('vm_rule') is not None else None, enforcing=self.param('vm_enforcing'), enabled=(self.param('vm_rule') in ['negative', 'positive']) if self.param('vm_rule') is not None else None, ) if (self.param('vm_enforcing') is not None or self.param('vm_rule') is not None) else None affinity_group.hosts = [ otypes.Host(id=host_id) for host_id in self._host_ids ] if self._host_ids is not None else None return affinity_group
def build_entity(self): return otypes.AffinityGroup( name=self._module.params['name'], description=self._module.params['description'], positive=(self._module.params['vm_rule'] == 'positive') if self._module.params['vm_rule'] is not None else None, enforcing=(self._module.params['vm_enforcing']) if self._module.params['vm_enforcing'] is not None else None, vms=[otypes.Vm(id=vm_id) for vm_id in self._vm_ids] if self._vm_ids is not None else None, hosts=[otypes.Host(id=host_id) for host_id in self._host_ids] if self._host_ids is not None else None, vms_rule=otypes.AffinityRule( positive=(self._module.params['vm_rule'] == 'positive') if self._module.params['vm_rule'] is not None else None, enforcing=self._module.params['vm_enforcing'], enabled=( self._module.params['vm_rule'] in ['negative', 'positive']) if self._module.params['vm_rule'] is not None else None, ) if (self._module.params['vm_enforcing'] is not None or self._module.params['vm_rule'] is not None) else None, hosts_rule=otypes.AffinityRule( positive=(self._module.params['host_rule'] == 'positive') if self._module.params['host_rule'] is not None else None, enforcing=self._module.params['host_enforcing'], ) if (self._module.params['host_enforcing'] is not None or self._module.params['host_rule'] is not None) else None, )