def _create_port(self, port): switchports = port['port']['switchports'] LOG.debug(_LE("_create_port switch: %s"), port) network_id = port['port']['network_id'] db_context = neutron_context.get_admin_context() subnets = db.get_subnets_by_network(db_context, network_id) if not subnets: LOG.error("Subnet not found for the network") self._raise_ml2_error(wexc.HTTPNotFound, 'create_port') for switchport in switchports: switch_mac_id = switchport['switch_id'] port_id = switchport['port_id'] bnp_switch = db.get_bnp_phys_switch_by_mac(db_context, switch_mac_id) # check for port and switch level existence if not bnp_switch: LOG.error(_LE("No physical switch found '%s' "), switch_mac_id) self._raise_ml2_error(wexc.HTTPNotFound, 'create_port') phys_port = db.get_bnp_phys_port(db_context, bnp_switch.id, port_id) if not phys_port: LOG.error(_LE("No physical port found for '%s' "), phys_port) self._raise_ml2_error(wexc.HTTPNotFound, 'create_port') if bnp_switch.port_prov != hp_const.SWITCH_STATUS['enable']: LOG.error(_LE("Physical switch is not Enabled '%s' "), bnp_switch.port_prov) self._raise_ml2_error(wexc.HTTPBadRequest, 'create_port')
def create_port(self, port_dict): """create_port. This call makes the REST request to the external SDN controller for provision VLAN for the switch port where bare metal is connected. """ LOG.debug("create_port port_dict %(port_dict)s", {'port_dict': port_dict}) network_id = port_dict['port']['network_id'] subnets = db.get_subnets_by_network(self.context, network_id) if not subnets: LOG.error("Subnet not found for the network") self._raise_ml2_error(wexc.HTTPNotFound, 'create_port') self.create_switch_port(port_dict)
def _create_port(self, port): switchports = port['port']['switchports'] LOG.debug(_LE("_create_port switch: %s"), port) network_id = port['port']['network_id'] db_context = neutron_context.get_admin_context() subnets = db.get_subnets_by_network(db_context, network_id) if not subnets: LOG.error(_LE("Subnet not found for the network")) self._raise_ml2_error(wexc.HTTPNotFound, 'create_port') for switchport in switchports: switch_mac_id = switchport['switch_id'] bnp_switch = db.get_bnp_phys_switch_by_mac(db_context, switch_mac_id) # check for port and switch level existence if not bnp_switch: LOG.error(_LE("No physical switch found '%s' "), switch_mac_id) self._raise_ml2_error(wexc.HTTPNotFound, 'create_port') self.sw_obj = bnp_sw.BNPSwitchController() mgmt_proto = bnp_switch['management_protocol'] creds = bnp_switch['credentials'] access_parameters = self.sw_obj._get_access_param(db_context, mgmt_proto, creds) for key, value in access_parameters.iteritems(): if key == hp_const.NAME: continue bnp_switch[key] = value driver_key = self.sw_obj._protocol_driver(bnp_switch) try: if driver_key: dr_obj = driver_key.obj mac_val = dr_obj.get_protocol_validation_result(bnp_switch) if mac_val != bnp_switch['mac_address']: self._raise_ml2_error(wexc.HTTPBadRequest, 'Invalid mac address') except Exception as e: LOG.error(e) self._raise_ml2_error(wexc.HTTPBadRequest, 'create_port') port_provisioning_db = bnp_switch.port_provisioning if (port_provisioning_db != hp_const.PORT_PROVISIONING_STATUS['enable']): LOG.error(_LE("Physical switch is not Enabled '%s' "), bnp_switch.port_provisioning) self._raise_ml2_error(wexc.HTTPBadRequest, 'create_port')
def _create_port(self, port): switchports = port['port']['switchports'] LOG.debug(_LE("_create_port switch: %s"), port) network_id = port['port']['network_id'] db_context = neutron_context.get_admin_context() subnets = db.get_subnets_by_network(db_context, network_id) if not subnets: LOG.error(_LE("Subnet not found for the network")) self._raise_ml2_error(wexc.HTTPNotFound, 'create_port') for switchport in switchports: switch_mac_id = switchport['switch_id'] bnp_switch = db.get_bnp_phys_switch_by_mac(db_context, switch_mac_id) # check for port and switch level existence if not bnp_switch: LOG.error(_LE("No physical switch found '%s' "), switch_mac_id) self._raise_ml2_error(wexc.HTTPNotFound, 'create_port') self.sw_obj = bnp_sw.BNPSwitchController() mgmt_proto = bnp_switch['management_protocol'] creds = bnp_switch['credentials'] access_parameters = self.sw_obj._get_access_param(db_context, mgmt_proto, creds) for key, value in access_parameters.iteritems(): if key == hp_const.NAME: continue bnp_switch[key] = value driver_key = self.sw_obj._protocol_driver(bnp_switch) try: if driver_key: dr_obj = driver_key.obj mac_val = dr_obj.get_protocol_validation_result(bnp_switch) if mac_val != bnp_switch['mac_address']: self._raise_ml2_error(wexc.HTTPBadRequest, 'Invalid mac address') except Exception as e: LOG.error(e) self._raise_ml2_error(wexc.HTTPBadRequest, 'create_port') port_provisioning_db = bnp_switch.port_provisioning if port_provisioning_db != hp_const.SWITCH_STATUS['enable']: LOG.error(_LE("Physical switch is not Enabled '%s' "), bnp_switch.port_provisioning) self._raise_ml2_error(wexc.HTTPBadRequest, 'create_port')
def _create_port(self, port): switchports = port["port"]["switchports"] LOG.debug(_LE("_create_port switch: %s"), port) network_id = port["port"]["network_id"] subnets = db.get_subnets_by_network(self.context, network_id) if not subnets: LOG.error("Subnet not found for the network") self._raise_ml2_error(wexc.HTTPNotFound, "create_port") for switchport in switchports: switch_mac_id = switchport["switch_id"] port_id = switchport["port_id"] bnp_switch = db.get_bnp_phys_switch_by_mac(self.context, switch_mac_id) # check for port and switch level existence if not bnp_switch: LOG.error(_LE("No physical switch found '%s' "), switch_mac_id) self._raise_ml2_error(wexc.HTTPNotFound, "create_port") phys_port = db.get_bnp_phys_port(self.context, bnp_switch.id, port_id) if not phys_port: LOG.error(_LE("No physical port found for '%s' "), phys_port) self._raise_ml2_error(wexc.HTTPNotFound, "create_port") if bnp_switch.status != constants.SWITCH_STATUS["enable"]: LOG.error(_LE("Physical switch is not Enabled '%s' "), bnp_switch.status) self._raise_ml2_error(wexc.HTTPBadRequest, "create_port")