Skip to content
This repository was archived by the owner on Nov 13, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions neutron/extensions/netos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from neutron.api.v2 import attributes as attr
from neutron.plugins.common import constants

FLAVOR = 'netos:flavor'
IMAGE = 'netos:image'
KEY = 'netos:key'
PORT = 'netos:port'
URL = 'netos:url'

EXTENDED_ATTRIBUTES_2_0 = {
'networks': {
FLAVOR: {'allow_post': True, 'allow_put': False,
'default': attr.ATTR_NOT_SPECIFIED,
'validate': {'type:string': None},
'is_visible': True
},
IMAGE: {'allow_post': True, 'allow_put': False,
'default': attr.ATTR_NOT_SPECIFIED,
'validate': {'type:string': None},
'is_visible': True
},
KEY: {'allow_post': True, 'allow_put': False,
'default': attr.ATTR_NOT_SPECIFIED,
'validate': {'type:string': None},
'is_visible': True
},
PORT: {'allow_post': True, 'allow_put': False,
'validate': {'type:range': [0, 65535]},
'default': attr.ATTR_NOT_SPECIFIED,
'convert_to': attr.convert_to_int,
'is_visible': True
},
URL: {'allow_post': True, 'allow_put': False,
'default': attr.ATTR_NOT_SPECIFIED,
'validate': {'type:string': None},
'is_visible': True
}
}
}

class Netos(object):
@classmethod
def get_name(cls):
return "Network OS Extension"

@classmethod
def get_alias(cls):
return "netos"

@classmethod
def get_description(cls):
return "Configure network operating system"

@classmethod
def get_namespace(cls):
# return "http://docs.openstack.org/ext/provider/api/v1.0"
# Nothing there right now
return "http://www.vicci.org/ext/opencloud/topology/api/v0.1"

@classmethod
def get_updated(cls):
return "2014-11-19T10:00:00-00:00"

def get_extended_resources(self, version):
if version == "2.0":
return EXTENDED_ATTRIBUTES_2_0
else:
return {}
6 changes: 3 additions & 3 deletions neutron/extensions/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
EXTENDED_ATTRIBUTES_2_0 = {
'networks': {
TYPE: {'allow_post': True, 'allow_put': False,
'default': constants.BIGSWITCH,
'validate': {'type:values': [constants.BIGSWITCH, constants.PHYSICAL, constants.CUSTOM]},
'is_visible': True
'default': constants.BIGSWITCH,
'validate': {'type:values': [constants.BIGSWITCH, constants.PHYSICAL, constants.CUSTOM]},
'is_visible': True
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion neutron/plugins/opencloud/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
'ip_version': 4,
'cidr': '171.66.164.0/24',
'gateway_ip': '171.66.164.1',
'dns_nameservers': [],
'dns_nameservers': ['8.8.8.8'],
'allocation_pools': [{"start": "171.66.164.3", "end": "171.66.164.254"}],
'host_routes': [],
'enable_dhcp': True
Expand Down
40 changes: 25 additions & 15 deletions neutron/plugins/ovx/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,19 @@
LOG = log.getLogger(__name__)

class OVXPluginApi(agent_rpc.PluginApi):
def update_ports(self, context, agent_id, dpid, ports_added, ports_removed):
def update_ports(self, context, agent_id, dpid,
ports_added, ports_removed, ports_updated):
"""RPC to update information of ports on Neutron plugin."""

LOG.info(_("Update ports: added=%(added)s, removed=%(removed)s"),
{'added': ports_added, 'removed': ports_removed})
LOG.info(_("Update ports: added=%(added)s, removed=%(removed)s, updated=%(updated)s"),
{'added': ports_added, 'removed': ports_removed, 'updated': ports_updated})
self.cast(context, self.make_msg('update_ports',
topic=topics.AGENT,
agent_id=agent_id,
dpid=dpid,
ports_added=ports_added,
ports_removed=ports_removed))
ports_removed=ports_removed,
ports_updated=ports_updated))

class OVXNeutronAgent():
def __init__(self, data_bridge, root_helper, polling_interval):
Expand Down Expand Up @@ -100,37 +102,45 @@ def _vif_port_to_port_info(self, vif_port):

def daemon_loop(self):
"""Runs an infinite loop where each iteration:
(a) checks if ports were added or removed,
(a) checks if ports were added, removed, or updated
(b) if port changes are observed, an RPC call on the plugin is triggered, and
(c) sleeps for the polling interval."""
(c) sleeps for the polling interval.

When rebooting an instance, the port may be deleted and added in the same iteration.
The only change will be the OpenFlow port number, so we need to check for updated ports.
"""

while True:
start = time.time()
try:
# List of port IDs
cur_ports = [] if self.need_sync else self.cur_ports
new_ports = []
# Dict with (key,value): (port ID, port info)
cur_ports = {} if self.need_sync else self.cur_ports
new_ports = {}

# List of port dicts
# Build list of all port IDs that are present now, and lists
# of ports that were added or updated since the previous iteration.
# List of full port info
ports_added = []
ports_updated = []
for vif_port in self.data_bridge.get_vif_ports():
port_info = self._vif_port_to_port_info(vif_port)
port_id = port_info['id']
new_ports.append(port_id)

new_ports[port_id] = port_info
if port_id not in cur_ports:
ports_added.append(port_info)
elif cur_ports[port_id]['port_no'] != port_info['port_no']:
ports_updated.append(port_info)

# List of port IDs
# Build list port IDs
ports_removed = []
for port_id in cur_ports:
if port_id not in new_ports:
ports_removed.append(port_id)

if ports_added or ports_removed:
if ports_added or ports_removed or ports_updated:
self.plugin_rpc.update_ports(self.context,
self.agent_id, self.dpid,
ports_added, ports_removed)
ports_added, ports_removed, ports_updated)
else:
LOG.debug(_("No ports changed."))

Expand Down
2 changes: 1 addition & 1 deletion neutron/plugins/ovx/ovx_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class NetworkMapping(model_base.BASEV2):
sa.ForeignKey('networks.id', ondelete="CASCADE"),
primary_key=True)
ovx_tenant_id = sa.Column(sa.Integer, nullable=False)
ovx_controller = sa.Column(sa.String(36), nullable=False)
ovx_controller = sa.Column(sa.String(36), nullable=True)

def __repr__(self):
return "<NetworkMapping(%s,%d,%s)>" % (self.neutron_network_id,
Expand Down
11 changes: 10 additions & 1 deletion neutron/plugins/ovx/ovxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ def del_ovx_port(session, neutron_port_id):
result = query.filter_by(neutron_port_id=neutron_port_id).one()
if result:
session.delete(result)


def set_ovx_port(session, neutron_port_id, ovx_vdpid, ovx_vport, ovx_host_id):
query = session.query(ovx_models.PortMapping)
result = query.filter_by(neutron_port_id=neutron_port_id).one()
result['ovx_vdpid'] = ovx_vdpid
result['ovx_vport'] = ovx_vport
result['ovx_host_id'] = ovx_vhost_id
session.merge(result)
session.flush()

def set_port_status(session, port_id, status):
"""Set the port status."""
query = session.query(models_v2.Port)
Expand Down
Loading