def update(self, dvg, vnid, client_type, transaction_type, version, operation, vIP): ''' This handle Endpoint Update on an Endpoint. The domain and DPS Client (on which the endpoint resides) should have been resolved before this step i.e. Migration and New Endpoint Scenario handled before this routine is called. @param dvg: The DVG based on Endpoint Update Parameters @type dvg: DVG @param vnid: The VNID (Maybe different from dvg.unique_id for Domain/DVG 0) @type vnid: Integer @param client_type: The Type of Client: should be in DpsClientType.types @type client_type: Integer @param transaction_type: The Type of Transaction: should be in DpsTransactionType @type transaction_type: Integer @param version: The Object Version Number @type version: Integer @param operation: Should be a dps_endpoint_update_option @type operation: Integer @param vIP: The IP Address of the Endpoint @type vIP: IPAddressLocation ''' self.in_migration = False #The Delete operation can set it to True. #Update client type self.client_type = client_type self.vnid = vnid #Since we got an update on this endpoint from an entity, #we can remove from Endpoint Expiration Timer List try: del DpsCollection.Endpoint_Expiration_Timer_Queue[self] except Exception: pass if self.dvg != dvg: #Remove self from old DVG DVG.endpoint_del(self.dvg, self) #Remove all old vIPs self.vIP_delete_all() self.vIP_set_show.clear() self.dvg = dvg DVG.endpoint_add(self.dvg, self) if transaction_type == DpsTransactionType.mass_transfer: #Don't verify version for mass transfer. Just stay at the highest rev if self.version < version: self.version = version else: if version == Endpoint.version_start: self.version = Endpoint.version_start elif version == self.version: self.version = version else: if version != self.version + 1: raise Exception('Invalid Version: Expecting %s, got %s!!!'%(self.version + 1, version)) self.version = version try: self.update_function_table[operation](self, vIP) except Exception: #log.warning('update: operation %s not supported\r', operation) pass return
def __init__(self, domain, dvg, vnid, client_type, transaction_type, tunnel_endpoint, vMac, vIP, version): ''' Constructor: @param domain: The Domain Object @type domain: Domain @param dvg: The DVG Object @type dvg: DVG @param vnid: The VNID (Maybe different from dvg.unique_id for Domain/DVG 0) @type vnid: Integer @param client_type: The Type of Client: should be in DpsClientType.types @type client_type: Integer @param transaction_type: The Type of Transaction: should be in DpsTransactionType @type transaction_type: Integer @param tunnel_endpoint: The DOVE Switch on which the Endpoint is hosted Maybe(None) - Then dove_gateway must be valid @type tunnel_endpoint: The Tunnel Endpoint @param vMAC: The Virtual MAC Address @type vMAC: ByteArray/String @param vIP: The IP Address of the Endpoint @type vIP: IPAddressLocation @param version: The version to start with @type version: integer ''' if DpsCollection.Endpoints_Count >= DpsCollection.Endpoints_Count_Max: raise MemoryError('Out of Memory') self.domain = domain self.dvg = dvg self.vnid = vnid self.client_type = client_type self.vMac = vMac self.tunnel_endpoint = tunnel_endpoint self.vIP_set = {} self.vIP_set_show = {} if vIP is not None: self.vIP_set[vIP.ip_value] = vIP self.vIP_set_show[vIP.ip_value] = vIP #self.version = self.version_start self.version = version self.valid = True self.in_migration = False ############################################################# #TODO:To be finished #Add to the appropriate DPS Client List #log.info('__init__: Adding to TunnelEndpoint\r') TunnelEndpoint.endpoint_add(tunnel_endpoint, self, transaction_type) #log.info('__init__: Added to TunnelEndpoint\r') #Add to the appropriate Domain Lists Domain.endpoint_add(domain, self) #log.info('__init__: Added to Domain\r') #Add to the appropriate DVG/VNID Lists DVG.endpoint_add(dvg, self) #log.info('__init__: Added to DVG\r') #self.show(None) DpsCollection.Endpoints_Count += 1
def vmotion(self, dvg, vnid, client_type, tunnel_endpoint, transaction_type): ''' This routine handles the scenario where the Endpoint has vmotioned (without being explicitly told by the migration source). This routine will unlink the Endpoint from the existing DpsClient and remove the vIPs @param dvg: The DVG Object @type dvg: DVG @param vnid: The VNID (Maybe different from dvg.unique_id for Domain/DVG 0) @type vnid: Integer @param client_type: The Type of Client: should be in DpsClientType.types @type client_type: Integer @param tunnel_endpoint: The New Tunnel Endpoint on which the endpoint exists @type tunnel_endpoint: TunnelEndpoint @param transaction_type: The Type of Transaction: should be in DpsTransactionType @type transaction_type: Integer ''' ####################################################################### #Remove from old values ####################################################################### if self.tunnel_endpoint is not None: TunnelEndpoint.endpoint_del(self.tunnel_endpoint, self) self.tunnel_endpoint = None if self.dvg is not None: DVG.endpoint_del(self.dvg, self) if self.dvg != dvg: #Change in VNIDs. Clear all IPs DVG.endpoint_del(self.dvg, self) self.vIP_delete_all() self.vIP_set_show.clear() ####################################################################### #Add to new values ####################################################################### self.dvg = dvg self.vnid = vnid DVG.endpoint_add(dvg, self) self.tunnel_endpoint = tunnel_endpoint self.client_type = client_type self.in_migration = False TunnelEndpoint.endpoint_add(self.tunnel_endpoint, self, transaction_type) return