Use PBR for setup/packaging

* Also enforced HACKING compliance
This commit is contained in:
Jason Kölker
2013-03-21 14:55:10 -05:00
parent 2a89bd4a52
commit b466948766
19 changed files with 176 additions and 161 deletions

View File

@@ -3,8 +3,8 @@ python:
- "2.7"
- "2.6"
install:
- pip install -r tools/pip-requires -r tools/test-requires . --use-mirrors
- pip install -r requirements.txt -r test-requirements.txt hacking . --use-mirrors
before_script:
- "flake8 --builtins=_ quark"
- "flake8 --show-source --builtins=_ quark"
script:
- nosetests

View File

@@ -17,8 +17,8 @@ import webob.dec
import webob.exc
from quantum import context
from quantum import wsgi
from quantum.openstack.common import log as logging
from quantum import wsgi
LOG = logging.getLogger(__name__)

View File

@@ -16,8 +16,8 @@
import webob
from quantum.api import extensions
from quantum.manager import QuantumManager
from quantum.common import exceptions
from quantum import manager
from quantum.openstack.common import log as logging
from quantum import wsgi
@@ -82,10 +82,10 @@ class IpAddressesController(wsgi.Controller):
class Ip_addresses(object):
"""Routes support"""
"""IP Addresses support."""
@classmethod
def get_name(cls):
return "IP Aaddresses for a tenant"
return "IP Addresses for a tenant"
@classmethod
def get_alias(cls):
@@ -112,8 +112,8 @@ class Ip_addresses(object):
@classmethod
def get_resources(cls):
""" Returns Ext Resources """
controller = IpAddressesController(QuantumManager.get_plugin())
"""Returns Ext Resources."""
controller = IpAddressesController(manager.QuantumManager.get_plugin())
return [extensions.ResourceExtension(
Ip_addresses.get_alias(),
controller)]

View File

@@ -16,7 +16,7 @@
import webob
from quantum.api import extensions
from quantum.manager import QuantumManager
from quantum import manager
from quantum.openstack.common import log as logging
from quantum import wsgi
@@ -47,7 +47,7 @@ class MacAddressRangesController(wsgi.Controller):
def create(self, request, body=None):
body = self._deserialize(request.body, request.get_content_type())
if not "cidr" in body[RESOURCE_NAME]:
if "cidr" not in body[RESOURCE_NAME]:
raise webob.exc.HTTPUnprocessableEntity()
return {"mac_address_range":
self._plugin.create_mac_address_range(request.context, body)}
@@ -68,7 +68,7 @@ class MacAddressRangesController(wsgi.Controller):
class Mac_address_ranges(object):
"""Routes support"""
"""Mac Address Range support."""
@classmethod
def get_name(cls):
return "MAC Address Ranges for a tenant"
@@ -99,8 +99,8 @@ class Mac_address_ranges(object):
@classmethod
def get_resources(cls):
""" Returns Ext Resources """
controller = MacAddressRangesController(QuantumManager.get_plugin())
return [extensions.ResourceExtension(
Mac_address_ranges.get_alias(),
controller)]
"""Returns Ext Resources."""
plugin = manager.QuantumManager.get_plugin()
controller = MacAddressRangesController(plugin)
return [extensions.ResourceExtension(Mac_address_ranges.get_alias(),
controller)]

View File

@@ -16,8 +16,8 @@
import webob
from quantum.api import extensions
from quantum.manager import QuantumManager
from quantum.common import exceptions
from quantum import manager
from quantum.openstack.common import log as logging
from quantum import wsgi
@@ -52,7 +52,7 @@ class RoutesController(wsgi.Controller):
body = self._deserialize(request.body, request.get_content_type())
keys = ["subnet_id", "gateway", "cidr"]
for k in keys:
if not k in body[RESOURCE_NAME]:
if k not in body[RESOURCE_NAME]:
raise webob.exc.HTTPUnprocessableEntity()
return {"route":
@@ -79,7 +79,7 @@ class RoutesController(wsgi.Controller):
class Routes(object):
"""Routes support"""
"""Routes support."""
@classmethod
def get_name(cls):
return "Routes for a tenant"
@@ -108,8 +108,8 @@ class Routes(object):
@classmethod
def get_resources(cls):
""" Returns Ext Resources """
controller = RoutesController(QuantumManager.get_plugin())
"""Returns Ext Resources."""
controller = RoutesController(manager.QuantumManager.get_plugin())
return [extensions.ResourceExtension(
Routes.get_alias(),
controller)]

View File

@@ -1,7 +1,7 @@
from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
from logging import config as logging_config
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
@@ -9,7 +9,7 @@ config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)
logging_config.fileConfig(config.config_file_name)
# add your model's MetaData object here
# for 'autogenerate' support

