def test_find_cna_for_mac(self): cna1 = self.__cna("1234567890AB") cna2 = self.__cna("123456789012") self.assertEqual(cna1, utils.find_cna_for_mac("1234567890AB", [cna1, cna2])) self.assertEqual(None, utils.find_cna_for_mac("9876543210AB", [cna1, cna2]))
def _update_req(self, request, lpar_uuids): """Attempts to provision a given UpdateVLANRequest. :param request: The UpdateVLANRequest. :return: True if the request was successfully processed. False if it was not able to process. """ # Pull the ProvisionRequest off the VLAN Update call. p_req = request.p_req client_adpts = [] try: if p_req.lpar_uuid in lpar_uuids: # Get the adapters just for the VM that the request is for. client_adpts = utils.list_cnas(self.adapter, self.host_uuid, lpar_uuid=p_req.lpar_uuid) cna = utils.find_cna_for_mac(p_req.mac_address, client_adpts) if cna: # If the PVID does not match, update the CNA. if cna.pvid != p_req.segmentation_id: utils.update_cna_pvid(cna, p_req.segmentation_id) LOG.info(_LI("Sending update device for %s"), p_req.mac_address) self.agent.update_device_up(p_req.rpc_device) self._remove_request(request) return except Exception as e: LOG.warn(_LW("An error occurred while attempting to update the " "PVID of the virtual NIC.")) LOG.exception(e) # Increment the request count. request.attempt_count += 1 if request.attempt_count >= ACONF.pvid_update_loops: # If it had been on the system...this is an error. if p_req.lpar_uuid in lpar_uuids: self._mark_failed(p_req, client_adpts) # Remove the request from the overall queue self._remove_request(request)