def _process_new_physical_ports(self, context, new_physical_ports): for physical_port in new_physical_ports: pp_dict = physical_port pp_dict[n_const.OVSDB_IDENTIFIER] = self.ovsdb_identifier p_port = db.get_physical_port(context, pp_dict) if not p_port: db.add_physical_port(context, pp_dict) if pp_dict.get('vlan_bindings'): for vlan_binding in pp_dict.get('vlan_bindings'): vlan_binding[ n_const.OVSDB_IDENTIFIER] = self.ovsdb_identifier vlan_binding['port_uuid'] = pp_dict.get('uuid') v_binding = db.get_vlan_binding(context, vlan_binding) if not v_binding: db.add_vlan_binding(context, vlan_binding)
def _process_modified_physical_ports(self, context, modified_physical_ports): for physical_port in modified_physical_ports: pp_dict = physical_port pp_dict[n_const.OVSDB_IDENTIFIER] = self.ovsdb_identifier modified_port = db.get_physical_port(context, pp_dict) if modified_port: db.update_physical_ports_status(context, pp_dict) port_vlan_bindings = physical_port.get('vlan_bindings') vlan_bindings = db.get_all_vlan_bindings_by_physical_port( context, pp_dict) for vlan_binding in vlan_bindings: db.delete_vlan_binding(context, vlan_binding) for port_vlan_binding in port_vlan_bindings: port_vlan_binding['port_uuid'] = pp_dict['uuid'] port_vlan_binding[ n_const.OVSDB_IDENTIFIER] = self.ovsdb_identifier db.add_vlan_binding(context, port_vlan_binding) else: db.add_physical_port(context, pp_dict)