View File

@@ -13,8 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from sqlalchemy import types
from sqlalchemy.dialects import sqlite
from sqlalchemy import types
class INET(types.TypeDecorator):

View File

@@ -17,14 +17,15 @@ import netaddr
import sqlalchemy as sa
from sqlalchemy import orm
from sqlalchemy.ext import associationproxy
from sqlalchemy.ext import declarative
from sqlalchemy.ext import hybrid
import quantum.db.model_base
from quantum.db.models_v2 import HasTenant, HasId
from quantum.openstack.common import timeutils
from quantum.db import models_v2 as models
from quantum.openstack.common import log as logging
from quantum.openstack.common import timeutils
from quark.db import custom_types
@@ -54,7 +55,7 @@ class QuarkBase(quantum.db.model_base.QuantumBaseV2):
BASEV2 = declarative.declarative_base(cls=QuarkBase)
class TagAssociation(BASEV2, HasId):
class TagAssociation(BASEV2, models.HasId):
__tablename__ = "quark_tag_associations"
discriminator = sa.Column(sa.String(255))
@@ -72,7 +73,7 @@ class TagAssociation(BASEV2, HasId):
return getattr(self, "%s_parent" % self.discriminator)
class Tag(BASEV2, HasId, HasTenant):
class Tag(BASEV2, models.HasId, models.HasTenant):
__tablename__ = "quark_tags"
association_uuid = sa.Column(sa.String(36),
sa.ForeignKey(TagAssociation.id),
@@ -102,10 +103,12 @@ class IsHazTags(object):
return orm.relationship("TagAssociation", backref=backref)
class IPAddress(BASEV2, HasId, HasTenant):
class IPAddress(BASEV2, models.HasId, models.HasTenant):
"""More closely emulate the melange version of the IP table.
We always mark the record as deallocated rather than deleting it.
Gives us an IP address owner audit log for free, essentially"""
Gives us an IP address owner audit log for free, essentially.
"""
__tablename__ = "quark_ip_addresses"
@@ -150,16 +153,15 @@ class IPAddress(BASEV2, HasId, HasTenant):
deallocated_at = sa.Column(sa.DateTime())
class Route(BASEV2, HasTenant, HasId, IsHazTags):
class Route(BASEV2, models.HasTenant, models.HasId, IsHazTags):
__tablename__ = "quark_routes"
cidr = sa.Column(sa.String(64))
gateway = sa.Column(sa.String(64))
subnet_id = sa.Column(sa.String(36), sa.ForeignKey("quark_subnets.id"))
class Subnet(BASEV2, HasId, HasTenant, IsHazTags):
"""
Upstream model for IPs
class Subnet(BASEV2, models.HasId, models.HasTenant, IsHazTags):
"""Upstream model for IPs.
Subnet -> has_many(IPAllocationPool)
IPAllocationPool -> has_many(IPAvailabilityRange)
@@ -215,7 +217,7 @@ port_ip_association_table = sa.Table(
sa.ForeignKey("quark_ip_addresses.id")))
class Port(BASEV2, HasTenant, HasId):
class Port(BASEV2, models.HasTenant, models.HasId):
__tablename__ = "quark_ports"
id = sa.Column(sa.String(36), primary_key=True)
network_id = sa.Column(sa.String(36), sa.ForeignKey("quark_networks.id"),
@@ -236,7 +238,7 @@ class Port(BASEV2, HasTenant, HasId):
backref="ports")
class MacAddress(BASEV2, HasTenant):
class MacAddress(BASEV2, models.HasTenant):
__tablename__ = "quark_mac_addresses"
address = sa.Column(sa.BigInteger(), primary_key=True)
mac_address_range_id = sa.Column(
@@ -247,14 +249,14 @@ class MacAddress(BASEV2, HasTenant):
orm.relationship(Port, backref="mac_address")
class MacAddressRange(BASEV2, HasId):
class MacAddressRange(BASEV2, models.HasId):
__tablename__ = "quark_mac_address_ranges"
cidr = sa.Column(sa.String(255), nullable=False)
first_address = sa.Column(sa.BigInteger(), nullable=False)
last_address = sa.Column(sa.BigInteger(), nullable=False)
class Network(BASEV2, HasTenant, HasId):
class Network(BASEV2, models.HasTenant, models.HasId):
__tablename__ = "quark_networks"
name = sa.Column(sa.String(255))
ports = orm.relationship(Port, backref='network')

View File

@@ -19,9 +19,9 @@ LOG = logging.getLogger("quantum.quark.base")
class BaseDriver(object):
"""
Base interface for all Quark drivers. Usable as a replacement
for the sample plugin
"""Base interface for all Quark drivers.
Usable as a replacement for the sample plugin.
"""
def load_config(self, path):
LOG.info("load_config %s" % path)

View File

@@ -19,13 +19,13 @@ NVP client driver for Quark
import ConfigParser
from oslo.config import cfg
import sqlalchemy as sa
from sqlalchemy import orm
from oslo.config import cfg
import aiclib
from quantum.openstack.common import log as logging
from quantum.db.models_v2 import HasId
from quark.db import models
from quark.drivers import base
@@ -76,7 +76,7 @@ class NVPDriver(base.BaseDriver):
def get_connection(self):
conn = self.nvp_connections[self.conn_index]
if not "connection" in conn:
if "connection" not in conn:
scheme = conn["port"] == "443" and "https" or "http"
uri = "%s://%s:%s" % (scheme, conn["ip_address"], conn["port"])
conn["connection"] = aiclib.nvp.Connection(uri)
@@ -248,7 +248,7 @@ class OptimizedNVPDriver(NVPDriver):
return switches
class LSwitchPort(models.BASEV2, HasId):
class LSwitchPort(models.BASEV2, models.models.HasId):
__tablename__ = "quark_nvp_driver_lswitchport"
port_id = sa.Column(sa.String(255), nullable=False)
switch_id = sa.Column(sa.String(255),
@@ -256,7 +256,7 @@ class LSwitchPort(models.BASEV2, HasId):
nullable=False)
class LSwitch(models.BASEV2, HasId):
class LSwitch(models.BASEV2, models.models.HasId):
__tablename__ = "quark_nvp_driver_lswitch"
nvp_id = sa.Column(sa.String(255), nullable=False)
network_id = sa.Column(sa.String(255), nullable=False)

View File

@@ -19,15 +19,18 @@ v2 Quantum Plug-in API Quark Implementation
import inspect
import netaddr
from oslo.config import cfg
from sqlalchemy import func as sql_func
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy import event
from zope.sqlalchemy import ZopeTransactionExtension
from oslo.config import cfg
from zope import sqlalchemy as zsa
from quantum import quantum_plugin_base_v2
from quantum.common import exceptions
from quantum.db import api as quantum_db_api
from quantum import quantum_plugin_base_v2
from quantum.openstack.common import importutils
from quantum.openstack.common import log as logging
from quantum.openstack.common import uuidutils
@@ -72,16 +75,17 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
def _initDBMaker(self):
# This needs to be called after _ENGINE is configured
quantum_db_api._MAKER = scoped_session(sessionmaker(
bind=quantum_db_api._ENGINE, extension=ZopeTransactionExtension()))
session_maker = sessionmaker(bind=quantum_db_api._ENGINE,
extension=zsa.ZopeTransactionExtension())
quantum_db_api._MAKER = scoped_session(session_maker)
def __init__(self):
# NOTE(jkoelker) Register the event on all models that have ids
for _name, klass in inspect.getmembers(models, inspect.isclass):
if klass is models.HasId:
if klass is models.models.HasId:
continue
if models.HasId in klass.mro():
if models.models.HasId in klass.mro():
event.listen(klass, "init", perhaps_generate_id)
quantum_db_api.configure_db()
@@ -214,9 +218,11 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
"subnet_id": address["subnet_id"]}
def create_subnet(self, context, subnet):
"""
Create a subnet, which represents a range of IP addresses
"""Create a subnet.
Create a subnet which represents a range of IP addresses
that can be allocated to devices
: param context: quantum api request context
: param subnet: dictionary describing the subnet, with keys
as listed in the RESOURCE_ATTRIBUTE_MAP object in
@@ -229,8 +235,8 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
return subnet_dict
def update_subnet(self, context, id, subnet):
"""
Update values of a subnet.
"""Update values of a subnet.
: param context: quantum api request context
: param id: UUID representing the subnet to update.
: param subnet: dictionary with keys indicating fields to update.
@@ -244,8 +250,8 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
raise NotImplementedError()
def get_subnet(self, context, id, fields=None):
"""
Retrieve a subnet.
"""Retrieve a subnet.
: param context: quantum api request context
: param id: UUID representing the subnet to fetch.
: param fields: a list of strings that are valid keys in a
@@ -259,10 +265,11 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
return self._make_subnet_dict(subnet)
def get_subnets(self, context, filters=None, fields=None):
"""
Retrieve a list of subnets. The contents of the list depends on
the identity of the user making the request (as indicated by the
context) as well as any filters.
"""Retrieve a list of subnets.
The contents of the list depends on the identity of the user
making the request (as indicated by the context) as well as any
filters.
: param context: quantum api request context
: param filters: a dictionary with keys that are valid keys for
a subnet as listed in the RESOURCE_ATTRIBUTE_MAP object
@@ -282,10 +289,10 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
return self._make_subnets_list(subnets, fields)
def get_subnets_count(self, context, filters=None):
"""
Return the number of subnets. The result depends on the identity of
the user making the request (as indicated by the context) as well as
any filters.
"""Return the number of subnets.
The result depends on the identity of the user making the request
(as indicated by the context) as well as any filters.
: param context: quantum api request context
: param filters: a dictionary with keys that are valid keys for
a network as listed in the RESOURCE_ATTRIBUTE_MAP object
@@ -308,8 +315,8 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
db_api.subnet_delete(context, subnet)
def delete_subnet(self, context, id):
"""
Delete a subnet.
"""Delete a subnet.
: param context: quantum api request context
: param id: UUID representing the subnet to delete.
"""
@@ -318,8 +325,9 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
self._delete_subnet(context, subnet)
def create_network(self, context, network):
"""
Create a network, which represents an L2 network segment which
"""Create a network.
Create a network which represents an L2 network segment which
can have a set of subnets and ports associated with it.
: param context: quantum api request context
: param network: dictionary describing the network, with keys
@@ -352,8 +360,8 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
return self._make_network_dict(new_net)
def update_network(self, context, id, network):
"""
Update values of a network.
"""Update values of a network.
: param context: quantum api request context
: param id: UUID representing the network to update.
: param network: dictionary with keys indicating fields to update.
@@ -371,8 +379,8 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
return self._make_network_dict(net)
def get_network(self, context, id, fields=None):
"""
Retrieve a network.
"""Retrieve a network.
: param context: quantum api request context
: param id: UUID representing the network to fetch.
: param fields: a list of strings that are valid keys in a
@@ -388,10 +396,11 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
return self._make_network_dict(network)
def get_networks(self, context, filters=None, fields=None):
"""
Retrieve a list of networks. The contents of the list depends on
the identity of the user making the request (as indicated by the
context) as well as any filters.
"""Retrieve a list of networks.
The contents of the list depends on the identity of the user
making the request (as indicated by the context) as well as any
filters.
: param context: quantum api request context
: param filters: a dictionary with keys that are valid keys for
a network as listed in the RESOURCE_ATTRIBUTE_MAP object
@@ -411,10 +420,10 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
return [self._make_network_dict(net) for net in nets]
def get_networks_count(self, context, filters=None):
"""
Return the number of networks. The result depends on the identity
of the user making the request (as indicated by the context) as well
as any filters.
"""Return the number of networks.
The result depends on the identity of the user making the request
(as indicated by the context) as well as any filters.
: param context: quantum api request context
: param filters: a dictionary with keys that are valid keys for
a network as listed in the RESOURCE_ATTRIBUTE_MAP object
@@ -432,8 +441,8 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
return db_api.network_count_all(context)
def delete_network(self, context, id):
"""
Delete a network.
"""Delete a network.
: param context: quantum api request context
: param id: UUID representing the network to delete.
"""
@@ -449,8 +458,9 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
db_api.network_delete(context, net)
def create_port(self, context, port):
"""
Create a port, which is a connection point of a device (e.g., a VM
"""Create a port
Create a port which is a connection point of a device (e.g., a VM
NIC) to attach to a L2 Quantum network.
: param context: quantum api request context
: param port: dictionary describing the port, with keys
@@ -493,8 +503,8 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
return self._make_port_dict(new_port)
def update_port(self, context, id, port):
"""
Update values of a port.
"""Update values of a port.
: param context: quantum api request context
: param id: UUID representing the port to update.
: param port: dictionary with keys indicating fields to update.
@@ -505,8 +515,8 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
raise NotImplementedError()
def get_port(self, context, id, fields=None):
"""
Retrieve a port.
"""Retrieve a port.
: param context: quantum api request context
: param id: UUID representing the port to fetch.
: param fields: a list of strings that are valid keys in a
@@ -552,10 +562,11 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
return query
def get_ports(self, context, filters=None, fields=None):
"""
Retrieve a list of ports. The contents of the list depends on
the identity of the user making the request (as indicated by the
context) as well as any filters.
"""Retrieve a list of ports.
The contents of the list depends on the identity of the user
making the request (as indicated by the context) as well as any
filters.
: param context: quantum api request context
: param filters: a dictionary with keys that are valid keys for
a port as listed in the RESOURCE_ATTRIBUTE_MAP object
@@ -575,10 +586,10 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
return self._make_ports_list(query, fields)
def get_ports_count(self, context, filters=None):
"""
Return the number of ports. The result depends on the identity of
the user making the request (as indicated by the context) as well as
any filters.
"""Return the number of ports.
The result depends on the identity of the user making the request
(as indicated by the context) as well as any filters.
: param context: quantum api request context
: param filters: a dictionary with keys that are valid keys for
a network as listed in the RESOURCE_ATTRIBUTE_MAP object
@@ -597,8 +608,8 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
return self._ports_query(context, filters, query=query).scalar()
def delete_port(self, context, id):
"""
Delete a port.
"""Delete a port.
: param context: quantum api request context
: param id: UUID representing the port to delete.
"""

View File

@@ -16,14 +16,14 @@
import contextlib
import mock
from oslo.config import cfg
from quantum import context
from quantum.common import exceptions
from quantum import context
from quantum.db import api as quantum_db_api
from quark.db import models
import quark.ipam
import test_base
from quark.tests import test_base
class QuarkIpamBaseTest(test_base.TestBase):
@@ -287,8 +287,11 @@ class QuarkIPAddressAllocateDeallocated(QuarkIpamBaseTest):
quark.ipam.QuarkIpam._choose_available_subnet.called)
def test_allocate_finds_no_deallocated_creates_new_ip(self):
'''Fails based on the choice of reuse_after argument. Allocates new ip
address instead of previously deallocated mac address.'''
'''Fails based on the choice of reuse_after argument.
Allocates new ip address instead of previously deallocated mac
address.
'''
with self._stubs(ip_find=False):
ipaddress = self.ipam.allocate_ip_address(self.context, 0, 0, 0)
self.assertIsNone(ipaddress['id'])

View File

@@ -22,7 +22,7 @@ from quantum.db import api as db_api
import quark.drivers.nvp_driver
import test_base
from quark.tests import test_base
class TestNVPDriver(test_base.TestBase):

View File

@@ -16,13 +16,13 @@
import netaddr
from oslo.config import cfg
from quantum import context
from quantum.common import exceptions
from quantum import context
from quantum.db import api as db_api
import quark.plugin
import test_base
from quark.tests import test_base
class TestQuarkPlugin(test_base.TestBase):
@@ -73,8 +73,7 @@ class TestSubnets(TestQuarkPlugin):
class TestIpAddresses(TestQuarkPlugin):
# TODO(amir): add test to check filter for tenant_id
def test_create_ip_address_success_1(self):
'''1. Create IP address with network id and device id.'''
def test_create_ip_address_network_and_device(self):
network_id = self._create_network()['id']
subnet = self._create_subnet(network_id)
self._create_mac_address_range()
@@ -93,16 +92,13 @@ class TestIpAddresses(TestQuarkPlugin):
self.assertEqual(response['port_ids'], [port_id])
self.assertEqual(response['subnet_id'], subnet['id'])
def test_create_ip_address_failure_1b(self):
'''1b. Create IP address with invalid network_id and invalid
device_id.'''
def test_create_ip_address_invalid_network_and_device(self):
with self.assertRaises(exceptions.PortNotFound):
ip_address = {'ip_address': {'network_id': 'fake',
'device_id': 'fake'}}
self.plugin.create_ip_address(self.context, ip_address)
def test_create_ip_address_success_2(self):
'''2. Create IP address with port_id.'''
def test_create_ip_address_with_port(self):
network_id = self._create_network()['id']
subnet = self._create_subnet(network_id)
self._create_mac_address_range()
@@ -119,27 +115,23 @@ class TestIpAddresses(TestQuarkPlugin):
self.assertEqual(response['port_ids'], [port_id])
self.assertEqual(response['subnet_id'], subnet['id'])
def test_create_ip_address_failure_2b(self):
'''2b. Create IP Address with invalid port_id.'''
def test_create_ip_address_invalid_port(self):
with self.assertRaises(exceptions.PortNotFound):
ip_address = {'ip_address': {'port_id': 'fake'}}
self.plugin.create_ip_address(self.context, ip_address)
def test_create_ip_address_failure_3(self):
'''3. Create IP address with none of network_id, device_id, port_id.'''
def test_create_ip_address_no_fields(self):
with self.assertRaises(exceptions.PortNotFound):
ip_address = {'ip_address': {}}
self.plugin.create_ip_address(self.context, ip_address)
def test_create_ip_address_failure_4(self):
'''4. Create IP address with network_id and without device_id.'''
def test_create_ip_address_no_device(self):
network_id = self._create_network()['id']
with self.assertRaises(exceptions.PortNotFound):
ip_address = {'ip_address': {'network_id': network_id}}
self.plugin.create_ip_address(self.context, ip_address)
def test_create_ip_address_failure_5(self):
'''5. Create IP Address without network_id and with device_id.'''
def test_create_ip_address_no_network(self):
network_id = self._create_network()['id']
self._create_subnet(network_id)['id']
self._create_mac_address_range()
@@ -150,8 +142,7 @@ class TestIpAddresses(TestQuarkPlugin):
ip_address = {'ip_address': {'device_id': device_id}}
self.plugin.create_ip_address(self.context, ip_address)
def test_create_ip_address_success_6(self):
'''6. Create IP Address with version (v4) specified.'''
def test_create_ip_address_ipv4(self):
network_id = self._create_network()['id']
subnet_v4 = self._create_subnet(network_id, cidr='192.168.10.1/24')
self._create_subnet(network_id, cidr='fc00::/7')
@@ -173,8 +164,7 @@ class TestIpAddresses(TestQuarkPlugin):
self.assertEqual(response['port_ids'], [port_id])
self.assertEqual(response['subnet_id'], subnet_v4['id'])
def test_create_ip_address_success_7(self):
'''7. Create IP address with version (v6) specified.'''
def test_create_ip_address_ipv6(self):
network_id = self._create_network()['id']
subnet_v6 = self._create_subnet(network_id, cidr='fc00::/7')
self._create_subnet(network_id, cidr='192.168.10.1/24')
@@ -196,8 +186,7 @@ class TestIpAddresses(TestQuarkPlugin):
self.assertEqual(response['port_ids'], [port_id])
self.assertEqual(response['subnet_id'], subnet_v6['id'])
def test_create_ip_address_failure_8(self):
'''8. Create IP Address with version (10) specified.'''
def test_create_ip_address_invalid_version(self):
network_id = self._create_network()['id']
self._create_subnet(network_id)
self._create_mac_address_range()
@@ -210,9 +199,7 @@ class TestIpAddresses(TestQuarkPlugin):
'version': 10}}
self.plugin.create_ip_address(self.context, ip_address)
def test_create_ip_address_success_9(self):
'''9. Create IP address with specific ip_address and ip_address doesn't
exist already.'''
def test_create_ip_address_new(self):
network_id = self._create_network()['id']
subnet = self._create_subnet(network_id)
self._create_mac_address_range()
@@ -232,9 +219,7 @@ class TestIpAddresses(TestQuarkPlugin):
self.assertEqual(response['port_ids'], [port['id']])
self.assertEqual(response['subnet_id'], subnet['id'])
def test_create_ip_address_success_10(self):
'''10. Create IP address with specific ip_address when ip_address does
exist already. Associates to new port successfully.'''
def test_create_ip_address_new_with_port(self):
network_id = self._create_network()['id']
subnet = self._create_subnet(network_id)
self._create_mac_address_range()
@@ -261,16 +246,13 @@ class TestIpAddresses(TestQuarkPlugin):
def test_get_ip_addresses_success(self):
pass
def test_update_ip_address_failure_1(self):
'''1. Update IP address when specific ip_address id doesn't exist.'''
def test_update_ip_address_does_not_exist(self):
with self.assertRaises(exceptions.NotFound):
self.plugin.update_ip_address(self.context,
'no_ip_address_id',
{'ip_address': {'port_ids': []}})
def test_update_ip_address_failure_2(self):
'''2. Update IP address when specific port_id in port_ids doesn't
exist.'''
def test_update_ip_address_port_not_found(self):
network_id = self._create_network()['id']
self._create_subnet(network_id)
self._create_mac_address_range()
@@ -288,8 +270,7 @@ class TestIpAddresses(TestQuarkPlugin):
response['id'],
ip_address)
def test_update_ip_address_success_3(self):
'''3. Update IP address to associate with specific port_ids.'''
def test_update_ip_address_specify_ports(self):
network_id = self._create_network()['id']
self._create_subnet(network_id)
self._create_mac_address_range()
@@ -305,8 +286,7 @@ class TestIpAddresses(TestQuarkPlugin):
ip_address)
self.assertEqual(response['port_ids'], [port_2['id']])
def test_update_ip_address_success_4(self):
'''4. Update IP address with valid id but no port_ids is no-op.'''
def test_update_ip_address_no_ports(self):
network_id = self._create_network()['id']
self._create_subnet(network_id)
self._create_mac_address_range()
@@ -321,8 +301,7 @@ class TestIpAddresses(TestQuarkPlugin):
ip_address)
self.assertEqual(response['port_ids'], [port['id']])
def test_update_ip_address_success_5(self):
'''5. Update IP address with valid id and empty list deletes all.'''
def test_update_ip_address_empty_ports_delete(self):
network_id = self._create_network()['id']
self._create_subnet(network_id)
self._create_mac_address_range()

25
setup.cfg Normal file
View File

@@ -0,0 +1,25 @@
[metadata]
name = quark
author = Ozone
author-email = jkoelker@rackspace.com
summary = A quantum plugin plugin
description-file = README.rst
license = Apache-2
home-page = http://github.com/jkoelker/quark
classifier =
Development Status :: 4 - Beta
Environment :: Console
Environment :: OpenStack
Intended Audience :: Developers
Intended Audience :: Information Technology
License :: OSI Approved :: Apache Software License
Operating System :: OS Independent
Programming Language :: Python
[files]
packages =
quark
[hooks]
setup-hooks =
pbr.hooks.setup_hook

View File

@@ -19,14 +19,6 @@ import setuptools
setuptools.setup(
name='quark',
version='0.1',
author='Ozone',
author_email='jkoelker@rackspace.com',
packages=setuptools.find_packages(exclude=['ez_setup',
'examples', 'tests']),
url='https://github.com/jkoelker/quark',
license='Apache Software License',
description='A quantum plugin plugin',
long_description=open('README.rst').read(),
setup_requires=['d2to1', 'pbr'],
d2to1=True,
)

13
tox.ini
View File

@@ -9,8 +9,8 @@ setenv = VIRTUAL_ENV={envdir}
NOSE_OPENSTACK_YELLOW=0.025
NOSE_OPENSTACK_SHOW_ELAPSED=1
NOSE_OPENSTACK_STDOUT=1
deps = -r{toxinidir}/tools/pip-requires
-r{toxinidir}/tools/test-requires
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = nosetests {posargs}
[tox:jenkins]
@@ -18,12 +18,12 @@ sitepackages = True
downloadcache = ~/cache/pip
[testenv:flake8]
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
hacking
commands =
flake8 --builtins=_ quark
[testenv:i18n]
commands = python ./tools/check_i18n.py ./quantum ./tools/i18n_cfg.py
[testenv:cover]
setenv = VIRTUAL_ENV={envdir}
NOSE_WITH_COVERAGE=1
@@ -34,3 +34,6 @@ commands = nosetests --cover-package=quark {posargs}
[testenv:venv]
commands = {posargs}
[flake8]
show-source = true