Rename Quantum to Neutron

quantumclient is gone upstream and has been replaced by neutronclient.

This patch retains the OS::Quantum::XX namespace

Fixes: bug #1197208

Change-Id: Id48f9598ea1884132d411ad533770ae49494102b
This commit is contained in:
Steven Dake 2013-08-06 19:41:26 -07:00
parent 9b53378e27
commit ed0fb7e823
27 changed files with 436 additions and 424 deletions

View File

@ -36,4 +36,4 @@ We have integration with
* https://github.com/openstack/python-novaclient (instance)
* https://github.com/openstack/python-keystoneclient (auth)
* https://github.com/openstack/python-swiftclient (s3)
* https://github.com/openstack/python-quantumclient (networking)
* https://github.com/openstack/python-neutronclient (networking)

View File

@ -5,7 +5,7 @@
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:html="http://www.w3.org/1999/xhtml"
version="5.0"
xml:id="quantum-cli-reference">
xml:id="neutron-cli-reference">
<?dbhtml stop-chunking?>
<title>OpenStack Heat CLI Guide</title>
<para>This section describes heat commands</para>

View File

@ -29,10 +29,10 @@ except ImportError:
swiftclient = None
logger.info('swiftclient not available')
try:
from quantumclient.v2_0 import client as quantumclient
from neutronclient.v2_0 import client as neutronclient
except ImportError:
quantumclient = None
logger.info('quantumclient not available')
neutronclient = None
logger.info('neutronclient not available')
try:
from cinderclient import client as cinderclient
except ImportError:
@ -64,7 +64,7 @@ class OpenStackClients(object):
self._nova = {}
self._keystone = None
self._swift = None
self._quantum = None
self._neutron = None
self._cinder = None
self._ceilometer = None
@ -133,15 +133,15 @@ class OpenStackClients(object):
self._swift = swiftclient.Connection(**args)
return self._swift
def quantum(self):
if quantumclient is None:
def neutron(self):
if neutronclient is None:
return None
if self._quantum:
return self._quantum
if self._neutron:
return self._neutron
con = self.context
if self.auth_token is None:
logger.error("Quantum connection failed, no auth_token!")
logger.error("Neutron connection failed, no auth_token!")
return None
args = {
@ -151,9 +151,9 @@ class OpenStackClients(object):
'endpoint_url': self.url_for(service_type='network')
}
self._quantum = quantumclient.Client(**args)
self._neutron = neutronclient.Client(**args)
return self._quantum
return self._neutron
def cinder(self):
if cinderclient is None:

View File

@ -325,8 +325,8 @@ class Resource(object):
def swift(self):
return self.stack.clients.swift()
def quantum(self):
return self.stack.clients.quantum()
def neutron(self):
return self.stack.clients.neutron()
def cinder(self):
return self.stack.clients.cinder()

View File

@ -280,9 +280,9 @@ class Instance(resource.Resource):
else:
# if SubnetId property in Instance, ensure subnet exists
if subnet_id:
quantumclient = self.quantum()
neutronclient = self.neutron()
network_id = NetworkInterface.network_id_from_subnet_id(
quantumclient, subnet_id)
neutronclient, subnet_id)
# if subnet verified, create a port to use this subnet
# if port is not created explicitly, nova will choose
# the first subnet in the given network.
@ -293,7 +293,7 @@ class Instance(resource.Resource):
'network_id': network_id,
'fixed_ips': [fixed_ip]
}
port = quantumclient.create_port({'port': props})['port']
port = neutronclient.create_port({'port': props})['port']
nics = [{'port-id': port['id']}]
return nics

View File

