Example #1
0
def get_mac_address_ranges(context):
    LOG.info("get_mac_address_ranges for tenant %s" % context.tenant_id)
    if not context.is_admin:
        raise n_exc.NotAuthorized()

    ranges = db_api.mac_address_range_find(context)
    return [v._make_mac_range_dict(m) for m in ranges]
Example #2
0
 def test_create_range_with_do_not_use(self):
     mar = dict(
         mac_address_range=dict(id=1, cidr="AA:BB:CC/24", do_not_use=True))
     admin_ctxt = self.context.elevated()
     res = self.plugin.create_mac_address_range(admin_ctxt, mar)
     self.assertEqual(res["cidr"], "AA:BB:CC:00:00:00/24")
     mac_range = db_api.mac_address_range_find(admin_ctxt,
                                               id=res["id"]).first()
     self.assertTrue(mac_range["do_not_use"])
 def test_create_range_with_do_not_use(self):
     mar = dict(mac_address_range=dict(id=1, cidr="AA:BB:CC/24",
                                       do_not_use=True))
     admin_ctxt = self.context.elevated()
     res = self.plugin.create_mac_address_range(admin_ctxt, mar)
     self.assertEqual(res["cidr"], "AA:BB:CC:00:00:00/24")
     mac_range = db_api.mac_address_range_find(admin_ctxt,
                                               id=res["id"]).first()
     self.assertTrue(mac_range["do_not_use"])
Example #4
0
def delete_mac_address_range(context, id):
    """Delete a mac_address_range.

    : param context: neutron api request context
    : param id: UUID representing the mac_address_range to delete.
    """
    LOG.info("delete_mac_address_range %s for tenant %s" %
             (id, context.tenant_id))
    mar = db_api.mac_address_range_find(context, id=id, scope=db_api.ONE)
    if not mar:
        raise quark_exceptions.MacAddressRangeNotFound(
            mac_address_range_id=id)
    _delete_mac_address_range(context, mar)
def delete_mac_address_range(context, id):
    """Delete a mac_address_range.

    : param context: neutron api request context
    : param id: UUID representing the mac_address_range to delete.
    """
    LOG.info("delete_mac_address_range %s for tenant %s" % (id, context.tenant_id))
    if not context.is_admin:
        raise n_exc.NotAuthorized()

    with context.session.begin():
        mar = db_api.mac_address_range_find(context, id=id, scope=db_api.ONE)
        if not mar:
            raise q_exc.MacAddressRangeNotFound(mac_address_range_id=id)
        _delete_mac_address_range(context, mar)
Example #6
0
def delete_mac_address_range(context, id):
    """Delete a mac_address_range.

    : param context: neutron api request context
    : param id: UUID representing the mac_address_range to delete.
    """
    LOG.info("delete_mac_address_range %s for tenant %s" %
             (id, context.tenant_id))
    if not context.is_admin:
        raise n_exc.NotAuthorized()

    with context.session.begin():
        mar = db_api.mac_address_range_find(context, id=id, scope=db_api.ONE)
        if not mar:
            raise q_exc.MacAddressRangeNotFound(
                mac_address_range_id=id)
        _delete_mac_address_range(context, mar)
Example #7
0
def get_mac_address_range(context, id, fields=None):
    """Retrieve a mac_address_range.

    : param context: neutron api request context
    : param id: UUID representing the network to fetch.
    : param fields: a list of strings that are valid keys in a
        network dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
        object in neutron/api/v2/attributes.py. Only these fields
        will be returned.
    """
    LOG.info("get_mac_address_range %s for tenant %s fields %s" %
            (id, context.tenant_id, fields))

    mac_address_range = db_api.mac_address_range_find(
        context, id=id, scope=db_api.ONE)

    if not mac_address_range:
        raise quark_exceptions.MacAddressRangeNotFound(
            mac_address_range_id=id)
    return v._make_mac_range_dict(mac_address_range)
Example #8
0
def get_mac_address_range(context, id, fields=None):
    """Retrieve a mac_address_range.

    : param context: neutron api request context
    : param id: UUID representing the network to fetch.
    : param fields: a list of strings that are valid keys in a
        network dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
        object in neutron/api/v2/attributes.py. Only these fields
        will be returned.
    """
    LOG.info("get_mac_address_range %s for tenant %s fields %s" %
            (id, context.tenant_id, fields))

    mac_address_range = db_api.mac_address_range_find(
        context, id=id, scope=db_api.ONE)

    if not mac_address_range:
        raise quark_exceptions.MacAddressRangeNotFound(
            mac_address_range_id=id)
    return v._make_mac_range_dict(mac_address_range)
Example #9
0
def get_mac_address_ranges(context):
    LOG.info("get_mac_address_ranges for tenant %s" % context.tenant_id)
    ranges = db_api.mac_address_range_find(context)
    return [v._make_mac_range_dict(m) for m in ranges]
Example #10
0
def get_mac_address_ranges(context):
    LOG.info("get_mac_address_ranges for tenant %s" % context.tenant_id)
    ranges = db_api.mac_address_range_find(context)
    return [v._make_mac_range_dict(m) for m in ranges]