def _port_action(self, context, func): """Verify configuration and then process event.""" device_id = context.current.get('device_id') host_id = context.current.get(portbindings.HOST_ID) # Workaround until vlan can be retrieved during delete_port_postcommit # (or prehaps unbind_port) event. if func == self._delete_switch_entry: vlan_id = self._delete_port_postcommit_vlan else: vlan_id = self._get_vlanid(context) if vlan_id and device_id and host_id: func(context, vlan_id, device_id, host_id) else: fields = "vlan_id " if not vlan_id else "" fields += "device_id " if not device_id else "" fields += "host_id" if not host_id else "" raise excep.NexusMissingRequiredFields(fields=fields) # Workaround until vlan can be retrieved during delete_port_postcommit # (or prehaps unbind_port) event. if func == self._delete_nxos_db: self._delete_port_postcommit_vlan = vlan_id else: self._delete_port_postcommit_vlan = 0
def _port_action(self, port, segment, func): """Verify configuration and then process event.""" device_id = port.get('device_id') host_id = port.get(portbindings.HOST_ID) vlan_id = self._get_vlanid(segment) if vlan_id and device_id and host_id: func(vlan_id, device_id, host_id) else: fields = "vlan_id " if not vlan_id else "" fields += "device_id " if not device_id else "" fields += "host_id" if not host_id else "" raise excep.NexusMissingRequiredFields(fields=fields)