LOG = logging.getLogger(__name__)
-# Port Status
-PORT_STATUS_UP = "UP"
-PORT_STATUS_DOWN = "DOWN"
-
class QuantumController(object):
""" Base controller class for Quantum API """
--- /dev/null
+# Copyright (c) 2012 OpenStack, LLC.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+NET_STATUS_ACTIVE = 'ACTIVE'
+NET_STATUS_BUILD = 'BUILD'
+NET_STATUS_DOWN = 'DOWN'
+NET_STATUS_ERROR = 'ERROR'
+
+PORT_STATUS_ACTIVE = 'ACTIVE'
+PORT_STATUS_BUILD = 'BUILD'
+PORT_STATUS_DOWN = 'DOWN'
+PORT_STATUS_ERROR = 'ERROR'
from nose import core
from nose import result
+from quantum.common import constants
+
class _AnsiColorizer(object):
"""
# quantum/plugins/openvswitch/ )
test_config = {
"plugin_name": "quantum.plugins.sample.SamplePlugin.FakePlugin",
- "default_net_op_status": "UP",
- "default_port_op_status": "UP",
+ "default_net_op_status": constants.NET_STATUS_ACTIVE,
+ "default_port_op_status": constants.PORT_STATUS_ACTIVE,
}
from sqlalchemy.orm import exc
from quantum.api.v2 import attributes
+from quantum.common import constants
from quantum.common import exceptions as q_exc
from quantum.common import utils
from quantum.db import api as db
name=n['name'],
admin_state_up=n['admin_state_up'],
shared=n['shared'],
- status="ACTIVE")
+ status=constants.NET_STATUS_ACTIVE)
context.session.add(network)
return self._make_network_dict(network)
network_id=p['network_id'],
mac_address=p['mac_address'],
admin_state_up=p['admin_state_up'],
- status="ACTIVE",
+ status=constants.PORT_STATUS_ACTIVE,
device_id=p['device_id'],
device_owner=p['device_owner'])
context.session.add(port)
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, exc, joinedload
+from quantum.common import constants
from quantum.common import exceptions as q_exc
from quantum.plugins.cisco.db import models
session = get_session()
for key in kwargs.keys():
if key == "state":
- if kwargs[key] not in ('ACTIVE', 'DOWN'):
+ if kwargs[key] not in (constants.PORT_STATUS_ACTIVE,
+ constants.PORT_STATUS_DOWN):
raise q_exc.StateInvalid(port_state=kwargs[key])
port[key] = kwargs[key]
session.merge(port)
import subprocess
import sys
+from quantum.common import constants
from quantum.plugins.cisco.common import cisco_constants as const
from quantum.plugins.cisco.db import api as db
from quantum.plugins.cisco.db import l2network_db as l2db
def create_multiport(tenant_id, networks_list, *args):
"""Creates ports on a single host"""
ports_info = {'multiport':
- {'status': 'ACTIVE',
+ {'status': constants.PORT_STATUS_ACTIVE,
'net_id_list': networks_list,
'ports_desc': {'key': 'value'}}}
request_url = "/multiport"
from quantum.agent.linux import utils
from quantum.agent import rpc as agent_rpc
from quantum.common import config as logging_config
+from quantum.common import constants
from quantum.common import topics
from quantum.openstack.common import cfg
from quantum.openstack.common import context
from quantum.openstack.common import rpc
from quantum.openstack.common.rpc import dispatcher
from quantum.plugins.linuxbridge.common import config
-from quantum.plugins.linuxbridge.common import constants
+from quantum.plugins.linuxbridge.common import constants as lconst
logging.basicConfig()
LOG = logging.getLogger(__name__)
BRIDGE_PORT_FS_FOR_DEVICE = BRIDGE_FS + DEVICE_NAME_PLACEHOLDER + "/brport"
VLAN_BINDINGS = "vlan_bindings"
PORT_BINDINGS = "port_bindings"
-OP_STATUS_UP = "UP"
-OP_STATUS_DOWN = "DOWN"
# Default inteval values
DEFAULT_POLLING_INTERVAL = 2
DEFAULT_RECONNECT_INTERVAL = 2
tap_device_name], root_helper=self.root_helper):
return False
- if int(vlan_id) == constants.FLAT_VLAN_ID:
+ if int(vlan_id) == lconst.FLAT_VLAN_ID:
self.ensure_flat_bridge(network_id, physical_interface)
else:
self.ensure_vlan_bridge(network_id, physical_interface, vlan_id)
interface_id,
physical_network,
vlan_id):
- all_bindings[port_id].status = OP_STATUS_UP
+ all_bindings[port_id].status = constants.PORT_STATUS_ACTIVE
plugged_interfaces.append(interface_id)
from sqlalchemy.orm import exc
-from quantum.api import api_common
+from quantum.common import constants
from quantum.common import exceptions as q_exc
import quantum.db.api as db
from quantum.db import models_v2
try:
port = session.query(models_v2.Port).filter_by(id=port_id).one()
port['status'] = status
- if status == api_common.PORT_STATUS_DOWN:
+ if status == constants.PORT_STATUS_DOWN:
port['device_id'] = ''
port['device_owner'] = ''
session.merge(port)
import logging
import sys
-from quantum.api import api_common
from quantum.api.v2 import attributes
+from quantum.common import constants
from quantum.common import exceptions as q_exc
from quantum.common import topics
from quantum.db import api as db_api
from quantum.openstack.common import rpc
from quantum.openstack.common.rpc import dispatcher
from quantum.openstack.common.rpc import proxy
-from quantum.plugins.linuxbridge.common import constants
+from quantum.plugins.linuxbridge.common import constants as lconst
from quantum.plugins.linuxbridge.db import l2network_db_v2 as db
from quantum import policy
'port_id': port['id'],
'admin_state_up': port['admin_state_up']}
# Set the port status to UP
- db.set_port_status(port['id'], api_common.PORT_STATUS_UP)
+ db.set_port_status(port['id'], constants.PORT_STATUS_ACTIVE)
else:
entry = {'device': device}
LOG.debug("%s can not be found in database", device)
entry = {'device': device,
'exists': True}
# Set port status to DOWN
- db.set_port_status(port['id'], api_common.PORT_STATUS_DOWN)
+ db.set_port_status(port['id'], constants.PORT_STATUS_DOWN)
else:
entry = {'device': device,
'exists': False}
if self._check_provider_view_auth(context, network):
binding = db.get_network_binding(context.session, network['id'])
network['provider:physical_network'] = binding.physical_network
- if binding.vlan_id == constants.FLAT_VLAN_ID:
+ if binding.vlan_id == lconst.FLAT_VLAN_ID:
network['provider:network_type'] = 'flat'
network['provider:vlan_id'] = None
else:
msg = _("provider:vlan_id specified for flat network")
raise q_exc.InvalidInput(error_message=msg)
else:
- vlan_id = constants.FLAT_VLAN_ID
+ vlan_id = lconst.FLAT_VLAN_ID
elif network_type == 'vlan':
if not vlan_id_set:
msg = _("provider:vlan_id required")
from quantum.openstack.common import cfg
from quantum.common import config as logging_config
+from quantum.common import constants
from quantum.plugins.linuxbridge.common import config
import quantum.plugins.linuxbridge.agent.linuxbridge_quantum_agent as lb
BRIDGE_NAME_PREFIX = "brq"
VLAN_BINDINGS = "vlan_bindings"
PORT_BINDINGS = "port_bindings"
-OP_STATUS_UP = "UP"
-OP_STATUS_DOWN = "DOWN"
# Default inteval values
DEFAULT_POLLING_INTERVAL = 2
DEFAULT_RECONNECT_INTERVAL = 2
entry = {'network_id': bind.network_id, 'state': bind.state,
'op_status': bind.op_status, 'uuid': bind.uuid,
'interface_id': bind.interface_id}
- append_entry = bind.state == 'ACTIVE'
+ append_entry = bind.state == constants.PORT_STATUS_ACTIVE
if append_entry:
port_bindings.append(entry)
interface_id,
vlan_id):
if self.target_v2_api:
- all_bindings[port_id].status = OP_STATUS_UP
+ all_bindings[port_id].status = constants.PORT_STATUS_ACTIVE
else:
- all_bindings[port_id].op_status = OP_STATUS_UP
+ all_bindings[port_id].op_status = (
+ constants.PORT_STATUS_ACTIVE)
plugged_interfaces.append(interface_id)
from quantum.agent.linux import ovs_lib
from quantum.common import config as logging_config
+from quantum.common import constants
from quantum.openstack.common import cfg
from quantum.plugins.openvswitch.common import config
from quantum.plugins.openvswitch.agent.ovs_quantum_agent import OVSQuantumAgent
logging.basicConfig()
LOG = logging.getLogger(__name__)
-# Global constants.
-OP_STATUS_UP = "UP"
-OP_STATUS_DOWN = "DOWN"
-
# A placeholder for dead vlans.
DEAD_VLAN_TAG = "4095"
% (old_b, str(p)))
self.port_unbound(p, True)
if p.vif_id in all_bindings:
- all_bindings[p.vif_id].status = OP_STATUS_DOWN
+ all_bindings[p.vif_id].status = (
+ constants.PORT_STATUS_DOWN)
if new_b is not None:
# If we don't have a binding we have to stick it on
# the dead vlan
vlan_id = vlan_bindings.get(net_id, DEAD_VLAN_TAG)
self.port_bound(p, vlan_id)
if p.vif_id in all_bindings:
- all_bindings[p.vif_id].status = OP_STATUS_UP
+ all_bindings[p.vif_id].status = (
+ constants.PORT_STATUS_ACTIVE)
LOG.info(("Adding binding to net-id = %s "
"for %s on vlan %s") %
(new_b, str(p), vlan_id))
old_b = old_local_bindings[vif_id]
self.port_unbound(old_vif_ports[vif_id], False)
if vif_id in all_bindings:
- all_bindings[vif_id].status = OP_STATUS_DOWN
+ all_bindings[vif_id].status = (
+ constants.PORT_STATUS_DOWN)
old_vif_ports = new_vif_ports
old_local_bindings = new_local_bindings
from nvp_plugin_version import PLUGIN_VERSION
from quantum.api.v2 import attributes
+from quantum.common import constants
from quantum.common import exceptions as exception
from quantum.db import api as db
from quantum.db import db_base_plugin_v2
'name': result['lswitch-display-name'],
'tenant_id': network['tenant_id'],
'admin_state_up': True,
- 'status': 'ACTIVE',
+ 'status': constants.NET_STATUS_ACTIVE,
'shared': network['shared'],
'subnets': []}
if nvp_lswitch["uuid"] == quantum_lswitch["id"]:
if (nvp_lswitch["_relations"]["LogicalSwitchStatus"]
["fabric_status"]):
- quantum_lswitch["status"] = "ACTIVE"
+ quantum_lswitch["status"] = constants.NET_STATUS_ACTIVE
else:
- quantum_lswitch["status"] = "DOWN"
+ quantum_lswitch["status"] = constants.NET_STATUS_DOWN
quantum_lswitch["name"] = nvp_lswitch["display_name"]
nvp_lswitches.remove(nvp_lswitch)
Found = True
["_relations"]
["LogicalPortStatus"]
["fabric_status_up"]):
- quantum_lport["status"] = "ACTIVE"
+ quantum_lport["status"] = constants.PORT_STATUS_ACTIVE
else:
- quantum_lport["status"] = "DOWN"
+ quantum_lport["status"] = constants.PORT_STATUS_DOWN
del nvp_lports[quantum_lport["id"]]
lports.append(quantum_lport)
quantum_db["admin_state_up"] = port["admin_status_enabled"]
if port["_relations"]["LogicalPortStatus"]["fabric_status_up"]:
- quantum_db["status"] = "ACTIVE"
+ quantum_db["status"] = constants.PORT_STATUS_ACTIVE
else:
- quantum_db["status"] = "DOWN"
+ quantum_db["status"] = constants.PORT_STATUS_DOWN
LOG.debug("Port details for tenant %s: %s" %
(context.tenant_id, quantum_db))
#FIXME(danwent): I'd like this file to get to the point where it has
# no quantum-specific logic in it
+from quantum.common import constants
from quantum.common import exceptions as exception
LOCAL_LOGGING = False
"tags": [{"tag": tenant_id, "scope": "os_tid"}]}
net = create_lswitch(cluster, lswitch_obj)
- net['net-op-status'] = "UP"
+ net['net-op-status'] = constants.NET_STATUS_ACTIVE
return net
except NvpApiClient.NvpApiException as e:
raise exception.QuantumException()
if r['link_status_up'] is True:
- return "UP"
+ return constants.PORT_STATUS_ACTIVE
else:
- return "DOWN"
+ return constants.PORT_STATUS_DOWN
def plug_interface(clusters, lswitch_id, port, type, attachment=None):
from quantum.agent import rpc as agent_rpc
from quantum.agent.linux import ovs_lib
from quantum.agent.linux import utils
+from quantum.common import constants
from quantum.common import config as logging_config
from quantum.common import topics
from quantum.openstack.common import cfg
logging.basicConfig()
LOG = logging.getLogger(__name__)
-# Global constants.
-OP_STATUS_UP = "UP"
-OP_STATUS_DOWN = "DOWN"
-
# A placeholder for dead vlans.
DEAD_VLAN_TAG = "4095"
% (old_b, str(p)))
self.port_unbound(p, True)
if p.vif_id in all_bindings:
- all_bindings[p.vif_id].status = OP_STATUS_DOWN
+ all_bindings[p.vif_id].status = (
+ constants.PORT_STATUS_DOWN)
if new_b is not None:
# If we don't have a binding we have to stick it on
# the dead vlan
vlan_id = vlan_bindings.get(net_id, DEAD_VLAN_TAG)
self.port_bound(p, vlan_id)
if p.vif_id in all_bindings:
- all_bindings[p.vif_id].status = OP_STATUS_UP
+ all_bindings[p.vif_id].status = (
+ constants.PORT_STATUS_ACTIVE)
LOG.info(("Adding binding to net-id = %s "
"for %s on vlan %s") %
(new_b, str(p), vlan_id))
old_b = old_local_bindings[vif_id]
self.port_unbound(old_vif_ports[vif_id], False)
if vif_id in all_bindings:
- all_bindings[vif_id].status = OP_STATUS_DOWN
+ all_bindings[vif_id].status = (
+ constants.PORT_STATUS_DOWN)
old_vif_ports = new_vif_ports
old_local_bindings = new_local_bindings
+ " added to dead vlan")
self.port_unbound(p, old_net_uuid)
if p.vif_id in all_bindings:
- all_bindings[p.vif_id].status = OP_STATUS_DOWN
+ all_bindings[p.vif_id].status = (
+ constants.PORT_STATUS_DOWN)
if not new_port:
self.port_dead(p)
lsw_id = lsw_id_bindings[new_net_uuid]
self.port_bound(p, new_net_uuid, lsw_id)
- all_bindings[p.vif_id].status = OP_STATUS_UP
+ all_bindings[p.vif_id].status = (
+ constants.PORT_STATUS_ACTIVE)
LOG.info("Port %s on net-id = %s bound to %s " % (
str(p), new_net_uuid,
str(self.local_vlan_map[new_net_uuid])))
for vif_id in disappeared_vif_ports_ids:
LOG.info("Port Disappeared: " + vif_id)
if vif_id in all_bindings:
- all_bindings[vif_id].status = OP_STATUS_DOWN
+ all_bindings[vif_id].status = (
+ constants.PORT_STATUS_DOWN)
old_port = old_local_bindings.get(vif_id)
if old_port:
self.port_unbound(old_vif_ports[vif_id],
from sqlalchemy.orm import exc
-from quantum.api import api_common
+from quantum.common import constants
from quantum.common import exceptions as q_exc
from quantum.db import models_v2
import quantum.db.api as db
try:
port = session.query(models_v2.Port).filter_by(id=port_id).one()
port['status'] = status
- if status == api_common.PORT_STATUS_DOWN:
+ if status == constants.PORT_STATUS_DOWN:
port['device_id'] = ''
port['device_owner'] = ''
session.merge(port)
import logging
import os
-from quantum.api import api_common
from quantum.api.v2 import attributes
+from quantum.common import constants
from quantum.common import exceptions as q_exc
from quantum.common import topics
from quantum.db import api as db
'port_id': port['id'],
'admin_state_up': port['admin_state_up']}
# Set the port status to UP
- ovs_db_v2.set_port_status(port['id'], api_common.PORT_STATUS_UP)
+ ovs_db_v2.set_port_status(port['id'], constants.PORT_STATUS_ACTIVE)
else:
entry = {'device': device}
LOG.debug("%s can not be found in database", device)
entry = {'device': device,
'exists': True}
# Set port status to DOWN
- ovs_db_v2.set_port_status(port['id'], api_common.PORT_STATUS_DOWN)
+ ovs_db_v2.set_port_status(port['id'], constants.PORT_STATUS_DOWN)
else:
entry = {'device': device,
'exists': False}
from quantum.agent.linux import ovs_lib
from quantum.agent.linux.ovs_lib import VifPort
from quantum.common import config as logging_config
+from quantum.common import constants
from quantum.openstack.common import cfg
from quantum.plugins.ryu.common import config
-OP_STATUS_UP = "UP"
-OP_STATUS_DOWN = "DOWN"
-
class OVSBridge(ovs_lib.OVSBridge):
def __init__(self, br_name, root_helper):
net_id = all_bindings[port.vif_id].network_id
local_bindings[port.vif_id] = net_id
self._port_update(net_id, port)
- self._set_port_status(all_bindings[port.vif_id], OP_STATUS_UP)
+ self._set_port_status(all_bindings[port.vif_id],
+ constants.PORT_STATUS_ACTIVE)
LOG.info("Updating binding to net-id = %s for %s",
net_id, str(port))
db.commit()
old_b, str(port))
if port.vif_id in all_bindings:
self._set_port_status(all_bindings[port.vif_id],
- OP_STATUS_DOWN)
+ constants.PORT_STATUS_DOWN)
if not new_b:
if port.vif_id in all_bindings:
self._set_port_status(all_bindings[port.vif_id],
- OP_STATUS_UP)
+ constants.PORT_STATUS_ACTIVE)
LOG.info("Adding binding to net-id = %s for %s",
new_b, str(port))
LOG.info("Port Disappeared: %s", vif_id)
if vif_id in all_bindings:
self._set_port_status(all_bindings[port.vif_id],
- OP_STATUS_DOWN)
+ constants.PORT_STATUS_DOWN)
old_vif_ports = new_vif_ports
old_local_bindings = new_local_bindings
:returns: a mapping sequence with the following signature:
{'port-id': uuid representing the
updated port on specified quantum network
- 'port-state': update port state( UP or DOWN)
+ 'port-state': update port state( ACTIVE or DOWN)
}
:raises: exception.StateInvalid
:raises: exception.PortNotFound