def sync_net_partitions(self, fip_quota, resources): net_partition_id_dict = {} for netpart_id in resources['netpartition']['add']: with self.context.session.begin(subtransactions=True): netpart = self._get_netpart_data(netpart_id) if netpart: result = self.nuageclient.create_netpart( netpart, fip_quota) netpart = result.get(netpart_id) if netpart: net_partition_id_dict[netpart_id] = netpart['id'] nuagedb.add_net_partition(self.context.session, netpart['id'], netpart['l3dom_tmplt_id'], netpart['l2dom_tmplt_id'], netpart['name']) return net_partition_id_dict
def sync_net_partitions(self, fip_quota, resources): net_partition_id_dict = {} for netpart_id in resources['netpartition']['add']: with self.context.session.begin(subtransactions=True): netpart = self._get_netpart_data(netpart_id) if netpart: result = self.nuageclient.create_netpart(netpart, fip_quota) netpart = result.get(netpart_id) if netpart: net_partition_id_dict[netpart_id] = netpart['id'] nuagedb.add_net_partition( self.context.session, netpart['id'], netpart['l3dom_tmplt_id'], netpart['l2dom_tmplt_id'], netpart['name']) return net_partition_id_dict
def _create_net_partition(self, session, net_part_name): fip_quota = cfg.CONF.RESTPROXY.default_floatingip_quota params = {"name": net_part_name, "fp_quota": str(fip_quota)} nuage_net_partition = self.nuageclient.create_net_partition(params) net_partitioninst = None if nuage_net_partition: nuage_entid = nuage_net_partition["nuage_entid"] l3dom_id = nuage_net_partition["l3dom_id"] l2dom_id = nuage_net_partition["l2dom_id"] with session.begin(): net_partitioninst = nuagedb.add_net_partition(session, nuage_entid, l3dom_id, l2dom_id, net_part_name) if not net_partitioninst: return {} return self._make_net_partition_dict(net_partitioninst)
def _create_net_partition(self, session, net_part_name): fip_quota = cfg.CONF.RESTPROXY.default_floatingip_quota params = {"name": net_part_name, "fp_quota": str(fip_quota)} nuage_net_partition = self.nuageclient.create_net_partition(params) net_partitioninst = None if nuage_net_partition: nuage_entid = nuage_net_partition['nuage_entid'] l3dom_id = nuage_net_partition['l3dom_id'] l2dom_id = nuage_net_partition['l2dom_id'] with session.begin(): net_partitioninst = nuagedb.add_net_partition( session, nuage_entid, l3dom_id, l2dom_id, net_part_name) if not net_partitioninst: return {} return self._make_net_partition_dict(net_partitioninst)
def _create_default_net_partition(self, default_net_part): def_netpart = self.nuageclient.get_def_netpartition_data( default_net_part) session = db.get_session() if def_netpart: net_partition = nuagedb.get_net_partition_by_name( session, default_net_part) with session.begin(subtransactions=True): if net_partition: nuagedb.delete_net_partition(session, net_partition) net_part = nuagedb.add_net_partition(session, def_netpart['np_id'], def_netpart['l3dom_tid'], def_netpart['l2dom_tid'], default_net_part) return self._make_net_partition_dict(net_part) else: return self._create_net_partition(session, default_net_part)