def __attach_nics(self, entity): # Attach NICs to VM, if specified: vnic_profiles_service = self._connection.system_service().vnic_profiles_service() nics_service = self._service.service(entity.id).nics_service() for nic in self._module.params['nics']: if search_by_name(nics_service, nic.get('name')) is None: if not self._module.check_mode: nics_service.add( otypes.Nic( name=nic.get('name'), interface=otypes.NicInterface( nic.get('interface', 'virtio') ), vnic_profile=otypes.VnicProfile( id=search_by_name( vnic_profiles_service, nic.get('profile_name'), ).id ) if nic.get('profile_name') else None, mac=otypes.Mac( address=nic.get('mac_address') ) if nic.get('mac_address') else None, ) ) self.changed = True
def build_entity(self): return otypes.Nic( name=self._module.params.get('name'), interface=otypes.NicInterface(self._module.params.get('interface')) if self._module.params.get('interface') else None, vnic_profile=otypes.VnicProfile(id=self.vnic_id, ) if self.vnic_id else None, mac=otypes.Mac(address=self._module.params.get('mac_address')) if self._module.params.get('mac_address') else None, )
def __attach_nics(self, entity): # Attach NICs to instance type, if specified: nics_service = self._service.service(entity.id).nics_service() for nic in self.param('nics'): if search_by_name(nics_service, nic.get('name')) is None: if not self._module.check_mode: nics_service.add( otypes.Nic( name=nic.get('name'), interface=otypes.NicInterface( nic.get('interface', 'virtio')), vnic_profile=otypes.VnicProfile( id=self.__get_vnic_profile_id(nic), ) if nic.get('profile_name') else None, mac=otypes.Mac(address=nic.get('mac_address')) if nic.get('mac_address') else None, )) self.changed = True