Ejemplo n.º 1
0
    def _create_default_net_partition(self, default_net_part):
        self.nuageclient.check_del_def_net_partition(default_net_part)
        session = db.get_session()
        net_partition = nuagedb.get_net_partition_by_name(session, default_net_part)
        if net_partition:
            with session.begin(subtransactions=True):
                nuagedb.delete_net_partition(session, net_partition)

        self._create_net_partition(session, default_net_part)
Ejemplo n.º 2
0
 def _create_default_net_partition(self, default_net_part):
     self.nuageclient.check_del_def_net_partition(default_net_part)
     session = db.get_session()
     net_partition = nuagedb.get_net_partition_by_name(session,
                                                       default_net_part)
     if net_partition:
         with session.begin(subtransactions=True):
             nuagedb.delete_net_partition(session, net_partition)
     self._create_net_partition(session, default_net_part)
Ejemplo n.º 3
0
 def _get_net_partition_for_router(self, context, rtr):
     ent = rtr.get('net_partition', None)
     if not ent:
         def_net_part = cfg.CONF.RESTPROXY.default_net_partition_name
         net_partition = nuagedb.get_net_partition_by_name(context.session,
                                                           def_net_part)
     else:
         net_partition = self._resource_finder(context, 'router',
                                               'net_partition', rtr)
     if not net_partition:
         msg = _("Either net_partition is not provided with router OR "
                 "default net_partition is not created at the start")
         raise n_exc.BadRequest(resource='router', msg=msg)
     return net_partition
Ejemplo n.º 4
0
 def _get_net_partition_for_subnet(self, context, subnet):
     ent = subnet.get('net_partition', None)
     if not ent:
         def_net_part = cfg.CONF.RESTPROXY.default_net_partition_name
         net_partition = nuagedb.get_net_partition_by_name(context.session,
                                                           def_net_part)
     else:
         net_partition = self._resource_finder(context, 'subnet',
                                               'net_partition', subnet)
     if not net_partition:
         msg = _('Either net_partition is not provided with subnet OR '
                 'default net_partition is not created at the start')
         raise n_exc.BadRequest(resource='subnet', msg=msg)
     return net_partition
Ejemplo n.º 5
0
 def _get_net_partition_for_router(self, context, rtr):
     ent = rtr.get('net_partition', None)
     if not ent:
         def_net_part = cfg.CONF.RESTPROXY.default_net_partition_name
         net_partition = nuagedb.get_net_partition_by_name(
             context.session, def_net_part)
     else:
         net_partition = self._resource_finder(context, 'router',
                                               'net_partition', rtr)
     if not net_partition:
         msg = _("Either net_partition is not provided with router OR "
                 "default net_partition is not created at the start")
         raise n_exc.BadRequest(resource='router', msg=msg)
     return net_partition
Ejemplo n.º 6
0
 def _get_net_partition_for_subnet(self, context, subnet):
     ent = subnet.get('net_partition', None)
     if not ent:
         def_net_part = cfg.CONF.RESTPROXY.default_net_partition_name
         net_partition = nuagedb.get_net_partition_by_name(
             context.session, def_net_part)
     else:
         net_partition = self._resource_finder(context, 'subnet',
                                               'net_partition', subnet)
     if not net_partition:
         msg = _('Either net_partition is not provided with subnet OR '
                 'default net_partition is not created at the start')
         raise n_exc.BadRequest(resource='subnet', msg=msg)
     return net_partition
Ejemplo n.º 7
0
 def _get_net_partition_for_subnet(self, context, subnet):
     subn = subnet["subnet"]
     ent = subn.get("net_partition", None)
     if not ent:
         def_net_part = cfg.CONF.RESTPROXY.default_net_partition_name
         net_partition = nuagedb.get_net_partition_by_name(context.session, def_net_part)
     else:
         net_partition = self._resource_finder(context, "subnet", "net_partition", subn)
     if not net_partition:
         msg = _(
             "Either net_partition is not provided with subnet OR "
             "default net_partition is not created at the start"
         )
         raise q_exc.BadRequest(resource="subnet", msg=msg)
     return net_partition
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
 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)