def cns_init(self, ctx, version,hostname): delta={} if version > 0: pass elif version == 0: #Network Delta fields = [] fields=['runtime_version'] current_version = 0 ver = self.deltadb.get_versions(ctx, filters=None, fields=fields) if ver: current_version = max(ver)['runtime_version'] LOG.debug(_("Runtime Version = %s"),str(current_version)) #current_version = 100 network_diff = self.networkdb.get_networks(ctx, filters=None, fields=None) for network in network_diff : fil={} id = network['id'] fil['network_id']= [id] fil['operation']= ['create'] NetDelta = self.deltadb.get_network_deltas(ctx,fil) arr = sorted(NetDelta, key=lambda t: t['version_id'], reverse=True) verid = arr[0]['version_id'] network.update({'operation':'create','version_id':current_version}) network_message={} network_message.update({'method':'create_virtual_network','payload':network}) delta[verid] = network_message #Subnet Delta subnet_diff = self.networkdb.get_subnets(ctx, filters=None, fields=None) for subnet in subnet_diff : fil={} id = subnet['id'] fil['subnet_id']= [id] fil['operation']= ['create'] SubDelta = self.deltadb.get_subnet_deltas(ctx,fil) arr = sorted(SubDelta, key=lambda t: t['version_id'], reverse=True) verid = arr[0]['version_id'] subnet.update({'operation':'create','version_id':current_version}) subnet_message={} subnet_message.update({'method':'create_subnet','payload':subnet}) delta[verid] = subnet_message #Compute Nodes Delta compute_diff = self.novadb.get_computes(ctx, filters=None, fields=None) for compute in compute_diff : fil={} id = compute['id'] fil['compute_id']= [id] fil['operation']= ['create'] CompDelta = self.deltadb.get_compute_deltas(ctx,fil) arr = sorted(CompDelta, key=lambda t: t['version_id'], reverse=True) verid = arr[0]['version_id'] compute.update({'operation':'create','version_id':current_version}) compute_message={} compute_message.update({'method':'create_datapath','payload':compute}) delta[verid] = compute_message #NWPORTS Delta nwport_diff = self.novadb.get_nwports(ctx, filters=None, fields=None) for nwport in nwport_diff : fil={} id = nwport['id'] fil['nwport_id']= [id] fil['operation']= ['create'] CompDelta = self.deltadb.get_nwport_deltas(ctx,fil) arr = sorted(CompDelta, key=lambda t: t['version_id'], reverse=True) verid = arr[0]['version_id'] nwport.update({'operation':'create','version_id':current_version}) nwport_message={} nwport_message.update({'method':'create_nwport','payload':nwport}) delta[verid] = nwport_message #Instances Delta instance_diff = self.novadb.get_instances(ctx, filters=None, fields=None) for instance in instance_diff : fil={} id = instance['id'] fil['instance_id']= [id] fil['operation']= ['create'] CompDelta = self.deltadb.get_instance_deltas(ctx,fil) arr = sorted(CompDelta, key=lambda t: t['version_id'], reverse=True) verid = arr[0]['version_id'] instance.update({'operation':'create','version_id':current_version}) instance_message={} instance_message.update({'method':'create_instance','payload':instance}) delta[verid] = instance_message #Port Delta port_diff = self.networkdb.get_ports(ctx, filters=None, fields=None) for port in port_diff : fil={} id = port['id'] fil['port_id']= [id] fil['operation']= ['create'] CompDelta = self.deltadb.get_port_deltas(ctx,fil) arr = sorted(CompDelta, key=lambda t: t['version_id'], reverse=True) verid = arr[0]['version_id'] port.update({'operation':'create','version_id':current_version}) port_message={} port_message.update({'method':'create_port','payload':port}) delta[verid] = port_message LOG.debug(_("Delta to consumer from CNS = %s"),str(delta)) return delta
def cns_init(self, ctx, version,hostname): delta={} if version > 0: pass elif version == 0: #Network Delta i = 0 fields = [] fields=['runtime_version'] current_version = 0 ver = self.deltadb.get_versions(ctx, filters=None, fields=fields) if ver: current_version = max(ver)['runtime_version'] LOG.debug(_("Runtime Version = %s"),str(current_version)) #current_version = 100 network_diff = self.networkdb.get_networks(ctx, filters=None, fields=None) for network in network_diff : network.update({'operation':'create','version_id':current_version}) network_message={} network_message.update({'method':'create_virtual_network','payload':network}) delta[i] = network_message i = i+1 #Subnet Delta subnet_diff = self.networkdb.get_subnets(ctx, filters=None, fields=None) for subnet in subnet_diff : subnet.update({'operation':'create','version_id':current_version}) subnet_message={} subnet_message.update({'method':'create_subnet','payload':subnet}) delta[i] = subnet_message i = i+1 #Compute Nodes Delta compute_diff = self.novadb.get_computes(ctx, filters=None, fields=None) for compute in compute_diff : compute.update({'operation':'create','version_id':current_version}) compute_message={} compute_message.update({'method':'create_datapath','payload':compute}) delta[i] = compute_message i = i+1 #NWPORTS Delta nwport_diff = self.novadb.get_nwports(ctx, filters=None, fields=None) for nwport in nwport_diff : nwport.update({'operation':'create','version_id':current_version}) nwport_message={} nwport_message.update({'method':'create_nwport','payload':nwport}) delta[i] = nwport_message i = i+1 #Instances Delta instance_diff = self.novadb.get_instances(ctx, filters=None, fields=None) for instance in instance_diff : instance.update({'operation':'create','version_id':current_version}) instance_message={} instance_message.update({'method':'create_instance','payload':instance}) delta[i] = instance_message i = i+1 #Port Delta port_diff = self.networkdb.get_ports(ctx, filters=None, fields=None) for port in port_diff : port.update({'operation':'create','version_id':current_version}) port_message={} port_message.update({'method':'create_port','payload':port}) delta[i] = port_message i = i+1 LOG.debug(_("Delta to consumer = %s"),str(delta)) return delta