Use a common constant for the port/network 'status' value
Fixes bug 1036054. 'status' have four values 'ACTIVE/DOWN/ERROR/BUILD' in v2 spec. However, some plugins still using 'UP/DOWN' from v1. In order to consistent the use of 'status' value. A common constant file was created and modified all plugins to use the same constant value. Change-Id: I865dffbe031d9a3e76e52e334db3050a3ef11ed0
This commit is contained in:
parent
6fc02c2711
commit
d30be04909
@ -24,10 +24,6 @@ from quantum import wsgi
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
# Port Status
|
||||
PORT_STATUS_UP = "UP"
|
||||
PORT_STATUS_DOWN = "DOWN"
|
||||
|
||||
|
||||
class QuantumController(object):
|
||||
""" Base controller class for Quantum API """
|
||||
|
24
quantum/common/constants.py
Normal file
24
quantum/common/constants.py
Normal file
@ -0,0 +1,24 @@
|
||||
# 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'
|
@ -44,6 +44,8 @@ import unittest
|
||||
from nose import core
|
||||
from nose import result
|
||||
|
||||
from quantum.common import constants
|
||||
|
||||
|
||||
class _AnsiColorizer(object):
|
||||
"""
|
||||
@ -283,6 +285,6 @@ def run_tests(c=None):
|
||||
# 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,
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ from sqlalchemy import orm
|
||||
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
|
||||
@ -756,7 +757,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
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)
|
||||
|
||||
@ -983,7 +984,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
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)
|
||||
|
@ -20,6 +20,7 @@
|
||||
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
|
||||
|
||||
@ -192,7 +193,8 @@ def port_update(port_id, net_id, **kwargs):
|
||||
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)
|
||||
|
@ -34,6 +34,7 @@ import re
|
||||
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
|
||||
@ -232,7 +233,7 @@ def connect_vm(tenant_id, vm_image_id, service_instance_id, *args):
|
||||
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"
|
||||
|
@ -37,13 +37,14 @@ from sqlalchemy.ext.sqlsoup import SqlSoup
|
||||
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__)
|
||||
@ -59,8 +60,6 @@ DEVICE_NAME_PLACEHOLDER = "device_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
|
||||
@ -255,7 +254,7 @@ class LinuxBridge:
|
||||
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)
|
||||
@ -508,7 +507,7 @@ class LinuxBridgeQuantumAgentDB:
|
||||
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)
|
||||
|
||||
|
@ -17,7 +17,7 @@ import logging
|
||||
|
||||
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
|
||||
@ -188,7 +188,7 @@ def set_port_status(port_id, status):
|
||||
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)
|
||||
|
@ -16,8 +16,8 @@
|
||||
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
|
||||
@ -29,7 +29,7 @@ from quantum.openstack.common import cfg
|
||||
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
|
||||
|
||||
@ -71,7 +71,7 @@ class LinuxBridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin):
|
||||
'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)
|
||||
@ -88,7 +88,7 @@ class LinuxBridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin):
|
||||
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}
|
||||
@ -217,7 +217,7 @@ class LinuxBridgePluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
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:
|
||||
@ -247,7 +247,7 @@ class LinuxBridgePluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
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")
|
||||
|
@ -31,6 +31,7 @@ from sqlalchemy.ext.sqlsoup import SqlSoup
|
||||
|
||||
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
|
||||
|
||||
@ -42,8 +43,6 @@ LOG = logging.getLogger(__name__)
|
||||
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
|
||||
@ -105,7 +104,7 @@ class MetaLinuxBridgeQuantumAgent(lb.LinuxBridgeQuantumAgent):
|
||||
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)
|
||||
|
||||
@ -122,9 +121,10 @@ class MetaLinuxBridgeQuantumAgent(lb.LinuxBridgeQuantumAgent):
|
||||
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)
|
||||
|
||||
|
@ -28,6 +28,7 @@ from sqlalchemy.ext import sqlsoup
|
||||
|
||||
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
|
||||
@ -35,10 +36,6 @@ 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"
|
||||
|
||||
@ -129,7 +126,8 @@ class MetaOVSQuantumAgent(OVSQuantumAgent):
|
||||
% (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
|
||||
@ -137,7 +135,8 @@ class MetaOVSQuantumAgent(OVSQuantumAgent):
|
||||
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))
|
||||
@ -149,7 +148,8 @@ class MetaOVSQuantumAgent(OVSQuantumAgent):
|
||||
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
|
||||
|
@ -39,6 +39,7 @@ import nvplib
|
||||
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
|
||||
@ -420,7 +421,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
'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': []}
|
||||
|
||||
@ -494,9 +495,9 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
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
|
||||
@ -645,9 +646,9 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
["_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)
|
||||
@ -831,9 +832,9 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
|
||||
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))
|
||||
|
@ -37,6 +37,7 @@ import NvpApiClient
|
||||
|
||||
#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
|
||||
@ -277,7 +278,7 @@ def create_network(tenant_id, net_name, **kwargs):
|
||||
"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
|
||||
|
||||
|
||||
@ -441,9 +442,9 @@ def get_port_status(cluster, lswitch_id, port_id):
|
||||
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):
|
||||
|
@ -30,6 +30,7 @@ from sqlalchemy.ext import sqlsoup
|
||||
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
|
||||
@ -41,10 +42,6 @@ from quantum.plugins.openvswitch.common import config
|
||||
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"
|
||||
|
||||
@ -258,7 +255,8 @@ class OVSQuantumAgent(object):
|
||||
% (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
|
||||
@ -266,7 +264,8 @@ class OVSQuantumAgent(object):
|
||||
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))
|
||||
@ -278,7 +277,8 @@ class OVSQuantumAgent(object):
|
||||
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
|
||||
@ -667,7 +667,8 @@ class OVSQuantumTunnelAgent(object):
|
||||
+ " 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)
|
||||
|
||||
@ -680,7 +681,8 @@ class OVSQuantumTunnelAgent(object):
|
||||
|
||||
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])))
|
||||
@ -688,7 +690,8 @@ class OVSQuantumTunnelAgent(object):
|
||||
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],
|
||||
|
@ -20,7 +20,7 @@ import logging
|
||||
|
||||
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
|
||||
@ -186,7 +186,7 @@ def set_port_status(port_id, status):
|
||||
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)
|
||||
|
@ -23,8 +23,8 @@
|
||||
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
|
||||
@ -75,7 +75,7 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin):
|
||||
'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)
|
||||
@ -92,7 +92,7 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin):
|
||||
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}
|
||||
|
@ -31,12 +31,10 @@ from sqlalchemy.ext.sqlsoup import SqlSoup
|
||||
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):
|
||||
@ -167,7 +165,8 @@ class OVSQuantumOFPRyuAgent:
|
||||
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()
|
||||
@ -196,11 +195,11 @@ class OVSQuantumOFPRyuAgent:
|
||||
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))
|
||||
|
||||
@ -209,7 +208,7 @@ class OVSQuantumOFPRyuAgent:
|
||||
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
|
||||
|
@ -162,7 +162,7 @@ class QuantumPluginBaseV2(object):
|
||||
: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
|
||||
|
Loading…
Reference in New Issue
Block a user