@ -83,26 +83,26 @@ class VPCGatewayAttachment(resource.Resource):
deps += (self, route_table)
def handle_create(self):
client = self.quantum()
client = self.neutron()
external_network_id = InternetGateway.get_external_network_id(client)
for router in self._vpc_route_tables():
client.add_gateway_router(router.resource_id, {
'network_id': external_network_id})
def handle_delete(self):
from quantumclient.common.exceptions import QuantumClientException
from neutronclient.common.exceptions import NeutronClientException
client = self.quantum()
client = self.neutron()
for router in self._vpc_route_tables():
try:
client.remove_gateway_router(router.resource_id)
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
def resource_mapping():
if clients.quantumclient is None:
if clients.neutronclient is None:
return {}
return {

View File

@ -44,12 +44,12 @@ class NetworkInterface(resource.Resource):
}
@staticmethod
def network_id_from_subnet_id(quantumclient, subnet_id):
subnet_info = quantumclient.show_subnet(subnet_id)
def network_id_from_subnet_id(neutronclient, subnet_id):
subnet_info = neutronclient.show_subnet(subnet_id)
return subnet_info['subnet']['network_id']
def handle_create(self):
client = self.quantum()
client = self.neutron()
subnet_id = self.properties['SubnetId']
network_id = self.network_id_from_subnet_id(client, subnet_id)
@ -80,18 +80,18 @@ class NetworkInterface(resource.Resource):
self.resource_id_set(port['id'])
def handle_delete(self):
from quantumclient.common.exceptions import QuantumClientException
from neutronclient.common.exceptions import NeutronClientException
client = self.quantum()
client = self.neutron()
try:
client.delete_port(self.resource_id)
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
def resource_mapping():
if clients.quantumclient is None:
if clients.neutronclient is None:
return {}
return {

View File

@ -15,15 +15,15 @@
from heat.engine import clients
from heat.openstack.common import log as logging
from heat.engine.resources.quantum import quantum
from heat.engine.resources.neutron import neutron
if clients.quantumclient is not None:
from quantumclient.common.exceptions import QuantumClientException
if clients.neutronclient is not None:
from neutronclient.common.exceptions import NeutronClientException
logger = logging.getLogger(__name__)
class FloatingIP(quantum.QuantumResource):
class FloatingIP(neutron.NeutronResource):
properties_schema = {'floating_network_id': {'Type': 'String',
'Required': True},
'value_specs': {'Type': 'Map',
@ -36,7 +36,8 @@ class FloatingIP(quantum.QuantumResource):
# depend on any RouterGateway in this template with the same
# network_id as this floating_network_id
for resource in self.stack.resources.itervalues():
if (resource.type() == 'OS::Quantum::RouterGateway' and
if ((resource.type() == 'OS::Neutron::RouterGateway' or
resource.type() == 'OS::Quantum::RouterGateway') and
resource.properties.get('network_id') ==
self.properties.get('floating_network_id')):
deps += (self, resource)
@ -45,29 +46,29 @@ class FloatingIP(quantum.QuantumResource):
props = self.prepare_properties(
self.properties,
self.physical_resource_name())
fip = self.quantum().create_floatingip({
fip = self.neutron().create_floatingip({
'floatingip': props})['floatingip']
self.resource_id_set(fip['id'])
def handle_delete(self):
client = self.quantum()
client = self.neutron()
try:
client.delete_floatingip(self.resource_id)
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
def FnGetAtt(self, key):
try:
attributes = self.quantum().show_floatingip(
attributes = self.neutron().show_floatingip(
self.resource_id)['floatingip']
except QuantumClientException as ex:
except NeutronClientException as ex:
logger.warn("failed to fetch resource attributes: %s" % str(ex))
return None
return self.handle_get_attributes(self.name, key, attributes)
class FloatingIPAssociation(quantum.QuantumResource):
class FloatingIPAssociation(neutron.NeutronResource):
properties_schema = {'floatingip_id': {'Type': 'String',
'Required': True},
'port_id': {'Type': 'String',
@ -79,29 +80,31 @@ class FloatingIPAssociation(quantum.QuantumResource):
floatingip_id = props.pop('floatingip_id')
self.quantum().update_floatingip(floatingip_id, {
self.neutron().update_floatingip(floatingip_id, {
'floatingip': props})['floatingip']
self.resource_id_set('%s:%s' % (floatingip_id, props['port_id']))
def handle_delete(self):
if not self.resource_id:
return
client = self.quantum()
client = self.neutron()
(floatingip_id, port_id) = self.resource_id.split(':')
try:
client.update_floatingip(
floatingip_id,
{'floatingip': {'port_id': None}})
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
def resource_mapping():
if clients.quantumclient is None:
if clients.neutronclient is None:
return {}
return {
'OS::Neutron::FloatingIP': FloatingIP,
'OS::Neutron::FloatingIPAssociation': FloatingIPAssociation,
'OS::Quantum::FloatingIP': FloatingIP,
'OS::Quantum::FloatingIPAssociation': FloatingIPAssociation,
}

View File

@ -15,16 +15,16 @@
from heat.engine import clients
from heat.openstack.common import log as logging
from heat.engine.resources.quantum import quantum
from heat.engine.resources.neutron import neutron
from heat.engine import scheduler
if clients.quantumclient is not None:
from quantumclient.common.exceptions import QuantumClientException
if clients.neutronclient is not None:
from neutronclient.common.exceptions import NeutronClientException
logger = logging.getLogger(__name__)
class Net(quantum.QuantumResource):
class Net(neutron.NeutronResource):
properties_schema = {'name': {'Type': 'String'},
'value_specs': {'Type': 'Map',
'Default': {}},
@ -43,11 +43,11 @@ class Net(quantum.QuantumResource):
props = self.prepare_properties(
self.properties,
self.physical_resource_name())
net = self.quantum().create_network({'network': props})['network']
net = self.neutron().create_network({'network': props})['network']
self.resource_id_set(net['id'])
def _show_resource(self):
return self.quantum().show_network(
return self.neutron().show_network(
self.resource_id)['network']
def check_create_complete(self, *args):
@ -55,10 +55,10 @@ class Net(quantum.QuantumResource):
return self.is_built(attributes)
def handle_delete(self):
client = self.quantum()
client = self.neutron()
try:
client.delete_network(self.resource_id)
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
else:
@ -66,9 +66,10 @@ class Net(quantum.QuantumResource):
def resource_mapping():
if clients.quantumclient is None:
if clients.neutronclient is None:
return {}
return {
'OS::Neutron::Net': Net,
'OS::Quantum::Net': Net,
}

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from quantumclient.common.exceptions import QuantumClientException
from neutronclient.common.exceptions import NeutronClientException
from heat.common import exception
from heat.engine import resource
@ -23,13 +23,13 @@ from heat.openstack.common import log as logging
logger = logging.getLogger(__name__)
class QuantumResource(resource.Resource):
class NeutronResource(resource.Resource):
def validate(self):
'''
Validate any of the provided params
'''
res = super(QuantumResource, self).validate()
res = super(NeutronResource, self).validate()
if res:
return res
return self.validate_properties(self.properties)
@ -54,7 +54,7 @@ class QuantumResource(resource.Resource):
def prepare_properties(properties, name):
'''
Prepares the property values so that they can be passed directly to
the Quantum call.
the Neutron call.
Removes None values and value_specs, merges value_specs with the main
values.
@ -91,13 +91,13 @@ class QuantumResource(resource.Resource):
return True
else:
raise exception.Error('%s resource[%s] status[%s]' %
('quantum reported unexpected',
('neutron reported unexpected',
attributes['name'], attributes['status']))
def _resolve_attribute(self, name):
try:
attributes = self._show_resource()
except QuantumClientException as ex:
except NeutronClientException as ex:
logger.warn("failed to fetch resource attributes: %s" % str(ex))
return None
return self.handle_get_attributes(self.name, name, attributes)
@ -107,7 +107,7 @@ class QuantumResource(resource.Resource):
try:
yield
self._show_resource()
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
return

View File

@ -15,16 +15,16 @@
from heat.engine import clients
from heat.openstack.common import log as logging
from heat.engine.resources.quantum import quantum
from heat.engine.resources.neutron import neutron
from heat.engine import scheduler
if clients.quantumclient is not None:
from quantumclient.common.exceptions import QuantumClientException
if clients.neutronclient is not None:
from neutronclient.common.exceptions import NeutronClientException
logger = logging.getLogger(__name__)
class Port(quantum.QuantumResource):
class Port(neutron.NeutronResource):
fixed_ip_schema = {'subnet_id': {'Type': 'String',
'Required': True},
@ -65,7 +65,8 @@ class Port(quantum.QuantumResource):
# to so all subnets in a network should be created before
# the ports in that network.
for resource in self.stack.resources.itervalues():
if (resource.type() == 'OS::Quantum::Subnet' and
if ((resource.type() == 'OS::Neutron::Subnet' or
resource.type() == 'OS::Quantum::Subnet') and
resource.properties.get('network_id') ==
self.properties.get('network_id')):
deps += (self, resource)
@ -74,11 +75,11 @@ class Port(quantum.QuantumResource):
props = self.prepare_properties(
self.properties,
self.physical_resource_name())
port = self.quantum().create_port({'port': props})['port']
port = self.neutron().create_port({'port': props})['port']
self.resource_id_set(port['id'])
def _show_resource(self):
return self.quantum().show_port(
return self.neutron().show_port(
self.resource_id)['port']
def check_create_complete(self, *args):
@ -86,10 +87,10 @@ class Port(quantum.QuantumResource):
return self.is_built(attributes)
def handle_delete(self):
client = self.quantum()
client = self.neutron()
try:
client.delete_port(self.resource_id)
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
else:
@ -97,9 +98,10 @@ class Port(quantum.QuantumResource):
def resource_mapping():
if clients.quantumclient is None:
if clients.neutronclient is None:
return {}
return {
'OS::Neutron::Port': Port,
'OS::Quantum::Port': Port,
}

View File

@ -14,18 +14,18 @@
# under the License.
from heat.engine import clients
from heat.engine.resources.quantum import quantum
from heat.engine.resources.neutron import neutron
from heat.engine import scheduler
if clients.quantumclient is not None:
from quantumclient.common.exceptions import QuantumClientException
if clients.neutronclient is not None:
from neutronclient.common.exceptions import NeutronClientException
from heat.openstack.common import log as logging
logger = logging.getLogger(__name__)
class Router(quantum.QuantumResource):
class Router(neutron.NeutronResource):
properties_schema = {'name': {'Type': 'String'},
'value_specs': {'Type': 'Map',
'Default': {}},
@ -44,11 +44,11 @@ class Router(quantum.QuantumResource):
props = self.prepare_properties(
self.properties,
self.physical_resource_name())
router = self.quantum().create_router({'router': props})['router']
router = self.neutron().create_router({'router': props})['router']
self.resource_id_set(router['id'])
def _show_resource(self):
return self.quantum().show_router(
return self.neutron().show_router(
self.resource_id)['router']
def check_create_complete(self, *args):
@ -56,17 +56,17 @@ class Router(quantum.QuantumResource):
return self.is_built(attributes)
def handle_delete(self):
client = self.quantum()
client = self.neutron()
try:
client.delete_router(self.resource_id)
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
else:
return scheduler.TaskRunner(self._confirm_delete)()
class RouterInterface(quantum.QuantumResource):
class RouterInterface(neutron.NeutronResource):
properties_schema = {'router_id': {'Type': 'String',
'Required': True},
'subnet_id': {'Type': 'String',
@ -75,24 +75,24 @@ class RouterInterface(quantum.QuantumResource):
def handle_create(self):
router_id = self.properties.get('router_id')
subnet_id = self.properties.get('subnet_id')
self.quantum().add_interface_router(
self.neutron().add_interface_router(
router_id,
{'subnet_id': subnet_id})
self.resource_id_set('%s:%s' % (router_id, subnet_id))
def handle_delete(self):
client = self.quantum()
client = self.neutron()
(router_id, subnet_id) = self.resource_id.split(':')
try:
client.remove_interface_router(
router_id,
{'subnet_id': subnet_id})
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
class RouterGateway(quantum.QuantumResource):
class RouterGateway(neutron.NeutronResource):
properties_schema = {'router_id': {'Type': 'String',
'Required': True},
'network_id': {'Type': 'String',
@ -103,14 +103,16 @@ class RouterGateway(quantum.QuantumResource):
for resource in self.stack.resources.itervalues():
# depend on any RouterInterface in this template with the same
# router_id as this router_id
if (resource.type() == 'OS::Quantum::RouterInterface' and
if ((resource.type() == 'OS::Neutron::RouterInterface' or
resource.type() == 'OS::Quantum::RouterInterface') and
resource.properties.get('router_id') ==
self.properties.get('router_id')):
deps += (self, resource)
# depend on any subnet in this template with the same network_id
# as this network_id, as the gateway implicitly creates a port
# on that subnet
elif (resource.type() == 'OS::Quantum::Subnet' and
elif ((resource.type() == 'OS::Neutron::Subnet' or
resource.type() == 'OS::Quantum::Subnet') and
resource.properties.get('network_id') ==
self.properties.get('network_id')):
deps += (self, resource)
@ -118,26 +120,29 @@ class RouterGateway(quantum.QuantumResource):
def handle_create(self):
router_id = self.properties.get('router_id')
network_id = self.properties.get('network_id')
self.quantum().add_gateway_router(
self.neutron().add_gateway_router(
router_id,
{'network_id': network_id})
self.resource_id_set('%s:%s' % (router_id, network_id))
def handle_delete(self):
client = self.quantum()
client = self.neutron()
(router_id, network_id) = self.resource_id.split(':')
try:
client.remove_gateway_router(router_id)
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
def resource_mapping():
if clients.quantumclient is None:
if clients.neutronclient is None:
return {}
return {
'OS::Neutron::Router': Router,
'OS::Neutron::RouterInterface': RouterInterface,
'OS::Neutron::RouterGateway': RouterGateway,
'OS::Quantum::Router': Router,
'OS::Quantum::RouterInterface': RouterInterface,
'OS::Quantum::RouterGateway': RouterGateway,

View File

@ -15,16 +15,16 @@
from heat.engine import clients
from heat.openstack.common import log as logging
from heat.engine.resources.quantum import quantum
from heat.engine.resources.neutron import neutron
from heat.engine import scheduler
if clients.quantumclient is not None:
from quantumclient.common.exceptions import QuantumClientException
if clients.neutronclient is not None:
from neutronclient.common.exceptions import NeutronClientException
logger = logging.getLogger(__name__)
class Subnet(quantum.QuantumResource):
class Subnet(neutron.NeutronResource):
allocation_schema = {'start': {'Type': 'String',
'Required': True},
@ -68,27 +68,28 @@ class Subnet(quantum.QuantumResource):
props = self.prepare_properties(
self.properties,
self.physical_resource_name())
subnet = self.quantum().create_subnet({'subnet': props})['subnet']
subnet = self.neutron().create_subnet({'subnet': props})['subnet']
self.resource_id_set(subnet['id'])
def handle_delete(self):
client = self.quantum()
client = self.neutron()
try:
client.delete_subnet(self.resource_id)
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
else:
return scheduler.TaskRunner(self._confirm_delete)()
def _show_resource(self):
return self.quantum().show_subnet(self.resource_id)['subnet']
return self.neutron().show_subnet(self.resource_id)['subnet']
def resource_mapping():
if clients.quantumclient is None:
if clients.neutronclient is None:
return {}
return {
'OS::Neutron::Subnet': Subnet,
'OS::Quantum::Subnet': Subnet,
}

View File

@ -83,8 +83,8 @@ class RackspaceResource(resource.Resource):
return self._cloud_blockstore
def quantum(self):
'''Rackspace quantum client.'''
def neutron(self):
'''Rackspace neutron client.'''
if not self._cloud_nw:
self.__authenticate()
self._cloud_nw = self.pyrax.cloud_networks

View File

@ -16,11 +16,11 @@
from heat.engine import clients
from heat.openstack.common import log as logging
from heat.engine import resource
from heat.engine.resources.quantum import quantum
from heat.engine.resources.neutron import neutron
from heat.engine.resources.vpc import VPC
if clients.quantumclient is not None:
from quantumclient.common.exceptions import QuantumClientException
if clients.neutronclient is not None:
from neutronclient.common.exceptions import NeutronClientException
logger = logging.getLogger(__name__)
@ -42,16 +42,16 @@ class RouteTable(resource.Resource):
}
def handle_create(self):
client = self.quantum()
client = self.neutron()
props = {'name': self.physical_resource_name()}
router = client.create_router({'router': props})['router']
self.resource_id_set(router['id'])
def check_create_complete(self, *args):
client = self.quantum()
client = self.neutron()
attributes = client.show_router(
self.resource_id)['router']
if not quantum.QuantumResource.is_built(attributes):
if not neutron.NeutronResource.is_built(attributes):
return False
network_id = self.properties.get('VpcId')
@ -66,19 +66,19 @@ class RouteTable(resource.Resource):
return True
def handle_delete(self):
client = self.quantum()
client = self.neutron()
router_id = self.resource_id
try:
client.delete_router(router_id)
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
# just in case this router has been added to a gateway, remove it
try:
client.remove_gateway_router(router_id)
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
@ -95,7 +95,7 @@ class SubnetRouteTableAssocation(resource.Resource):
}
def handle_create(self):
client = self.quantum()
client = self.neutron()
subnet_id = self.properties.get('SubnetId')
router_id = self.properties.get('RouteTableId')
@ -107,7 +107,7 @@ class SubnetRouteTableAssocation(resource.Resource):
client.remove_interface_router(
previous_router['id'],
{'subnet_id': subnet_id})
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
@ -115,14 +115,14 @@ class SubnetRouteTableAssocation(resource.Resource):
router_id, {'subnet_id': subnet_id})
def _router_for_subnet(self, subnet_id):
client = self.quantum()
client = self.neutron()
subnet = client.show_subnet(
subnet_id)['subnet']
network_id = subnet['network_id']
return VPC.router_for_vpc(client, network_id)
def handle_delete(self):
client = self.quantum()
client = self.neutron()
subnet_id = self.properties.get('SubnetId')
router_id = self.properties.get('RouteTableId')
@ -130,7 +130,7 @@ class SubnetRouteTableAssocation(resource.Resource):
try:
client.remove_interface_router(router_id, {
'subnet_id': subnet_id})
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
@ -140,13 +140,13 @@ class SubnetRouteTableAssocation(resource.Resource):
if default_router:
client.add_interface_router(
default_router['id'], {'subnet_id': subnet_id})
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
def resource_mapping():
if clients.quantumclient is None:
if clients.neutronclient is None:
return {}
return {

View File

@ -29,14 +29,14 @@ class SecurityGroup(resource.Resource):
'SecurityGroupEgress': {'Type': 'List'}}
def handle_create(self):
if self.properties['VpcId'] and clients.quantumclient is not None:
self._handle_create_quantum()
if self.properties['VpcId'] and clients.neutronclient is not None:
self._handle_create_neutron()
else:
self._handle_create_nova()
def _handle_create_quantum(self):
from quantumclient.common.exceptions import QuantumClientException
client = self.quantum()
def _handle_create_neutron(self):
from neutronclient.common.exceptions import NeutronClientException
client = self.neutron()
sec = client.create_security_group({'security_group': {
'name': self.physical_resource_name(),
@ -46,7 +46,7 @@ class SecurityGroup(resource.Resource):
self.resource_id_set(sec['id'])
if self.properties['SecurityGroupIngress']:
for i in self.properties['SecurityGroupIngress']:
# Quantum only accepts positive ints
# Neutron only accepts positive ints
if int(i['FromPort']) < 0:
i['FromPort'] = None
if int(i['ToPort']) < 0:
@ -66,7 +66,7 @@ class SecurityGroup(resource.Resource):
'security_group_id': sec['id']
}
})
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code == 409:
# no worries, the rule is already there
pass
@ -87,7 +87,7 @@ class SecurityGroup(resource.Resource):
'security_group_id': sec['id']
}
})
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code == 409:
# no worries, the rule is already there
pass
@ -128,8 +128,8 @@ class SecurityGroup(resource.Resource):
raise
def handle_delete(self):
if self.properties['VpcId'] and clients.quantumclient is not None:
self._handle_delete_quantum()
if self.properties['VpcId'] and clients.neutronclient is not None:
self._handle_delete_neutron()
else:
self._handle_delete_nova()
@ -149,28 +149,28 @@ class SecurityGroup(resource.Resource):
self.nova().security_groups.delete(self.resource_id)
self.resource_id = None
def _handle_delete_quantum(self):
from quantumclient.common.exceptions import QuantumClientException
client = self.quantum()
def _handle_delete_neutron(self):
from neutronclient.common.exceptions import NeutronClientException
client = self.neutron()
if self.resource_id is not None:
try:
sec = client.show_security_group(
self.resource_id)['security_group']
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise
else:
for rule in sec['security_group_rules']:
try:
client.delete_security_group_rule(rule['id'])
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise
try:
client.delete_security_group(self.resource_id)
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise
self.resource_id = None

View File

@ -43,7 +43,7 @@ class Subnet(resource.Resource):
}
def handle_create(self):
client = self.quantum()
client = self.neutron()
# TODO(sbaker) Verify that this CidrBlock is within the vpc CidrBlock
network_id = self.properties.get('VpcId')
@ -55,7 +55,7 @@ class Subnet(resource.Resource):
}
subnet = client.create_subnet({'subnet': props})['subnet']
router = VPC.router_for_vpc(self.quantum(), network_id)
router = VPC.router_for_vpc(self.neutron(), network_id)
if router:
client.add_interface_router(
router['id'],
@ -63,25 +63,25 @@ class Subnet(resource.Resource):
self.resource_id_set(subnet['id'])
def handle_delete(self):
from quantumclient.common.exceptions import QuantumClientException
from neutronclient.common.exceptions import NeutronClientException
client = self.quantum()
client = self.neutron()
network_id = self.properties.get('VpcId')
subnet_id = self.resource_id
try:
router = VPC.router_for_vpc(self.quantum(), network_id)
router = VPC.router_for_vpc(self.neutron(), network_id)
if router:
client.remove_interface_router(
router['id'],
{'subnet_id': subnet_id})
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
try:
client.delete_subnet(subnet_id)
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
@ -92,7 +92,7 @@ class Subnet(resource.Resource):
def resource_mapping():
if clients.quantumclient is None:
if clients.neutronclient is None:
return {}
return {

View File

@ -17,7 +17,7 @@ from heat.common import exception
from heat.engine import clients
from heat.openstack.common import log as logging
from heat.engine import resource
from heat.engine.resources.quantum import quantum
from heat.engine.resources.neutron import neutron
logger = logging.getLogger(__name__)
@ -43,7 +43,7 @@ class VPC(resource.Resource):
}
def handle_create(self):
client = self.quantum()
client = self.neutron()
# The VPC's net and router are associated by having identical names.
net_props = {'name': self.physical_resource_name()}
router_props = {'name': self.physical_resource_name()}
@ -59,7 +59,7 @@ class VPC(resource.Resource):
@staticmethod
def router_for_vpc(client, network_id):
# first get the quantum net
# first get the neutron net
net = VPC.network_for_vpc(client, network_id)
# then find a router with the same name
routers = client.list_routers(name=net['name'])['routers']
@ -73,31 +73,31 @@ class VPC(resource.Resource):
return routers[0]
def check_create_complete(self, *args):
net = self.network_for_vpc(self.quantum(), self.resource_id)
if not quantum.QuantumResource.is_built(net):
net = self.network_for_vpc(self.neutron(), self.resource_id)
if not neutron.NeutronResource.is_built(net):
return False
router = self.router_for_vpc(self.quantum(), self.resource_id)
return quantum.QuantumResource.is_built(router)
router = self.router_for_vpc(self.neutron(), self.resource_id)
return neutron.NeutronResource.is_built(router)
def handle_delete(self):
from quantumclient.common.exceptions import QuantumClientException
client = self.quantum()
from neutronclient.common.exceptions import NeutronClientException
client = self.neutron()
router = self.router_for_vpc(client, self.resource_id)
try:
client.delete_router(router['id'])
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
try:
client.delete_network(self.resource_id)
except QuantumClientException as ex:
except NeutronClientException as ex:
if ex.status_code != 404:
raise ex
def resource_mapping():
if clients.quantumclient is None:
if clients.neutronclient is None:
return {}
return {

View File

@ -1,7 +1,7 @@
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Template to test Quantum resources",
"Description" : "Template to test Neutron resources",
"Parameters" : {
@ -9,23 +9,23 @@
"Resources" : {
"network": {
"Type": "OS::Quantum::Net",
"Type": "OS::Neutron::Net",
"Properties": {
"name": "the_network"
}
},
"unnamed_network": {
"Type": "OS::Quantum::Net"
"Type": "OS::Neutron::Net"
},
"admin_down_network": {
"Type": "OS::Quantum::Net",
"Type": "OS::Neutron::Net",
"Properties": {
"admin_state_up": false
}
},
"subnet": {
"Type": "OS::Quantum::Subnet",
"Type": "OS::Neutron::Subnet",
"Properties": {
"network_id": { "Ref" : "network" },
"ip_version": 4,
@ -35,7 +35,7 @@
},
"port": {
"Type": "OS::Quantum::Port",
"Type": "OS::Neutron::Port",
"Properties": {
"device_id": "d6b4d3a5-c700-476f-b609-1493dd9dadc0",
"name": "port1",
@ -48,11 +48,11 @@
},
"router": {
"Type": "OS::Quantum::Router"
"Type": "OS::Neutron::Router"
},
"router_interface": {
"Type": "OS::Quantum::RouterInterface",
"Type": "OS::Neutron::RouterInterface",
"Properties": {
"router_id": { "Ref" : "router" },
"subnet_id": { "Ref" : "subnet" }
@ -97,4 +97,4 @@
"Description" : "All attributes for router"
}
}
}
}

View File

@ -1,16 +1,16 @@
HeatTemplateFormatVersion: '2012-12-12'
Description: Template to test Quantum resources
Description: Template to test Neutron resources
Resources:
network:
Type: OS::Quantum::Net
Type: OS::Neutron::Net
Properties: {name: the_network}
unnamed_network:
Type: 'OS::Quantum::Net'
Type: 'OS::Neutron::Net'
admin_down_network:
Type: OS::Quantum::Net
Type: OS::Neutron::Net
Properties: {admin_state_up: false}
subnet:
Type: OS::Quantum::Subnet
Type: OS::Neutron::Subnet
Properties:
network_id: {Ref: network}
ip_version: 4
@ -18,7 +18,7 @@ Resources:
allocation_pools:
- {end: 10.0.3.150, start: 10.0.3.20}
port:
Type: OS::Quantum::Port
Type: OS::Neutron::Port
Properties:
device_id: d6b4d3a5-c700-476f-b609-1493dd9dadc0
name: port1
@ -27,9 +27,9 @@ Resources:
- subnet_id: {Ref: subnet}
ip_address: 10.0.3.21
router:
Type: 'OS::Quantum::Router'
Type: 'OS::Neutron::Router'
router_interface:
Type: OS::Quantum::RouterInterface
Type: OS::Neutron::RouterInterface
Properties:
router_id: {Ref: router}
subnet_id: {Ref: subnet}

View File

@ -110,7 +110,7 @@ wp_template_with_nic = '''
'''
class FakeQuantum(object):
class FakeNeutron(object):
def show_subnet(self, subnet, **_params):
return {
@ -169,8 +169,8 @@ class instancesTest(HeatTestCase):
self.m.StubOutWithMock(instance, 'nova')
instance.nova().MultipleTimes().AndReturn(self.fc)
self.m.StubOutWithMock(instance, 'quantum')
instance.quantum().MultipleTimes().AndReturn(FakeQuantum())
self.m.StubOutWithMock(instance, 'neutron')
instance.neutron().MultipleTimes().AndReturn(FakeNeutron())
instance.t = instance.stack.resolve_runtime_data(instance.t)
@ -212,8 +212,8 @@ class instancesTest(HeatTestCase):
instance = instances.Instance('%s_name' % name,
t['Resources']['WebServer'], stack)
self.m.StubOutWithMock(nic, 'quantum')
nic.quantum().MultipleTimes().AndReturn(FakeQuantum())
self.m.StubOutWithMock(nic, 'neutron')
nic.neutron().MultipleTimes().AndReturn(FakeNeutron())
self.m.StubOutWithMock(instance, 'nova')
instance.nova().MultipleTimes().AndReturn(self.fc)

View File

@ -21,10 +21,10 @@ from heat.common import template_format
from heat.engine import properties
from heat.engine import resource
from heat.engine import scheduler
from heat.engine.resources.quantum import net
from heat.engine.resources.quantum import subnet
from heat.engine.resources.quantum import router
from heat.engine.resources.quantum.quantum import QuantumResource as qr
from heat.engine.resources.neutron import net
from heat.engine.resources.neutron import subnet
from heat.engine.resources.neutron import router
from heat.engine.resources.neutron.neutron import NeutronResource as qr
from heat.openstack.common.importutils import try_import
from heat.tests.common import HeatTestCase
from heat.tests import fakes
@ -32,32 +32,32 @@ from heat.tests import utils
from heat.tests.utils import setup_dummy_db
from heat.tests.utils import parse_stack
quantumclient = try_import('quantumclient.v2_0.client')
qe = try_import('quantumclient.common.exceptions')
neutronclient = try_import('neutronclient.v2_0.client')
qe = try_import('neutronclient.common.exceptions')
quantum_template = '''
neutron_template = '''
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Template to test Quantum resources",
"Description" : "Template to test Neutron resources",
"Parameters" : {},
"Resources" : {
"network": {
"Type": "OS::Quantum::Net",
"Type": "OS::Neutron::Net",
"Properties": {
"name": "the_network"
}
},
"unnamed_network": {
"Type": "OS::Quantum::Net"
"Type": "OS::Neutron::Net"
},
"admin_down_network": {
"Type": "OS::Quantum::Net",
"Type": "OS::Neutron::Net",
"Properties": {
"admin_state_up": false
}
},
"subnet": {
"Type": "OS::Quantum::Subnet",
"Type": "OS::Neutron::Subnet",
"Properties": {
"network_id": { "Ref" : "network" },
"ip_version": 4,
@ -67,7 +67,7 @@ quantum_template = '''
}
},
"port": {
"Type": "OS::Quantum::Port",
"Type": "OS::Neutron::Port",
"Properties": {
"device_id": "d6b4d3a5-c700-476f-b609-1493dd9dadc0",
"name": "port1",
@ -79,24 +79,24 @@ quantum_template = '''
}
},
"port2": {
"Type": "OS::Quantum::Port",
"Type": "OS::Neutron::Port",
"Properties": {
"name": "port2",
"network_id": { "Ref" : "network" }
}
},
"router": {
"Type": "OS::Quantum::Router"
"Type": "OS::Neutron::Router"
},
"router_interface": {
"Type": "OS::Quantum::RouterInterface",
"Type": "OS::Neutron::RouterInterface",
"Properties": {
"router_id": { "Ref" : "router" },
"subnet_id": { "Ref" : "subnet" }
}
},
"gateway": {
"Type": "OS::Quantum::RouterGateway",
"Type": "OS::Neutron::RouterGateway",
"Properties": {
"router_id": { "Ref" : "router" },
"network_id": { "Ref" : "network" }
@ -106,14 +106,14 @@ quantum_template = '''
}
'''
quantum_floating_template = '''
neutron_floating_template = '''
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Template to test Quantum resources",
"Description" : "Template to test Neutron resources",
"Parameters" : {},
"Resources" : {
"port_floating": {
"Type": "OS::Quantum::Port",
"Type": "OS::Neutron::Port",
"Properties": {
"network_id": "xyz1234",
"fixed_ips": [{
@ -123,23 +123,23 @@ quantum_floating_template = '''
}
},
"floating_ip": {
"Type": "OS::Quantum::FloatingIP",
"Type": "OS::Neutron::FloatingIP",
"Properties": {
"floating_network_id": "abcd1234",
}
},
"floating_ip_assoc": {
"Type": "OS::Quantum::FloatingIPAssociation",
"Type": "OS::Neutron::FloatingIPAssociation",
"Properties": {
"floatingip_id": { "Ref" : "floating_ip" },
"port_id": { "Ref" : "port_floating" }
}
},
"router": {
"Type": "OS::Quantum::Router"
"Type": "OS::Neutron::Router"
},
"gateway": {
"Type": "OS::Quantum::RouterGateway",
"Type": "OS::Neutron::RouterGateway",
"Properties": {
"router_id": { "Ref" : "router" },
"network_id": "abcd1234"
@ -150,7 +150,7 @@ quantum_floating_template = '''
'''
class QuantumTest(HeatTestCase):
class NeutronTest(HeatTestCase):
def test_validate_properties(self):
vs = {'router:external': True}
@ -205,14 +205,14 @@ class QuantumTest(HeatTestCase):
})
@skipIf(quantumclient is None, 'quantumclient unavailable')
class QuantumNetTest(HeatTestCase):
@skipIf(neutronclient is None, 'neutronclient unavailable')
class NeutronNetTest(HeatTestCase):
def setUp(self):
super(QuantumNetTest, self).setUp()
self.m.StubOutWithMock(quantumclient.Client, 'create_network')
self.m.StubOutWithMock(quantumclient.Client, 'delete_network')
self.m.StubOutWithMock(quantumclient.Client, 'show_network')
super(NeutronNetTest, self).setUp()
self.m.StubOutWithMock(neutronclient.Client, 'create_network')
self.m.StubOutWithMock(neutronclient.Client, 'delete_network')
self.m.StubOutWithMock(neutronclient.Client, 'show_network')
self.m.StubOutWithMock(clients.OpenStackClients, 'keystone')
setup_dummy_db()
@ -225,7 +225,7 @@ class QuantumNetTest(HeatTestCase):
def test_net(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
quantumclient.Client.create_network({
neutronclient.Client.create_network({
'network': {'name': u'the_network', 'admin_state_up': True}
}).AndReturn({"network": {
"status": "BUILD",
@ -237,7 +237,7 @@ class QuantumNetTest(HeatTestCase):
"id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"
}})
quantumclient.Client.show_network(
neutronclient.Client.show_network(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndReturn({"network": {
"status": "BUILD",
@ -249,7 +249,7 @@ class QuantumNetTest(HeatTestCase):
"id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"
}})
quantumclient.Client.show_network(
neutronclient.Client.show_network(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndReturn({"network": {
"status": "ACTIVE",
@ -261,11 +261,11 @@ class QuantumNetTest(HeatTestCase):
"id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"
}})
quantumclient.Client.show_network(
neutronclient.Client.show_network(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndRaise(qe.QuantumClientException(status_code=404))
).AndRaise(qe.NeutronClientException(status_code=404))
quantumclient.Client.show_network(
neutronclient.Client.show_network(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndReturn({"network": {
"status": "ACTIVE",
@ -277,7 +277,7 @@ class QuantumNetTest(HeatTestCase):
"id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"
}})
quantumclient.Client.show_network(
neutronclient.Client.show_network(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndReturn({"network": {
"status": "ACTIVE",
@ -289,20 +289,20 @@ class QuantumNetTest(HeatTestCase):
"id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"
}})
quantumclient.Client.delete_network(
neutronclient.Client.delete_network(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndReturn(None)
quantumclient.Client.show_network(
neutronclient.Client.show_network(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndRaise(qe.QuantumClientException(status_code=404))
).AndRaise(qe.NeutronClientException(status_code=404))
quantumclient.Client.delete_network(
neutronclient.Client.delete_network(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndRaise(qe.QuantumClientException(status_code=404))
).AndRaise(qe.NeutronClientException(status_code=404))
self.m.ReplayAll()
t = template_format.parse(quantum_template)
t = template_format.parse(neutron_template)
stack = parse_stack(t)
rsrc = self.create_net(t, stack, 'network')
@ -339,14 +339,14 @@ class QuantumNetTest(HeatTestCase):
self.m.VerifyAll()
@skipIf(quantumclient is None, 'quantumclient unavailable')
class QuantumSubnetTest(HeatTestCase):
@skipIf(neutronclient is None, 'neutronclient unavailable')
class NeutronSubnetTest(HeatTestCase):
def setUp(self):
super(QuantumSubnetTest, self).setUp()
self.m.StubOutWithMock(quantumclient.Client, 'create_subnet')
self.m.StubOutWithMock(quantumclient.Client, 'delete_subnet')
self.m.StubOutWithMock(quantumclient.Client, 'show_subnet')
super(NeutronSubnetTest, self).setUp()
self.m.StubOutWithMock(neutronclient.Client, 'create_subnet')
self.m.StubOutWithMock(neutronclient.Client, 'delete_subnet')
self.m.StubOutWithMock(neutronclient.Client, 'show_subnet')
self.m.StubOutWithMock(clients.OpenStackClients, 'keystone')
setup_dummy_db()
@ -361,7 +361,7 @@ class QuantumSubnetTest(HeatTestCase):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
quantumclient.Client.create_subnet({
neutronclient.Client.create_subnet({
'subnet': {
'name': utils.PhysName('test_stack', 'test_subnet'),
'network_id': u'None',
@ -386,9 +386,9 @@ class QuantumSubnetTest(HeatTestCase):
"tenant_id": "c1210485b2424d48804aad5d39c61b8f"
}
})
quantumclient.Client.show_subnet(
neutronclient.Client.show_subnet(
'91e47a57-7508-46fe-afc9-fc454e8580e1').AndRaise(
qe.QuantumClientException(status_code=404))
qe.NeutronClientException(status_code=404))
sn = {
"subnet": {
"name": "name",
@ -404,27 +404,27 @@ class QuantumSubnetTest(HeatTestCase):
"enable_dhcp": True,
}
}
quantumclient.Client.show_subnet(
neutronclient.Client.show_subnet(
'91e47a57-7508-46fe-afc9-fc454e8580e1').AndReturn(sn)
quantumclient.Client.show_subnet(
neutronclient.Client.show_subnet(
'91e47a57-7508-46fe-afc9-fc454e8580e1').AndReturn(sn)
quantumclient.Client.show_subnet(
neutronclient.Client.show_subnet(
'91e47a57-7508-46fe-afc9-fc454e8580e1').AndReturn(sn)
quantumclient.Client.delete_subnet(
neutronclient.Client.delete_subnet(
'91e47a57-7508-46fe-afc9-fc454e8580e1'
).AndReturn(None)
quantumclient.Client.show_subnet(
neutronclient.Client.show_subnet(
'91e47a57-7508-46fe-afc9-fc454e8580e1'
).AndRaise(qe.QuantumClientException(status_code=404))
).AndRaise(qe.NeutronClientException(status_code=404))
quantumclient.Client.delete_subnet(
neutronclient.Client.delete_subnet(
'91e47a57-7508-46fe-afc9-fc454e8580e1'
).AndRaise(qe.QuantumClientException(status_code=404))
).AndRaise(qe.NeutronClientException(status_code=404))
self.m.ReplayAll()
t = template_format.parse(quantum_template)
t = template_format.parse(neutron_template)
stack = parse_stack(t)
rsrc = self.create_subnet(t, stack, 'subnet')
@ -457,7 +457,7 @@ class QuantumSubnetTest(HeatTestCase):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
quantumclient.Client.create_subnet({
neutronclient.Client.create_subnet({
'subnet': {
'name': utils.PhysName('test_stack', 'test_subnet'),
'network_id': u'None',
@ -484,7 +484,7 @@ class QuantumSubnetTest(HeatTestCase):
}
})
quantumclient.Client.show_subnet(
neutronclient.Client.show_subnet(
'91e47a57-7508-46fe-afc9-fc454e8580e1').AndReturn({
"subnet": {
"name": "name",
@ -501,16 +501,16 @@ class QuantumSubnetTest(HeatTestCase):
}
})
quantumclient.Client.delete_subnet(
neutronclient.Client.delete_subnet(
'91e47a57-7508-46fe-afc9-fc454e8580e1'
).AndReturn(None)
quantumclient.Client.show_subnet(
neutronclient.Client.show_subnet(
'91e47a57-7508-46fe-afc9-fc454e8580e1'
).AndRaise(qe.QuantumClientException(status_code=404))
).AndRaise(qe.NeutronClientException(status_code=404))
self.m.ReplayAll()
t = template_format.parse(quantum_template)
t = template_format.parse(neutron_template)
t['Resources']['subnet']['Properties']['enable_dhcp'] = 'False'
stack = parse_stack(t)
rsrc = self.create_subnet(t, stack, 'subnet')
@ -524,17 +524,17 @@ class QuantumSubnetTest(HeatTestCase):
self.m.VerifyAll()
@skipIf(quantumclient is None, 'quantumclient unavailable')
class QuantumRouterTest(HeatTestCase):
@skipIf(neutronclient is None, 'neutronclient unavailable')
class NeutronRouterTest(HeatTestCase):
def setUp(self):
super(QuantumRouterTest, self).setUp()
self.m.StubOutWithMock(quantumclient.Client, 'create_router')
self.m.StubOutWithMock(quantumclient.Client, 'delete_router')
self.m.StubOutWithMock(quantumclient.Client, 'show_router')
self.m.StubOutWithMock(quantumclient.Client, 'add_interface_router')
self.m.StubOutWithMock(quantumclient.Client, 'remove_interface_router')
self.m.StubOutWithMock(quantumclient.Client, 'add_gateway_router')
self.m.StubOutWithMock(quantumclient.Client, 'remove_gateway_router')
super(NeutronRouterTest, self).setUp()
self.m.StubOutWithMock(neutronclient.Client, 'create_router')
self.m.StubOutWithMock(neutronclient.Client, 'delete_router')
self.m.StubOutWithMock(neutronclient.Client, 'show_router')
self.m.StubOutWithMock(neutronclient.Client, 'add_interface_router')
self.m.StubOutWithMock(neutronclient.Client, 'remove_interface_router')
self.m.StubOutWithMock(neutronclient.Client, 'add_gateway_router')
self.m.StubOutWithMock(neutronclient.Client, 'remove_gateway_router')
self.m.StubOutWithMock(clients.OpenStackClients, 'keystone')
setup_dummy_db()
@ -567,7 +567,7 @@ class QuantumRouterTest(HeatTestCase):
def test_router(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
quantumclient.Client.create_router({
neutronclient.Client.create_router({
'router': {
'name': utils.PhysName('test_stack', 'router'),
'admin_state_up': True,
@ -582,7 +582,7 @@ class QuantumRouterTest(HeatTestCase):
"id": "3e46229d-8fce-4733-819a-b5fe630550f8"
}
})
quantumclient.Client.show_router(
neutronclient.Client.show_router(
'3e46229d-8fce-4733-819a-b5fe630550f8').AndReturn({
"router": {
"status": "BUILD",
@ -594,7 +594,7 @@ class QuantumRouterTest(HeatTestCase):
"id": "3e46229d-8fce-4733-819a-b5fe630550f8"
}
})
quantumclient.Client.show_router(
neutronclient.Client.show_router(
'3e46229d-8fce-4733-819a-b5fe630550f8').AndReturn({
"router": {
"status": "ACTIVE",
@ -607,10 +607,10 @@ class QuantumRouterTest(HeatTestCase):
}
})
quantumclient.Client.show_router(
neutronclient.Client.show_router(
'3e46229d-8fce-4733-819a-b5fe630550f8').AndRaise(
qe.QuantumClientException(status_code=404))
quantumclient.Client.show_router(
qe.NeutronClientException(status_code=404))
neutronclient.Client.show_router(
'3e46229d-8fce-4733-819a-b5fe630550f8').AndReturn({
"router": {
"status": "ACTIVE",
@ -622,7 +622,7 @@ class QuantumRouterTest(HeatTestCase):
"id": "3e46229d-8fce-4733-819a-b5fe630550f8"
}
})
quantumclient.Client.show_router(
neutronclient.Client.show_router(
'3e46229d-8fce-4733-819a-b5fe630550f8').AndReturn({
"router": {
"status": "ACTIVE",
@ -635,20 +635,20 @@ class QuantumRouterTest(HeatTestCase):
}
})
quantumclient.Client.delete_router(
neutronclient.Client.delete_router(
'3e46229d-8fce-4733-819a-b5fe630550f8'
).AndReturn(None)
quantumclient.Client.show_router(
neutronclient.Client.show_router(
'3e46229d-8fce-4733-819a-b5fe630550f8'
).AndRaise(qe.QuantumClientException(status_code=404))
).AndRaise(qe.NeutronClientException(status_code=404))
quantumclient.Client.delete_router(
neutronclient.Client.delete_router(
'3e46229d-8fce-4733-819a-b5fe630550f8'
).AndRaise(qe.QuantumClientException(status_code=404))
).AndRaise(qe.NeutronClientException(status_code=404))
self.m.ReplayAll()
t = template_format.parse(quantum_template)
t = template_format.parse(neutron_template)
stack = parse_stack(t)
rsrc = self.create_router(t, stack, 'router')
@ -674,20 +674,20 @@ class QuantumRouterTest(HeatTestCase):
def test_router_interface(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
quantumclient.Client.add_interface_router(
neutronclient.Client.add_interface_router(
'3e46229d-8fce-4733-819a-b5fe630550f8',
{'subnet_id': '91e47a57-7508-46fe-afc9-fc454e8580e1'}
).AndReturn(None)
quantumclient.Client.remove_interface_router(
neutronclient.Client.remove_interface_router(
'3e46229d-8fce-4733-819a-b5fe630550f8',
{'subnet_id': '91e47a57-7508-46fe-afc9-fc454e8580e1'}
).AndReturn(None)
quantumclient.Client.remove_interface_router(
neutronclient.Client.remove_interface_router(
'3e46229d-8fce-4733-819a-b5fe630550f8',
{'subnet_id': '91e47a57-7508-46fe-afc9-fc454e8580e1'}
).AndRaise(qe.QuantumClientException(status_code=404))
).AndRaise(qe.NeutronClientException(status_code=404))
self.m.ReplayAll()
t = template_format.parse(quantum_template)
t = template_format.parse(neutron_template)
stack = parse_stack(t)
rsrc = self.create_router_interface(
@ -704,18 +704,18 @@ class QuantumRouterTest(HeatTestCase):
def test_gateway_router(self):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
quantumclient.Client.add_gateway_router(
neutronclient.Client.add_gateway_router(
'3e46229d-8fce-4733-819a-b5fe630550f8',
{'network_id': 'fc68ea2c-b60b-4b4f-bd82-94ec81110766'}
).AndReturn(None)
quantumclient.Client.remove_gateway_router(
neutronclient.Client.remove_gateway_router(
'3e46229d-8fce-4733-819a-b5fe630550f8'
).AndReturn(None)
quantumclient.Client.remove_gateway_router(
neutronclient.Client.remove_gateway_router(
'3e46229d-8fce-4733-819a-b5fe630550f8'
).AndRaise(qe.QuantumClientException(status_code=404))
).AndRaise(qe.NeutronClientException(status_code=404))
self.m.ReplayAll()
t = template_format.parse(quantum_template)
t = template_format.parse(neutron_template)
stack = parse_stack(t)
rsrc = self.create_gateway_router(
@ -730,18 +730,18 @@ class QuantumRouterTest(HeatTestCase):
self.m.VerifyAll()
@skipIf(quantumclient is None, 'quantumclient unavailable')
class QuantumFloatingIPTest(HeatTestCase):
@skipIf(net.clients.quantumclient is None, "Missing Quantum Client")
@skipIf(neutronclient is None, 'neutronclient unavailable')
class NeutronFloatingIPTest(HeatTestCase):
@skipIf(net.clients.neutronclient is None, "Missing Neutron Client")
def setUp(self):
super(QuantumFloatingIPTest, self).setUp()
self.m.StubOutWithMock(quantumclient.Client, 'create_floatingip')
self.m.StubOutWithMock(quantumclient.Client, 'delete_floatingip')
self.m.StubOutWithMock(quantumclient.Client, 'show_floatingip')
self.m.StubOutWithMock(quantumclient.Client, 'update_floatingip')
self.m.StubOutWithMock(quantumclient.Client, 'create_port')
self.m.StubOutWithMock(quantumclient.Client, 'delete_port')
self.m.StubOutWithMock(quantumclient.Client, 'show_port')
super(NeutronFloatingIPTest, self).setUp()
self.m.StubOutWithMock(neutronclient.Client, 'create_floatingip')
self.m.StubOutWithMock(neutronclient.Client, 'delete_floatingip')
self.m.StubOutWithMock(neutronclient.Client, 'show_floatingip')
self.m.StubOutWithMock(neutronclient.Client, 'update_floatingip')
self.m.StubOutWithMock(neutronclient.Client, 'create_port')
self.m.StubOutWithMock(neutronclient.Client, 'delete_port')
self.m.StubOutWithMock(neutronclient.Client, 'show_port')
self.m.StubOutWithMock(clients.OpenStackClients, 'keystone')
setup_dummy_db()
@ -749,31 +749,31 @@ class QuantumFloatingIPTest(HeatTestCase):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
quantumclient.Client.create_floatingip({
neutronclient.Client.create_floatingip({
'floatingip': {'floating_network_id': u'abcd1234'}
}).AndReturn({'floatingip': {
"status": "ACTIVE",
"id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"
}})
quantumclient.Client.show_floatingip(
neutronclient.Client.show_floatingip(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndRaise(qe.QuantumClientException(status_code=404))
quantumclient.Client.show_floatingip(
).AndRaise(qe.NeutronClientException(status_code=404))
neutronclient.Client.show_floatingip(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).MultipleTimes().AndReturn({'floatingip': {
"status": "ACTIVE",
"id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"
}})
quantumclient.Client.delete_floatingip(
neutronclient.Client.delete_floatingip(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766').AndReturn(None)
quantumclient.Client.delete_floatingip(
neutronclient.Client.delete_floatingip(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766').AndRaise(
qe.QuantumClientException(status_code=404))
qe.NeutronClientException(status_code=404))
self.m.ReplayAll()
t = template_format.parse(quantum_floating_template)
t = template_format.parse(neutron_floating_template)
stack = parse_stack(t)
# assert the implicit dependency between the floating_ip
@ -811,7 +811,7 @@ class QuantumFloatingIPTest(HeatTestCase):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
quantumclient.Client.create_port({'port': {
neutronclient.Client.create_port({'port': {
'network_id': u'xyz1234',
'fixed_ips': [
{'subnet_id': u'12.12.12.0', 'ip_address': u'10.0.0.10'}
@ -822,22 +822,22 @@ class QuantumFloatingIPTest(HeatTestCase):
"status": "BUILD",
"id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"
}})
quantumclient.Client.show_port(
neutronclient.Client.show_port(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndReturn({'port': {
"status": "BUILD",
"id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"
}})
quantumclient.Client.show_port(
neutronclient.Client.show_port(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndReturn({'port': {
"status": "ACTIVE",
"id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"
}})
quantumclient.Client.show_port(
neutronclient.Client.show_port(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndRaise(qe.QuantumClientException(status_code=404))
quantumclient.Client.show_port(
).AndRaise(qe.NeutronClientException(status_code=404))
neutronclient.Client.show_port(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).MultipleTimes().AndReturn({'port': {
"status": "ACTIVE",
@ -846,7 +846,7 @@ class QuantumFloatingIPTest(HeatTestCase):
self.m.ReplayAll()
t = template_format.parse(quantum_floating_template)
t = template_format.parse(neutron_floating_template)
stack = parse_stack(t)
p = stack['port_floating']
@ -877,14 +877,14 @@ class QuantumFloatingIPTest(HeatTestCase):
clients.OpenStackClients.keystone().AndReturn(
fakes.FakeKeystoneClient())
quantumclient.Client.create_floatingip({
neutronclient.Client.create_floatingip({
'floatingip': {'floating_network_id': u'abcd1234'}
}).AndReturn({'floatingip': {
"status": "ACTIVE",
"id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"
}})
quantumclient.Client.create_port({'port': {
neutronclient.Client.create_port({'port': {
'network_id': u'xyz1234',
'fixed_ips': [
{'subnet_id': u'12.12.12.0', 'ip_address': u'10.0.0.10'}
@ -895,13 +895,13 @@ class QuantumFloatingIPTest(HeatTestCase):
"status": "BUILD",
"id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"
}})
quantumclient.Client.show_port(
neutronclient.Client.show_port(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndReturn({'port': {
"status": "ACTIVE",
"id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"
}})
quantumclient.Client.update_floatingip(
neutronclient.Client.update_floatingip(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
{
'floatingip': {
@ -911,41 +911,41 @@ class QuantumFloatingIPTest(HeatTestCase):
"id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"
}})
quantumclient.Client.update_floatingip(
neutronclient.Client.update_floatingip(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
{'floatingip': {
'port_id': None
}}).AndReturn(None)
quantumclient.Client.delete_port(
neutronclient.Client.delete_port(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndReturn(None)
quantumclient.Client.show_port(
neutronclient.Client.show_port(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndRaise(qe.QuantumClientException(status_code=404))
).AndRaise(qe.NeutronClientException(status_code=404))
quantumclient.Client.delete_floatingip(
neutronclient.Client.delete_floatingip(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndReturn(None)
quantumclient.Client.update_floatingip(
neutronclient.Client.update_floatingip(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
{'floatingip': {
'port_id': None
}}).AndRaise(qe.QuantumClientException(status_code=404))
}}).AndRaise(qe.NeutronClientException(status_code=404))
quantumclient.Client.delete_port(
neutronclient.Client.delete_port(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndRaise(qe.QuantumClientException(status_code=404))
).AndRaise(qe.NeutronClientException(status_code=404))
quantumclient.Client.delete_floatingip(
neutronclient.Client.delete_floatingip(
'fc68ea2c-b60b-4b4f-bd82-94ec81110766'
).AndRaise(qe.QuantumClientException(status_code=404))
).AndRaise(qe.NeutronClientException(status_code=404))
self.m.ReplayAll()
t = template_format.parse(quantum_floating_template)
t = template_format.parse(neutron_floating_template)
stack = parse_stack(t)
fip = stack['floating_ip']

View File

@ -28,8 +28,8 @@ from heat.tests.utils import stack_delete_after
from novaclient.v1_1 import security_groups as nova_sg
from novaclient.v1_1 import security_group_rules as nova_sgr
from quantumclient.common.exceptions import QuantumClientException
from quantumclient.v2_0 import client as quantumclient
from neutronclient.common.exceptions import NeutronClientException
from neutronclient.v2_0 import client as neutronclient
NovaSG = collections.namedtuple('NovaSG',
' '.join([
@ -60,7 +60,7 @@ Resources:
CidrIp : 0.0.0.0/0
'''
test_template_quantum = '''
test_template_neutron = '''
HeatTemplateFormatVersion: '2012-12-12'
Resources:
the_sg:
@ -96,13 +96,13 @@ Resources:
self.m.StubOutWithMock(nova_sg.SecurityGroupManager, 'get')
self.m.StubOutWithMock(nova_sg.SecurityGroupManager, 'list')
setup_dummy_db()
self.m.StubOutWithMock(quantumclient.Client, 'create_security_group')
self.m.StubOutWithMock(neutronclient.Client, 'create_security_group')
self.m.StubOutWithMock(
quantumclient.Client, 'create_security_group_rule')
self.m.StubOutWithMock(quantumclient.Client, 'show_security_group')
neutronclient.Client, 'create_security_group_rule')
self.m.StubOutWithMock(neutronclient.Client, 'show_security_group')
self.m.StubOutWithMock(
quantumclient.Client, 'delete_security_group_rule')
self.m.StubOutWithMock(quantumclient.Client, 'delete_security_group')
neutronclient.Client, 'delete_security_group_rule')
self.m.StubOutWithMock(neutronclient.Client, 'delete_security_group')
def create_stack(self, template):
t = template_format.parse(template)
@ -275,12 +275,12 @@ Resources:
self.m.VerifyAll()
@stack_delete_after
def test_security_group_quantum(self):
def test_security_group_neutron(self):
#create script
clients.OpenStackClients.keystone().AndReturn(
FakeKeystoneClient())
sg_name = utils.PhysName('test_stack', 'the_sg')
quantumclient.Client.create_security_group({
neutronclient.Client.create_security_group({
'security_group': {
'name': sg_name,
'description': 'HTTP and SSH access'
@ -295,7 +295,7 @@ Resources:
}
})
quantumclient.Client.create_security_group_rule({
neutronclient.Client.create_security_group_rule({
'security_group_rule': {
'direction': 'ingress',
'remote_ip_prefix': '0.0.0.0/0',
@ -317,7 +317,7 @@ Resources:
'id': 'bbbb'
}
})
quantumclient.Client.create_security_group_rule({
neutronclient.Client.create_security_group_rule({
'security_group_rule': {
'direction': 'ingress',
'remote_ip_prefix': '0.0.0.0/0',
@ -339,7 +339,7 @@ Resources:
'id': 'cccc'
}
})
quantumclient.Client.create_security_group_rule({
neutronclient.Client.create_security_group_rule({
'security_group_rule': {
'direction': 'egress',
'remote_ip_prefix': '10.0.1.0/24',
@ -363,7 +363,7 @@ Resources:
})
# delete script
quantumclient.Client.show_security_group('aaaa').AndReturn({
neutronclient.Client.show_security_group('aaaa').AndReturn({
'security_group': {
'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',
'name': 'sc1',
@ -400,13 +400,13 @@ Resources:
'port_range_min': 22
}],
'id': 'aaaa'}})
quantumclient.Client.delete_security_group_rule('bbbb').AndReturn(None)
quantumclient.Client.delete_security_group_rule('cccc').AndReturn(None)
quantumclient.Client.delete_security_group_rule('dddd').AndReturn(None)
quantumclient.Client.delete_security_group('aaaa').AndReturn(None)
neutronclient.Client.delete_security_group_rule('bbbb').AndReturn(None)
neutronclient.Client.delete_security_group_rule('cccc').AndReturn(None)
neutronclient.Client.delete_security_group_rule('dddd').AndReturn(None)
neutronclient.Client.delete_security_group('aaaa').AndReturn(None)
self.m.ReplayAll()
stack = self.create_stack(self.test_template_quantum)
stack = self.create_stack(self.test_template_neutron)
sg = stack['the_sg']
self.assertRaises(resource.UpdateReplace, sg.handle_update, {}, {}, {})
@ -417,12 +417,12 @@ Resources:
self.m.VerifyAll()
@stack_delete_after
def test_security_group_quantum_exception(self):
def test_security_group_neutron_exception(self):
#create script
clients.OpenStackClients.keystone().AndReturn(
FakeKeystoneClient())
sg_name = utils.PhysName('test_stack', 'the_sg')
quantumclient.Client.create_security_group({
neutronclient.Client.create_security_group({
'security_group': {
'name': sg_name,
'description': 'HTTP and SSH access'
@ -437,7 +437,7 @@ Resources:
}
})
quantumclient.Client.create_security_group_rule({
neutronclient.Client.create_security_group_rule({
'security_group_rule': {
'direction': 'ingress',
'remote_ip_prefix': '0.0.0.0/0',
@ -448,8 +448,8 @@ Resources:
'security_group_id': 'aaaa'
}
}).AndRaise(
QuantumClientException(status_code=409))
quantumclient.Client.create_security_group_rule({
NeutronClientException(status_code=409))
neutronclient.Client.create_security_group_rule({
'security_group_rule': {
'direction': 'ingress',
'remote_ip_prefix': '0.0.0.0/0',
@ -460,8 +460,8 @@ Resources:
'security_group_id': 'aaaa'
}
}).AndRaise(
QuantumClientException(status_code=409))
quantumclient.Client.create_security_group_rule({
NeutronClientException(status_code=409))
neutronclient.Client.create_security_group_rule({
'security_group_rule': {
'direction': 'egress',
'remote_ip_prefix': '10.0.1.0/24',
@ -472,10 +472,10 @@ Resources:
'security_group_id': 'aaaa'
}
}).AndRaise(
QuantumClientException(status_code=409))
NeutronClientException(status_code=409))
# delete script
quantumclient.Client.show_security_group('aaaa').AndReturn({
neutronclient.Client.show_security_group('aaaa').AndReturn({
'security_group': {
'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',
'name': 'sc1',
@ -512,20 +512,20 @@ Resources:
'port_range_min': 22
}],
'id': 'aaaa'}})
quantumclient.Client.delete_security_group_rule('bbbb').AndRaise(
QuantumClientException(status_code=404))
quantumclient.Client.delete_security_group_rule('cccc').AndRaise(
QuantumClientException(status_code=404))
quantumclient.Client.delete_security_group_rule('dddd').AndRaise(
QuantumClientException(status_code=404))
quantumclient.Client.delete_security_group('aaaa').AndRaise(
QuantumClientException(status_code=404))
neutronclient.Client.delete_security_group_rule('bbbb').AndRaise(
NeutronClientException(status_code=404))
neutronclient.Client.delete_security_group_rule('cccc').AndRaise(
NeutronClientException(status_code=404))
neutronclient.Client.delete_security_group_rule('dddd').AndRaise(
NeutronClientException(status_code=404))
neutronclient.Client.delete_security_group('aaaa').AndRaise(
NeutronClientException(status_code=404))
quantumclient.Client.show_security_group('aaaa').AndRaise(
QuantumClientException(status_code=404))
neutronclient.Client.show_security_group('aaaa').AndRaise(
NeutronClientException(status_code=404))
self.m.ReplayAll()
stack = self.create_stack(self.test_template_quantum)
stack = self.create_stack(self.test_template_neutron)
sg = stack['the_sg']
self.assertRaises(resource.UpdateReplace, sg.handle_update, {}, {}, {})

View File

@ -151,9 +151,9 @@ class JsonYamlResolvedCompareTest(HeatTestCase):
for key in stack1.resources:
self.assertEqual(stack1.resources[key].t, stack2.resources[key].t)
@skipIf(clients.quantumclient is None, 'quantumclient unavailable')
def test_quantum_resolved(self):
self.compare_stacks('Quantum.template', 'Quantum.yaml', {})
@skipIf(clients.neutronclient is None, 'neutronclient unavailable')
def test_neutron_resolved(self):
self.compare_stacks('Neutron.template', 'Neutron.yaml', {})
def test_wordpress_resolved(self):
self.compare_stacks('WordPress_Single_Instance.template',

View File

@ -26,42 +26,42 @@ from heat.tests.utils import dummy_context
from heat.tests.utils import setup_dummy_db
try:
from quantumclient.common.exceptions import QuantumClientException
from quantumclient.v2_0 import client as quantumclient
from neutronclient.common.exceptions import NeutronClientException
from neutronclient.v2_0 import client as neutronclient
except ImportError:
quantumclient = None
neutronclient = None
class VPCTestBase(HeatTestCase):
@skipIf(quantumclient is None, 'quantumclient unavaialble')
@skipIf(neutronclient is None, 'neutronclient unavaialble')
def setUp(self):
super(VPCTestBase, self).setUp()
setup_dummy_db()
self.m.StubOutWithMock(quantumclient.Client, 'add_interface_router')
self.m.StubOutWithMock(quantumclient.Client, 'add_gateway_router')
self.m.StubOutWithMock(quantumclient.Client, 'create_network')
self.m.StubOutWithMock(quantumclient.Client, 'create_port')
self.m.StubOutWithMock(quantumclient.Client, 'create_router')
self.m.StubOutWithMock(quantumclient.Client, 'create_subnet')
self.m.StubOutWithMock(quantumclient.Client, 'delete_network')
self.m.StubOutWithMock(quantumclient.Client, 'delete_port')
self.m.StubOutWithMock(quantumclient.Client, 'delete_router')
self.m.StubOutWithMock(quantumclient.Client, 'delete_subnet')
self.m.StubOutWithMock(quantumclient.Client, 'list_networks')
self.m.StubOutWithMock(quantumclient.Client, 'list_routers')
self.m.StubOutWithMock(quantumclient.Client, 'remove_gateway_router')
self.m.StubOutWithMock(quantumclient.Client, 'remove_interface_router')
self.m.StubOutWithMock(quantumclient.Client, 'show_subnet')
self.m.StubOutWithMock(quantumclient.Client, 'show_network')
self.m.StubOutWithMock(quantumclient.Client, 'show_router')
self.m.StubOutWithMock(quantumclient.Client, 'create_security_group')
self.m.StubOutWithMock(quantumclient.Client, 'show_security_group')
self.m.StubOutWithMock(quantumclient.Client, 'delete_security_group')
self.m.StubOutWithMock(neutronclient.Client, 'add_interface_router')
self.m.StubOutWithMock(neutronclient.Client, 'add_gateway_router')
self.m.StubOutWithMock(neutronclient.Client, 'create_network')
self.m.StubOutWithMock(neutronclient.Client, 'create_port')
self.m.StubOutWithMock(neutronclient.Client, 'create_router')
self.m.StubOutWithMock(neutronclient.Client, 'create_subnet')
self.m.StubOutWithMock(neutronclient.Client, 'delete_network')
self.m.StubOutWithMock(neutronclient.Client, 'delete_port')
self.m.StubOutWithMock(neutronclient.Client, 'delete_router')
self.m.StubOutWithMock(neutronclient.Client, 'delete_subnet')
self.m.StubOutWithMock(neutronclient.Client, 'list_networks')
self.m.StubOutWithMock(neutronclient.Client, 'list_routers')
self.m.StubOutWithMock(neutronclient.Client, 'remove_gateway_router')
self.m.StubOutWithMock(neutronclient.Client, 'remove_interface_router')
self.m.StubOutWithMock(neutronclient.Client, 'show_subnet')
self.m.StubOutWithMock(neutronclient.Client, 'show_network')
self.m.StubOutWithMock(neutronclient.Client, 'show_router')
self.m.StubOutWithMock(neutronclient.Client, 'create_security_group')
self.m.StubOutWithMock(neutronclient.Client, 'show_security_group')
self.m.StubOutWithMock(neutronclient.Client, 'delete_security_group')
self.m.StubOutWithMock(
quantumclient.Client, 'create_security_group_rule')
neutronclient.Client, 'create_security_group_rule')
self.m.StubOutWithMock(
quantumclient.Client, 'delete_security_group_rule')
neutronclient.Client, 'delete_security_group_rule')
self.m.StubOutWithMock(clients.OpenStackClients, 'keystone')
def create_stack(self, template):
@ -83,7 +83,7 @@ class VPCTestBase(HeatTestCase):
def mock_create_network(self):
self.vpc_name = utils.PhysName('test_stack', 'the_vpc')
quantumclient.Client.create_network(
neutronclient.Client.create_network(
{
'network': {'name': self.vpc_name}
}).AndReturn({'network': {
@ -95,7 +95,7 @@ class VPCTestBase(HeatTestCase):
'tenant_id': 'c1210485b2424d48804aad5d39c61b8f',
'id': 'aaaa'
}})
quantumclient.Client.show_network(
neutronclient.Client.show_network(
'aaaa'
).AndReturn({"network": {
"status": "BUILD",
@ -107,7 +107,7 @@ class VPCTestBase(HeatTestCase):
"id": "aaaa"
}})
quantumclient.Client.show_network(
neutronclient.Client.show_network(
'aaaa'
).MultipleTimes().AndReturn({"network": {
"status": "ACTIVE",
@ -118,7 +118,7 @@ class VPCTestBase(HeatTestCase):
"tenant_id": "c1210485b2424d48804aad5d39c61b8f",
"id": "aaaa"
}})
quantumclient.Client.create_router(
neutronclient.Client.create_router(
{'router': {'name': self.vpc_name}}).AndReturn({
'router': {
'status': 'BUILD',
@ -127,7 +127,7 @@ class VPCTestBase(HeatTestCase):
'tenant_id': 'c1210485b2424d48804aad5d39c61b8f',
'id': 'bbbb'
}})
quantumclient.Client.list_routers(name=self.vpc_name).AndReturn({
neutronclient.Client.list_routers(name=self.vpc_name).AndReturn({
"routers": [{
"status": "BUILD",
"external_gateway_info": None,
@ -142,7 +142,7 @@ class VPCTestBase(HeatTestCase):
def mock_create_subnet(self):
self.subnet_name = utils.PhysName('test_stack', 'the_subnet')
quantumclient.Client.create_subnet(
neutronclient.Client.create_subnet(
{'subnet': {
'network_id': u'aaaa',
'cidr': u'10.0.0.0/24',
@ -155,12 +155,12 @@ class VPCTestBase(HeatTestCase):
'tenant_id': 'c1210485b2424d48804aad5d39c61b8f',
'id': 'cccc'}})
self.mock_router_for_vpc()
quantumclient.Client.add_interface_router(
neutronclient.Client.add_interface_router(
u'bbbb',
{'subnet_id': 'cccc'}).AndReturn(None)
def mock_show_subnet(self):
quantumclient.Client.show_subnet('cccc').AndReturn({
neutronclient.Client.show_subnet('cccc').AndReturn({
'subnet': {
'name': self.subnet_name,
'network_id': 'aaaa',
@ -176,7 +176,7 @@ class VPCTestBase(HeatTestCase):
def mock_create_security_group(self):
self.sg_name = utils.PhysName('test_stack', 'the_sg')
quantumclient.Client.create_security_group({
neutronclient.Client.create_security_group({
'security_group': {
'name': self.sg_name,
'description': 'SSH access'
@ -191,7 +191,7 @@ class VPCTestBase(HeatTestCase):
}
})
quantumclient.Client.create_security_group_rule({
neutronclient.Client.create_security_group_rule({
'security_group_rule': {
'direction': 'ingress',
'remote_ip_prefix': '0.0.0.0/0',
@ -216,7 +216,7 @@ class VPCTestBase(HeatTestCase):
def mock_delete_security_group(self):
sg_name = utils.PhysName('test_stack', 'the_sg')
quantumclient.Client.show_security_group('eeee').AndReturn({
neutronclient.Client.show_security_group('eeee').AndReturn({
'security_group': {
'tenant_id': 'c1210485b2424d48804aad5d39c61b8f',
'name': sg_name,
@ -233,11 +233,11 @@ class VPCTestBase(HeatTestCase):
'port_range_min': 22
}],
'id': 'eeee'}})
quantumclient.Client.delete_security_group_rule('bbbb').AndReturn(None)
quantumclient.Client.delete_security_group('eeee').AndReturn(None)
neutronclient.Client.delete_security_group_rule('bbbb').AndReturn(None)
neutronclient.Client.delete_security_group('eeee').AndReturn(None)
def mock_router_for_vpc(self):
quantumclient.Client.list_routers(name=self.vpc_name).AndReturn({
neutronclient.Client.list_routers(name=self.vpc_name).AndReturn({
"routers": [{
"status": "ACTIVE",
"external_gateway_info": {
@ -253,19 +253,19 @@ class VPCTestBase(HeatTestCase):
def mock_delete_network(self):
self.mock_router_for_vpc()
quantumclient.Client.delete_router('bbbb').AndReturn(None)
quantumclient.Client.delete_network('aaaa').AndReturn(None)
neutronclient.Client.delete_router('bbbb').AndReturn(None)
neutronclient.Client.delete_network('aaaa').AndReturn(None)
def mock_delete_subnet(self):
self.mock_router_for_vpc()
quantumclient.Client.remove_interface_router(
neutronclient.Client.remove_interface_router(
u'bbbb',
{'subnet_id': 'cccc'}).AndReturn(None)
quantumclient.Client.delete_subnet('cccc').AndReturn(None)
neutronclient.Client.delete_subnet('cccc').AndReturn(None)
def mock_create_route_table(self):
self.rt_name = utils.PhysName('test_stack', 'the_route_table')
quantumclient.Client.create_router({
neutronclient.Client.create_router({
'router': {'name': self.rt_name}}).AndReturn({
'router': {
'status': 'BUILD',
@ -275,7 +275,7 @@ class VPCTestBase(HeatTestCase):
'id': 'ffff'
}
})
quantumclient.Client.show_router('ffff').AndReturn({
neutronclient.Client.show_router('ffff').AndReturn({
'router': {
'status': 'BUILD',
'name': self.rt_name,
@ -284,7 +284,7 @@ class VPCTestBase(HeatTestCase):
'id': 'ffff'
}
})
quantumclient.Client.show_router('ffff').AndReturn({
neutronclient.Client.show_router('ffff').AndReturn({
'router': {
'status': 'ACTIVE',
'name': self.rt_name,
@ -294,32 +294,32 @@ class VPCTestBase(HeatTestCase):
}
})
self.mock_router_for_vpc()
quantumclient.Client.add_gateway_router(
neutronclient.Client.add_gateway_router(
'ffff', {'network_id': 'zzzz'}).AndReturn(None)
def mock_create_association(self):
self.mock_show_subnet()
self.mock_router_for_vpc()
quantumclient.Client.remove_interface_router(
neutronclient.Client.remove_interface_router(
'bbbb',
{'subnet_id': u'cccc'}).AndReturn(None)
quantumclient.Client.add_interface_router(
neutronclient.Client.add_interface_router(
u'ffff',
{'subnet_id': 'cccc'}).AndReturn(None)
def mock_delete_association(self):
self.mock_show_subnet()
self.mock_router_for_vpc()
quantumclient.Client.remove_interface_router(
neutronclient.Client.remove_interface_router(
'ffff',
{'subnet_id': u'cccc'}).AndReturn(None)
quantumclient.Client.add_interface_router(
neutronclient.Client.add_interface_router(
u'bbbb',
{'subnet_id': 'cccc'}).AndReturn(None)
def mock_delete_route_table(self):
quantumclient.Client.delete_router('ffff').AndReturn(None)
quantumclient.Client.remove_gateway_router('ffff').AndReturn(None)
neutronclient.Client.delete_router('ffff').AndReturn(None)
neutronclient.Client.remove_gateway_router('ffff').AndReturn(None)
def assertResourceState(self, resource, ref_id):
self.assertEqual(None, resource.validate())
@ -378,12 +378,12 @@ Resources:
# mock delete subnet which is already deleted
self.mock_router_for_vpc()
quantumclient.Client.remove_interface_router(
neutronclient.Client.remove_interface_router(
u'bbbb',
{'subnet_id': 'cccc'}).AndRaise(
QuantumClientException(status_code=404))
quantumclient.Client.delete_subnet('cccc').AndRaise(
QuantumClientException(status_code=404))
NeutronClientException(status_code=404))
neutronclient.Client.delete_subnet('cccc').AndRaise(
NeutronClientException(status_code=404))
self.m.ReplayAll()
stack = self.create_stack(self.test_template)
@ -523,7 +523,7 @@ Resources:
if security_groups:
port['security_groups'] = security_groups
quantumclient.Client.create_port({'port': port}).AndReturn({
neutronclient.Client.create_port({'port': port}).AndReturn({
'port': {
'admin_state_up': True,
'device_id': '',
@ -544,7 +544,7 @@ Resources:
})
def mock_delete_network_interface(self):
quantumclient.Client.delete_port('dddd').AndReturn(None)
neutronclient.Client.delete_port('dddd').AndReturn(None)
def test_network_interface(self):
self.mock_keystone()
@ -659,7 +659,7 @@ Resources:
'''
def mock_create_internet_gateway(self):
quantumclient.Client.list_networks(
neutronclient.Client.list_networks(
**{'router:external': True}).AndReturn({'networks': [{
'status': 'ACTIVE',
'subnets': [],
@ -672,11 +672,11 @@ Resources:
}]})
def mock_create_gateway_attachment(self):
quantumclient.Client.add_gateway_router(
neutronclient.Client.add_gateway_router(
'ffff', {'network_id': 'eeee'}).AndReturn(None)
def mock_delete_gateway_attachment(self):
quantumclient.Client.remove_gateway_router('ffff').AndReturn(None)
neutronclient.Client.remove_gateway_router('ffff').AndReturn(None)
def test_internet_gateway(self):
self.mock_keystone()

View File

@ -18,7 +18,7 @@ SQLAlchemy>=0.7.8,<0.7.99
WebOb==1.2.3
python-keystoneclient>=0.2.1
python-swiftclient>=1.2
python-quantumclient>=2.2.0
python-neutronclient>=2.2.3,<3
python-ceilometerclient>=1.0.1
python-cinderclient>=1.0.4
PyYAML>=3.1.0