remove unnecessary files under neutron/db
Change-Id: I3b730a4161febbbd14f216d002335a4fd10317e8
This commit is contained in:
parent
aa337ef161
commit
2a4b74fe5a
|
@ -1,219 +0,0 @@
|
|||
# Copyright (c) 2013 OpenStack Foundation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from eventlet import greenthread
|
||||
|
||||
from oslo.config import cfg
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.orm import exc
|
||||
|
||||
from neutron.common import rpc_compat
|
||||
from neutron.db import model_base
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import agent as ext_agent
|
||||
from neutron import manager
|
||||
from neutron.openstack.common.db import exception as db_exc
|
||||
from neutron.openstack.common import excutils
|
||||
from neutron.openstack.common import jsonutils
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.openstack.common import timeutils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
cfg.CONF.register_opt(
|
||||
cfg.IntOpt('agent_down_time', default=75,
|
||||
help=_("Seconds to regard the agent is down; should be at "
|
||||
"least twice report_interval, to be sure the "
|
||||
"agent is down for good.")))
|
||||
|
||||
|
||||
class Agent(model_base.BASEV2, models_v2.HasId):
|
||||
"""Represents agents running in neutron deployments."""
|
||||
|
||||
__table_args__ = (
|
||||
sa.UniqueConstraint('agent_type', 'host',
|
||||
name='uniq_agents0agent_type0host'),
|
||||
)
|
||||
|
||||
# L3 agent, DHCP agent, OVS agent, LinuxBridge
|
||||
agent_type = sa.Column(sa.String(255), nullable=False)
|
||||
binary = sa.Column(sa.String(255), nullable=False)
|
||||
# TOPIC is a fanout exchange topic
|
||||
topic = sa.Column(sa.String(255), nullable=False)
|
||||
# TOPIC.host is a target topic
|
||||
host = sa.Column(sa.String(255), nullable=False)
|
||||
admin_state_up = sa.Column(sa.Boolean, default=True,
|
||||
nullable=False)
|
||||
# the time when first report came from agents
|
||||
created_at = sa.Column(sa.DateTime, nullable=False)
|
||||
# the time when first report came after agents start
|
||||
started_at = sa.Column(sa.DateTime, nullable=False)
|
||||
# updated when agents report
|
||||
heartbeat_timestamp = sa.Column(sa.DateTime, nullable=False)
|
||||
# description is note for admin user
|
||||
description = sa.Column(sa.String(255))
|
||||
# configurations: a json dict string, I think 4095 is enough
|
||||
configurations = sa.Column(sa.String(4095), nullable=False)
|
||||
|
||||
@property
|
||||
def is_active(self):
|
||||
return not AgentDbMixin.is_agent_down(self.heartbeat_timestamp)
|
||||
|
||||
|
||||
class AgentDbMixin(ext_agent.AgentPluginBase):
|
||||
"""Mixin class to add agent extension to db_base_plugin_v2."""
|
||||
|
||||
def _get_agent(self, context, id):
|
||||
try:
|
||||
agent = self._get_by_id(context, Agent, id)
|
||||
except exc.NoResultFound:
|
||||
raise ext_agent.AgentNotFound(id=id)
|
||||
return agent
|
||||
|
||||
@classmethod
|
||||
def is_agent_down(cls, heart_beat_time):
|
||||
return timeutils.is_older_than(heart_beat_time,
|
||||
cfg.CONF.agent_down_time)
|
||||
|
||||
def get_configuration_dict(self, agent_db):
|
||||
try:
|
||||
conf = jsonutils.loads(agent_db.configurations)
|
||||
except Exception:
|
||||
msg = _('Configuration for agent %(agent_type)s on host %(host)s'
|
||||
' is invalid.')
|
||||
LOG.warn(msg, {'agent_type': agent_db.agent_type,
|
||||
'host': agent_db.host})
|
||||
conf = {}
|
||||
return conf
|
||||
|
||||
def _make_agent_dict(self, agent, fields=None):
|
||||
attr = ext_agent.RESOURCE_ATTRIBUTE_MAP.get(
|
||||
ext_agent.RESOURCE_NAME + 's')
|
||||
res = dict((k, agent[k]) for k in attr
|
||||
if k not in ['alive', 'configurations'])
|
||||
res['alive'] = not AgentDbMixin.is_agent_down(
|
||||
res['heartbeat_timestamp'])
|
||||
res['configurations'] = self.get_configuration_dict(agent)
|
||||
return self._fields(res, fields)
|
||||
|
||||
def delete_agent(self, context, id):
|
||||
with context.session.begin(subtransactions=True):
|
||||
agent = self._get_agent(context, id)
|
||||
context.session.delete(agent)
|
||||
|
||||
def update_agent(self, context, id, agent):
|
||||
agent_data = agent['agent']
|
||||
with context.session.begin(subtransactions=True):
|
||||
agent = self._get_agent(context, id)
|
||||
agent.update(agent_data)
|
||||
return self._make_agent_dict(agent)
|
||||
|
||||
def get_agents_db(self, context, filters=None):
|
||||
query = self._get_collection_query(context, Agent, filters=filters)
|
||||
return query.all()
|
||||
|
||||
def get_agents(self, context, filters=None, fields=None):
|
||||
return self._get_collection(context, Agent,
|
||||
self._make_agent_dict,
|
||||
filters=filters, fields=fields)
|
||||
|
||||
def _get_agent_by_type_and_host(self, context, agent_type, host):
|
||||
query = self._model_query(context, Agent)
|
||||
try:
|
||||
agent_db = query.filter(Agent.agent_type == agent_type,
|
||||
Agent.host == host).one()
|
||||
return agent_db
|
||||
except exc.NoResultFound:
|
||||
raise ext_agent.AgentNotFoundByTypeHost(agent_type=agent_type,
|
||||
host=host)
|
||||
except exc.MultipleResultsFound:
|
||||
raise ext_agent.MultipleAgentFoundByTypeHost(agent_type=agent_type,
|
||||
host=host)
|
||||
|
||||
def get_agent(self, context, id, fields=None):
|
||||
agent = self._get_agent(context, id)
|
||||
return self._make_agent_dict(agent, fields)
|
||||
|
||||
def _create_or_update_agent(self, context, agent):
|
||||
with context.session.begin(subtransactions=True):
|
||||
res_keys = ['agent_type', 'binary', 'host', 'topic']
|
||||
res = dict((k, agent[k]) for k in res_keys)
|
||||
|
||||
configurations_dict = agent.get('configurations', {})
|
||||
res['configurations'] = jsonutils.dumps(configurations_dict)
|
||||
current_time = timeutils.utcnow()
|
||||
try:
|
||||
agent_db = self._get_agent_by_type_and_host(
|
||||
context, agent['agent_type'], agent['host'])
|
||||
res['heartbeat_timestamp'] = current_time
|
||||
if agent.get('start_flag'):
|
||||
res['started_at'] = current_time
|
||||
greenthread.sleep(0)
|
||||
agent_db.update(res)
|
||||
except ext_agent.AgentNotFoundByTypeHost:
|
||||
greenthread.sleep(0)
|
||||
res['created_at'] = current_time
|
||||
res['started_at'] = current_time
|
||||
res['heartbeat_timestamp'] = current_time
|
||||
res['admin_state_up'] = True
|
||||
agent_db = Agent(**res)
|
||||
greenthread.sleep(0)
|
||||
context.session.add(agent_db)
|
||||
greenthread.sleep(0)
|
||||
|
||||
def create_or_update_agent(self, context, agent):
|
||||
"""Create or update agent according to report."""
|
||||
|
||||
try:
|
||||
return self._create_or_update_agent(context, agent)
|
||||
except db_exc.DBDuplicateEntry as e:
|
||||
with excutils.save_and_reraise_exception() as ctxt:
|
||||
if e.columns == ['agent_type', 'host']:
|
||||
# It might happen that two or more concurrent transactions
|
||||
# are trying to insert new rows having the same value of
|
||||
# (agent_type, host) pair at the same time (if there has
|
||||
# been no such entry in the table and multiple agent status
|
||||
# updates are being processed at the moment). In this case
|
||||
# having a unique constraint on (agent_type, host) columns
|
||||
# guarantees that only one transaction will succeed and
|
||||
# insert a new agent entry, others will fail and be rolled
|
||||
# back. That means we must retry them one more time: no
|
||||
# INSERTs will be issued, because
|
||||
# _get_agent_by_type_and_host() will return the existing
|
||||
# agent entry, which will be updated multiple times
|
||||
ctxt.reraise = False
|
||||
return self._create_or_update_agent(context, agent)
|
||||
|
||||
|
||||
class AgentExtRpcCallback(rpc_compat.RpcCallback):
|
||||
"""Processes the rpc report in plugin implementations."""
|
||||
|
||||
RPC_API_VERSION = '1.0'
|
||||
START_TIME = timeutils.utcnow()
|
||||
|
||||
def __init__(self, plugin=None):
|
||||
super(AgentExtRpcCallback, self).__init__()
|
||||
self.plugin = plugin
|
||||
|
||||
def report_state(self, context, **kwargs):
|
||||
"""Report state from agent to server."""
|
||||
time = kwargs['time']
|
||||
time = timeutils.parse_strtime(time)
|
||||
if self.START_TIME > time:
|
||||
LOG.debug(_("Message with invalid timestamp received"))
|
||||
return
|
||||
agent_state = kwargs['agent_state']['agent_state']
|
||||
if not self.plugin:
|
||||
self.plugin = manager.NeutronManager.get_plugin()
|
||||
self.plugin.create_or_update_agent(context, agent_state)
|
|
@ -1,226 +0,0 @@
|
|||
# Copyright (c) 2013 OpenStack Foundation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslo.config import cfg
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
from sqlalchemy.orm import exc
|
||||
from sqlalchemy.orm import joinedload
|
||||
|
||||
from neutron.common import constants
|
||||
from neutron.common import utils
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import model_base
|
||||
from neutron.extensions import agent as ext_agent
|
||||
from neutron.extensions import dhcpagentscheduler
|
||||
from neutron.openstack.common import log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
AGENTS_SCHEDULER_OPTS = [
|
||||
cfg.StrOpt('network_scheduler_driver',
|
||||
default='neutron.scheduler.'
|
||||
'dhcp_agent_scheduler.ChanceScheduler',
|
||||
help=_('Driver to use for scheduling network to DHCP agent')),
|
||||
cfg.BoolOpt('network_auto_schedule', default=True,
|
||||
help=_('Allow auto scheduling networks to DHCP agent.')),
|
||||
cfg.IntOpt('dhcp_agents_per_network', default=1,
|
||||
help=_('Number of DHCP agents scheduled to host a network.')),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(AGENTS_SCHEDULER_OPTS)
|
||||
|
||||
|
||||
class NetworkDhcpAgentBinding(model_base.BASEV2):
|
||||
"""Represents binding between neutron networks and DHCP agents."""
|
||||
|
||||
network_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey("networks.id", ondelete='CASCADE'),
|
||||
primary_key=True)
|
||||
dhcp_agent = orm.relation(agents_db.Agent)
|
||||
dhcp_agent_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey("agents.id",
|
||||
ondelete='CASCADE'),
|
||||
primary_key=True)
|
||||
|
||||
|
||||
class AgentSchedulerDbMixin(agents_db.AgentDbMixin):
|
||||
"""Common class for agent scheduler mixins."""
|
||||
|
||||
# agent notifiers to handle agent update operations;
|
||||
# should be updated by plugins;
|
||||
agent_notifiers = {
|
||||
constants.AGENT_TYPE_DHCP: None,
|
||||
constants.AGENT_TYPE_L3: None,
|
||||
constants.AGENT_TYPE_LOADBALANCER: None,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def is_eligible_agent(active, agent):
|
||||
if active is None:
|
||||
# filtering by activeness is disabled, all agents are eligible
|
||||
return True
|
||||
else:
|
||||
# note(rpodolyaka): original behaviour is saved here: if active
|
||||
# filter is set, only agents which are 'up'
|
||||
# (i.e. have a recent heartbeat timestamp)
|
||||
# are eligible, even if active is False
|
||||
return not agents_db.AgentDbMixin.is_agent_down(
|
||||
agent['heartbeat_timestamp'])
|
||||
|
||||
def update_agent(self, context, id, agent):
|
||||
original_agent = self.get_agent(context, id)
|
||||
result = super(AgentSchedulerDbMixin, self).update_agent(
|
||||
context, id, agent)
|
||||
agent_data = agent['agent']
|
||||
agent_notifier = self.agent_notifiers.get(original_agent['agent_type'])
|
||||
if (agent_notifier and
|
||||
'admin_state_up' in agent_data and
|
||||
original_agent['admin_state_up'] != agent_data['admin_state_up']):
|
||||
agent_notifier.agent_updated(context,
|
||||
agent_data['admin_state_up'],
|
||||
original_agent['host'])
|
||||
return result
|
||||
|
||||
|
||||
class DhcpAgentSchedulerDbMixin(dhcpagentscheduler
|
||||
.DhcpAgentSchedulerPluginBase,
|
||||
AgentSchedulerDbMixin):
|
||||
"""Mixin class to add DHCP agent scheduler extension to db_base_plugin_v2.
|
||||
"""
|
||||
|
||||
network_scheduler = None
|
||||
|
||||
def get_dhcp_agents_hosting_networks(
|
||||
self, context, network_ids, active=None):
|
||||
if not network_ids:
|
||||
return []
|
||||
query = context.session.query(NetworkDhcpAgentBinding)
|
||||
query = query.options(joinedload('dhcp_agent'))
|
||||
if len(network_ids) == 1:
|
||||
query = query.filter(
|
||||
NetworkDhcpAgentBinding.network_id == network_ids[0])
|
||||
elif network_ids:
|
||||
query = query.filter(
|
||||
NetworkDhcpAgentBinding.network_id in network_ids)
|
||||
if active is not None:
|
||||
query = (query.filter(agents_db.Agent.admin_state_up == active))
|
||||
|
||||
return [binding.dhcp_agent
|
||||
for binding in query
|
||||
if AgentSchedulerDbMixin.is_eligible_agent(active,
|
||||
binding.dhcp_agent)]
|
||||
|
||||
def add_network_to_dhcp_agent(self, context, id, network_id):
|
||||
self._get_network(context, network_id)
|
||||
with context.session.begin(subtransactions=True):
|
||||
agent_db = self._get_agent(context, id)
|
||||
if (agent_db['agent_type'] != constants.AGENT_TYPE_DHCP or
|
||||
not agent_db['admin_state_up']):
|
||||
raise dhcpagentscheduler.InvalidDHCPAgent(id=id)
|
||||
dhcp_agents = self.get_dhcp_agents_hosting_networks(
|
||||
context, [network_id])
|
||||
for dhcp_agent in dhcp_agents:
|
||||
if id == dhcp_agent.id:
|
||||
raise dhcpagentscheduler.NetworkHostedByDHCPAgent(
|
||||
network_id=network_id, agent_id=id)
|
||||
binding = NetworkDhcpAgentBinding()
|
||||
binding.dhcp_agent_id = id
|
||||
binding.network_id = network_id
|
||||
context.session.add(binding)
|
||||
dhcp_notifier = self.agent_notifiers.get(constants.AGENT_TYPE_DHCP)
|
||||
if dhcp_notifier:
|
||||
dhcp_notifier.network_added_to_agent(
|
||||
context, network_id, agent_db.host)
|
||||
|
||||
def remove_network_from_dhcp_agent(self, context, id, network_id):
|
||||
agent = self._get_agent(context, id)
|
||||
with context.session.begin(subtransactions=True):
|
||||
try:
|
||||
query = context.session.query(NetworkDhcpAgentBinding)
|
||||
binding = query.filter(
|
||||
NetworkDhcpAgentBinding.network_id == network_id,
|
||||
NetworkDhcpAgentBinding.dhcp_agent_id == id).one()
|
||||
except exc.NoResultFound:
|
||||
raise dhcpagentscheduler.NetworkNotHostedByDhcpAgent(
|
||||
network_id=network_id, agent_id=id)
|
||||
|
||||
# reserve the port, so the ip is reused on a subsequent add
|
||||
device_id = utils.get_dhcp_agent_device_id(network_id,
|
||||
agent['host'])
|
||||
filters = dict(device_id=[device_id])
|
||||
ports = self.get_ports(context, filters=filters)
|
||||
for port in ports:
|
||||
port['device_id'] = constants.DEVICE_ID_RESERVED_DHCP_PORT
|
||||
self.update_port(context, port['id'], dict(port=port))
|
||||
|
||||
context.session.delete(binding)
|
||||
dhcp_notifier = self.agent_notifiers.get(constants.AGENT_TYPE_DHCP)
|
||||
if dhcp_notifier:
|
||||
dhcp_notifier.network_removed_from_agent(
|
||||
context, network_id, agent.host)
|
||||
|
||||
def list_networks_on_dhcp_agent(self, context, id):
|
||||
query = context.session.query(NetworkDhcpAgentBinding.network_id)
|
||||
query = query.filter(NetworkDhcpAgentBinding.dhcp_agent_id == id)
|
||||
|
||||
net_ids = [item[0] for item in query]
|
||||
if net_ids:
|
||||
return {'networks':
|
||||
self.get_networks(context, filters={'id': net_ids})}
|
||||
else:
|
||||
return {'networks': []}
|
||||
|
||||
def list_active_networks_on_active_dhcp_agent(self, context, host):
|
||||
try:
|
||||
agent = self._get_agent_by_type_and_host(
|
||||
context, constants.AGENT_TYPE_DHCP, host)
|
||||
except ext_agent.AgentNotFoundByTypeHost:
|
||||
LOG.debug("DHCP Agent not found on host %s", host)
|
||||
return []
|
||||
|
||||
if not agent.admin_state_up:
|
||||
return []
|
||||
query = context.session.query(NetworkDhcpAgentBinding.network_id)
|
||||
query = query.filter(NetworkDhcpAgentBinding.dhcp_agent_id == agent.id)
|
||||
|
||||
net_ids = [item[0] for item in query]
|
||||
if net_ids:
|
||||
return self.get_networks(
|
||||
context,
|
||||
filters={'id': net_ids, 'admin_state_up': [True]}
|
||||
)
|
||||
else:
|
||||
return []
|
||||
|
||||
def list_dhcp_agents_hosting_network(self, context, network_id):
|
||||
dhcp_agents = self.get_dhcp_agents_hosting_networks(
|
||||
context, [network_id])
|
||||
agent_ids = [dhcp_agent.id for dhcp_agent in dhcp_agents]
|
||||
if agent_ids:
|
||||
return {
|
||||
'agents': self.get_agents(context, filters={'id': agent_ids})}
|
||||
else:
|
||||
return {'agents': []}
|
||||
|
||||
def schedule_network(self, context, created_network):
|
||||
if self.network_scheduler:
|
||||
return self.network_scheduler.schedule(
|
||||
self, context, created_network)
|
||||
|
||||
def auto_schedule_networks(self, context, host):
|
||||
if self.network_scheduler:
|
||||
self.network_scheduler.auto_schedule_networks(self, context, host)
|
|
@ -1,147 +0,0 @@
|
|||
# Copyright 2013 VMware, Inc. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import model_base
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import allowedaddresspairs as addr_pair
|
||||
|
||||
|
||||
class AllowedAddressPair(model_base.BASEV2):
|
||||
port_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey('ports.id', ondelete="CASCADE"),
|
||||
primary_key=True)
|
||||
mac_address = sa.Column(sa.String(32), nullable=False, primary_key=True)
|
||||
ip_address = sa.Column(sa.String(64), nullable=False, primary_key=True)
|
||||
|
||||
port = orm.relationship(
|
||||
models_v2.Port,
|
||||
backref=orm.backref("allowed_address_pairs",
|
||||
lazy="joined", cascade="delete"))
|
||||
|
||||
|
||||
class AllowedAddressPairsMixin(object):
|
||||
"""Mixin class for allowed address pairs."""
|
||||
|
||||
def _process_create_allowed_address_pairs(self, context, port,
|
||||
allowed_address_pairs):
|
||||
if not attr.is_attr_set(allowed_address_pairs):
|
||||
return []
|
||||
with context.session.begin(subtransactions=True):
|
||||
for address_pair in allowed_address_pairs:
|
||||
# use port.mac_address if no mac address in address pair
|
||||
if 'mac_address' not in address_pair:
|
||||
address_pair['mac_address'] = port['mac_address']
|
||||
db_pair = AllowedAddressPair(
|
||||
port_id=port['id'],
|
||||
mac_address=address_pair['mac_address'],
|
||||
ip_address=address_pair['ip_address'])
|
||||
context.session.add(db_pair)
|
||||
|
||||
return allowed_address_pairs
|
||||
|
||||
def get_allowed_address_pairs(self, context, port_id):
|
||||
pairs = (context.session.query(AllowedAddressPair).
|
||||
filter_by(port_id=port_id))
|
||||
return [self._make_allowed_address_pairs_dict(pair)
|
||||
for pair in pairs]
|
||||
|
||||
def _extend_port_dict_allowed_address_pairs(self, port_res, port_db):
|
||||
# If port_db is provided, allowed address pairs will be accessed via
|
||||
# sqlalchemy models. As they're loaded together with ports this
|
||||
# will not cause an extra query.
|
||||
allowed_address_pairs = [
|
||||
self._make_allowed_address_pairs_dict(address_pair) for
|
||||
address_pair in port_db.allowed_address_pairs]
|
||||
port_res[addr_pair.ADDRESS_PAIRS] = allowed_address_pairs
|
||||
return port_res
|
||||
|
||||
# Register dict extend functions for ports
|
||||
db_base_plugin_v2.NeutronDbPluginV2.register_dict_extend_funcs(
|
||||
attr.PORTS, ['_extend_port_dict_allowed_address_pairs'])
|
||||
|
||||
def _delete_allowed_address_pairs(self, context, id):
|
||||
query = self._model_query(context, AllowedAddressPair)
|
||||
with context.session.begin(subtransactions=True):
|
||||
query.filter(AllowedAddressPair.port_id == id).delete()
|
||||
|
||||
def _make_allowed_address_pairs_dict(self, allowed_address_pairs,
|
||||
fields=None):
|
||||
res = {'mac_address': allowed_address_pairs['mac_address'],
|
||||
'ip_address': allowed_address_pairs['ip_address']}
|
||||
return self._fields(res, fields)
|
||||
|
||||
def _has_address_pairs(self, port):
|
||||
return (attr.is_attr_set(port['port'][addr_pair.ADDRESS_PAIRS])
|
||||
and port['port'][addr_pair.ADDRESS_PAIRS] != [])
|
||||
|
||||
def _check_update_has_allowed_address_pairs(self, port):
|
||||
"""Determine if request has an allowed address pair.
|
||||
|
||||
Return True if the port parameter has a non-empty
|
||||
'allowed_address_pairs' attribute. Otherwise returns False.
|
||||
"""
|
||||
return (addr_pair.ADDRESS_PAIRS in port['port'] and
|
||||
self._has_address_pairs(port))
|
||||
|
||||
def _check_update_deletes_allowed_address_pairs(self, port):
|
||||
"""Determine if request deletes address pair.
|
||||
|
||||
Return True if port has as a allowed address pair and its value
|
||||
is either [] or not is_attr_set, otherwise return False
|
||||
"""
|
||||
return (addr_pair.ADDRESS_PAIRS in port['port'] and
|
||||
not self._has_address_pairs(port))
|
||||
|
||||
def is_address_pairs_attribute_updated(self, port, update_attrs):
|
||||
"""Check if the address pairs attribute is being updated.
|
||||
|
||||
Returns True if there is an update. This can be used to decide
|
||||
if a port update notification should be sent to agents or third
|
||||
party controllers.
|
||||
"""
|
||||
|
||||
new_pairs = update_attrs.get(addr_pair.ADDRESS_PAIRS)
|
||||
if new_pairs is None:
|
||||
return False
|
||||
old_pairs = port.get(addr_pair.ADDRESS_PAIRS)
|
||||
|
||||
# Missing or unchanged address pairs in attributes mean no update
|
||||
return new_pairs != old_pairs
|
||||
|
||||
def update_address_pairs_on_port(self, context, port_id, port,
|
||||
original_port, updated_port):
|
||||
"""Update allowed address pairs on port.
|
||||
|
||||
Returns True if an update notification is required. Notification
|
||||
is not done here because other changes on the port may need
|
||||
notification. This method is expected to be called within
|
||||
a transaction.
|
||||
"""
|
||||
new_pairs = port['port'].get(addr_pair.ADDRESS_PAIRS)
|
||||
|
||||
if self.is_address_pairs_attribute_updated(original_port,
|
||||
port['port']):
|
||||
updated_port[addr_pair.ADDRESS_PAIRS] = new_pairs
|
||||
self._delete_allowed_address_pairs(context, port_id)
|
||||
self._process_create_allowed_address_pairs(
|
||||
context, updated_port, new_pairs)
|
||||
return True
|
||||
|
||||
return False
|
|
@ -1,287 +0,0 @@
|
|||
# Copyright (c) 2012 OpenStack Foundation.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import constants
|
||||
from neutron.common import exceptions as n_exc
|
||||
from neutron.common import utils
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager
|
||||
from neutron.openstack.common.db import exception as db_exc
|
||||
from neutron.openstack.common import excutils
|
||||
from neutron.openstack.common import log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DhcpRpcCallbackMixin(object):
|
||||
"""A mix-in that enable DHCP agent support in plugin implementations."""
|
||||
|
||||
def _get_active_networks(self, context, **kwargs):
|
||||
"""Retrieve and return a list of the active networks."""
|
||||
host = kwargs.get('host')
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
if utils.is_extension_supported(
|
||||
plugin, constants.DHCP_AGENT_SCHEDULER_EXT_ALIAS):
|
||||
if cfg.CONF.network_auto_schedule:
|
||||
plugin.auto_schedule_networks(context, host)
|
||||
nets = plugin.list_active_networks_on_active_dhcp_agent(
|
||||
context, host)
|
||||
else:
|
||||
filters = dict(admin_state_up=[True])
|
||||
nets = plugin.get_networks(context, filters=filters)
|
||||
return nets
|
||||
|
||||
def _port_action(self, plugin, context, port, action):
|
||||
"""Perform port operations taking care of concurrency issues."""
|
||||
try:
|
||||
if action == 'create_port':
|
||||
return plugin.create_port(context, port)
|
||||
elif action == 'update_port':
|
||||
return plugin.update_port(context, port['id'], port['port'])
|
||||
else:
|
||||
msg = _('Unrecognized action')
|
||||
raise n_exc.Invalid(message=msg)
|
||||
except (db_exc.DBError, n_exc.NetworkNotFound,
|
||||
n_exc.SubnetNotFound, n_exc.IpAddressGenerationFailure) as e:
|
||||
with excutils.save_and_reraise_exception(reraise=False) as ctxt:
|
||||
if isinstance(e, n_exc.IpAddressGenerationFailure):
|
||||
# Check if the subnet still exists and if it does not,
|
||||
# this is the reason why the ip address generation failed.
|
||||
# In any other unlikely event re-raise
|
||||
try:
|
||||
subnet_id = port['port']['fixed_ips'][0]['subnet_id']
|
||||
plugin.get_subnet(context, subnet_id)
|
||||
except n_exc.SubnetNotFound:
|
||||
pass
|
||||
else:
|
||||
ctxt.reraise = True
|
||||
net_id = port['port']['network_id']
|
||||
LOG.warn(_("Action %(action)s for network %(net_id)s "
|
||||
"could not complete successfully: %(reason)s")
|
||||
% {"action": action, "net_id": net_id, 'reason': e})
|
||||
|
||||
def get_active_networks(self, context, **kwargs):
|
||||
"""Retrieve and return a list of the active network ids."""
|
||||
# NOTE(arosen): This method is no longer used by the DHCP agent but is
|
||||
# left so that neutron-dhcp-agents will still continue to work if
|
||||
# neutron-server is upgraded and not the agent.
|
||||
host = kwargs.get('host')
|
||||
LOG.debug(_('get_active_networks requested from %s'), host)
|
||||
nets = self._get_active_networks(context, **kwargs)
|
||||
return [net['id'] for net in nets]
|
||||
|
||||
def get_active_networks_info(self, context, **kwargs):
|
||||
"""Returns all the networks/subnets/ports in system."""
|
||||
host = kwargs.get('host')
|
||||
LOG.debug(_('get_active_networks_info from %s'), host)
|
||||
networks = self._get_active_networks(context, **kwargs)
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
filters = {'network_id': [network['id'] for network in networks]}
|
||||
ports = plugin.get_ports(context, filters=filters)
|
||||
filters['enable_dhcp'] = [True]
|
||||
subnets = plugin.get_subnets(context, filters=filters)
|
||||
|
||||
for network in networks:
|
||||
network['subnets'] = [subnet for subnet in subnets
|
||||
if subnet['network_id'] == network['id']]
|
||||
network['ports'] = [port for port in ports
|
||||
if port['network_id'] == network['id']]
|
||||
|
||||
return networks
|
||||
|
||||
def get_network_info(self, context, **kwargs):
|
||||
"""Retrieve and return a extended information about a network."""
|
||||
network_id = kwargs.get('network_id')
|
||||
host = kwargs.get('host')
|
||||
LOG.debug(_('Network %(network_id)s requested from '
|
||||
'%(host)s'), {'network_id': network_id,
|
||||
'host': host})
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
try:
|
||||
network = plugin.get_network(context, network_id)
|
||||
except n_exc.NetworkNotFound:
|
||||
LOG.warn(_("Network %s could not be found, it might have "
|
||||
"been deleted concurrently."), network_id)
|
||||
return
|
||||
filters = dict(network_id=[network_id])
|
||||
network['subnets'] = plugin.get_subnets(context, filters=filters)
|
||||
network['ports'] = plugin.get_ports(context, filters=filters)
|
||||
return network
|
||||
|
||||
def get_dhcp_port(self, context, **kwargs):
|
||||
"""Allocate a DHCP port for the host and return port information.
|
||||
|
||||
This method will re-use an existing port if one already exists. When a
|
||||
port is re-used, the fixed_ip allocation will be updated to the current
|
||||
network state. If an expected failure occurs, a None port is returned.
|
||||
|
||||
"""
|
||||
host = kwargs.get('host')
|
||||
network_id = kwargs.get('network_id')
|
||||
device_id = kwargs.get('device_id')
|
||||
# There could be more than one dhcp server per network, so create
|
||||
# a device id that combines host and network ids
|
||||
|
||||
LOG.debug(_('Port %(device_id)s for %(network_id)s requested from '
|
||||
'%(host)s'), {'device_id': device_id,
|
||||
'network_id': network_id,
|
||||
'host': host})
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
retval = None
|
||||
|
||||
filters = dict(network_id=[network_id])
|
||||
subnets = dict([(s['id'], s) for s in
|
||||
plugin.get_subnets(context, filters=filters)])
|
||||
|
||||
dhcp_enabled_subnet_ids = [s['id'] for s in
|
||||
subnets.values() if s['enable_dhcp']]
|
||||
|
||||
try:
|
||||
filters = dict(network_id=[network_id], device_id=[device_id])
|
||||
ports = plugin.get_ports(context, filters=filters)
|
||||
if ports:
|
||||
# Ensure that fixed_ips cover all dhcp_enabled subnets.
|
||||
port = ports[0]
|
||||
for fixed_ip in port['fixed_ips']:
|
||||
if fixed_ip['subnet_id'] in dhcp_enabled_subnet_ids:
|
||||
dhcp_enabled_subnet_ids.remove(fixed_ip['subnet_id'])
|
||||
port['fixed_ips'].extend(
|
||||
[dict(subnet_id=s) for s in dhcp_enabled_subnet_ids])
|
||||
|
||||
retval = plugin.update_port(context, port['id'],
|
||||
dict(port=port))
|
||||
|
||||
except n_exc.NotFound as e:
|
||||
LOG.warning(e)
|
||||
|
||||
if retval is None:
|
||||
# No previous port exists, so create a new one.
|
||||
LOG.debug(_('DHCP port %(device_id)s on network %(network_id)s '
|
||||
'does not exist on %(host)s'),
|
||||
{'device_id': device_id,
|
||||
'network_id': network_id,
|
||||
'host': host})
|
||||
try:
|
||||
network = plugin.get_network(context, network_id)
|
||||
except n_exc.NetworkNotFound:
|
||||
LOG.warn(_("Network %s could not be found, it might have "
|
||||
"been deleted concurrently."), network_id)
|
||||
return
|
||||
|
||||
port_dict = dict(
|
||||
admin_state_up=True,
|
||||
device_id=device_id,
|
||||
network_id=network_id,
|
||||
tenant_id=network['tenant_id'],
|
||||
mac_address=attributes.ATTR_NOT_SPECIFIED,
|
||||
name='',
|
||||
device_owner=constants.DEVICE_OWNER_DHCP,
|
||||
fixed_ips=[dict(subnet_id=s) for s in dhcp_enabled_subnet_ids])
|
||||
|
||||
retval = self._port_action(plugin, context, {'port': port_dict},
|
||||
'create_port')
|
||||
if not retval:
|
||||
return
|
||||
|
||||
# Convert subnet_id to subnet dict
|
||||
for fixed_ip in retval['fixed_ips']:
|
||||
subnet_id = fixed_ip.pop('subnet_id')
|
||||
fixed_ip['subnet'] = subnets[subnet_id]
|
||||
|
||||
return retval
|
||||
|
||||
def release_dhcp_port(self, context, **kwargs):
|
||||
"""Release the port currently being used by a DHCP agent."""
|
||||
host = kwargs.get('host')
|
||||
network_id = kwargs.get('network_id')
|
||||
device_id = kwargs.get('device_id')
|
||||
|
||||
LOG.debug(_('DHCP port deletion for %(network_id)s request from '
|
||||
'%(host)s'),
|
||||
{'network_id': network_id, 'host': host})
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
plugin.delete_ports_by_device_id(context, device_id, network_id)
|
||||
|
||||
def release_port_fixed_ip(self, context, **kwargs):
|
||||
"""Release the fixed_ip associated the subnet on a port."""
|
||||
host = kwargs.get('host')
|
||||
network_id = kwargs.get('network_id')
|
||||
device_id = kwargs.get('device_id')
|
||||
subnet_id = kwargs.get('subnet_id')
|
||||
|
||||
LOG.debug(_('DHCP port remove fixed_ip for %(subnet_id)s request '
|
||||
'from %(host)s'),
|
||||
{'subnet_id': subnet_id, 'host': host})
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
filters = dict(network_id=[network_id], device_id=[device_id])
|
||||
ports = plugin.get_ports(context, filters=filters)
|
||||
|
||||
if ports:
|
||||
port = ports[0]
|
||||
|
||||
fixed_ips = port.get('fixed_ips', [])
|
||||
for i in range(len(fixed_ips)):
|
||||
if fixed_ips[i]['subnet_id'] == subnet_id:
|
||||
del fixed_ips[i]
|
||||
break
|
||||
plugin.update_port(context, port['id'], dict(port=port))
|
||||
|
||||
def update_lease_expiration(self, context, **kwargs):
|
||||
"""Release the fixed_ip associated the subnet on a port."""
|
||||
# NOTE(arosen): This method is no longer used by the DHCP agent but is
|
||||
# left so that neutron-dhcp-agents will still continue to work if
|
||||
# neutron-server is upgraded and not the agent.
|
||||
host = kwargs.get('host')
|
||||
|
||||
LOG.warning(_('Updating lease expiration is now deprecated. Issued '
|
||||
'from host %s.'), host)
|
||||
|
||||
def create_dhcp_port(self, context, **kwargs):
|
||||
"""Create and return dhcp port information.
|
||||
|
||||
If an expected failure occurs, a None port is returned.
|
||||
|
||||
"""
|
||||
host = kwargs.get('host')
|
||||
port = kwargs.get('port')
|
||||
LOG.debug(_('Create dhcp port %(port)s '
|
||||
'from %(host)s.'),
|
||||
{'port': port,
|
||||
'host': host})
|
||||
|
||||
port['port']['device_owner'] = constants.DEVICE_OWNER_DHCP
|
||||
port['port'][portbindings.HOST_ID] = host
|
||||
if 'mac_address' not in port['port']:
|
||||
port['port']['mac_address'] = attributes.ATTR_NOT_SPECIFIED
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
return self._port_action(plugin, context, port, 'create_port')
|
||||
|
||||
def update_dhcp_port(self, context, **kwargs):
|
||||
"""Update the dhcp port."""
|
||||
host = kwargs.get('host')
|
||||
port_id = kwargs.get('port_id')
|
||||
port = kwargs.get('port')
|
||||
LOG.debug(_('Update dhcp port %(port)s '
|
||||
'from %(host)s.'),
|
||||
{'port': port,
|
||||
'host': host})
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
return self._port_action(plugin, context,
|
||||
{'id': port_id, 'port': port},
|
||||
'update_port')
|
|
@ -1,163 +0,0 @@
|
|||
# Copyright (c) 2013 OpenStack Foundation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
from sqlalchemy.orm import exc
|
||||
from sqlalchemy.sql import expression as expr
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import constants as l3_constants
|
||||
from neutron.common import exceptions as n_exc
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import model_base
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import external_net
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as service_constants
|
||||
|
||||
|
||||
DEVICE_OWNER_ROUTER_GW = l3_constants.DEVICE_OWNER_ROUTER_GW
|
||||
|
||||
|
||||
class ExternalNetwork(model_base.BASEV2):
|
||||
network_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey('networks.id', ondelete="CASCADE"),
|
||||
primary_key=True)
|
||||
|
||||
# Add a relationship to the Network model in order to instruct
|
||||
# SQLAlchemy to eagerly load this association
|
||||
network = orm.relationship(
|
||||
models_v2.Network,
|
||||
backref=orm.backref("external", lazy='joined',
|
||||
uselist=False, cascade='delete'))
|
||||
|
||||
|
||||
class External_net_db_mixin(object):
|
||||
"""Mixin class to add external network methods to db_base_plugin_v2."""
|
||||
|
||||
def _network_model_hook(self, context, original_model, query):
|
||||
query = query.outerjoin(ExternalNetwork,
|
||||
(original_model.id ==
|
||||
ExternalNetwork.network_id))
|
||||
return query
|
||||
|
||||
def _network_filter_hook(self, context, original_model, conditions):
|
||||
if conditions is not None and not hasattr(conditions, '__iter__'):
|
||||
conditions = (conditions, )
|
||||
# Apply the external network filter only in non-admin context
|
||||
if not context.is_admin and hasattr(original_model, 'tenant_id'):
|
||||
conditions = expr.or_(ExternalNetwork.network_id != expr.null(),
|
||||
*conditions)
|
||||
return conditions
|
||||
|
||||
def _network_result_filter_hook(self, query, filters):
|
||||
vals = filters and filters.get(external_net.EXTERNAL, [])
|
||||
if not vals:
|
||||
return query
|
||||
if vals[0]:
|
||||
return query.filter((ExternalNetwork.network_id != expr.null()))
|
||||
return query.filter((ExternalNetwork.network_id == expr.null()))
|
||||
|
||||
# TODO(salvatore-orlando): Perform this operation without explicitly
|
||||
# referring to db_base_plugin_v2, as plugins that do not extend from it
|
||||
# might exist in the future
|
||||
db_base_plugin_v2.NeutronDbPluginV2.register_model_query_hook(
|
||||
models_v2.Network,
|
||||
"external_net",
|
||||
'_network_model_hook',
|
||||
'_network_filter_hook',
|
||||
'_network_result_filter_hook')
|
||||
|
||||
def _network_is_external(self, context, net_id):
|
||||
try:
|
||||
context.session.query(ExternalNetwork).filter_by(
|
||||
network_id=net_id).one()
|
||||
return True
|
||||
except exc.NoResultFound:
|
||||
return False
|
||||
|
||||
def _extend_network_dict_l3(self, network_res, network_db):
|
||||
# Comparing with None for converting uuid into bool
|
||||
network_res[external_net.EXTERNAL] = network_db.external is not None
|
||||
return network_res
|
||||
|
||||
# Register dict extend functions for networks
|
||||
db_base_plugin_v2.NeutronDbPluginV2.register_dict_extend_funcs(
|
||||
attributes.NETWORKS, ['_extend_network_dict_l3'])
|
||||
|
||||
def _process_l3_create(self, context, net_data, req_data):
|
||||
external = req_data.get(external_net.EXTERNAL)
|
||||
external_set = attributes.is_attr_set(external)
|
||||
|
||||
if not external_set:
|
||||
return
|
||||
|
||||
if external:
|
||||
# expects to be called within a plugin's session
|
||||
context.session.add(ExternalNetwork(network_id=net_data['id']))
|
||||
net_data[external_net.EXTERNAL] = external
|
||||
|
||||
def _process_l3_update(self, context, net_data, req_data):
|
||||
|
||||
new_value = req_data.get(external_net.EXTERNAL)
|
||||
net_id = net_data['id']
|
||||
if not attributes.is_attr_set(new_value):
|
||||
return
|
||||
|
||||
if net_data.get(external_net.EXTERNAL) == new_value:
|
||||
return
|
||||
|
||||
if new_value:
|
||||
context.session.add(ExternalNetwork(network_id=net_id))
|
||||
net_data[external_net.EXTERNAL] = True
|
||||
else:
|
||||
# must make sure we do not have any external gateway ports
|
||||
# (and thus, possible floating IPs) on this network before
|
||||
# allow it to be update to external=False
|
||||
port = context.session.query(models_v2.Port).filter_by(
|
||||
device_owner=DEVICE_OWNER_ROUTER_GW,
|
||||
network_id=net_data['id']).first()
|
||||
if port:
|
||||
raise external_net.ExternalNetworkInUse(net_id=net_id)
|
||||
|
||||
context.session.query(ExternalNetwork).filter_by(
|
||||
network_id=net_id).delete()
|
||||
net_data[external_net.EXTERNAL] = False
|
||||
|
||||
def _process_l3_delete(self, context, network_id):
|
||||
l3plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
if l3plugin:
|
||||
l3plugin.delete_disassociated_floatingips(context, network_id)
|
||||
|
||||
def _filter_nets_l3(self, context, nets, filters):
|
||||
vals = filters and filters.get(external_net.EXTERNAL, [])
|
||||
if not vals:
|
||||
return nets
|
||||
|
||||
ext_nets = set(en['network_id']
|
||||
for en in context.session.query(ExternalNetwork))
|
||||
if vals[0]:
|
||||
return [n for n in nets if n['id'] in ext_nets]
|
||||
else:
|
||||
return [n for n in nets if n['id'] not in ext_nets]
|
||||
|
||||
def get_external_network_id(self, context):
|
||||
nets = self.get_networks(context, {external_net.EXTERNAL: [True]})
|
||||
if len(nets) > 1:
|
||||
raise n_exc.TooManyExternalNetworks()
|
||||
else:
|
||||
return nets[0]['id'] if nets else None
|
|
@ -1,127 +0,0 @@
|
|||
# Copyright (c) 2013 OpenStack Foundation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# @author: Don Kehn, dekehn@gmail.com
|
||||
#
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import model_base
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import extra_dhcp_opt as edo_ext
|
||||
from neutron.openstack.common import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ExtraDhcpOpt(model_base.BASEV2, models_v2.HasId):
|
||||
"""Represent a generic concept of extra options associated to a port.
|
||||
|
||||
Each port may have none to many dhcp opts associated to it that can
|
||||
define specifically different or extra options to DHCP clients.
|
||||
These will be written to the <network_id>/opts files, and each option's
|
||||
tag will be referenced in the <network_id>/host file.
|
||||
"""
|
||||
port_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey('ports.id', ondelete="CASCADE"),
|
||||
nullable=False)
|
||||
opt_name = sa.Column(sa.String(64), nullable=False)
|
||||
opt_value = sa.Column(sa.String(255), nullable=False)
|
||||
__table_args__ = (sa.UniqueConstraint('port_id',
|
||||
'opt_name',
|
||||
name='uidx_portid_optname'),
|
||||
model_base.BASEV2.__table_args__,)
|
||||
|
||||
# Add a relationship to the Port model in order to instruct SQLAlchemy to
|
||||
# eagerly load extra_dhcp_opts bindings
|
||||
ports = orm.relationship(
|
||||
models_v2.Port,
|
||||
backref=orm.backref("dhcp_opts", lazy='joined', cascade='delete'))
|
||||
|
||||
|
||||
class ExtraDhcpOptMixin(object):
|
||||
"""Mixin class to add extra options to the DHCP opts file
|
||||
and associate them to a port.
|
||||
"""
|
||||
def _process_port_create_extra_dhcp_opts(self, context, port,
|
||||
extra_dhcp_opts):
|
||||
if not extra_dhcp_opts:
|
||||
return port
|
||||
with context.session.begin(subtransactions=True):
|
||||
for dopt in extra_dhcp_opts:
|
||||
if dopt['opt_value']:
|
||||
db = ExtraDhcpOpt(
|
||||
port_id=port['id'],
|
||||
opt_name=dopt['opt_name'],
|
||||
opt_value=dopt['opt_value'])
|
||||
context.session.add(db)
|
||||
return self._extend_port_extra_dhcp_opts_dict(context, port)
|
||||
|
||||
def _extend_port_extra_dhcp_opts_dict(self, context, port):
|
||||
port[edo_ext.EXTRADHCPOPTS] = self._get_port_extra_dhcp_opts_binding(
|
||||
context, port['id'])
|
||||
|
||||
def _get_port_extra_dhcp_opts_binding(self, context, port_id):
|
||||
query = self._model_query(context, ExtraDhcpOpt)
|
||||
binding = query.filter(ExtraDhcpOpt.port_id == port_id)
|
||||
return [{'opt_name': r.opt_name, 'opt_value': r.opt_value}
|
||||
for r in binding]
|
||||
|
||||
def _update_extra_dhcp_opts_on_port(self, context, id, port,
|
||||
updated_port=None):
|
||||
# It is not necessary to update in a transaction, because
|
||||
# its called from within one from ovs_neutron_plugin.
|
||||
dopts = port['port'].get(edo_ext.EXTRADHCPOPTS)
|
||||
|
||||
if dopts:
|
||||
opt_db = self._model_query(
|
||||
context, ExtraDhcpOpt).filter_by(port_id=id).all()
|
||||
# if there are currently no dhcp_options associated to
|
||||
# this port, Then just insert the new ones and be done.
|
||||
with context.session.begin(subtransactions=True):
|
||||
for upd_rec in dopts:
|
||||
for opt in opt_db:
|
||||
if opt['opt_name'] == upd_rec['opt_name']:
|
||||
# to handle deleting of a opt from the port.
|
||||
if upd_rec['opt_value'] is None:
|
||||
context.session.delete(opt)
|
||||
elif opt['opt_value'] != upd_rec['opt_value']:
|
||||
opt.update(
|
||||
{'opt_value': upd_rec['opt_value']})
|
||||
break
|
||||
else:
|
||||
if upd_rec['opt_value'] is not None:
|
||||
db = ExtraDhcpOpt(
|
||||
port_id=id,
|
||||
opt_name=upd_rec['opt_name'],
|
||||
opt_value=upd_rec['opt_value'])
|
||||
context.session.add(db)
|
||||
|
||||
if updated_port:
|
||||
edolist = self._get_port_extra_dhcp_opts_binding(context, id)
|
||||
updated_port[edo_ext.EXTRADHCPOPTS] = edolist
|
||||
|
||||
return bool(dopts)
|
||||
|
||||
def _extend_port_dict_extra_dhcp_opt(self, res, port):
|
||||
res[edo_ext.EXTRADHCPOPTS] = [{'opt_name': dho.opt_name,
|
||||
'opt_value': dho.opt_value}
|
||||
for dho in port.dhcp_opts]
|
||||
return res
|
||||
|
||||
db_base_plugin_v2.NeutronDbPluginV2.register_dict_extend_funcs(
|
||||
attributes.PORTS, ['_extend_port_dict_extra_dhcp_opt'])
|
|
@ -1,185 +0,0 @@
|
|||
# Copyright 2013, Nachi Ueno, NTT MCL, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import netaddr
|
||||
from oslo.config import cfg
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
||||
from neutron.common import utils
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import l3_db
|
||||
from neutron.db import model_base
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import extraroute
|
||||
from neutron.extensions import l3
|
||||
from neutron.openstack.common import log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
extra_route_opts = [
|
||||
#TODO(nati): use quota framework when it support quota for attributes
|
||||
cfg.IntOpt('max_routes', default=30,
|
||||
help=_("Maximum number of routes")),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(extra_route_opts)
|
||||
|
||||
|
||||
class RouterRoute(model_base.BASEV2, models_v2.Route):
|
||||
router_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey('routers.id',
|
||||
ondelete="CASCADE"),
|
||||
primary_key=True)
|
||||
|
||||
router = orm.relationship(l3_db.Router,
|
||||
backref=orm.backref("route_list",
|
||||
lazy='joined',
|
||||
cascade='delete'))
|
||||
|
||||
|
||||
class ExtraRoute_db_mixin(l3_db.L3_NAT_db_mixin):
|
||||
"""Mixin class to support extra route configuration on router."""
|
||||
|
||||
def _extend_router_dict_extraroute(self, router_res, router_db):
|
||||
router_res['routes'] = (ExtraRoute_db_mixin.
|
||||
_make_extra_route_list(
|
||||
router_db['route_list']
|
||||
))
|
||||
|
||||
db_base_plugin_v2.NeutronDbPluginV2.register_dict_extend_funcs(
|
||||
l3.ROUTERS, ['_extend_router_dict_extraroute'])
|
||||
|
||||
def update_router(self, context, id, router):
|
||||
r = router['router']
|
||||
with context.session.begin(subtransactions=True):
|
||||
#check if route exists and have permission to access
|
||||
router_db = self._get_router(context, id)
|
||||
if 'routes' in r:
|
||||
self._update_extra_routes(context, router_db, r['routes'])
|
||||
routes = self._get_extra_routes_by_router_id(context, id)
|
||||
router_updated = super(ExtraRoute_db_mixin, self).update_router(
|
||||
context, id, router)
|
||||
router_updated['routes'] = routes
|
||||
|
||||
return router_updated
|
||||
|
||||
def _get_subnets_by_cidr(self, context, cidr):
|
||||
query_subnets = context.session.query(models_v2.Subnet)
|
||||
return query_subnets.filter_by(cidr=cidr).all()
|
||||
|
||||
def _validate_routes_nexthop(self, cidrs, ips, routes, nexthop):
|
||||
#Note(nati): Nexthop should be connected,
|
||||
# so we need to check
|
||||
# nexthop belongs to one of cidrs of the router ports
|
||||
if not netaddr.all_matching_cidrs(nexthop, cidrs):
|
||||
raise extraroute.InvalidRoutes(
|
||||
routes=routes,
|
||||
reason=_('the nexthop is not connected with router'))
|
||||
#Note(nati) nexthop should not be same as fixed_ips
|
||||
if nexthop in ips:
|
||||
raise extraroute.InvalidRoutes(
|
||||
routes=routes,
|
||||
reason=_('the nexthop is used by router'))
|
||||
|
||||
def _validate_routes(self, context,
|
||||
router_id, routes):
|
||||
if len(routes) > cfg.CONF.max_routes:
|
||||
raise extraroute.RoutesExhausted(
|
||||
router_id=router_id,
|
||||
quota=cfg.CONF.max_routes)
|
||||
|
||||
filters = {'device_id': [router_id]}
|
||||
ports = self._core_plugin.get_ports(context, filters)
|
||||
cidrs = []
|
||||
ips = []
|
||||
for port in ports:
|
||||
for ip in port['fixed_ips']:
|
||||
cidrs.append(self._core_plugin._get_subnet(
|
||||
context, ip['subnet_id'])['cidr'])
|
||||
ips.append(ip['ip_address'])
|
||||
for route in routes:
|
||||
self._validate_routes_nexthop(
|
||||
cidrs, ips, routes, route['nexthop'])
|
||||
|
||||
def _update_extra_routes(self, context, router, routes):
|
||||
self._validate_routes(context, router['id'],
|
||||
routes)
|
||||
old_routes, routes_dict = self._get_extra_routes_dict_by_router_id(
|
||||
context, router['id'])
|
||||
added, removed = utils.diff_list_of_dict(old_routes,
|
||||
routes)
|
||||
LOG.debug(_('Added routes are %s'), added)
|
||||
for route in added:
|
||||
router_routes = RouterRoute(
|
||||
router_id=router['id'],
|
||||
destination=route['destination'],
|
||||
nexthop=route['nexthop'])
|
||||
context.session.add(router_routes)
|
||||
|
||||
LOG.debug(_('Removed routes are %s'), removed)
|
||||
for route in removed:
|
||||
context.session.delete(
|
||||
routes_dict[(route['destination'], route['nexthop'])])
|
||||
|
||||
@staticmethod
|
||||
def _make_extra_route_list(extra_routes):
|
||||
return [{'destination': route['destination'],
|
||||
'nexthop': route['nexthop']}
|
||||
for route in extra_routes]
|
||||
|
||||
def _get_extra_routes_by_router_id(self, context, id):
|
||||
query = context.session.query(RouterRoute)
|
||||
query = query.filter_by(router_id=id)
|
||||
return self._make_extra_route_list(query)
|
||||
|
||||
def _get_extra_routes_dict_by_router_id(self, context, id):
|
||||
query = context.session.query(RouterRoute)
|
||||
query = query.filter_by(router_id=id)
|
||||
routes = []
|
||||
routes_dict = {}
|
||||
for route in query:
|
||||
routes.append({'destination': route['destination'],
|
||||
'nexthop': route['nexthop']})
|
||||
routes_dict[(route['destination'], route['nexthop'])] = route
|
||||
return routes, routes_dict
|
||||
|
||||
def get_router(self, context, id, fields=None):
|
||||
with context.session.begin(subtransactions=True):
|
||||
router = super(ExtraRoute_db_mixin, self).get_router(
|
||||
context, id, fields)
|
||||
return router
|
||||
|
||||
def get_routers(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
with context.session.begin(subtransactions=True):
|
||||
routers = super(ExtraRoute_db_mixin, self).get_routers(
|
||||
context, filters, fields, sorts=sorts, limit=limit,
|
||||
marker=marker, page_reverse=page_reverse)
|
||||
return routers
|
||||
|
||||
def _confirm_router_interface_not_in_use(self, context, router_id,
|
||||
subnet_id):
|
||||
super(ExtraRoute_db_mixin, self)._confirm_router_interface_not_in_use(
|
||||
context, router_id, subnet_id)
|
||||
subnet_db = self._core_plugin._get_subnet(context, subnet_id)
|
||||
subnet_cidr = netaddr.IPNetwork(subnet_db['cidr'])
|
||||
extra_routes = self._get_extra_routes_by_router_id(context, router_id)
|
||||
for route in extra_routes:
|
||||
if netaddr.all_matching_cidrs(route['nexthop'], [subnet_cidr]):
|
||||
raise extraroute.RouterInterfaceInUseByRoute(
|
||||
router_id=router_id, subnet_id=subnet_id)
|
|
@ -1,16 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
|
@ -1,481 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 Big Switch Networks, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# @author: Sumit Naiksatam, sumitnaiksatam@gmail.com, Big Switch Networks, Inc.
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.ext.orderinglist import ordering_list
|
||||
from sqlalchemy import orm
|
||||
from sqlalchemy.orm import exc
|
||||
|
||||
from neutron.db import db_base_plugin_v2 as base_db
|
||||
from neutron.db import model_base
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import firewall
|
||||
from neutron import manager
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.openstack.common import uuidutils
|
||||
from neutron.plugins.common import constants as const
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FirewallRule(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
||||
"""Represents a Firewall rule."""
|
||||
__tablename__ = 'firewall_rules'
|
||||
name = sa.Column(sa.String(255))
|
||||
description = sa.Column(sa.String(1024))
|
||||
firewall_policy_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey('firewall_policies.id'),
|
||||
nullable=True)
|
||||
shared = sa.Column(sa.Boolean)
|
||||
protocol = sa.Column(sa.String(40))
|
||||
ip_version = sa.Column(sa.Integer, nullable=False)
|
||||
source_ip_address = sa.Column(sa.String(46))
|
||||
destination_ip_address = sa.Column(sa.String(46))
|
||||
source_port_range_min = sa.Column(sa.Integer)
|
||||
source_port_range_max = sa.Column(sa.Integer)
|
||||
destination_port_range_min = sa.Column(sa.Integer)
|
||||
destination_port_range_max = sa.Column(sa.Integer)
|
||||
action = sa.Column(sa.Enum('allow', 'deny', name='firewallrules_action'))
|
||||
enabled = sa.Column(sa.Boolean)
|
||||
position = sa.Column(sa.Integer)
|
||||
|
||||
|
||||
class Firewall(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
||||
"""Represents a Firewall resource."""
|
||||
__tablename__ = 'firewalls'
|
||||
name = sa.Column(sa.String(255))
|
||||
description = sa.Column(sa.String(1024))
|
||||
shared = sa.Column(sa.Boolean)
|
||||
admin_state_up = sa.Column(sa.Boolean)
|
||||
status = sa.Column(sa.String(16))
|
||||
firewall_policy_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey('firewall_policies.id'),
|
||||
nullable=True)
|
||||
|
||||
|
||||
class FirewallPolicy(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
||||
"""Represents a Firewall Policy resource."""
|
||||
__tablename__ = 'firewall_policies'
|
||||
name = sa.Column(sa.String(255))
|
||||
description = sa.Column(sa.String(1024))
|
||||
shared = sa.Column(sa.Boolean)
|
||||
firewall_rules = orm.relationship(
|
||||
FirewallRule,
|
||||
backref=orm.backref('firewall_policies', cascade='all, delete'),
|
||||
order_by='FirewallRule.position',
|
||||
collection_class=ordering_list('position', count_from=1))
|
||||
audited = sa.Column(sa.Boolean)
|
||||
firewalls = orm.relationship(Firewall, backref='firewall_policies')
|
||||
|
||||
|
||||
class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin):
|
||||
"""Mixin class for Firewall DB implementation."""
|
||||
|
||||
@property
|
||||
def _core_plugin(self):
|
||||
return manager.NeutronManager.get_plugin()
|
||||
|
||||
def _get_firewall(self, context, id):
|
||||
try:
|
||||
return self._get_by_id(context, Firewall, id)
|
||||
except exc.NoResultFound:
|
||||
raise firewall.FirewallNotFound(firewall_id=id)
|
||||
|
||||
def _get_firewall_policy(self, context, id):
|
||||
try:
|
||||
return self._get_by_id(context, FirewallPolicy, id)
|
||||
except exc.NoResultFound:
|
||||
raise firewall.FirewallPolicyNotFound(firewall_policy_id=id)
|
||||
|
||||
def _get_firewall_rule(self, context, id):
|
||||
try:
|
||||
return self._get_by_id(context, FirewallRule, id)
|
||||
except exc.NoResultFound:
|
||||
raise firewall.FirewallRuleNotFound(firewall_rule_id=id)
|
||||
|
||||
def _make_firewall_dict(self, fw, fields=None):
|
||||
res = {'id': fw['id'],
|
||||
'tenant_id': fw['tenant_id'],
|
||||
'name': fw['name'],
|
||||
'description': fw['description'],
|
||||
'shared': fw['shared'],
|
||||
'admin_state_up': fw['admin_state_up'],
|
||||
'status': fw['status'],
|
||||
'firewall_policy_id': fw['firewall_policy_id']}
|
||||
return self._fields(res, fields)
|
||||
|
||||
def _make_firewall_policy_dict(self, firewall_policy, fields=None):
|
||||
fw_rules = [rule['id'] for rule in firewall_policy['firewall_rules']]
|
||||
firewalls = [fw['id'] for fw in firewall_policy['firewalls']]
|
||||
res = {'id': firewall_policy['id'],
|
||||
'tenant_id': firewall_policy['tenant_id'],
|
||||
'name': firewall_policy['name'],
|
||||
'description': firewall_policy['description'],
|
||||
'shared': firewall_policy['shared'],
|
||||
'audited': firewall_policy['audited'],
|
||||
'firewall_rules': fw_rules,
|
||||
'firewall_list': firewalls}
|
||||
return self._fields(res, fields)
|
||||
|
||||
def _make_firewall_rule_dict(self, firewall_rule, fields=None):
|
||||
position = None
|
||||
# We return the position only if the firewall_rule is bound to a
|
||||
# firewall_policy.
|
||||
if firewall_rule['firewall_policy_id']:
|
||||
position = firewall_rule['position']
|
||||
src_port_range = self._get_port_range_from_min_max_ports(
|
||||
firewall_rule['source_port_range_min'],
|
||||
firewall_rule['source_port_range_max'])
|
||||
dst_port_range = self._get_port_range_from_min_max_ports(
|
||||
firewall_rule['destination_port_range_min'],
|
||||
firewall_rule['destination_port_range_max'])
|
||||
res = {'id': firewall_rule['id'],
|
||||
'tenant_id': firewall_rule['tenant_id'],
|
||||
'name': firewall_rule['name'],
|
||||
'description': firewall_rule['description'],
|
||||
'firewall_policy_id': firewall_rule['firewall_policy_id'],
|
||||
'shared': firewall_rule['shared'],
|
||||
'protocol': firewall_rule['protocol'],
|
||||
'ip_version': firewall_rule['ip_version'],
|
||||
'source_ip_address': firewall_rule['source_ip_address'],
|
||||
'destination_ip_address':
|
||||
firewall_rule['destination_ip_address'],
|
||||
'source_port': src_port_range,
|
||||
'destination_port': dst_port_range,
|
||||
'action': firewall_rule['action'],
|
||||
'position': position,
|
||||
'enabled': firewall_rule['enabled']}
|
||||
return self._fields(res, fields)
|
||||
|
||||
def _set_rules_for_policy(self, context, firewall_policy_db, rule_id_list):
|
||||
fwp_db = firewall_policy_db
|
||||
with context.session.begin(subtransactions=True):
|
||||
if not rule_id_list:
|
||||
fwp_db.firewall_rules = []
|
||||
fwp_db.audited = False
|
||||
return
|
||||
# We will first check if the new list of rules is valid
|
||||
filters = {'id': [r_id for r_id in rule_id_list]}
|
||||
rules_in_db = self._get_collection_query(context, FirewallRule,
|
||||
filters=filters)
|
||||
rules_dict = dict((fwr_db['id'], fwr_db) for fwr_db in rules_in_db)
|
||||
for fwrule_id in rule_id_list:
|
||||
if fwrule_id not in rules_dict:
|
||||
# If we find an invalid rule in the list we
|
||||
# do not perform the update since this breaks
|
||||
# the integrity of this list.
|
||||
raise firewall.FirewallRuleNotFound(firewall_rule_id=
|
||||
fwrule_id)
|
||||
elif rules_dict[fwrule_id]['firewall_policy_id']:
|
||||
if (rules_dict[fwrule_id]['firewall_policy_id'] !=
|
||||
fwp_db['id']):
|
||||
raise firewall.FirewallRuleInUse(
|
||||
firewall_rule_id=fwrule_id)
|
||||
# New list of rules is valid so we will first reset the existing
|
||||
# list and then add each rule in order.
|
||||
# Note that the list could be empty in which case we interpret
|
||||
# it as clearing existing rules.
|
||||
fwp_db.firewall_rules = []
|
||||
for fwrule_id in rule_id_list:
|
||||
fwp_db.firewall_rules.append(rules_dict[fwrule_id])
|
||||
fwp_db.firewall_rules.reorder()
|
||||
fwp_db.audited = False
|
||||
|
||||
def _process_rule_for_policy(self, context, firewall_policy_id,
|
||||
firewall_rule_db, position):
|
||||
with context.session.begin(subtransactions=True):
|
||||
fwp_query = context.session.query(
|
||||
FirewallPolicy).with_lockmode('update')
|
||||
fwp_db = fwp_query.filter_by(id=firewall_policy_id).one()
|
||||
if position:
|
||||
# Note that although position numbering starts at 1,
|
||||
# internal ordering of the list starts at 0, so we compensate.
|
||||
fwp_db.firewall_rules.insert(position - 1, firewall_rule_db)
|
||||
else:
|
||||
fwp_db.firewall_rules.remove(firewall_rule_db)
|
||||
fwp_db.firewall_rules.reorder()
|
||||
fwp_db.audited = False
|
||||
return self._make_firewall_policy_dict(fwp_db)
|
||||
|
||||
def _get_min_max_ports_from_range(self, port_range):
|
||||
if not port_range:
|
||||
return [None, None]
|
||||
min_port, sep, max_port = port_range.partition(":")
|
||||
if not max_port:
|
||||
max_port = min_port
|
||||
return [int(min_port), int(max_port)]
|
||||
|
||||
def _get_port_range_from_min_max_ports(self, min_port, max_port):
|
||||
if not min_port:
|
||||
return None
|
||||
if min_port == max_port:
|
||||
return str(min_port)
|
||||
else:
|
||||
return '%d:%d' % (min_port, max_port)
|
||||
|
||||
def _validate_fwr_protocol_parameters(self, fwr):
|
||||
protocol = fwr['protocol']
|
||||
if protocol not in (const.TCP, const.UDP):
|
||||
if fwr['source_port'] or fwr['destination_port']:
|
||||
raise firewall.FirewallRuleInvalidICMPParameter(
|
||||
param="Source, destination port")
|
||||
|
||||
def create_firewall(self, context, firewall):
|
||||
LOG.debug(_("create_firewall() called"))
|
||||
fw = firewall['firewall']
|
||||
tenant_id = self._get_tenant_id_for_create(context, fw)
|
||||
with context.session.begin(subtransactions=True):
|
||||
firewall_db = Firewall(id=uuidutils.generate_uuid(),
|
||||
tenant_id=tenant_id,
|
||||
name=fw['name'],
|
||||
description=fw['description'],
|
||||
firewall_policy_id=
|
||||
fw['firewall_policy_id'],
|
||||
admin_state_up=fw['admin_state_up'],
|
||||
status=const.PENDING_CREATE)
|
||||
context.session.add(firewall_db)
|
||||
return self._make_firewall_dict(firewall_db)
|
||||
|
||||
def update_firewall(self, context, id, firewall):
|
||||
LOG.debug(_("update_firewall() called"))
|
||||
fw = firewall['firewall']
|
||||
with context.session.begin(subtransactions=True):
|
||||
fw_query = context.session.query(
|
||||
Firewall).with_lockmode('update')
|
||||
firewall_db = fw_query.filter_by(id=id).one()
|
||||
firewall_db.update(fw)
|
||||
return self._make_firewall_dict(firewall_db)
|
||||
|
||||
def delete_firewall(self, context, id):
|
||||
LOG.debug(_("delete_firewall() called"))
|
||||
with context.session.begin(subtransactions=True):
|
||||
fw_query = context.session.query(
|
||||
Firewall).with_lockmode('update')
|
||||
firewall_db = fw_query.filter_by(id=id).one()
|
||||
# Note: Plugin should ensure that it's okay to delete if the
|
||||
# firewall is active
|
||||
context.session.delete(firewall_db)
|
||||
|
||||
def get_firewall(self, context, id, fields=None):
|
||||
LOG.debug(_("get_firewall() called"))
|
||||
fw = self._get_firewall(context, id)
|
||||
return self._make_firewall_dict(fw, fields)
|
||||
|
||||
def get_firewalls(self, context, filters=None, fields=None):
|
||||
LOG.debug(_("get_firewalls() called"))
|
||||
return self._get_collection(context, Firewall,
|
||||
self._make_firewall_dict,
|
||||
filters=filters, fields=fields)
|
||||
|
||||
def get_firewalls_count(self, context, filters=None):
|
||||
LOG.debug(_("get_firewalls_count() called"))
|
||||
return self._get_collection_count(context, Firewall,
|
||||
filters=filters)
|
||||
|
||||
def create_firewall_policy(self, context, firewall_policy):
|
||||
LOG.debug(_("create_firewall_policy() called"))
|
||||
fwp = firewall_policy['firewall_policy']
|
||||
tenant_id = self._get_tenant_id_for_create(context, fwp)
|
||||
with context.session.begin(subtransactions=True):
|
||||
fwp_db = FirewallPolicy(id=uuidutils.generate_uuid(),
|
||||
tenant_id=tenant_id,
|
||||
name=fwp['name'],
|
||||
description=fwp['description'],
|
||||
shared=fwp['shared'])
|
||||
context.session.add(fwp_db)
|
||||
self._set_rules_for_policy(context, fwp_db,
|
||||
fwp['firewall_rules'])
|
||||
fwp_db.audited = fwp['audited']
|
||||
return self._make_firewall_policy_dict(fwp_db)
|
||||
|
||||
def update_firewall_policy(self, context, id, firewall_policy):
|
||||
LOG.debug(_("update_firewall_policy() called"))
|
||||
fwp = firewall_policy['firewall_policy']
|
||||
with context.session.begin(subtransactions=True):
|
||||
fwp_db = self._get_firewall_policy(context, id)
|
||||
if 'firewall_rules' in fwp:
|
||||
self._set_rules_for_policy(context, fwp_db,
|
||||
fwp['firewall_rules'])
|
||||
del fwp['firewall_rules']
|
||||
fwp_db.update(fwp)
|
||||
return self._make_firewall_policy_dict(fwp_db)
|
||||
|
||||
def delete_firewall_policy(self, context, id):
|
||||
LOG.debug(_("delete_firewall_policy() called"))
|
||||
with context.session.begin(subtransactions=True):
|
||||
fwp = self._get_firewall_policy(context, id)
|
||||
# Ensure that the firewall_policy is not
|
||||
# being used
|
||||
qry = context.session.query(Firewall)
|
||||
if qry.filter_by(firewall_policy_id=id).first():
|
||||
raise firewall.FirewallPolicyInUse(firewall_policy_id=id)
|
||||
else:
|
||||
context.session.delete(fwp)
|
||||
|
||||
def get_firewall_policy(self, context, id, fields=None):
|
||||
LOG.debug(_("get_firewall_policy() called"))
|
||||
fwp = self._get_firewall_policy(context, id)
|
||||
return self._make_firewall_policy_dict(fwp, fields)
|
||||
|
||||
def get_firewall_policies(self, context, filters=None, fields=None):
|
||||
LOG.debug(_("get_firewall_policies() called"))
|
||||
return self._get_collection(context, FirewallPolicy,
|
||||
self._make_firewall_policy_dict,
|
||||
filters=filters, fields=fields)
|
||||
|
||||
def get_firewalls_policies_count(self, context, filters=None):
|
||||
LOG.debug(_("get_firewall_policies_count() called"))
|
||||
return self._get_collection_count(context, FirewallPolicy,
|
||||
filters=filters)
|
||||
|
||||
def create_firewall_rule(self, context, firewall_rule):
|
||||
LOG.debug(_("create_firewall_rule() called"))
|
||||
fwr = firewall_rule['firewall_rule']
|
||||
self._validate_fwr_protocol_parameters(fwr)
|
||||
tenant_id = self._get_tenant_id_for_create(context, fwr)
|
||||
src_port_min, src_port_max = self._get_min_max_ports_from_range(
|
||||
fwr['source_port'])
|
||||
dst_port_min, dst_port_max = self._get_min_max_ports_from_range(
|
||||
fwr['destination_port'])
|
||||
with context.session.begin(subtransactions=True):
|
||||
fwr_db = FirewallRule(id=uuidutils.generate_uuid(),
|
||||
tenant_id=tenant_id,
|
||||
name=fwr['name'],
|
||||
description=fwr['description'],
|
||||
shared=fwr['shared'],
|
||||
protocol=fwr['protocol'],
|
||||
ip_version=fwr['ip_version'],
|
||||
source_ip_address=fwr['source_ip_address'],
|
||||
destination_ip_address=
|
||||
fwr['destination_ip_address'],
|
||||
source_port_range_min=src_port_min,
|
||||
source_port_range_max=src_port_max,
|
||||
destination_port_range_min=dst_port_min,
|
||||
destination_port_range_max=dst_port_max,
|
||||
action=fwr['action'],
|
||||
enabled=fwr['enabled'])
|
||||
context.session.add(fwr_db)
|
||||
return self._make_firewall_rule_dict(fwr_db)
|
||||
|
||||
def update_firewall_rule(self, context, id, firewall_rule):
|
||||
LOG.debug(_("update_firewall_rule() called"))
|
||||
fwr = firewall_rule['firewall_rule']
|
||||
if 'source_port' in fwr:
|
||||
src_port_min, src_port_max = self._get_min_max_ports_from_range(
|
||||
fwr['source_port'])
|
||||
fwr['source_port_range_min'] = src_port_min
|
||||
fwr['source_port_range_max'] = src_port_max
|
||||
del fwr['source_port']
|
||||
if 'destination_port' in fwr:
|
||||
dst_port_min, dst_port_max = self._get_min_max_ports_from_range(
|
||||
fwr['destination_port'])
|
||||
fwr['destination_port_range_min'] = dst_port_min
|
||||
fwr['destination_port_range_max'] = dst_port_max
|
||||
del fwr['destination_port']
|
||||
with context.session.begin(subtransactions=True):
|
||||
fwr_db = self._get_firewall_rule(context, id)
|
||||
fwr_db.update(fwr)
|
||||
if fwr_db.firewall_policy_id:
|
||||
fwp_db = self._get_firewall_policy(context,
|
||||
fwr_db.firewall_policy_id)
|
||||
fwp_db.audited = False
|
||||
return self._make_firewall_rule_dict(fwr_db)
|
||||
|
||||
def delete_firewall_rule(self, context, id):
|
||||
LOG.debug(_("delete_firewall_rule() called"))
|
||||
with context.session.begin(subtransactions=True):
|
||||
fwr = self._get_firewall_rule(context, id)
|
||||
if fwr.firewall_policy_id:
|
||||
raise firewall.FirewallRuleInUse(firewall_rule_id=id)
|
||||
context.session.delete(fwr)
|
||||
|
||||
def get_firewall_rule(self, context, id, fields=None):
|
||||
LOG.debug(_("get_firewall_rule() called"))
|
||||
fwr = self._get_firewall_rule(context, id)
|
||||
return self._make_firewall_rule_dict(fwr, fields)
|
||||
|
||||
def get_firewall_rules(self, context, filters=None, fields=None):
|
||||
LOG.debug(_("get_firewall_rules() called"))
|
||||
return self._get_collection(context, FirewallRule,
|
||||
self._make_firewall_rule_dict,
|
||||
filters=filters, fields=fields)
|
||||
|
||||
def get_firewalls_rules_count(self, context, filters=None):
|
||||
LOG.debug(_("get_firewall_rules_count() called"))
|
||||
return self._get_collection_count(context, FirewallRule,
|
||||
filters=filters)
|
||||
|
||||
def _validate_insert_remove_rule_request(self, id, rule_info):
|
||||
if not rule_info or 'firewall_rule_id' not in rule_info:
|
||||
raise firewall.FirewallRuleInfoMissing()
|
||||
|
||||
def insert_rule(self, context, id, rule_info):
|
||||
LOG.debug(_("insert_rule() called"))
|
||||
self._validate_insert_remove_rule_request(id, rule_info)
|
||||
firewall_rule_id = rule_info['firewall_rule_id']
|
||||
insert_before = True
|
||||
ref_firewall_rule_id = None
|
||||
if not firewall_rule_id:
|
||||
raise firewall.FirewallRuleNotFound(firewall_rule_id=None)
|
||||
if 'insert_before' in rule_info:
|
||||
ref_firewall_rule_id = rule_info['insert_before']
|
||||
if not ref_firewall_rule_id and 'insert_after' in rule_info:
|
||||
# If insert_before is set, we will ignore insert_after.
|
||||
ref_firewall_rule_id = rule_info['insert_after']
|
||||
insert_before = False
|
||||
with context.session.begin(subtransactions=True):
|
||||
fwr_db = self._get_firewall_rule(context, firewall_rule_id)
|
||||
if fwr_db.firewall_policy_id:
|
||||
raise firewall.FirewallRuleInUse(firewall_rule_id=fwr_db['id'])
|
||||
if ref_firewall_rule_id:
|
||||
# If reference_firewall_rule_id is set, the new rule
|
||||
# is inserted depending on the value of insert_before.
|
||||
# If insert_before is set, the new rule is inserted before
|
||||
# reference_firewall_rule_id, and if it is not set the new
|
||||
# rule is inserted after reference_firewall_rule_id.
|
||||
ref_fwr_db = self._get_firewall_rule(
|
||||
context, ref_firewall_rule_id)
|
||||
if insert_before:
|
||||
position = ref_fwr_db.position
|
||||
else:
|
||||
position = ref_fwr_db.position + 1
|
||||
else:
|
||||
# If reference_firewall_rule_id is not set, it is assumed
|
||||
# that the new rule needs to be inserted at the top.
|
||||
# insert_before field is ignored.
|
||||
# So default insertion is always at the top.
|
||||
# Also note that position numbering starts at 1.
|
||||
position = 1
|
||||
return self._process_rule_for_policy(context, id, fwr_db,
|
||||
position)
|
||||
|
||||
def remove_rule(self, context, id, rule_info):
|
||||
LOG.debug(_("remove_rule() called"))
|
||||
self._validate_insert_remove_rule_request(id, rule_info)
|
||||
firewall_rule_id = rule_info['firewall_rule_id']
|
||||
if not firewall_rule_id:
|
||||
raise firewall.FirewallRuleNotFound(firewall_rule_id=None)
|
||||
with context.session.begin(subtransactions=True):
|
||||
fwr_db = self._get_firewall_rule(context, firewall_rule_id)
|
||||
if fwr_db.firewall_policy_id != id:
|
||||
raise firewall.FirewallRuleNotAssociatedWithPolicy(
|
||||
firewall_rule_id=fwr_db['id'],
|
||||
firewall_policy_id=id)
|
||||
return self._process_rule_for_policy(context, id, fwr_db, None)
|
|
@ -1,291 +0,0 @@
|
|||
# Copyright (c) 2013 OpenStack Foundation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslo.config import cfg
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy import orm
|
||||
from sqlalchemy.orm import exc
|
||||
from sqlalchemy.orm import joinedload
|
||||
|
||||
from neutron.common import constants
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import agentschedulers_db
|
||||
from neutron.db import model_base
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import l3agentscheduler
|
||||
|
||||
|
||||
L3_AGENTS_SCHEDULER_OPTS = [
|
||||
cfg.StrOpt('router_scheduler_driver',
|
||||
default='neutron.scheduler.l3_agent_scheduler.ChanceScheduler',
|
||||
help=_('Driver to use for scheduling '
|
||||
'router to a default L3 agent')),
|
||||
cfg.BoolOpt('router_auto_schedule', default=True,
|
||||
help=_('Allow auto scheduling of routers to L3 agent.')),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(L3_AGENTS_SCHEDULER_OPTS)
|
||||
|
||||
|
||||
class RouterL3AgentBinding(model_base.BASEV2, models_v2.HasId):
|
||||
"""Represents binding between neutron routers and L3 agents."""
|
||||
|
||||
router_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey("routers.id", ondelete='CASCADE'))
|
||||
l3_agent = orm.relation(agents_db.Agent)
|
||||
l3_agent_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey("agents.id",
|
||||
ondelete='CASCADE'))
|
||||
|
||||
|
||||
class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
||||
agentschedulers_db.AgentSchedulerDbMixin):
|
||||
"""Mixin class to add l3 agent scheduler extension to plugins
|
||||
using the l3 agent for routing.
|
||||
"""
|
||||
|
||||
router_scheduler = None
|
||||
|
||||
def add_router_to_l3_agent(self, context, agent_id, router_id):
|
||||
"""Add a l3 agent to host a router."""
|
||||
router = self.get_router(context, router_id)
|
||||
with context.session.begin(subtransactions=True):
|
||||
agent_db = self._get_agent(context, agent_id)
|
||||
if (agent_db['agent_type'] != constants.AGENT_TYPE_L3 or
|
||||
not agent_db['admin_state_up'] or
|
||||
not self.get_l3_agent_candidates(router, [agent_db])):
|
||||
raise l3agentscheduler.InvalidL3Agent(id=agent_id)
|
||||
query = context.session.query(RouterL3AgentBinding)
|
||||
try:
|
||||
binding = query.filter_by(router_id=router_id).one()
|
||||
|
||||
raise l3agentscheduler.RouterHostedByL3Agent(
|
||||
router_id=router_id,
|
||||
agent_id=binding.l3_agent_id)
|
||||
except exc.NoResultFound:
|
||||
pass
|
||||
|
||||
result = self.auto_schedule_routers(context,
|
||||
agent_db.host,
|
||||
[router_id])
|
||||
if not result:
|
||||
raise l3agentscheduler.RouterSchedulingFailed(
|
||||
router_id=router_id, agent_id=agent_id)
|
||||
|
||||
l3_notifier = self.agent_notifiers.get(constants.AGENT_TYPE_L3)
|
||||
if l3_notifier:
|
||||
l3_notifier.router_added_to_agent(
|
||||
context, [router_id], agent_db.host)
|
||||
|
||||
def remove_router_from_l3_agent(self, context, agent_id, router_id):
|
||||
"""Remove the router from l3 agent.
|
||||
|
||||
After removal, the router will be non-hosted until there is update
|
||||
which leads to re-schedule or be added to another agent manually.
|
||||
"""
|
||||
agent = self._get_agent(context, agent_id)
|
||||
self._unbind_router(context, router_id, agent_id)
|
||||
l3_notifier = self.agent_notifiers.get(constants.AGENT_TYPE_L3)
|
||||
if l3_notifier:
|
||||
l3_notifier.router_removed_from_agent(
|
||||
context, router_id, agent.host)
|
||||
|
||||
def _unbind_router(self, context, router_id, agent_id):
|
||||
with context.session.begin(subtransactions=True):
|
||||
query = context.session.query(RouterL3AgentBinding)
|
||||
query = query.filter(
|
||||
RouterL3AgentBinding.router_id == router_id,
|
||||
RouterL3AgentBinding.l3_agent_id == agent_id)
|
||||
try:
|
||||
binding = query.one()
|
||||
except exc.NoResultFound:
|
||||
raise l3agentscheduler.RouterNotHostedByL3Agent(
|
||||
router_id=router_id, agent_id=agent_id)
|
||||
context.session.delete(binding)
|
||||
|
||||
def reschedule_router(self, context, router_id, candidates=None):
|
||||
"""Reschedule router to a new l3 agent
|
||||
|
||||
Remove the router from the agent(s) currently hosting it and
|
||||
schedule it again
|
||||
"""
|
||||
cur_agents = self.list_l3_agents_hosting_router(
|
||||
context, router_id)['agents']
|
||||
with context.session.begin(subtransactions=True):
|
||||
for agent in cur_agents:
|
||||
self._unbind_router(context, router_id, agent['id'])
|
||||
|
||||
new_agent = self.schedule_router(context, router_id,
|
||||
candidates=candidates)
|
||||
if not new_agent:
|
||||
raise l3agentscheduler.RouterReschedulingFailed(
|
||||
router_id=router_id)
|
||||
|
||||
l3_notifier = self.agent_notifiers.get(constants.AGENT_TYPE_L3)
|
||||
if l3_notifier:
|
||||
for agent in cur_agents:
|
||||
l3_notifier.router_removed_from_agent(
|
||||
context, router_id, agent['host'])
|
||||
l3_notifier.router_added_to_agent(
|
||||
context, [router_id], new_agent.host)
|
||||
|
||||
def list_routers_on_l3_agent(self, context, agent_id):
|
||||
query = context.session.query(RouterL3AgentBinding.router_id)
|
||||
query = query.filter(RouterL3AgentBinding.l3_agent_id == agent_id)
|
||||
|
||||
router_ids = [item[0] for item in query]
|
||||
if router_ids:
|
||||
return {'routers':
|
||||
self.get_routers(context, filters={'id': router_ids})}
|
||||
else:
|
||||
return {'routers': []}
|
||||
|
||||
def list_active_sync_routers_on_active_l3_agent(
|
||||
self, context, host, router_ids):
|
||||
agent = self._get_agent_by_type_and_host(
|
||||
context, constants.AGENT_TYPE_L3, host)
|
||||
if not agent.admin_state_up:
|
||||
return []
|
||||
query = context.session.query(RouterL3AgentBinding.router_id)
|
||||
query = query.filter(
|
||||
RouterL3AgentBinding.l3_agent_id == agent.id)
|
||||
|
||||
if not router_ids:
|
||||
pass
|
||||
else:
|
||||
query = query.filter(
|
||||
RouterL3AgentBinding.router_id.in_(router_ids))
|
||||
router_ids = [item[0] for item in query]
|
||||
if router_ids:
|
||||
return self.get_sync_data(context, router_ids=router_ids,
|
||||
active=True)
|
||||
else:
|
||||
return []
|
||||
|
||||
def get_l3_agents_hosting_routers(self, context, router_ids,
|
||||
admin_state_up=None,
|
||||
active=None):
|
||||
if not router_ids:
|
||||
return []
|
||||
query = context.session.query(RouterL3AgentBinding)
|
||||
if len(router_ids) > 1:
|
||||
query = query.options(joinedload('l3_agent')).filter(
|
||||
RouterL3AgentBinding.router_id.in_(router_ids))
|
||||
else:
|
||||
query = query.options(joinedload('l3_agent')).filter(
|
||||
RouterL3AgentBinding.router_id == router_ids[0])
|
||||
if admin_state_up is not None:
|
||||
query = (query.filter(agents_db.Agent.admin_state_up ==
|
||||
admin_state_up))
|
||||
l3_agents = [binding.l3_agent for binding in query]
|
||||
if active is not None:
|
||||
l3_agents = [l3_agent for l3_agent in
|
||||
l3_agents if not
|
||||
agents_db.AgentDbMixin.is_agent_down(
|
||||
l3_agent['heartbeat_timestamp'])]
|
||||
return l3_agents
|
||||
|
||||
def _get_l3_bindings_hosting_routers(self, context, router_ids):
|
||||
if not router_ids:
|
||||
return []
|
||||
query = context.session.query(RouterL3AgentBinding)
|
||||
if len(router_ids) > 1:
|
||||
query = query.options(joinedload('l3_agent')).filter(
|
||||
RouterL3AgentBinding.router_id.in_(router_ids))
|
||||
else:
|
||||
query = query.options(joinedload('l3_agent')).filter(
|
||||
RouterL3AgentBinding.router_id == router_ids[0])
|
||||
return query.all()
|
||||
|
||||
def list_l3_agents_hosting_router(self, context, router_id):
|
||||
with context.session.begin(subtransactions=True):
|
||||
bindings = self._get_l3_bindings_hosting_routers(
|
||||
context, [router_id])
|
||||
results = []
|
||||
for binding in bindings:
|
||||
l3_agent_dict = self._make_agent_dict(binding.l3_agent)
|
||||
results.append(l3_agent_dict)
|
||||
if results:
|
||||
return {'agents': results}
|
||||
else:
|
||||
return {'agents': []}
|
||||
|
||||
def get_l3_agents(self, context, active=None, filters=None):
|
||||
query = context.session.query(agents_db.Agent)
|
||||
query = query.filter(
|
||||
agents_db.Agent.agent_type == constants.AGENT_TYPE_L3)
|
||||
if active is not None:
|
||||
query = (query.filter(agents_db.Agent.admin_state_up == active))
|
||||
if filters:
|
||||
for key, value in filters.iteritems():
|
||||
column = getattr(agents_db.Agent, key, None)
|
||||
if column:
|
||||
query = query.filter(column.in_(value))
|
||||
|
||||
return [l3_agent
|
||||
for l3_agent in query
|
||||
if agentschedulers_db.AgentSchedulerDbMixin.is_eligible_agent(
|
||||
active, l3_agent)]
|
||||
|
||||
def get_l3_agent_candidates(self, sync_router, l3_agents):
|
||||
"""Get the valid l3 agents for the router from a list of l3_agents."""
|
||||
candidates = []
|
||||
for l3_agent in l3_agents:
|
||||
if not l3_agent.admin_state_up:
|
||||
continue
|
||||
agent_conf = self.get_configuration_dict(l3_agent)
|
||||
router_id = agent_conf.get('router_id', None)
|
||||
use_namespaces = agent_conf.get('use_namespaces', True)
|
||||
handle_internal_only_routers = agent_conf.get(
|
||||
'handle_internal_only_routers', True)
|
||||
gateway_external_network_id = agent_conf.get(
|
||||
'gateway_external_network_id', None)
|
||||
if not use_namespaces and router_id != sync_router['id']:
|
||||
continue
|
||||
ex_net_id = (sync_router['external_gateway_info'] or {}).get(
|
||||
'network_id')
|
||||
if ((not ex_net_id and not handle_internal_only_routers) or
|
||||
(ex_net_id and gateway_external_network_id and
|
||||
ex_net_id != gateway_external_network_id)):
|
||||
continue
|
||||
candidates.append(l3_agent)
|
||||
return candidates
|
||||
|
||||
def auto_schedule_routers(self, context, host, router_ids):
|
||||
if self.router_scheduler:
|
||||
return self.router_scheduler.auto_schedule_routers(
|
||||
self, context, host, router_ids)
|
||||
|
||||
def schedule_router(self, context, router, candidates=None):
|
||||
if self.router_scheduler:
|
||||
return self.router_scheduler.schedule(
|
||||
self, context, router, candidates)
|
||||
|
||||
def schedule_routers(self, context, routers):
|
||||
"""Schedule the routers to l3 agents."""
|
||||
for router in routers:
|
||||
self.schedule_router(context, router)
|
||||
|
||||
def get_l3_agent_with_min_routers(self, context, agent_ids):
|
||||
"""Return l3 agent with the least number of routers."""
|
||||
query = context.session.query(
|
||||
agents_db.Agent,
|
||||
func.count(
|
||||
RouterL3AgentBinding.router_id
|
||||
).label('count')).outerjoin(RouterL3AgentBinding).group_by(
|
||||
RouterL3AgentBinding.l3_agent_id).order_by('count')
|
||||
res = query.filter(agents_db.Agent.id.in_(agent_ids)).first()
|
||||
return res[0]
|
1039
neutron/db/l3_db.py
1039
neutron/db/l3_db.py
File diff suppressed because it is too large
Load Diff
|
@ -1,73 +0,0 @@
|
|||
# Copyright 2013 VMware, Inc. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron.db import l3_db
|
||||
from neutron.extensions import l3
|
||||
from neutron.openstack.common import log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
EXTERNAL_GW_INFO = l3.EXTERNAL_GW_INFO
|
||||
|
||||
# Modify the Router Data Model adding the enable_snat attribute
|
||||
setattr(l3_db.Router, 'enable_snat',
|
||||
sa.Column(sa.Boolean, default=True, nullable=False))
|
||||
|
||||
|
||||
class L3_NAT_db_mixin(l3_db.L3_NAT_db_mixin):
|
||||
"""Mixin class to add configurable gateway modes."""
|
||||
|
||||
# Register dict extend functions for ports and networks
|
||||
db_base_plugin_v2.NeutronDbPluginV2.register_dict_extend_funcs(
|
||||
l3.ROUTERS, ['_extend_router_dict_gw_mode'])
|
||||
|
||||
def _extend_router_dict_gw_mode(self, router_res, router_db):
|
||||
if router_db.gw_port_id:
|
||||
nw_id = router_db.gw_port['network_id']
|
||||
router_res[EXTERNAL_GW_INFO] = {
|
||||
'network_id': nw_id,
|
||||
'enable_snat': router_db.enable_snat}
|
||||
|
||||
def _update_router_gw_info(self, context, router_id, info, router=None):
|
||||
# Load the router only if necessary
|
||||
if not router:
|
||||
router = self._get_router(context, router_id)
|
||||
# if enable_snat is not specified use the value
|
||||
# stored in the database (default:True)
|
||||
enable_snat = not info or info.get('enable_snat', router.enable_snat)
|
||||
with context.session.begin(subtransactions=True):
|
||||
router.enable_snat = enable_snat
|
||||
|
||||
# Calls superclass, pass router db object for avoiding re-loading
|
||||
super(L3_NAT_db_mixin, self)._update_router_gw_info(
|
||||
context, router_id, info, router=router)
|
||||
# Returning the router might come back useful if this
|
||||
# method is overriden in child classes
|
||||
return router
|
||||
|
||||
def _build_routers_list(self, routers, gw_ports):
|
||||
gw_port_id_gw_port_dict = {}
|
||||
for gw_port in gw_ports:
|
||||
gw_port_id_gw_port_dict[gw_port['id']] = gw_port
|
||||
for rtr in routers:
|
||||
gw_port_id = rtr['gw_port_id']
|
||||
if gw_port_id:
|
||||
rtr['gw_port'] = gw_port_id_gw_port_dict[gw_port_id]
|
||||
# Add enable_snat key
|
||||
rtr['enable_snat'] = rtr[EXTERNAL_GW_INFO]['enable_snat']
|
||||
return routers
|
|
@ -1,128 +0,0 @@
|
|||
# Copyright (c) 2012 OpenStack Foundation.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.common import constants
|
||||
from neutron.common import utils
|
||||
from neutron import context as neutron_context
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager
|
||||
from neutron.openstack.common import jsonutils
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.plugins.common import constants as plugin_constants
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class L3RpcCallbackMixin(object):
|
||||
"""A mix-in that enable L3 agent rpc support in plugin implementations."""
|
||||
|
||||
def sync_routers(self, context, **kwargs):
|
||||
"""Sync routers according to filters to a specific agent.
|
||||
|
||||
@param context: contain user information
|
||||
@param kwargs: host, router_ids
|
||||
@return: a list of routers
|
||||
with their interfaces and floating_ips
|
||||
"""
|
||||
router_ids = kwargs.get('router_ids')
|
||||
host = kwargs.get('host')
|
||||
context = neutron_context.get_admin_context()
|
||||
l3plugin = manager.NeutronManager.get_service_plugins()[
|
||||
plugin_constants.L3_ROUTER_NAT]
|
||||
if not l3plugin:
|
||||
routers = {}
|
||||
LOG.error(_('No plugin for L3 routing registered! Will reply '
|
||||
'to l3 agent with empty router dictionary.'))
|
||||
elif utils.is_extension_supported(
|
||||
l3plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
|
||||
if cfg.CONF.router_auto_schedule:
|
||||
l3plugin.auto_schedule_routers(context, host, router_ids)
|
||||
routers = l3plugin.list_active_sync_routers_on_active_l3_agent(
|
||||
context, host, router_ids)
|
||||
else:
|
||||
routers = l3plugin.get_sync_data(context, router_ids)
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
if utils.is_extension_supported(
|
||||
plugin, constants.PORT_BINDING_EXT_ALIAS):
|
||||
self._ensure_host_set_on_ports(context, plugin, host, routers)
|
||||
LOG.debug(_("Routers returned to l3 agent:\n %s"),
|
||||
jsonutils.dumps(routers, indent=5))
|
||||
return routers
|
||||
|
||||
def _ensure_host_set_on_ports(self, context, plugin, host, routers):
|
||||
for router in routers:
|
||||
LOG.debug(_("Checking router: %(id)s for host: %(host)s"),
|
||||
{'id': router['id'], 'host': host})
|
||||
self._ensure_host_set_on_port(context, plugin, host,
|
||||
router.get('gw_port'))
|
||||
for interface in router.get(constants.INTERFACE_KEY, []):
|
||||
self._ensure_host_set_on_port(context, plugin, host,
|
||||
interface)
|
||||
|
||||
def _ensure_host_set_on_port(self, context, plugin, host, port):
|
||||
if (port and
|
||||
(port.get(portbindings.HOST_ID) != host or
|
||||
port.get(portbindings.VIF_TYPE) ==
|
||||
portbindings.VIF_TYPE_BINDING_FAILED)):
|
||||
plugin.update_port(context, port['id'],
|
||||
{'port': {portbindings.HOST_ID: host}})
|
||||
|
||||
def get_external_network_id(self, context, **kwargs):
|
||||
"""Get one external network id for l3 agent.
|
||||
|
||||
l3 agent expects only on external network when it performs
|
||||
this query.
|
||||
"""
|
||||
context = neutron_context.get_admin_context()
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
net_id = plugin.get_external_network_id(context)
|
||||
LOG.debug(_("External network ID returned to l3 agent: %s"),
|
||||
net_id)
|
||||
return net_id
|
||||
|
||||
def update_floatingip_statuses(self, context, router_id, fip_statuses):
|
||||
"""Update operational status for a floating IP."""
|
||||
l3_plugin = manager.NeutronManager.get_service_plugins()[
|
||||
plugin_constants.L3_ROUTER_NAT]
|
||||
with context.session.begin(subtransactions=True):
|
||||
for (floatingip_id, status) in fip_statuses.iteritems():
|
||||
LOG.debug(_("New status for floating IP %(floatingip_id)s: "
|
||||
"%(status)s"), {'floatingip_id': floatingip_id,
|
||||
'status': status})
|
||||
try:
|
||||
l3_plugin.update_floatingip_status(context,
|
||||
floatingip_id,
|
||||
status)
|
||||
except l3.FloatingIPNotFound:
|
||||
LOG.debug(_("Floating IP: %s no longer present."),
|
||||
floatingip_id)
|
||||
# Find all floating IPs known to have been the given router
|
||||
# for which an update was not received. Set them DOWN mercilessly
|
||||
# This situation might occur for some asynchronous backends if
|
||||
# notifications were missed
|
||||
known_router_fips = l3_plugin.get_floatingips(
|
||||
context, {'last_known_router_id': [router_id]})
|
||||
# Consider only floating ips which were disassociated in the API
|
||||
# FIXME(salv-orlando): Filtering in code should be avoided.
|
||||
# the plugin should offer a way to specify a null filter
|
||||
fips_to_disable = (fip['id'] for fip in known_router_fips
|
||||
if not fip['router_id'])
|
||||
for fip_id in fips_to_disable:
|
||||
l3_plugin.update_floatingip_status(
|
||||
context, fip_id, constants.FLOATINGIP_STATUS_DOWN)
|
|
@ -1,15 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
|
@ -1,802 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation. All rights reserved
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
from sqlalchemy.orm import exc
|
||||
from sqlalchemy.orm import validates
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import exceptions as n_exc
|
||||
from neutron.db import db_base_plugin_v2 as base_db
|
||||
from neutron.db import model_base
|
||||
from neutron.db import models_v2
|
||||
from neutron.db import servicetype_db as st_db
|
||||
from neutron.extensions import loadbalancer
|
||||
from neutron import manager
|
||||
from neutron.openstack.common.db import exception
|
||||
from neutron.openstack.common import excutils
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.openstack.common import uuidutils
|
||||
from neutron.plugins.common import constants
|
||||
from neutron.services.loadbalancer import constants as lb_const
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SessionPersistence(model_base.BASEV2):
|
||||
|
||||
vip_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey("vips.id"),
|
||||
primary_key=True)
|
||||
type = sa.Column(sa.Enum("SOURCE_IP",
|
||||
"HTTP_COOKIE",
|
||||
"APP_COOKIE",
|
||||
name="sesssionpersistences_type"),
|
||||
nullable=False)
|
||||
cookie_name = sa.Column(sa.String(1024))
|
||||
|
||||
|
||||
class PoolStatistics(model_base.BASEV2):
|
||||
"""Represents pool statistics."""
|
||||
|
||||
pool_id = sa.Column(sa.String(36), sa.ForeignKey("pools.id"),
|
||||
primary_key=True)
|
||||
bytes_in = sa.Column(sa.BigInteger, nullable=False)
|
||||
bytes_out = sa.Column(sa.BigInteger, nullable=False)
|
||||
active_connections = sa.Column(sa.BigInteger, nullable=False)
|
||||
total_connections = sa.Column(sa.BigInteger, nullable=False)
|
||||
|
||||
@validates('bytes_in', 'bytes_out',
|
||||
'active_connections', 'total_connections')
|
||||
def validate_non_negative_int(self, key, value):
|
||||
if value < 0:
|
||||
data = {'key': key, 'value': value}
|
||||
raise ValueError(_('The %(key)s field can not have '
|
||||
'negative value. '
|
||||
'Current value is %(value)d.') % data)
|
||||
return value
|
||||
|
||||
|
||||
class Vip(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant,
|
||||
models_v2.HasStatusDescription):
|
||||
"""Represents a v2 neutron loadbalancer vip."""
|
||||
|
||||
name = sa.Column(sa.String(255))
|
||||
description = sa.Column(sa.String(255))
|
||||
port_id = sa.Column(sa.String(36), sa.ForeignKey('ports.id'))
|
||||
protocol_port = sa.Column(sa.Integer, nullable=False)
|
||||
protocol = sa.Column(sa.Enum("HTTP", "HTTPS", "TCP", name="lb_protocols"),
|
||||
nullable=False)
|
||||
pool_id = sa.Column(sa.String(36), nullable=False, unique=True)
|
||||
session_persistence = orm.relationship(SessionPersistence,
|
||||
uselist=False,
|
||||
backref="vips",
|
||||
cascade="all, delete-orphan")
|
||||
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
|
||||
connection_limit = sa.Column(sa.Integer)
|
||||
port = orm.relationship(models_v2.Port)
|
||||
|
||||
|
||||
class Member(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant,
|
||||
models_v2.HasStatusDescription):
|
||||
"""Represents a v2 neutron loadbalancer member."""
|
||||
|
||||
__table_args__ = (
|
||||
sa.schema.UniqueConstraint('pool_id', 'address', 'protocol_port',
|
||||
name='uniq_member0pool_id0address0port'),
|
||||
)
|
||||
pool_id = sa.Column(sa.String(36), sa.ForeignKey("pools.id"),
|
||||
nullable=False)
|
||||
address = sa.Column(sa.String(64), nullable=False)
|
||||
protocol_port = sa.Column(sa.Integer, nullable=False)
|
||||
weight = sa.Column(sa.Integer, nullable=False)
|
||||
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
|
||||
|
||||
|
||||
class Pool(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant,
|
||||
models_v2.HasStatusDescription):
|
||||
"""Represents a v2 neutron loadbalancer pool."""
|
||||
|
||||
vip_id = sa.Column(sa.String(36), sa.ForeignKey("vips.id"))
|
||||
name = sa.Column(sa.String(255))
|
||||
description = sa.Column(sa.String(255))
|
||||
subnet_id = sa.Column(sa.String(36), nullable=False)
|
||||
protocol = sa.Column(sa.Enum("HTTP", "HTTPS", "TCP", name="lb_protocols"),
|
||||
nullable=False)
|
||||
lb_method = sa.Column(sa.Enum("ROUND_ROBIN",
|
||||
"LEAST_CONNECTIONS",
|
||||
"SOURCE_IP",
|
||||
name="pools_lb_method"),
|
||||
nullable=False)
|
||||
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
|
||||
stats = orm.relationship(PoolStatistics,
|
||||
uselist=False,
|
||||
backref="pools",
|
||||
cascade="all, delete-orphan")
|
||||
members = orm.relationship(Member, backref="pools",
|
||||
cascade="all, delete-orphan")
|
||||
monitors = orm.relationship("PoolMonitorAssociation", backref="pools",
|
||||
cascade="all, delete-orphan")
|
||||
vip = orm.relationship(Vip, backref='pool')
|
||||
|
||||
provider = orm.relationship(
|
||||
st_db.ProviderResourceAssociation,
|
||||
uselist=False,
|
||||
lazy="joined",
|
||||
primaryjoin="Pool.id==ProviderResourceAssociation.resource_id",
|
||||
foreign_keys=[st_db.ProviderResourceAssociation.resource_id]
|
||||
)
|
||||
|
||||
|
||||
class HealthMonitor(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
||||
"""Represents a v2 neutron loadbalancer healthmonitor."""
|
||||
|
||||
type = sa.Column(sa.Enum("PING", "TCP", "HTTP", "HTTPS",
|
||||
name="healthmontiors_type"),
|
||||
nullable=False)
|
||||
delay = sa.Column(sa.Integer, nullable=False)
|
||||
timeout = sa.Column(sa.Integer, nullable=False)
|
||||
max_retries = sa.Column(sa.Integer, nullable=False)
|
||||
http_method = sa.Column(sa.String(16))
|
||||
url_path = sa.Column(sa.String(255))
|
||||
expected_codes = sa.Column(sa.String(64))
|
||||
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
|
||||
|
||||
pools = orm.relationship(
|
||||
"PoolMonitorAssociation", backref="healthmonitor",
|
||||
cascade="all", lazy="joined"
|
||||
)
|
||||
|
||||
|
||||
class PoolMonitorAssociation(model_base.BASEV2,
|
||||
models_v2.HasStatusDescription):
|
||||
"""Many-to-many association between pool and healthMonitor classes."""
|
||||
|
||||
pool_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey("pools.id"),
|
||||
primary_key=True)
|
||||
monitor_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey("healthmonitors.id"),
|
||||
primary_key=True)
|
||||
|
||||
|
||||
class LoadBalancerPluginDb(loadbalancer.LoadBalancerPluginBase,
|
||||
base_db.CommonDbMixin):
|
||||
"""Wraps loadbalancer with SQLAlchemy models.
|
||||
|
||||
A class that wraps the implementation of the Neutron loadbalancer
|
||||
plugin database access interface using SQLAlchemy models.
|
||||
"""
|
||||
|
||||
@property
|
||||
def _core_plugin(self):
|
||||
return manager.NeutronManager.get_plugin()
|
||||
|
||||
def update_status(self, context, model, id, status,
|
||||
status_description=None):
|
||||
with context.session.begin(subtransactions=True):
|
||||
if issubclass(model, Vip):
|
||||
try:
|
||||
v_db = (self._model_query(context, model).
|
||||
filter(model.id == id).
|
||||
options(orm.noload('port')).
|
||||
one())
|
||||
except exc.NoResultFound:
|
||||
raise loadbalancer.VipNotFound(vip_id=id)
|
||||
else:
|
||||
v_db = self._get_resource(context, model, id)
|
||||
if v_db.status != status:
|
||||
v_db.status = status
|
||||
# update status_description in two cases:
|
||||
# - new value is passed
|
||||
# - old value is not None (needs to be updated anyway)
|
||||
if status_description or v_db['status_description']:
|
||||
v_db.status_description = status_description
|
||||
|
||||
def _get_resource(self, context, model, id):
|
||||
try:
|
||||
r = self._get_by_id(context, model, id)
|
||||
except exc.NoResultFound:
|
||||
with excutils.save_and_reraise_exception(reraise=False) as ctx:
|
||||
if issubclass(model, Vip):
|
||||
raise loadbalancer.VipNotFound(vip_id=id)
|
||||
elif issubclass(model, Pool):
|
||||
raise loadbalancer.PoolNotFound(pool_id=id)
|
||||
elif issubclass(model, Member):
|
||||
raise loadbalancer.MemberNotFound(member_id=id)
|
||||
elif issubclass(model, HealthMonitor):
|
||||
raise loadbalancer.HealthMonitorNotFound(monitor_id=id)
|
||||
ctx.reraise = True
|
||||
return r
|
||||
|
||||
def assert_modification_allowed(self, obj):
|
||||
status = getattr(obj, 'status', None)
|
||||
|
||||
if status == constants.PENDING_DELETE:
|
||||
raise loadbalancer.StateInvalid(id=id, state=status)
|
||||
|
||||
########################################################
|
||||
# VIP DB access
|
||||
def _make_vip_dict(self, vip, fields=None):
|
||||
fixed_ip = (vip.port.fixed_ips or [{}])[0]
|
||||
|
||||
res = {'id': vip['id'],
|
||||
'tenant_id': vip['tenant_id'],
|
||||
'name': vip['name'],
|
||||
'description': vip['description'],
|
||||
'subnet_id': fixed_ip.get('subnet_id'),
|
||||
'address': fixed_ip.get('ip_address'),
|
||||
'port_id': vip['port_id'],
|
||||
'protocol_port': vip['protocol_port'],
|
||||
'protocol': vip['protocol'],
|
||||
'pool_id': vip['pool_id'],
|
||||
'session_persistence': None,
|
||||
'connection_limit': vip['connection_limit'],
|
||||
'admin_state_up': vip['admin_state_up'],
|
||||
'status': vip['status'],
|
||||
'status_description': vip['status_description']}
|
||||
|
||||
if vip['session_persistence']:
|
||||
s_p = {
|
||||
'type': vip['session_persistence']['type']
|
||||
}
|
||||
|
||||
if vip['session_persistence']['type'] == 'APP_COOKIE':
|
||||
s_p['cookie_name'] = vip['session_persistence']['cookie_name']
|
||||
|
||||
res['session_persistence'] = s_p
|
||||
|
||||
return self._fields(res, fields)
|
||||
|
||||
def _check_session_persistence_info(self, info):
|
||||
"""Performs sanity check on session persistence info.
|
||||
|
||||
:param info: Session persistence info
|
||||
"""
|
||||
if info['type'] == 'APP_COOKIE':
|
||||
if not info.get('cookie_name'):
|
||||
raise ValueError(_("'cookie_name' should be specified for this"
|
||||
" type of session persistence."))
|
||||
else:
|
||||
if 'cookie_name' in info:
|
||||
raise ValueError(_("'cookie_name' is not allowed for this type"
|
||||
" of session persistence"))
|
||||
|
||||
def _create_session_persistence_db(self, session_info, vip_id):
|
||||
self._check_session_persistence_info(session_info)
|
||||
|
||||
sesspersist_db = SessionPersistence(
|
||||
type=session_info['type'],
|
||||
cookie_name=session_info.get('cookie_name'),
|
||||
vip_id=vip_id)
|
||||
return sesspersist_db
|
||||
|
||||
def _update_vip_session_persistence(self, context, vip_id, info):
|
||||
self._check_session_persistence_info(info)
|
||||
|
||||
vip = self._get_resource(context, Vip, vip_id)
|
||||
|
||||
with context.session.begin(subtransactions=True):
|
||||
# Update sessionPersistence table
|
||||
sess_qry = context.session.query(SessionPersistence)
|
||||
sesspersist_db = sess_qry.filter_by(vip_id=vip_id).first()
|
||||
|
||||
# Insert a None cookie_info if it is not present to overwrite an
|
||||
# an existing value in the database.
|
||||
if 'cookie_name' not in info:
|
||||
info['cookie_name'] = None
|
||||
|
||||
if sesspersist_db:
|
||||
sesspersist_db.update(info)
|
||||
else:
|
||||
sesspersist_db = SessionPersistence(
|
||||
type=info['type'],
|
||||
cookie_name=info['cookie_name'],
|
||||
vip_id=vip_id)
|
||||
context.session.add(sesspersist_db)
|
||||
# Update vip table
|
||||
vip.session_persistence = sesspersist_db
|
||||
context.session.add(vip)
|
||||
|
||||
def _delete_session_persistence(self, context, vip_id):
|
||||
with context.session.begin(subtransactions=True):
|
||||
sess_qry = context.session.query(SessionPersistence)
|
||||
sess_qry.filter_by(vip_id=vip_id).delete()
|
||||
|
||||
def _create_port_for_vip(self, context, vip_db, subnet_id, ip_address):
|
||||
# resolve subnet and create port
|
||||
subnet = self._core_plugin.get_subnet(context, subnet_id)
|
||||
fixed_ip = {'subnet_id': subnet['id']}
|
||||
if ip_address and ip_address != attributes.ATTR_NOT_SPECIFIED:
|
||||
fixed_ip['ip_address'] = ip_address
|
||||
|
||||
port_data = {
|
||||
'tenant_id': vip_db.tenant_id,
|
||||
'name': 'vip-' + vip_db.id,
|
||||
'network_id': subnet['network_id'],
|
||||
'mac_address': attributes.ATTR_NOT_SPECIFIED,
|
||||
'admin_state_up': False,
|
||||
'device_id': '',
|
||||
'device_owner': '',
|
||||
'fixed_ips': [fixed_ip]
|
||||
}
|
||||
|
||||
port = self._core_plugin.create_port(context, {'port': port_data})
|
||||
vip_db.port_id = port['id']
|
||||
|
||||
def create_vip(self, context, vip):
|
||||
v = vip['vip']
|
||||
tenant_id = self._get_tenant_id_for_create(context, v)
|
||||
|
||||
with context.session.begin(subtransactions=True):
|
||||
if v['pool_id']:
|
||||
pool = self._get_resource(context, Pool, v['pool_id'])
|
||||
# validate that the pool has same tenant
|
||||
if pool['tenant_id'] != tenant_id:
|
||||
raise n_exc.NotAuthorized()
|
||||
# validate that the pool has same protocol
|
||||
if pool['protocol'] != v['protocol']:
|
||||
raise loadbalancer.ProtocolMismatch(
|
||||
vip_proto=v['protocol'],
|
||||
pool_proto=pool['protocol'])
|
||||
if pool['status'] == constants.PENDING_DELETE:
|
||||
raise loadbalancer.StateInvalid(state=pool['status'],
|
||||
id=pool['id'])
|
||||
else:
|
||||
pool = None
|
||||
|
||||
vip_db = Vip(id=uuidutils.generate_uuid(),
|
||||
tenant_id=tenant_id,
|
||||
name=v['name'],
|
||||
description=v['description'],
|
||||
port_id=None,
|
||||
protocol_port=v['protocol_port'],
|
||||
protocol=v['protocol'],
|
||||
pool_id=v['pool_id'],
|
||||
connection_limit=v['connection_limit'],
|
||||
admin_state_up=v['admin_state_up'],
|
||||
status=constants.PENDING_CREATE)
|
||||
|
||||
session_info = v['session_persistence']
|
||||
|
||||
if session_info:
|
||||
s_p = self._create_session_persistence_db(
|
||||
session_info,
|
||||
vip_db['id'])
|
||||
vip_db.session_persistence = s_p
|
||||
|
||||
try:
|
||||
context.session.add(vip_db)
|
||||
context.session.flush()
|
||||
except exception.DBDuplicateEntry:
|
||||
raise loadbalancer.VipExists(pool_id=v['pool_id'])
|
||||
|
||||
# create a port to reserve address for IPAM
|
||||
self._create_port_for_vip(
|
||||
context,
|
||||
vip_db,
|
||||
v['subnet_id'],
|
||||
v.get('address')
|
||||
)
|
||||
|
||||
if pool:
|
||||
pool['vip_id'] = vip_db['id']
|
||||
|
||||
return self._make_vip_dict(vip_db)
|
||||
|
||||
def update_vip(self, context, id, vip):
|
||||
v = vip['vip']
|
||||
|
||||
sess_persist = v.pop('session_persistence', None)
|
||||
with context.session.begin(subtransactions=True):
|
||||
vip_db = self._get_resource(context, Vip, id)
|
||||
|
||||
self.assert_modification_allowed(vip_db)
|
||||
|
||||
if sess_persist:
|
||||
self._update_vip_session_persistence(context, id, sess_persist)
|
||||
else:
|
||||
self._delete_session_persistence(context, id)
|
||||
|
||||
if v:
|
||||
try:
|
||||
# in case new pool already has a vip
|
||||
# update will raise integrity error at first query
|
||||
old_pool_id = vip_db['pool_id']
|
||||
vip_db.update(v)
|
||||
# If the pool_id is changed, we need to update
|
||||
# the associated pools
|
||||
if 'pool_id' in v:
|
||||
new_pool = self._get_resource(context, Pool,
|
||||
v['pool_id'])
|
||||
self.assert_modification_allowed(new_pool)
|
||||
|
||||
# check that the pool matches the tenant_id
|
||||
if new_pool['tenant_id'] != vip_db['tenant_id']:
|
||||
raise n_exc.NotAuthorized()
|
||||
# validate that the pool has same protocol
|
||||
if new_pool['protocol'] != vip_db['protocol']:
|
||||
raise loadbalancer.ProtocolMismatch(
|
||||
vip_proto=vip_db['protocol'],
|
||||
pool_proto=new_pool['protocol'])
|
||||
if new_pool['status'] == constants.PENDING_DELETE:
|
||||
raise loadbalancer.StateInvalid(
|
||||
state=new_pool['status'],
|
||||
id=new_pool['id'])
|
||||
|
||||
if old_pool_id:
|
||||
old_pool = self._get_resource(
|
||||
context,
|
||||
Pool,
|
||||
old_pool_id
|
||||
)
|
||||
old_pool['vip_id'] = None
|
||||
|
||||
new_pool['vip_id'] = vip_db['id']
|
||||
except exception.DBDuplicateEntry:
|
||||
raise loadbalancer.VipExists(pool_id=v['pool_id'])
|
||||
|
||||
return self._make_vip_dict(vip_db)
|
||||
|
||||
def delete_vip(self, context, id):
|
||||
with context.session.begin(subtransactions=True):
|
||||
vip = self._get_resource(context, Vip, id)
|
||||
qry = context.session.query(Pool)
|
||||
for pool in qry.filter_by(vip_id=id):
|
||||
pool.update({"vip_id": None})
|
||||
|
||||
context.session.delete(vip)
|
||||
if vip.port: # this is a Neutron port
|
||||
self._core_plugin.delete_port(context, vip.port.id)
|
||||
|
||||
def get_vip(self, context, id, fields=None):
|
||||
vip = self._get_resource(context, Vip, id)
|
||||
return self._make_vip_dict(vip, fields)
|
||||
|
||||
def get_vips(self, context, filters=None, fields=None):
|
||||
return self._get_collection(context, Vip,
|
||||
self._make_vip_dict,
|
||||
filters=filters, fields=fields)
|
||||
|
||||
########################################################
|
||||
# Pool DB access
|
||||
def _make_pool_dict(self, pool, fields=None):
|
||||
res = {'id': pool['id'],
|
||||
'tenant_id': pool['tenant_id'],
|
||||
'name': pool['name'],
|
||||
'description': pool['description'],
|
||||
'subnet_id': pool['subnet_id'],
|
||||
'protocol': pool['protocol'],
|
||||
'vip_id': pool['vip_id'],
|
||||
'lb_method': pool['lb_method'],
|
||||
'admin_state_up': pool['admin_state_up'],
|
||||
'status': pool['status'],
|
||||
'status_description': pool['status_description'],
|
||||
'provider': ''
|
||||
}
|
||||
|
||||
if pool.provider:
|
||||
res['provider'] = pool.provider.provider_name
|
||||
|
||||
# Get the associated members
|
||||
res['members'] = [member['id'] for member in pool['members']]
|
||||
|
||||
# Get the associated health_monitors
|
||||
res['health_monitors'] = [
|
||||
monitor['monitor_id'] for monitor in pool['monitors']]
|
||||
res['health_monitors_status'] = [
|
||||
{'monitor_id': monitor['monitor_id'],
|
||||
'status': monitor['status'],
|
||||
'status_description': monitor['status_description']}
|
||||
for monitor in pool['monitors']]
|
||||
return self._fields(res, fields)
|
||||
|
||||
def update_pool_stats(self, context, pool_id, data=None):
|
||||
"""Update a pool with new stats structure."""
|
||||
data = data or {}
|
||||
with context.session.begin(subtransactions=True):
|
||||
pool_db = self._get_resource(context, Pool, pool_id)
|
||||
self.assert_modification_allowed(pool_db)
|
||||
pool_db.stats = self._create_pool_stats(context, pool_id, data)
|
||||
|
||||
for member, stats in data.get('members', {}).items():
|
||||
stats_status = stats.get(lb_const.STATS_STATUS)
|
||||
if stats_status:
|
||||
self.update_status(context, Member, member, stats_status)
|
||||
|
||||
def _create_pool_stats(self, context, pool_id, data=None):
|
||||
# This is internal method to add pool statistics. It won't
|
||||
# be exposed to API
|
||||
if not data:
|
||||
data = {}
|
||||
stats_db = PoolStatistics(
|
||||
pool_id=pool_id,
|
||||
bytes_in=data.get(lb_const.STATS_IN_BYTES, 0),
|
||||
bytes_out=data.get(lb_const.STATS_OUT_BYTES, 0),
|
||||
active_connections=data.get(lb_const.STATS_ACTIVE_CONNECTIONS, 0),
|
||||
total_connections=data.get(lb_const.STATS_TOTAL_CONNECTIONS, 0)
|
||||
)
|
||||
return stats_db
|
||||
|
||||
def _delete_pool_stats(self, context, pool_id):
|
||||
# This is internal method to delete pool statistics. It won't
|
||||
# be exposed to API
|
||||
with context.session.begin(subtransactions=True):
|
||||
stats_qry = context.session.query(PoolStatistics)
|
||||
try:
|
||||
stats = stats_qry.filter_by(pool_id=pool_id).one()
|
||||
except exc.NoResultFound:
|
||||
raise loadbalancer.PoolStatsNotFound(pool_id=pool_id)
|
||||
context.session.delete(stats)
|
||||
|
||||
def create_pool(self, context, pool):
|
||||
v = pool['pool']
|
||||
|
||||
tenant_id = self._get_tenant_id_for_create(context, v)
|
||||
with context.session.begin(subtransactions=True):
|
||||
pool_db = Pool(id=uuidutils.generate_uuid(),
|
||||
tenant_id=tenant_id,
|
||||
name=v['name'],
|
||||
description=v['description'],
|
||||
subnet_id=v['subnet_id'],
|
||||
protocol=v['protocol'],
|
||||
lb_method=v['lb_method'],
|
||||
admin_state_up=v['admin_state_up'],
|
||||
status=constants.PENDING_CREATE)
|
||||
pool_db.stats = self._create_pool_stats(context, pool_db['id'])
|
||||
context.session.add(pool_db)
|
||||
|
||||
return self._make_pool_dict(pool_db)
|
||||
|
||||
def update_pool(self, context, id, pool):
|
||||
p = pool['pool']
|
||||
with context.session.begin(subtransactions=True):
|
||||
pool_db = self._get_resource(context, Pool, id)
|
||||
self.assert_modification_allowed(pool_db)
|
||||
if p:
|
||||
pool_db.update(p)
|
||||
|
||||
return self._make_pool_dict(pool_db)
|
||||
|
||||
def _ensure_pool_delete_conditions(self, context, pool_id):
|
||||
if context.session.query(Vip).filter_by(pool_id=pool_id).first():
|
||||
raise loadbalancer.PoolInUse(pool_id=pool_id)
|
||||
|
||||
def delete_pool(self, context, pool_id):
|
||||
# Check if the pool is in use
|
||||
self._ensure_pool_delete_conditions(context, pool_id)
|
||||
|
||||
with context.session.begin(subtransactions=True):
|
||||
self._delete_pool_stats(context, pool_id)
|
||||
pool_db = self._get_resource(context, Pool, pool_id)
|
||||
context.session.delete(pool_db)
|
||||
|
||||
def get_pool(self, context, id, fields=None):
|
||||
pool = self._get_resource(context, Pool, id)
|
||||
return self._make_pool_dict(pool, fields)
|
||||
|
||||
def get_pools(self, context, filters=None, fields=None):
|
||||
collection = self._model_query(context, Pool)
|
||||
collection = self._apply_filters_to_query(collection, Pool, filters)
|
||||
return [self._make_pool_dict(c, fields)
|
||||
for c in collection]
|
||||
|
||||
def stats(self, context, pool_id):
|
||||
with context.session.begin(subtransactions=True):
|
||||
pool = self._get_resource(context, Pool, pool_id)
|
||||
stats = pool['stats']
|
||||
|
||||
res = {lb_const.STATS_IN_BYTES: stats['bytes_in'],
|
||||
lb_const.STATS_OUT_BYTES: stats['bytes_out'],
|
||||
lb_const.STATS_ACTIVE_CONNECTIONS: stats['active_connections'],
|
||||
lb_const.STATS_TOTAL_CONNECTIONS: stats['total_connections']}
|
||||
return {'stats': res}
|
||||
|
||||
def create_pool_health_monitor(self, context, health_monitor, pool_id):
|
||||
monitor_id = health_monitor['health_monitor']['id']
|
||||
with context.session.begin(subtransactions=True):
|
||||
assoc_qry = context.session.query(PoolMonitorAssociation)
|
||||
assoc = assoc_qry.filter_by(pool_id=pool_id,
|
||||
monitor_id=monitor_id).first()
|
||||
if assoc:
|
||||
raise loadbalancer.PoolMonitorAssociationExists(
|
||||
monitor_id=monitor_id, pool_id=pool_id)
|
||||
|
||||
pool = self._get_resource(context, Pool, pool_id)
|
||||
|
||||
assoc = PoolMonitorAssociation(pool_id=pool_id,
|
||||
monitor_id=monitor_id,
|
||||
status=constants.PENDING_CREATE)
|
||||
pool.monitors.append(assoc)
|
||||
monitors = [monitor['monitor_id'] for monitor in pool['monitors']]
|
||||
|
||||
res = {"health_monitor": monitors}
|
||||
return res
|
||||
|
||||
def delete_pool_health_monitor(self, context, id, pool_id):
|
||||
with context.session.begin(subtransactions=True):
|
||||
assoc = self._get_pool_health_monitor(context, id, pool_id)
|
||||
pool = self._get_resource(context, Pool, pool_id)
|
||||
pool.monitors.remove(assoc)
|
||||
|
||||
def _get_pool_health_monitor(self, context, id, pool_id):
|
||||
try:
|
||||
assoc_qry = context.session.query(PoolMonitorAssociation)
|
||||
return assoc_qry.filter_by(monitor_id=id, pool_id=pool_id).one()
|
||||
except exc.NoResultFound:
|
||||
raise loadbalancer.PoolMonitorAssociationNotFound(
|
||||
monitor_id=id, pool_id=pool_id)
|
||||
|
||||
def get_pool_health_monitor(self, context, id, pool_id, fields=None):
|
||||
pool_hm = self._get_pool_health_monitor(context, id, pool_id)
|
||||
# need to add tenant_id for admin_or_owner policy check to pass
|
||||
hm = self.get_health_monitor(context, id)
|
||||
res = {'pool_id': pool_id,
|
||||
'monitor_id': id,
|
||||
'status': pool_hm['status'],
|
||||
'status_description': pool_hm['status_description'],
|
||||
'tenant_id': hm['tenant_id']}
|
||||
return self._fields(res, fields)
|
||||
|
||||
def update_pool_health_monitor(self, context, id, pool_id,
|
||||
status, status_description=None):
|
||||
with context.session.begin(subtransactions=True):
|
||||
assoc = self._get_pool_health_monitor(context, id, pool_id)
|
||||
self.assert_modification_allowed(assoc)
|
||||
assoc.status = status
|
||||
assoc.status_description = status_description
|
||||
|
||||
########################################################
|
||||
# Member DB access
|
||||
def _make_member_dict(self, member, fields=None):
|
||||
res = {'id': member['id'],
|
||||
'tenant_id': member['tenant_id'],
|
||||
'pool_id': member['pool_id'],
|
||||
'address': member['address'],
|
||||
'protocol_port': member['protocol_port'],
|
||||
'weight': member['weight'],
|
||||
'admin_state_up': member['admin_state_up'],
|
||||
'status': member['status'],
|
||||
'status_description': member['status_description']}
|
||||
|
||||
return self._fields(res, fields)
|
||||
|
||||
def create_member(self, context, member):
|
||||
v = member['member']
|
||||
tenant_id = self._get_tenant_id_for_create(context, v)
|
||||
|
||||
try:
|
||||
with context.session.begin(subtransactions=True):
|
||||
# ensuring that pool exists
|
||||
self._get_resource(context, Pool, v['pool_id'])
|
||||
member_db = Member(id=uuidutils.generate_uuid(),
|
||||
tenant_id=tenant_id,
|
||||
pool_id=v['pool_id'],
|
||||
address=v['address'],
|
||||
protocol_port=v['protocol_port'],
|
||||
weight=v['weight'],
|
||||
admin_state_up=v['admin_state_up'],
|
||||
status=constants.PENDING_CREATE)
|
||||
context.session.add(member_db)
|
||||
return self._make_member_dict(member_db)
|
||||
except exception.DBDuplicateEntry:
|
||||
raise loadbalancer.MemberExists(
|
||||
address=v['address'],
|
||||
port=v['protocol_port'],
|
||||
pool=v['pool_id'])
|
||||
|
||||
def update_member(self, context, id, member):
|
||||
v = member['member']
|
||||
try:
|
||||
with context.session.begin(subtransactions=True):
|
||||
member_db = self._get_resource(context, Member, id)
|
||||
self.assert_modification_allowed(member_db)
|
||||
if v:
|
||||
member_db.update(v)
|
||||
return self._make_member_dict(member_db)
|
||||
except exception.DBDuplicateEntry:
|
||||
raise loadbalancer.MemberExists(
|
||||
address=member_db['address'],
|
||||
port=member_db['protocol_port'],
|
||||
pool=member_db['pool_id'])
|
||||
|
||||
def delete_member(self, context, id):
|
||||
with context.session.begin(subtransactions=True):
|
||||
member_db = self._get_resource(context, Member, id)
|
||||
context.session.delete(member_db)
|
||||
|
||||
def get_member(self, context, id, fields=None):
|
||||
member = self._get_resource(context, Member, id)
|
||||
return self._make_member_dict(member, fields)
|
||||
|
||||
def get_members(self, context, filters=None, fields=None):
|
||||
return self._get_collection(context, Member,
|
||||
self._make_member_dict,
|
||||
filters=filters, fields=fields)
|
||||
|
||||
########################################################
|
||||
# HealthMonitor DB access
|
||||
def _make_health_monitor_dict(self, health_monitor, fields=None):
|
||||
res = {'id': health_monitor['id'],
|
||||
'tenant_id': health_monitor['tenant_id'],
|
||||
'type': health_monitor['type'],
|
||||
'delay': health_monitor['delay'],
|
||||
'timeout': health_monitor['timeout'],
|
||||
'max_retries': health_monitor['max_retries'],
|
||||
'admin_state_up': health_monitor['admin_state_up']}
|
||||
# no point to add the values below to
|
||||
# the result if the 'type' is not HTTP/S
|
||||
if res['type'] in ['HTTP', 'HTTPS']:
|
||||
for attr in ['url_path', 'http_method', 'expected_codes']:
|
||||
res[attr] = health_monitor[attr]
|
||||
res['pools'] = [{'pool_id': p['pool_id'],
|
||||
'status': p['status'],
|
||||
'status_description': p['status_description']}
|
||||
for p in health_monitor.pools]
|
||||
return self._fields(res, fields)
|
||||
|
||||
def create_health_monitor(self, context, health_monitor):
|
||||
v = health_monitor['health_monitor']
|
||||
tenant_id = self._get_tenant_id_for_create(context, v)
|
||||
with context.session.begin(subtransactions=True):
|
||||
# setting ACTIVE status since healthmon is shared DB object
|
||||
monitor_db = HealthMonitor(id=uuidutils.generate_uuid(),
|
||||
tenant_id=tenant_id,
|
||||
type=v['type'],
|
||||
delay=v['delay'],
|
||||
timeout=v['timeout'],
|
||||
max_retries=v['max_retries'],
|
||||
http_method=v['http_method'],
|
||||
url_path=v['url_path'],
|
||||
expected_codes=v['expected_codes'],
|
||||
admin_state_up=v['admin_state_up'])
|
||||
context.session.add(monitor_db)
|
||||
return self._make_health_monitor_dict(monitor_db)
|
||||
|
||||
def update_health_monitor(self, context, id, health_monitor):
|
||||
v = health_monitor['health_monitor']
|
||||
with context.session.begin(subtransactions=True):
|
||||
monitor_db = self._get_resource(context, HealthMonitor, id)
|
||||
self.assert_modification_allowed(monitor_db)
|
||||
if v:
|
||||
monitor_db.update(v)
|
||||
return self._make_health_monitor_dict(monitor_db)
|
||||
|
||||
def delete_health_monitor(self, context, id):
|
||||
"""Delete health monitor object from DB
|
||||
|
||||
Raises an error if the monitor has associations with pools
|
||||
"""
|
||||
query = self._model_query(context, PoolMonitorAssociation)
|
||||
has_associations = query.filter_by(monitor_id=id).first()
|
||||
if has_associations:
|
||||
raise loadbalancer.HealthMonitorInUse(monitor_id=id)
|
||||
|
||||
with context.session.begin(subtransactions=True):
|
||||
monitor_db = self._get_resource(context, HealthMonitor, id)
|
||||
context.session.delete(monitor_db)
|
||||
|
||||
def get_health_monitor(self, context, id, fields=None):
|
||||
healthmonitor = self._get_resource(context, HealthMonitor, id)
|
||||
return self._make_health_monitor_dict(healthmonitor, fields)
|
||||
|
||||
def get_health_monitors(self, context, filters=None, fields=None):
|
||||
return self._get_collection(context, HealthMonitor,
|
||||
self._make_health_monitor_dict,
|
||||
filters=filters, fields=fields)
|
|
@ -1,15 +0,0 @@
|
|||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Sylvain Afchain <sylvain.afchain@enovance.com>
|
||||
#
|
||||
# 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.
|
|
@ -1,239 +0,0 @@
|
|||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Sylvain Afchain <sylvain.afchain@enovance.com>
|
||||
#
|
||||
# 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.
|
||||
|
||||
import netaddr
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
||||
from neutron.api.rpc.agentnotifiers import metering_rpc_agent_api
|
||||
from neutron.common import constants
|
||||
from neutron.db import api as dbapi
|
||||
from neutron.db import db_base_plugin_v2 as base_db
|
||||
from neutron.db import l3_db
|
||||
from neutron.db import model_base
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import metering
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.openstack.common import uuidutils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MeteringLabelRule(model_base.BASEV2, models_v2.HasId):
|
||||
direction = sa.Column(sa.Enum('ingress', 'egress',
|
||||
name='meteringlabels_direction'))
|
||||
remote_ip_prefix = sa.Column(sa.String(64))
|
||||
metering_label_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey("meteringlabels.id",
|
||||
ondelete="CASCADE"),
|
||||
nullable=False)
|
||||
excluded = sa.Column(sa.Boolean, default=False)
|
||||
|
||||
|
||||
class MeteringLabel(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
||||
name = sa.Column(sa.String(255))
|
||||
description = sa.Column(sa.String(1024))
|
||||
rules = orm.relationship(MeteringLabelRule, backref="label",
|
||||
cascade="delete", lazy="joined")
|
||||
routers = orm.relationship(
|
||||
l3_db.Router,
|
||||
primaryjoin="MeteringLabel.tenant_id==Router.tenant_id",
|
||||
foreign_keys='MeteringLabel.tenant_id',
|
||||
uselist=True)
|
||||
|
||||
|
||||
class MeteringDbMixin(metering.MeteringPluginBase,
|
||||
base_db.CommonDbMixin):
|
||||
|
||||
def __init__(self):
|
||||
dbapi.register_models()
|
||||
|
||||
self.meter_rpc = metering_rpc_agent_api.MeteringAgentNotifyAPI()
|
||||
|
||||
def _make_metering_label_dict(self, metering_label, fields=None):
|
||||
res = {'id': metering_label['id'],
|
||||
'name': metering_label['name'],
|
||||
'description': metering_label['description'],
|
||||
'tenant_id': metering_label['tenant_id']}
|
||||
return self._fields(res, fields)
|
||||
|
||||
def create_metering_label(self, context, metering_label):
|
||||
m = metering_label['metering_label']
|
||||
tenant_id = self._get_tenant_id_for_create(context, m)
|
||||
|
||||
with context.session.begin(subtransactions=True):
|
||||
metering_db = MeteringLabel(id=uuidutils.generate_uuid(),
|
||||
description=m['description'],
|
||||
tenant_id=tenant_id,
|
||||
name=m['name'])
|
||||
context.session.add(metering_db)
|
||||
|
||||
return self._make_metering_label_dict(metering_db)
|
||||
|
||||
def delete_metering_label(self, context, label_id):
|
||||
with context.session.begin(subtransactions=True):
|
||||
try:
|
||||
label = self._get_by_id(context, MeteringLabel, label_id)
|
||||
except orm.exc.NoResultFound:
|
||||
raise metering.MeteringLabelNotFound(label_id=label_id)
|
||||
|
||||
context.session.delete(label)
|
||||
|
||||
def get_metering_label(self, context, label_id, fields=None):
|
||||
try:
|
||||
metering_label = self._get_by_id(context, MeteringLabel, label_id)
|
||||
except orm.exc.NoResultFound:
|
||||
raise metering.MeteringLabelNotFound(label_id=label_id)
|
||||
|
||||
return self._make_metering_label_dict(metering_label, fields)
|
||||
|
||||
def get_metering_labels(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
marker_obj = self._get_marker_obj(context, 'metering_labels', limit,
|
||||
marker)
|
||||
return self._get_collection(context, MeteringLabel,
|
||||
self._make_metering_label_dict,
|
||||
filters=filters, fields=fields,
|
||||
sorts=sorts,
|
||||
limit=limit,
|
||||
marker_obj=marker_obj,
|
||||
page_reverse=page_reverse)
|
||||
|
||||
def _make_metering_label_rule_dict(self, metering_label_rule, fields=None):
|
||||
res = {'id': metering_label_rule['id'],
|
||||
'metering_label_id': metering_label_rule['metering_label_id'],
|
||||
'direction': metering_label_rule['direction'],
|
||||
'remote_ip_prefix': metering_label_rule['remote_ip_prefix'],
|
||||
'excluded': metering_label_rule['excluded']}
|
||||
return self._fields(res, fields)
|
||||
|
||||
def get_metering_label_rules(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
marker_obj = self._get_marker_obj(context, 'metering_label_rules',
|
||||
limit, marker)
|
||||
|
||||
return self._get_collection(context, MeteringLabelRule,
|
||||
self._make_metering_label_rule_dict,
|
||||
filters=filters, fields=fields,
|
||||
sorts=sorts,
|
||||
limit=limit,
|
||||
marker_obj=marker_obj,
|
||||
page_reverse=page_reverse)
|
||||
|
||||
def get_metering_label_rule(self, context, rule_id, fields=None):
|
||||
try:
|
||||
metering_label_rule = self._get_by_id(context,
|
||||
MeteringLabelRule, rule_id)
|
||||
except orm.exc.NoResultFound:
|
||||
raise metering.MeteringLabelRuleNotFound(rule_id=rule_id)
|
||||
|
||||
return self._make_metering_label_rule_dict(metering_label_rule, fields)
|
||||
|
||||
def _validate_cidr(self, context, label_id, remote_ip_prefix,
|
||||
direction, excluded):
|
||||
r_ips = self.get_metering_label_rules(context,
|
||||
filters={'metering_label_id':
|
||||
label_id,
|
||||
'direction':
|
||||
[direction],
|
||||
'excluded':
|
||||
[excluded]},
|
||||
fields=['remote_ip_prefix'])
|
||||
|
||||
cidrs = [r['remote_ip_prefix'] for r in r_ips]
|
||||
new_cidr_ipset = netaddr.IPSet([remote_ip_prefix])
|
||||
if (netaddr.IPSet(cidrs) & new_cidr_ipset):
|
||||
raise metering.MeteringLabelRuleOverlaps(remote_ip_prefix=
|
||||
remote_ip_prefix)
|
||||
|
||||
def create_metering_label_rule(self, context, metering_label_rule):
|
||||
m = metering_label_rule['metering_label_rule']
|
||||
with context.session.begin(subtransactions=True):
|
||||
label_id = m['metering_label_id']
|
||||
ip_prefix = m['remote_ip_prefix']
|
||||
direction = m['direction']
|
||||
excluded = m['excluded']
|
||||
|
||||
self._validate_cidr(context, label_id, ip_prefix, direction,
|
||||
excluded)
|
||||
metering_db = MeteringLabelRule(id=uuidutils.generate_uuid(),
|
||||
metering_label_id=label_id,
|
||||
direction=direction,
|
||||
excluded=m['excluded'],
|
||||
remote_ip_prefix=ip_prefix)
|
||||
context.session.add(metering_db)
|
||||
|
||||
return self._make_metering_label_rule_dict(metering_db)
|
||||
|
||||
def delete_metering_label_rule(self, context, rule_id):
|
||||
with context.session.begin(subtransactions=True):
|
||||
try:
|
||||
rule = self._get_by_id(context, MeteringLabelRule, rule_id)
|
||||
except orm.exc.NoResultFound:
|
||||
raise metering.MeteringLabelRuleNotFound(rule_id=rule_id)
|
||||
|
||||
context.session.delete(rule)
|
||||
|
||||
def _get_metering_rules_dict(self, metering_label):
|
||||
rules = []
|
||||
for rule in metering_label.rules:
|
||||
rule_dict = self._make_metering_label_rule_dict(rule)
|
||||
rules.append(rule_dict)
|
||||
|
||||
return rules
|
||||
|
||||
def _make_router_dict(self, router):
|
||||
res = {'id': router['id'],
|
||||
'name': router['name'],
|
||||
'tenant_id': router['tenant_id'],
|
||||
'admin_state_up': router['admin_state_up'],
|
||||
'status': router['status'],
|
||||
'gw_port_id': router['gw_port_id'],
|
||||
constants.METERING_LABEL_KEY: []}
|
||||
|
||||
return res
|
||||
|
||||
def _process_sync_metering_data(self, labels):
|
||||
routers_dict = {}
|
||||
for label in labels:
|
||||
routers = label.routers
|
||||
for router in routers:
|
||||
router_dict = routers_dict.get(
|
||||
router['id'],
|
||||
self._make_router_dict(router))
|
||||
|
||||
rules = self._get_metering_rules_dict(label)
|
||||
|
||||
data = {'id': label['id'], 'rules': rules}
|
||||
router_dict[constants.METERING_LABEL_KEY].append(data)
|
||||
|
||||
routers_dict[router['id']] = router_dict
|
||||
|
||||
return routers_dict.values()
|
||||
|
||||
def get_sync_data_metering(self, context, label_id=None, router_ids=None):
|
||||
labels = context.session.query(MeteringLabel)
|
||||
|
||||
if label_id:
|
||||
labels = labels.filter(MeteringLabel.id == label_id)
|
||||
elif router_ids:
|
||||
labels = (labels.join(MeteringLabel.routers).
|
||||
filter(l3_db.Router.id.in_(router_ids)))
|
||||
|
||||
return self._process_sync_metering_data(labels)
|
|
@ -1,55 +0,0 @@
|
|||
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Sylvain Afchain <sylvain.afchain@enovance.com>
|
||||
#
|
||||
# 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.
|
||||
|
||||
from neutron.common import constants as consts
|
||||
from neutron.common import utils
|
||||
from neutron import manager
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.plugins.common import constants as service_constants
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MeteringRpcCallbacks(object):
|
||||
|
||||
RPC_API_VERSION = '1.0'
|
||||
|
||||
def __init__(self, meter_plugin):
|
||||
self.meter_plugin = meter_plugin
|
||||
|
||||
def get_sync_data_metering(self, context, **kwargs):
|
||||
l3_plugin = manager.NeutronManager.get_service_plugins().get(
|
||||
service_constants.L3_ROUTER_NAT)
|
||||
if not l3_plugin:
|
||||
return
|
||||
|
||||
host = kwargs.get('host')
|
||||
if not utils.is_extension_supported(
|
||||
l3_plugin, consts.L3_AGENT_SCHEDULER_EXT_ALIAS) or not host:
|
||||
return self.meter_plugin.get_sync_data_metering(context)
|
||||
else:
|
||||
agents = l3_plugin.get_l3_agents(context, filters={'host': [host]})
|
||||
if not agents:
|
||||
LOG.error(_('Unable to find agent %s.'), host)
|
||||
return
|
||||
|
||||
routers = l3_plugin.list_routers_on_l3_agent(context, agents[0].id)
|
||||
router_ids = [router['id'] for router in routers['routers']]
|
||||
if not router_ids:
|
||||
return
|
||||
|
||||
return self.meter_plugin.get_sync_data_metering(context,
|
||||
router_ids=router_ids)
|
|
@ -1,83 +0,0 @@
|
|||
# Copyright 2013 Openstack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""
|
||||
Upgrade/downgrade operations for 'community' extensions
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade_l3():
|
||||
op.create_table(
|
||||
'routers',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('status', sa.String(length=16), nullable=True),
|
||||
sa.Column('admin_state_up', sa.Boolean(), nullable=True),
|
||||
sa.Column('gw_port_id', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['gw_port_id'], ['ports.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'externalnetworks',
|
||||
sa.Column('network_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('network_id')
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'floatingips',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('floating_ip_address', sa.String(length=64), nullable=False),
|
||||
sa.Column('floating_network_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('floating_port_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('fixed_port_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('fixed_ip_address', sa.String(length=64), nullable=True),
|
||||
sa.Column('router_id', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['fixed_port_id'], ['ports.id'], ),
|
||||
sa.ForeignKeyConstraint(['floating_port_id'], ['ports.id'], ),
|
||||
sa.ForeignKeyConstraint(['router_id'], ['routers.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
|
||||
def upgrade_quota(options=None):
|
||||
if not (options or {}).get('folsom_quota_db_enabled'):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'quotas',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('tenant_id', sa.String(255), index=True),
|
||||
sa.Column('resource', sa.String(255)),
|
||||
sa.Column('limit', sa.Integer()),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
|
||||
def downgrade_l3():
|
||||
for table in ('floatingips', 'routers', 'externalnetworks'):
|
||||
op.drop_table(table)
|
||||
|
||||
|
||||
def downgrade_quota(options=None):
|
||||
if (options or {}).get('folsom_quota_db_enabled'):
|
||||
op.drop_table('quotas')
|
|
@ -1,63 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nec-pf-port-del
|
||||
|
||||
Revision ID: 1064e98b7917
|
||||
Revises: 3d6fae8b70b0
|
||||
Create Date: 2013-09-24 05:33:54.602618
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1064e98b7917'
|
||||
down_revision = '3d6fae8b70b0'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.alter_column('packetfilters', 'in_port',
|
||||
existing_type=sa.String(length=36),
|
||||
nullable=True)
|
||||
op.create_foreign_key(
|
||||
'packetfilters_ibfk_2',
|
||||
source='packetfilters', referent='ports',
|
||||
local_cols=['in_port'], remote_cols=['id'],
|
||||
ondelete='CASCADE')
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_constraint('packetfilters_ibfk_2', 'packetfilters', 'foreignkey')
|
||||
op.alter_column('packetfilters', 'in_port',
|
||||
existing_type=sa.String(length=36),
|
||||
nullable=False)
|
|
@ -1,68 +0,0 @@
|
|||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nuage_extraroute
|
||||
|
||||
Revision ID: 10cd28e692e9
|
||||
Revises: 1b837a7125a9
|
||||
Create Date: 2014-05-14 14:47:53.148132
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '10cd28e692e9'
|
||||
down_revision = '1b837a7125a9'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nuage.plugin.NuagePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'routerroutes_mapping',
|
||||
sa.Column('router_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('nuage_route_id', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
|
||||
ondelete='CASCADE'),
|
||||
)
|
||||
op.create_table(
|
||||
'routerroutes',
|
||||
sa.Column('destination', sa.String(length=64), nullable=False),
|
||||
sa.Column('nexthop', sa.String(length=64), nullable=False),
|
||||
sa.Column('router_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('destination', 'nexthop',
|
||||
'router_id'),
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('routerroutes')
|
||||
op.drop_table('routerroutes_mapping')
|
|
@ -1,84 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""initial port security
|
||||
|
||||
Revision ID: 1149d7de0cfa
|
||||
Revises: 1b693c095aa3
|
||||
Create Date: 2013-01-22 14:05:20.696502
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1149d7de0cfa'
|
||||
down_revision = '1b693c095aa3'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('networksecuritybindings',
|
||||
sa.Column('network_id', sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('port_security_enabled', sa.Boolean(),
|
||||
nullable=False),
|
||||
sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('network_id'))
|
||||
op.create_table('portsecuritybindings',
|
||||
sa.Column('port_id', sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('port_security_enabled', sa.Boolean(),
|
||||
nullable=False),
|
||||
sa.ForeignKeyConstraint(['port_id'], ['ports.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('port_id'))
|
||||
### end Alembic commands ###
|
||||
|
||||
# Copy network and port ids over to network|port(securitybindings) table
|
||||
# and set port_security_enabled to false as ip address pairs were not
|
||||
# configured in NVP/NSX originally.
|
||||
op.execute("INSERT INTO networksecuritybindings SELECT id as "
|
||||
"network_id, False as port_security_enabled from networks")
|
||||
op.execute("INSERT INTO portsecuritybindings SELECT id as port_id, "
|
||||
"False as port_security_enabled from ports")
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('portsecuritybindings')
|
||||
op.drop_table('networksecuritybindings')
|
||||
### end Alembic commands ###
|
|
@ -1,208 +0,0 @@
|
|||
# Copyright 2014 NEC Corporation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nec: delete old ofc mapping tables
|
||||
|
||||
Revision ID: 117643811bca
|
||||
Revises: 81c553f3776c
|
||||
Create Date: 2014-03-02 05:26:47.073318
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '117643811bca'
|
||||
down_revision = '81c553f3776c'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.ext import compiler as sa_compiler
|
||||
from sqlalchemy.sql import expression as sa_expr
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
# sqlalchemy does not support the expression:
|
||||
# INSERT INTO <table> (<column>, ...) (SELECT ...)
|
||||
# The following class is to support this expression.
|
||||
# Reference: http://docs.sqlalchemy.org/en/rel_0_9/core/compiler.html
|
||||
# section: "Compiling sub-elements of a custom expression construct"
|
||||
|
||||
class InsertFromSelect(sa_expr.Executable, sa_expr.ClauseElement):
|
||||
_execution_options = (sa_expr.Executable._execution_options.
|
||||
union({'autocommit': True}))
|
||||
|
||||
def __init__(self, insert_spec, select):
|
||||
self.insert_spec = insert_spec
|
||||
self.select = select
|
||||
|
||||
|
||||
@sa_compiler.compiles(InsertFromSelect)
|
||||
def visit_insert_from_select(element, compiler, **kw):
|
||||
if type(element.insert_spec) == list:
|
||||
columns = []
|
||||
for column in element.insert_spec:
|
||||
columns.append(column.name)
|
||||
table = compiler.process(element.insert_spec[0].table, asfrom=True)
|
||||
columns = ", ".join(columns)
|
||||
sql = ("INSERT INTO %s (%s) (%s)" %
|
||||
(table, columns, compiler.process(element.select)))
|
||||
else:
|
||||
sql = ("INSERT INTO %s (%s)" %
|
||||
(compiler.process(element.insert_spec, asfrom=True),
|
||||
compiler.process(element.select)))
|
||||
return sql
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
# Table definitions below are only used for sqlalchemy to generate
|
||||
# SQL statements, so in networks/ports tables only required field
|
||||
# are declared. Note that 'quantum_id' in OFC ID mapping tables
|
||||
# will be renamed in a later patch (bug 1287432).
|
||||
|
||||
ofctenants = sa_expr.table(
|
||||
'ofctenants',
|
||||
sa_expr.column('id'),
|
||||
sa_expr.column('quantum_id'))
|
||||
ofcnetworks = sa_expr.table(
|
||||
'ofcnetworks',
|
||||
sa_expr.column('id'),
|
||||
sa_expr.column('quantum_id'))
|
||||
ofcports = sa_expr.table(
|
||||
'ofcports',
|
||||
sa_expr.column('id'),
|
||||
sa_expr.column('quantum_id'))
|
||||
ofcfilters = sa_expr.table(
|
||||
'ofcfilters',
|
||||
sa_expr.column('id'),
|
||||
sa_expr.column('quantum_id'))
|
||||
|
||||
ofctenantmappings = sa_expr.table(
|
||||
'ofctenantmappings',
|
||||
sa_expr.column('ofc_id'),
|
||||
sa_expr.column('quantum_id'))
|
||||
ofcnetworkmappings = sa_expr.table(
|
||||
'ofcnetworkmappings',
|
||||
sa_expr.column('ofc_id'),
|
||||
sa_expr.column('quantum_id'))
|
||||
ofcportmappings = sa_expr.table(
|
||||
'ofcportmappings',
|
||||
sa_expr.column('ofc_id'),
|
||||
sa_expr.column('quantum_id'))
|
||||
ofcfiltermappings = sa_expr.table(
|
||||
'ofcfiltermappings',
|
||||
sa_expr.column('ofc_id'),
|
||||
sa_expr.column('quantum_id'))
|
||||
|
||||
networks = sa_expr.table(
|
||||
'networks',
|
||||
sa_expr.column('id'),
|
||||
sa_expr.column('tenant_id'))
|
||||
ports = sa_expr.table(
|
||||
'ports',
|
||||
sa_expr.column('id'),
|
||||
sa_expr.column('network_id'))
|
||||
|
||||
# ofctenants -> ofctenantmappings
|
||||
select_obj = sa.select([ofctenants.c.quantum_id,
|
||||
op.inline_literal('/tenants/') + ofctenants.c.id])
|
||||
stmt = InsertFromSelect([ofctenantmappings.c.quantum_id,
|
||||
ofctenantmappings.c.ofc_id],
|
||||
select_obj)
|
||||
op.execute(stmt)
|
||||
|
||||
# ofcnetworks -> ofcnetworkmappings
|
||||
select_obj = ofcnetworks.join(
|
||||
networks,
|
||||
ofcnetworks.c.quantum_id == networks.c.id)
|
||||
select_obj = select_obj.join(
|
||||
ofctenantmappings,
|
||||
ofctenantmappings.c.quantum_id == networks.c.tenant_id)
|
||||
select_obj = sa.select(
|
||||
[ofcnetworks.c.quantum_id,
|
||||
(ofctenantmappings.c.ofc_id +
|
||||
op.inline_literal('/networks/') + ofcnetworks.c.id)],
|
||||
from_obj=select_obj)
|
||||
stmt = InsertFromSelect([ofcnetworkmappings.c.quantum_id,
|
||||
ofcnetworkmappings.c.ofc_id],
|
||||
select_obj)
|
||||
op.execute(stmt)
|
||||
|
||||
# ofcports -> ofcportmappings
|
||||
select_obj = ofcports.join(ports, ofcports.c.quantum_id == ports.c.id)
|
||||
select_obj = select_obj.join(
|
||||
ofcnetworkmappings,
|
||||
ofcnetworkmappings.c.quantum_id == ports.c.network_id)
|
||||
select_obj = sa.select(
|
||||
[ofcports.c.quantum_id,
|
||||
(ofcnetworkmappings.c.ofc_id +
|
||||
op.inline_literal('/ports/') + ofcports.c.id)],
|
||||
from_obj=select_obj)
|
||||
stmt = InsertFromSelect([ofcportmappings.c.quantum_id,
|
||||
ofcportmappings.c.ofc_id],
|
||||
select_obj)
|
||||
op.execute(stmt)
|
||||
|
||||
# ofcfilters -> ofcfiltermappings
|
||||
select_obj = sa.select([ofcfilters.c.quantum_id,
|
||||
op.inline_literal('/filters/') + ofcfilters.c.id])
|
||||
stmt = InsertFromSelect([ofcfiltermappings.c.quantum_id,
|
||||
ofcfiltermappings.c.ofc_id],
|
||||
select_obj)
|
||||
op.execute(stmt)
|
||||
|
||||
# drop old mapping tables
|
||||
op.drop_table('ofctenants')
|
||||
op.drop_table('ofcnetworks')
|
||||
op.drop_table('ofcports')
|
||||
op.drop_table('ofcfilters')
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'ofctenants',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('quantum_id', sa.String(length=36), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table(
|
||||
'ofcnetworks',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('quantum_id', sa.String(length=36), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table(
|
||||
'ofcports',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('quantum_id', sa.String(length=36), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table(
|
||||
'ofcfilters',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('quantum_id', sa.String(length=36), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
|
@ -1,62 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Pool Monitor status field
|
||||
|
||||
Revision ID: 11c6e18605c8
|
||||
Revises: 52ff27f7567a
|
||||
Create Date: 2013-07-10 06:07:20.878520
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '11c6e18605c8'
|
||||
down_revision = '52ff27f7567a'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.add_column('poolmonitorassociations', sa.Column('status',
|
||||
sa.String(16),
|
||||
server_default='',
|
||||
nullable=False))
|
||||
op.add_column('poolmonitorassociations', sa.Column('status_description',
|
||||
sa.String(255)))
|
||||
|
||||
# Set status to ACTIVE for existing associations
|
||||
op.execute("UPDATE poolmonitorassociations SET status='ACTIVE'")
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_column('poolmonitorassociations', 'status')
|
||||
op.drop_column('poolmonitorassociations', 'status_description')
|
|
@ -1,71 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""ext_gw_mode
|
||||
|
||||
Revision ID: 128e042a2b68
|
||||
Revises: 32b517556ec9
|
||||
Create Date: 2013-03-27 00:35:17.323280
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '128e042a2b68'
|
||||
down_revision = '32b517556ec9'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.hyperv.hyperv_neutron_plugin.HyperVNeutronPlugin',
|
||||
'neutron.plugins.linuxbridge.lb_neutron_plugin.LinuxBridgePluginV2',
|
||||
'neutron.plugins.metaplugin.meta_neutron_plugin.MetaPluginV2',
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin',
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2',
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2',
|
||||
'neutron.plugins.ryu.ryu_neutron_plugin.RyuNeutronPluginV2',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin',
|
||||
'neutron.plugins.embrane.plugins.embrane_ovs_plugin.EmbraneOvsPlugin',
|
||||
'neutron.plugins.ibm.sdnve_neutron_plugin.SdnvePluginV2',
|
||||
'neutron.plugins.oneconvergence.plugin.OneConvergencePluginV2',
|
||||
'neutron.plugins.cisco.network_plugin.PluginV2',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.add_column('routers', sa.Column('enable_snat', sa.Boolean(),
|
||||
nullable=False, default=True))
|
||||
# Set enable_snat to True for existing routers
|
||||
op.execute("UPDATE routers SET enable_snat=True")
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_column('routers', 'enable_snat')
|
|
@ -1,70 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nvp_net_binding
|
||||
|
||||
Revision ID: 1341ed32cc1e
|
||||
Revises: 4692d074d587
|
||||
Create Date: 2013-02-26 01:28:29.182195
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1341ed32cc1e'
|
||||
down_revision = '4692d074d587'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
new_type = sa.Enum('flat', 'vlan', 'stt', 'gre', 'l3_ext',
|
||||
name='nvp_network_bindings_binding_type')
|
||||
old_type = sa.Enum('flat', 'vlan', 'stt', 'gre',
|
||||
name='nvp_network_bindings_binding_type')
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
op.alter_column('nvp_network_bindings', 'tz_uuid',
|
||||
name='phy_uuid',
|
||||
existing_type=sa.String(36),
|
||||
existing_nullable=True)
|
||||
migration.alter_enum('nvp_network_bindings', 'binding_type', new_type,
|
||||
nullable=False)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
op.alter_column('nvp_network_bindings', 'phy_uuid',
|
||||
name='tz_uuid',
|
||||
existing_type=sa.String(36),
|
||||
existing_nullable=True)
|
||||
migration.alter_enum('nvp_network_bindings', 'binding_type', old_type,
|
||||
nullable=False)
|
|
@ -1,55 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nec_add_pf_name
|
||||
|
||||
Revision ID: 13de305df56e
|
||||
Revises: b7a8863760e
|
||||
Create Date: 2013-07-06 00:42:26.991175
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '13de305df56e'
|
||||
down_revision = 'b7a8863760e'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.add_column('packetfilters',
|
||||
sa.Column('name', sa.String(length=255), nullable=True))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_column('packetfilters', 'name')
|
|
@ -1,74 +0,0 @@
|
|||
# Copyright 2014 VMware, Inc.
|
||||
|
||||
# All Rights Reserved
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""NSX DHCP/metadata support
|
||||
|
||||
Revision ID: 1421183d533f
|
||||
Revises: 8f682276ee4
|
||||
Create Date: 2013-10-11 14:33:37.303215
|
||||
|
||||
"""
|
||||
|
||||
revision = '1421183d533f'
|
||||
down_revision = '8f682276ee4'
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'lsn',
|
||||
sa.Column('net_id',
|
||||
sa.String(length=36), nullable=False),
|
||||
sa.Column('lsn_id',
|
||||
sa.String(length=36), nullable=False),
|
||||
sa.PrimaryKeyConstraint('lsn_id'))
|
||||
|
||||
op.create_table(
|
||||
'lsn_port',
|
||||
sa.Column('lsn_port_id',
|
||||
sa.String(length=36), nullable=False),
|
||||
sa.Column('lsn_id',
|
||||
sa.String(length=36), nullable=False),
|
||||
sa.Column('sub_id',
|
||||
sa.String(length=36), nullable=False, unique=True),
|
||||
sa.Column('mac_addr',
|
||||
sa.String(length=32), nullable=False, unique=True),
|
||||
sa.ForeignKeyConstraint(['lsn_id'], ['lsn.lsn_id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('lsn_port_id'))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('lsn_port')
|
||||
op.drop_table('lsn')
|
|
@ -1,78 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""DB Migration for Arista ml2 mechanism driver
|
||||
|
||||
Revision ID: 14f24494ca31
|
||||
Revises: 2a3bae1ceb8
|
||||
Create Date: 2013-08-15 18:54:16.083640
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '14f24494ca31'
|
||||
down_revision = '2a3bae1ceb8'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'arista_provisioned_nets',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('network_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('segmentation_id', sa.Integer(),
|
||||
autoincrement=False, nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'))
|
||||
|
||||
op.create_table(
|
||||
'arista_provisioned_vms',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('vm_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('host_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('port_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('network_id', sa.String(length=36), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'))
|
||||
|
||||
op.create_table(
|
||||
'arista_provisioned_tenants',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('arista_provisioned_tenants')
|
||||
op.drop_table('arista_provisioned_vms')
|
||||
op.drop_table('arista_provisioned_nets')
|
|
@ -1,55 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""ml2 binding:profile
|
||||
|
||||
Revision ID: 157a5d299379
|
||||
Revises: 50d5ba354c23
|
||||
Create Date: 2014-02-13 23:48:25.147279
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '157a5d299379'
|
||||
down_revision = '50d5ba354c23'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.add_column('ml2_port_bindings',
|
||||
sa.Column('profile', sa.String(length=4095),
|
||||
nullable=False, server_default=''))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_column('ml2_port_bindings', 'profile')
|
|
@ -1,66 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Add portbindings db
|
||||
|
||||
Revision ID: 176a85fc7d79
|
||||
Revises: f489cf14a79c
|
||||
Create Date: 2013-03-21 14:59:53.052600
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '176a85fc7d79'
|
||||
down_revision = 'f489cf14a79c'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.bigswitch.plugin.NeutronRestProxyV2',
|
||||
'neutron.plugins.linuxbridge.lb_neutron_plugin.LinuxBridgePluginV2',
|
||||
'neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2',
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin',
|
||||
'neutron.plugins.ibm.sdnve_neutron_plugin.SdnvePluginV2',
|
||||
'neutron.plugins.oneconvergence.plugin.OneConvergencePluginV2',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'portbindingports',
|
||||
sa.Column('port_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('host', sa.String(length=255), nullable=False),
|
||||
sa.ForeignKeyConstraint(['port_id'], ['ports.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('port_id')
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
op.drop_table('portbindingports')
|
|
@ -1,103 +0,0 @@
|
|||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nsx_gw_devices
|
||||
|
||||
Revision ID: 19180cf98af6
|
||||
Revises: 117643811bca
|
||||
Create Date: 2014-02-26 02:46:26.151741
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '19180cf98af6'
|
||||
down_revision = '117643811bca'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'networkgatewaydevicereferences',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('network_gateway_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('interface_name', sa.String(length=64), nullable=True),
|
||||
sa.ForeignKeyConstraint(['network_gateway_id'], ['networkgateways.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id', 'network_gateway_id', 'interface_name'),
|
||||
mysql_engine='InnoDB')
|
||||
# Copy data from networkgatewaydevices into networkgatewaydevicereference
|
||||
op.execute("INSERT INTO networkgatewaydevicereferences SELECT "
|
||||
"id, network_gateway_id, interface_name FROM "
|
||||
"networkgatewaydevices")
|
||||
# drop networkgatewaydevices
|
||||
op.drop_table('networkgatewaydevices')
|
||||
op.create_table(
|
||||
'networkgatewaydevices',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('nsx_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('connector_type', sa.String(length=10), nullable=True),
|
||||
sa.Column('connector_ip', sa.String(length=64), nullable=True),
|
||||
sa.Column('status', sa.String(length=16), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_engine='InnoDB')
|
||||
# Create a networkgatewaydevice for each existing reference.
|
||||
# For existing references nsx_id == neutron_id
|
||||
# Do not fill conenctor info as they would be unknown
|
||||
op.execute("INSERT INTO networkgatewaydevices (id, nsx_id, tenant_id) "
|
||||
"SELECT gw_dev_ref.id, gw_dev_ref.id as nsx_id, tenant_id "
|
||||
"FROM networkgatewaydevicereferences AS gw_dev_ref "
|
||||
"INNER JOIN networkgateways AS net_gw ON "
|
||||
"gw_dev_ref.network_gateway_id=net_gw.id")
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('networkgatewaydevices')
|
||||
# Re-create previous version of networkgatewaydevices table
|
||||
op.create_table(
|
||||
'networkgatewaydevices',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('network_gateway_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('interface_name', sa.String(length=64), nullable=True),
|
||||
sa.ForeignKeyConstraint(['network_gateway_id'], ['networkgateways.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_engine='InnoDB')
|
||||
# Copy from networkgatewaydevicereferences to networkgatewaydevices
|
||||
op.execute("INSERT INTO networkgatewaydevices SELECT "
|
||||
"id, network_gateway_id, interface_name FROM "
|
||||
"networkgatewaydevicereferences")
|
||||
# Dropt networkgatewaydevicereferences
|
||||
op.drop_table('networkgatewaydevicereferences')
|
|
@ -1,61 +0,0 @@
|
|||
# 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.
|
||||
#
|
||||
|
||||
"""nsx_sec_group_mapping
|
||||
|
||||
Revision ID: 1b2580001654
|
||||
Revises: abc88c33f74f
|
||||
Create Date: 2013-12-27 13:02:42.894648
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1b2580001654'
|
||||
down_revision = 'abc88c33f74f'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
# Create table for security group mappings
|
||||
op.create_table(
|
||||
'neutron_nsx_security_group_mappings',
|
||||
sa.Column('neutron_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('nsx_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['neutron_id'], ['securitygroups.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('neutron_id', 'nsx_id'))
|
||||
# Execute statement to add a record in security group mappings for
|
||||
# each record in securitygroups
|
||||
op.execute("INSERT INTO neutron_nsx_security_group_mappings SELECT id,id "
|
||||
"from securitygroups")
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
op.drop_table('neutron_nsx_security_group_mappings')
|
|
@ -1,64 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Quota ext support added in Grizzly
|
||||
|
||||
Revision ID: 1b693c095aa3
|
||||
Revises: 1d76643bcec4
|
||||
Create Date: 2013-01-19 02:58:17.667524
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1b693c095aa3'
|
||||
down_revision = '2a6d0b51f4bb'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
'quotas',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('resource', sa.String(length=255), nullable=True),
|
||||
sa.Column('limit', sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('quotas')
|
||||
### end Alembic commands ###
|
|
@ -1,74 +0,0 @@
|
|||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Cisco APIC Mechanism Driver
|
||||
|
||||
Revision ID: 1b837a7125a9
|
||||
Revises: 6be312499f9
|
||||
Create Date: 2014-02-13 09:35:19.147619
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1b837a7125a9'
|
||||
down_revision = '6be312499f9'
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'cisco_ml2_apic_epgs',
|
||||
sa.Column('network_id', sa.String(length=255), nullable=False),
|
||||
sa.Column('epg_id', sa.String(length=64), nullable=False),
|
||||
sa.Column('segmentation_id', sa.String(length=64), nullable=False),
|
||||
sa.Column('provider', sa.Boolean(), default=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('network_id'))
|
||||
|
||||
op.create_table(
|
||||
'cisco_ml2_apic_port_profiles',
|
||||
sa.Column('node_id', sa.String(length=255), nullable=False),
|
||||
sa.Column('profile_id', sa.String(length=64), nullable=False),
|
||||
sa.Column('hpselc_id', sa.String(length=64), nullable=False),
|
||||
sa.Column('module', sa.String(length=10), nullable=False),
|
||||
sa.Column('from_port', sa.Integer(), nullable=False),
|
||||
sa.Column('to_port', sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('node_id'))
|
||||
|
||||
op.create_table(
|
||||
'cisco_ml2_apic_contracts',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=False),
|
||||
sa.Column('contract_id', sa.String(length=64), nullable=False),
|
||||
sa.Column('filter_id', sa.String(length=64), nullable=False),
|
||||
sa.PrimaryKeyConstraint('tenant_id'))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('cisco_ml2_apic_contracts')
|
||||
op.drop_table('cisco_ml2_apic_port_profiles')
|
||||
op.drop_table('cisco_ml2_apic_epgs')
|
|
@ -1,82 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Support routing table configuration on Router
|
||||
|
||||
Revision ID: 1c33fa3cd1a1
|
||||
Revises: 45680af419f9
|
||||
Create Date: 2013-01-17 14:35:09.386975
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1c33fa3cd1a1'
|
||||
down_revision = '45680af419f9'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2',
|
||||
'neutron.plugins.linuxbridge.lb_neutron_plugin.LinuxBridgePluginV2',
|
||||
'neutron.plugins.metaplugin.meta_neutron_plugin.MetaPluginV2',
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin',
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2',
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.ryu.ryu_neutron_plugin.RyuNeutronPluginV2',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin',
|
||||
'neutron.plugins.oneconvergence.plugin.OneConvergencePluginV2',
|
||||
'neutron.plugins.cisco.network_plugin.PluginV2',
|
||||
'neutron.plugins.bigswitch.plugin.NeutronRestProxyV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.rename_table(
|
||||
'routes',
|
||||
'subnetroutes',
|
||||
)
|
||||
op.create_table(
|
||||
'routerroutes',
|
||||
sa.Column('destination', sa.String(length=64), nullable=False),
|
||||
sa.Column(
|
||||
'nexthop', sa.String(length=64), nullable=False),
|
||||
sa.Column('router_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
['router_id'], ['routers.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('destination', 'nexthop', 'router_id')
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.rename_table(
|
||||
'subnetroutes',
|
||||
'routes',
|
||||
)
|
||||
op.drop_table('routerroutes')
|
|
@ -1,67 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nvp_netbinding
|
||||
|
||||
Revision ID: 1d76643bcec4
|
||||
Revises: 3cb5d900c5de
|
||||
Create Date: 2013-01-15 07:36:10.024346
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1d76643bcec4'
|
||||
down_revision = '3cb5d900c5de'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'nvp_network_bindings',
|
||||
sa.Column('network_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('binding_type',
|
||||
sa.Enum('flat', 'vlan', 'stt', 'gre',
|
||||
name='nvp_network_bindings_binding_type'),
|
||||
nullable=False),
|
||||
sa.Column('tz_uuid', sa.String(length=36), nullable=True),
|
||||
sa.Column('vlan_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('network_id'))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('nvp_network_bindings')
|
|
@ -1,66 +0,0 @@
|
|||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""set_not_null_fields_lb_stats
|
||||
|
||||
Revision ID: 1e5dd1d09b22
|
||||
Revises: 54f7549a0e5f
|
||||
Create Date: 2014-03-17 11:00:35.370618
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1e5dd1d09b22'
|
||||
down_revision = '54f7549a0e5f'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.alter_column('poolstatisticss', 'bytes_in', nullable=False,
|
||||
existing_type=sa.BigInteger())
|
||||
op.alter_column('poolstatisticss', 'bytes_out', nullable=False,
|
||||
existing_type=sa.BigInteger())
|
||||
op.alter_column('poolstatisticss', 'active_connections', nullable=False,
|
||||
existing_type=sa.BigInteger())
|
||||
op.alter_column('poolstatisticss', 'total_connections', nullable=False,
|
||||
existing_type=sa.BigInteger())
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.alter_column('poolstatisticss', 'bytes_in', nullable=True,
|
||||
existing_type=sa.BigInteger())
|
||||
op.alter_column('poolstatisticss', 'bytes_out', nullable=True,
|
||||
existing_type=sa.BigInteger())
|
||||
op.alter_column('poolstatisticss', 'active_connections', nullable=True,
|
||||
existing_type=sa.BigInteger())
|
||||
op.alter_column('poolstatisticss', 'total_connections', nullable=True,
|
||||
existing_type=sa.BigInteger())
|
|
@ -1,67 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""allowedaddresspairs
|
||||
|
||||
Revision ID: 1efb85914233
|
||||
Revises: 51b4de912379
|
||||
Create Date: 2013-07-23 12:56:00.402855
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1efb85914233'
|
||||
down_revision = '51b4de912379'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.cisco.network_plugin.PluginV2',
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin',
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2',
|
||||
'neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'allowedaddresspairs',
|
||||
sa.Column('port_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('mac_address', sa.String(length=32), nullable=False),
|
||||
sa.Column('ip_address', sa.String(length=64), nullable=False),
|
||||
sa.ForeignKeyConstraint(['port_id'], ['ports.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('port_id', 'mac_address', 'ip_address'),
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('allowedaddresspairs')
|
|
@ -1,73 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Add a unique constraint on (agent_type, host) columns to prevent a race
|
||||
condition when an agent entry is 'upserted'.
|
||||
|
||||
Revision ID: 1fcfc149aca4
|
||||
Revises: e197124d4b9
|
||||
Create Date: 2013-11-27 18:35:28.148680
|
||||
|
||||
"""
|
||||
|
||||
revision = '1fcfc149aca4'
|
||||
down_revision = 'e197124d4b9'
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.brocade.NeutronPlugin.BrocadePluginV2',
|
||||
'neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2',
|
||||
'neutron.plugins.linuxbridge.lb_neutron_plugin.LinuxBridgePluginV2',
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2',
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin',
|
||||
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
|
||||
'neutron.plugins.ibm.sdnve_neutron_plugin.SdnvePluginV2',
|
||||
'neutron.plugins.oneconvergence.plugin.OneConvergencePluginV2',
|
||||
'neutron.plugins.mlnx.mlnx_plugin.MellanoxEswitchPlugin',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
TABLE_NAME = 'agents'
|
||||
UC_NAME = 'uniq_agents0agent_type0host'
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_unique_constraint(
|
||||
name=UC_NAME,
|
||||
source=TABLE_NAME,
|
||||
local_cols=['agent_type', 'host']
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_constraint(
|
||||
name=UC_NAME,
|
||||
table_name=TABLE_NAME,
|
||||
type_='unique'
|
||||
)
|
|
@ -1,57 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""LBaaS add status description
|
||||
|
||||
Revision ID: 2032abe8edac
|
||||
Revises: 477a4488d3f4
|
||||
Create Date: 2013-06-24 06:51:47.308545
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2032abe8edac'
|
||||
down_revision = '477a4488d3f4'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
ENTITIES = ['vips', 'pools', 'members', 'healthmonitors']
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
for entity in ENTITIES:
|
||||
op.add_column(entity, sa.Column('status_description', sa.String(255)))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
for entity in ENTITIES:
|
||||
op.drop_column(entity, 'status_description')
|
|
@ -1,66 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""DB Migration for ML2 GRE Type Driver
|
||||
|
||||
Revision ID: 20ae61555e95
|
||||
Revises: 13de305df56e
|
||||
Create Date: 2013-07-10 17:19:03.021937
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '20ae61555e95'
|
||||
down_revision = '13de305df56e'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'ml2_gre_allocations',
|
||||
sa.Column('gre_id', sa.Integer, nullable=False,
|
||||
autoincrement=False),
|
||||
sa.Column('allocated', sa.Boolean, nullable=False),
|
||||
sa.PrimaryKeyConstraint('gre_id')
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'ml2_gre_endpoints',
|
||||
sa.Column('ip_address', sa.String(length=64)),
|
||||
sa.PrimaryKeyConstraint('ip_address')
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('ml2_gre_allocations')
|
||||
op.drop_table('ml2_gre_endpoints')
|
|
@ -1,81 +0,0 @@
|
|||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# @author Sean M. Collins (Comcast)
|
||||
|
||||
"""Add IPv6 Subnet properties
|
||||
|
||||
Revision ID: 2447ad0e9585
|
||||
Revises: 33dd0a9fa487
|
||||
Create Date: 2013-10-23 16:36:44.188904
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2447ad0e9585'
|
||||
down_revision = '33dd0a9fa487'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'*'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
# Workaround for Alemic bug #89
|
||||
# https://bitbucket.org/zzzeek/alembic/issue/89
|
||||
context = op.get_context()
|
||||
if context.bind.dialect.name == 'postgresql':
|
||||
op.execute("CREATE TYPE ipv6_ra_modes AS ENUM ('%s', '%s', '%s')"
|
||||
% ('slaac', 'dhcpv6-stateful', 'dhcpv6-stateless'))
|
||||
op.execute("CREATE TYPE ipv6_address_modes AS ENUM ('%s', '%s', '%s')"
|
||||
% ('slaac', 'dhcpv6-stateful', 'dhcpv6-stateless'))
|
||||
op.add_column('subnets',
|
||||
sa.Column('ipv6_ra_mode',
|
||||
sa.Enum('slaac',
|
||||
'dhcpv6-stateful',
|
||||
'dhcpv6-stateless',
|
||||
name='ipv6_ra_modes'),
|
||||
nullable=True)
|
||||
)
|
||||
op.add_column('subnets',
|
||||
sa.Column('ipv6_address_mode',
|
||||
sa.Enum('slaac',
|
||||
'dhcpv6-stateful',
|
||||
'dhcpv6-stateless',
|
||||
name='ipv6_address_modes'),
|
||||
nullable=True)
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_column('subnets', 'ipv6_ra_mode')
|
||||
op.drop_column('subnets', 'ipv6_address_mode')
|
||||
context = op.get_context()
|
||||
if context.bind.dialect.name == 'postgresql':
|
||||
op.execute('DROP TYPE ipv6_ra_modes')
|
||||
op.execute('DROP TYPE ipv6_address_modes')
|
|
@ -1,60 +0,0 @@
|
|||
# Copyright 2014 Cisco Systems, Inc. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Cisco CSR VPNaaS
|
||||
|
||||
Revision ID: 24c7ea5160d7
|
||||
Revises: 492a106273f8
|
||||
Create Date: 2014-02-03 13:06:50.407601
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '24c7ea5160d7'
|
||||
down_revision = '492a106273f8'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.services.vpn.plugin.VPNDriverPlugin',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'cisco_csr_identifier_map',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('ipsec_site_conn_id', sa.String(length=64),
|
||||
primary_key=True),
|
||||
sa.Column('csr_tunnel_id', sa.Integer(), nullable=False),
|
||||
sa.Column('csr_ike_policy_id', sa.Integer(), nullable=False),
|
||||
sa.Column('csr_ipsec_policy_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['ipsec_site_conn_id'],
|
||||
['ipsec_site_connections.id'],
|
||||
ondelete='CASCADE')
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('cisco_csr_identifier_map')
|
|
@ -1,61 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""NEC PacketFilter network_id nullable fix
|
||||
|
||||
Revision ID: 2528ceb28230
|
||||
Revises: 1064e98b7917
|
||||
Create Date: 2013-09-24 12:07:43.124256
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2528ceb28230'
|
||||
down_revision = '1064e98b7917'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.alter_column('packetfilters', 'network_id',
|
||||
existing_type=sa.String(length=36),
|
||||
nullable=False)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
# NOTE(amotoki): There is a bug that nullable of network_id is
|
||||
# set to True by mistake in folsom_initial (bug 1229508).
|
||||
# To make sure nullable=False in any revision, nullable is set
|
||||
# to False in both upgrade and downgrade.
|
||||
op.alter_column('packetfilters', 'network_id',
|
||||
existing_type=sa.String(length=36),
|
||||
nullable=False)
|
|
@ -1,66 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Cisco plugin db cleanup part II
|
||||
|
||||
Revision ID: 263772d65691
|
||||
Revises: 35c7c198ddea
|
||||
Create Date: 2013-07-29 02:31:26.646343
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '263772d65691'
|
||||
down_revision = '35c7c198ddea'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.cisco.network_plugin.PluginV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.rename_table('credentials', 'cisco_credentials')
|
||||
op.rename_table('nexusport_bindings', 'cisco_nexusport_bindings')
|
||||
op.rename_table('qoss', 'cisco_qos_policies')
|
||||
|
||||
op.drop_table('cisco_vlan_ids')
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'cisco_vlan_ids',
|
||||
sa.Column('vlan_id', sa.Integer, nullable=False),
|
||||
sa.Column('vlan_used', sa.Boolean),
|
||||
sa.PrimaryKeyConstraint('vlan_id'),
|
||||
)
|
||||
|
||||
op.rename_table('cisco_credentials', 'credentials')
|
||||
op.rename_table('cisco_nexusport_bindings', 'nexusport_bindings')
|
||||
op.rename_table('cisco_qos_policies', 'qoss')
|
|
@ -1,54 +0,0 @@
|
|||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""ml2_vnic_type
|
||||
|
||||
Revision ID: 27cc183af192
|
||||
Revises: 4ca36cfc898c
|
||||
Create Date: 2014-02-09 12:19:21.362967
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '27cc183af192'
|
||||
down_revision = '4ca36cfc898c'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.add_column('ml2_port_bindings',
|
||||
sa.Column('vnic_type', sa.String(length=64),
|
||||
nullable=False,
|
||||
server_default='normal'))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_column('ml2_port_bindings', 'vnic_type')
|
|
@ -1,65 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""quota_in_plumgrid_plugin
|
||||
|
||||
Revision ID: 27ef74513d33
|
||||
Revises: 3a520dd165d0
|
||||
Create Date: 2013-10-08 10:59:19.860397
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '27ef74513d33'
|
||||
down_revision = '3a520dd165d0'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.plumgrid.plumgrid_plugin.plumgrid_plugin.'
|
||||
'NeutronPluginPLUMgridV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
'quotas',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('resource', sa.String(length=255), nullable=True),
|
||||
sa.Column('limit', sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('quotas')
|
||||
### end Alembic commands ###
|
|
@ -1,65 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""NEC Port Binding
|
||||
|
||||
Revision ID: 2a3bae1ceb8
|
||||
Revises: 46a0efbd8f0
|
||||
Create Date: 2013-08-22 11:09:19.955386
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2a3bae1ceb8'
|
||||
down_revision = '46a0efbd8f0'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'portbindingports',
|
||||
sa.Column('port_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('host', sa.String(length=255), nullable=False),
|
||||
sa.ForeignKeyConstraint(['port_id'], ['ports.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('port_id')
|
||||
)
|
||||
op.create_foreign_key(
|
||||
'portinfos_ibfk_1',
|
||||
source='portinfos', referent='ports',
|
||||
local_cols=['id'], remote_cols=['id'],
|
||||
ondelete='CASCADE')
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_constraint('portinfos_ibfk_1', 'portinfos', 'foreignkey')
|
||||
op.drop_table('portbindingports')
|
|
@ -1,88 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""cisco plugin cleanup
|
||||
|
||||
Revision ID: 2a6d0b51f4bb
|
||||
Revises: 1d76643bcec4
|
||||
Create Date: 2013-01-17 22:24:37.730466
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2a6d0b51f4bb'
|
||||
down_revision = '1d76643bcec4'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.cisco.network_plugin.PluginV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table(u'portprofile_bindings')
|
||||
op.drop_table(u'portprofiles')
|
||||
op.drop_table(u'port_bindings')
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
u'port_bindings',
|
||||
sa.Column(u'id', sa.Integer(), autoincrement=True,
|
||||
nullable=False),
|
||||
sa.Column(u'port_id', sa.String(255), nullable=False),
|
||||
sa.Column(u'blade_intf_dn', sa.String(255), nullable=False),
|
||||
sa.Column(u'portprofile_name', sa.String(255),
|
||||
nullable=True),
|
||||
sa.Column(u'vlan_name', sa.String(255), nullable=True),
|
||||
sa.Column(u'vlan_id', sa.Integer(), nullable=True),
|
||||
sa.Column(u'qos', sa.String(255), nullable=True),
|
||||
sa.Column(u'tenant_id', sa.String(255), nullable=True),
|
||||
sa.Column(u'vif_id', sa.String(255), nullable=True),
|
||||
sa.PrimaryKeyConstraint(u'id')
|
||||
)
|
||||
op.create_table(
|
||||
u'portprofiles',
|
||||
sa.Column(u'uuid', sa.String(255), nullable=False),
|
||||
sa.Column(u'name', sa.String(255), nullable=True),
|
||||
sa.Column(u'vlan_id', sa.Integer(), nullable=True),
|
||||
sa.Column(u'qos', sa.String(255), nullable=True),
|
||||
sa.PrimaryKeyConstraint(u'uuid')
|
||||
)
|
||||
op.create_table(
|
||||
u'portprofile_bindings',
|
||||
sa.Column(u'id', sa.String(255), nullable=False),
|
||||
sa.Column(u'tenant_id', sa.String(255), nullable=True),
|
||||
sa.Column(u'port_id', sa.String(255), nullable=True),
|
||||
sa.Column(u'portprofile_id', sa.String(255), nullable=True),
|
||||
sa.Column(u'default', sa.Boolean(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['portprofile_id'], ['portprofiles.uuid'], ),
|
||||
sa.ForeignKeyConstraint(['port_id'], ['ports.id'], ),
|
||||
sa.PrimaryKeyConstraint(u'id')
|
||||
)
|
|
@ -1,56 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""l3_support
|
||||
|
||||
Revision ID: 2c4af419145b
|
||||
Revises: folsom
|
||||
Create Date: 2013-03-11 19:26:45.697774
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2c4af419145b'
|
||||
down_revision = 'folsom'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.bigswitch.plugin.NeutronRestProxyV2',
|
||||
'neutron.plugins.hyperv.hyperv_neutron_plugin.HyperVNeutronPlugin',
|
||||
'neutron.plugins.midonet.plugin.MidonetPluginV2',
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin',
|
||||
'neutron.plugins.embrane.plugins.embrane_ovs_plugin.EmbraneOvsPlugin',
|
||||
]
|
||||
|
||||
from neutron.db import migration
|
||||
from neutron.db.migration.alembic_migrations import common_ext_ops
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
common_ext_ops.upgrade_l3()
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
common_ext_ops.downgrade_l3()
|
|
@ -1,83 +0,0 @@
|
|||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nuage_floatingip
|
||||
|
||||
Revision ID: 2db5203cb7a9
|
||||
Revises: 10cd28e692e9
|
||||
Create Date: 2014-05-19 16:39:42.048125
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2db5203cb7a9'
|
||||
down_revision = '10cd28e692e9'
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nuage.plugin.NuagePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'nuage_floatingip_pool_mapping',
|
||||
sa.Column('fip_pool_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('net_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('router_id', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['net_id'], ['networks.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('fip_pool_id'),
|
||||
)
|
||||
op.create_table(
|
||||
'nuage_floatingip_mapping',
|
||||
sa.Column('fip_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('router_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('nuage_fip_id', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['fip_id'], ['floatingips.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('fip_id'),
|
||||
)
|
||||
op.rename_table('net_partitions', 'nuage_net_partitions')
|
||||
op.rename_table('net_partition_router_mapping',
|
||||
'nuage_net_partition_router_mapping')
|
||||
op.rename_table('router_zone_mapping', 'nuage_router_zone_mapping')
|
||||
op.rename_table('subnet_l2dom_mapping', 'nuage_subnet_l2dom_mapping')
|
||||
op.rename_table('port_mapping', 'nuage_port_mapping')
|
||||
op.rename_table('routerroutes_mapping', 'nuage_routerroutes_mapping')
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('nuage_floatingip_mapping')
|
||||
op.drop_table('nuage_floatingip_pool_mapping')
|
||||
op.rename_table('nuage_net_partitions', 'net_partitions')
|
||||
op.rename_table('nuage_net_partition_router_mapping',
|
||||
'net_partition_router_mapping')
|
||||
op.rename_table('nuage_router_zone_mapping', 'router_zone_mapping')
|
||||
op.rename_table('nuage_subnet_l2dom_mapping', 'subnet_l2dom_mapping')
|
||||
op.rename_table('nuage_port_mapping', 'port_mapping')
|
||||
op.rename_table('nuage_routerroutes_mapping', 'routerroutes_mapping')
|
|
@ -1,81 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""floatingip_status
|
||||
|
||||
Revision ID: 2eeaf963a447
|
||||
Revises: f44ab9871cd6
|
||||
Create Date: 2014-01-14 11:58:13.754747
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2eeaf963a447'
|
||||
down_revision = 'f44ab9871cd6'
|
||||
|
||||
# This migration is applied to all L3 capable plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.bigswitch.plugin.NeutronRestProxyV2',
|
||||
'neutron.plugins.brocade.NeutronPlugin.BrocadePluginV2',
|
||||
'neutron.plugins.cisco.network_plugin.PluginV2',
|
||||
'neutron.plugins.cisco.n1kv.n1kv_neutron_plugin.N1kvNeutronPluginV2',
|
||||
'neutron.plugins.embrane.plugins.embrane_ovs_plugin.EmbraneOvsPlugin',
|
||||
'neutron.plugins.hyperv.hyperv_neutron_plugin.HyperVNeutronPlugin',
|
||||
'neutron.plugins.ibm.sdnve_neutron_plugin.SdnvePluginV2',
|
||||
'neutron.plugins.linuxbridge.lb_neutron_plugin.LinuxBridgePluginV2',
|
||||
'neutron.plugins.metaplugin.meta_neutron_plugin.MetaPluginV2',
|
||||
'neutron.plugins.mlnx.mlnx_plugin.MellanoxEswitchPlugin',
|
||||
'neutron.plugins.midonet.plugin.MidonetPluginV2',
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin',
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2',
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.nuage.plugin.NuagePlugin',
|
||||
'neutron.plugins.oneconvergence.plugin.OneConvergencePluginV2',
|
||||
'neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2',
|
||||
'neutron.plugins.plumgrid.plumgrid_plugin.plumgrid_plugin.'
|
||||
'NeutronPluginPLUMgridV2',
|
||||
'neutron.plugins.ryu.ryu_neutron_plugin.RyuNeutronPluginV2',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
op.add_column('floatingips',
|
||||
sa.Column('last_known_router_id',
|
||||
sa.String(length=36),
|
||||
nullable=True))
|
||||
op.add_column('floatingips',
|
||||
sa.Column('status',
|
||||
sa.String(length=16),
|
||||
nullable=True))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
op.drop_column('floatingips', 'last_known_router_id')
|
||||
op.drop_column('floatingips', 'status')
|
|
@ -1,70 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""ml2 portbinding
|
||||
|
||||
Revision ID: 32a65f71af51
|
||||
Revises: 14f24494ca31
|
||||
Create Date: 2013-09-03 08:40:22.706651
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '32a65f71af51'
|
||||
down_revision = '14f24494ca31'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'ml2_port_bindings',
|
||||
sa.Column('port_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('host', sa.String(length=255), nullable=False),
|
||||
sa.Column('vif_type', sa.String(length=64), nullable=False),
|
||||
sa.Column('cap_port_filter', sa.Boolean(), nullable=False),
|
||||
sa.Column('driver', sa.String(length=64), nullable=True),
|
||||
sa.Column('segment', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['port_id'], ['ports.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['segment'], ['ml2_network_segments.id'],
|
||||
ondelete='SET NULL'),
|
||||
sa.PrimaryKeyConstraint('port_id')
|
||||
)
|
||||
|
||||
# Note that 176a85fc7d79_add_portbindings_db.py was never enabled
|
||||
# for ml2, so there is no need to drop the portbindingports table
|
||||
# that is no longer used.
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('ml2_port_bindings')
|
|
@ -1,58 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""remove TunnelIP model
|
||||
|
||||
Revision ID: 32b517556ec9
|
||||
Revises: 176a85fc7d79
|
||||
Create Date: 2013-05-23 06:46:57.390838
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '32b517556ec9'
|
||||
down_revision = '176a85fc7d79'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('ovs_tunnel_ips')
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'ovs_tunnel_ips',
|
||||
sa.Column('ip_address', sa.String(length=255), nullable=False),
|
||||
sa.PrimaryKeyConstraint('ip_address')
|
||||
)
|
|
@ -1,55 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""vpnaas peer_address size increase
|
||||
|
||||
Revision ID: 338d7508968c
|
||||
Revises: 4a666eb208c2
|
||||
Create Date: 2013-09-16 11:31:39.410189
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '338d7508968c'
|
||||
down_revision = '4a666eb208c2'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.services.vpn.plugin.VPNDriverPlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.alter_column('ipsec_site_connections', 'peer_address',
|
||||
type_=sa.String(255), existing_type=sa.String(64))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.alter_column('ipsec_site_connections', 'peer_address',
|
||||
type_=sa.String(64), existing_type=sa.String(255))
|
|
@ -1,58 +0,0 @@
|
|||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""set_length_of_description_field_metering
|
||||
|
||||
Revision ID: 33c3db036fe4
|
||||
Revises: b65aa907aec
|
||||
Create Date: 2014-03-25 11:04:27.341830
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '33c3db036fe4'
|
||||
down_revision = 'b65aa907aec'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.services.metering.metering_plugin.MeteringPlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.execute("CREATE TABLE IF NOT EXISTS meteringlabels( "
|
||||
"tenant_id VARCHAR(255) NULL, "
|
||||
"id VARCHAR(36) PRIMARY KEY NOT NULL, "
|
||||
"name VARCHAR(255) NULL, "
|
||||
"description VARCHAR(255) NULL)")
|
||||
|
||||
op.alter_column('meteringlabels', 'description', type_=sa.String(1024),
|
||||
existing_nullable=True)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
pass
|
|
@ -1,61 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""embrane_lbaas_driver
|
||||
|
||||
Revision ID: 33dd0a9fa487
|
||||
Revises: 19180cf98af6
|
||||
Create Date: 2014-02-25 00:15:35.567111
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '33dd0a9fa487'
|
||||
down_revision = '19180cf98af6'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
u'embrane_pool_port',
|
||||
sa.Column(u'pool_id', sa.String(length=36), nullable=False),
|
||||
sa.Column(u'port_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['pool_id'], [u'pools.id'],
|
||||
name=u'embrane_pool_port_ibfk_1'),
|
||||
sa.ForeignKeyConstraint(['port_id'], [u'ports.id'],
|
||||
name=u'embrane_pool_port_ibfk_2'),
|
||||
sa.PrimaryKeyConstraint(u'pool_id'))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table(u'embrane_pool_port')
|
|
@ -1,58 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""remove status from HealthMonitor
|
||||
|
||||
Revision ID: 35c7c198ddea
|
||||
Revises: 11c6e18605c8
|
||||
Create Date: 2013-08-02 23:14:54.037976
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '35c7c198ddea'
|
||||
down_revision = '11c6e18605c8'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
op.drop_column('healthmonitors', 'status')
|
||||
op.drop_column('healthmonitors', 'status_description')
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.add_column('healthmonitors', sa.Column('status',
|
||||
sa.String(16),
|
||||
nullable=False))
|
||||
op.add_column('healthmonitors', sa.Column('status_description',
|
||||
sa.String(255)))
|
|
@ -1,100 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nvp_network_gw
|
||||
|
||||
Revision ID: 363468ac592c
|
||||
Revises: 1c33fa3cd1a1
|
||||
Create Date: 2013-02-07 03:19:14.455372
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '363468ac592c'
|
||||
down_revision = '1c33fa3cd1a1'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
op.create_table('networkgateways',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('tenant_id', sa.String(length=36),
|
||||
nullable=True),
|
||||
sa.Column('default', sa.Boolean(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'))
|
||||
op.create_table('networkgatewaydevices',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('network_gateway_id', sa.String(length=36),
|
||||
nullable=True),
|
||||
sa.Column('interface_name', sa.String(length=64),
|
||||
nullable=True),
|
||||
sa.ForeignKeyConstraint(['network_gateway_id'],
|
||||
['networkgateways.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id'))
|
||||
op.create_table('networkconnections',
|
||||
sa.Column('tenant_id', sa.String(length=255),
|
||||
nullable=True),
|
||||
sa.Column('network_gateway_id', sa.String(length=36),
|
||||
nullable=True),
|
||||
sa.Column('network_id', sa.String(length=36),
|
||||
nullable=True),
|
||||
sa.Column('segmentation_type',
|
||||
sa.Enum('flat', 'vlan',
|
||||
name="net_conn_seg_type"),
|
||||
nullable=True),
|
||||
sa.Column('segmentation_id', sa.Integer(),
|
||||
nullable=True),
|
||||
sa.Column('port_id', sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.ForeignKeyConstraint(['network_gateway_id'],
|
||||
['networkgateways.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['port_id'], ['ports.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('port_id'),
|
||||
sa.UniqueConstraint('network_gateway_id',
|
||||
'segmentation_type',
|
||||
'segmentation_id'))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('networkconnections')
|
||||
op.drop_table('networkgatewaydevices')
|
||||
op.drop_table('networkgateways')
|
|
@ -1,62 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nvp_portmap
|
||||
|
||||
Revision ID: 38335592a0dc
|
||||
Revises: 49332180ca96
|
||||
Create Date: 2013-01-15 06:04:56.328991
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '38335592a0dc'
|
||||
down_revision = '49332180ca96'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'quantum_nvp_port_mapping',
|
||||
sa.Column('quantum_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('nvp_id', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['quantum_id'], ['ports.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('quantum_id'))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('quantum_nvp_port_mapping')
|
|
@ -1,57 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Cisco N1KV overlay support
|
||||
|
||||
Revision ID: 38fc1f6789f8
|
||||
Revises: 1efb85914233
|
||||
Create Date: 2013-08-20 18:31:16.158387
|
||||
|
||||
"""
|
||||
|
||||
revision = '38fc1f6789f8'
|
||||
down_revision = '1efb85914233'
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.cisco.network_plugin.PluginV2'
|
||||
]
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
new_type = sa.Enum('vlan', 'overlay', 'trunk', 'multi-segment',
|
||||
name='vlan_type')
|
||||
old_type = sa.Enum('vlan', 'vxlan', 'trunk', 'multi-segment',
|
||||
name='vlan_type')
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
migration.alter_enum('cisco_network_profiles', 'segment_type', new_type,
|
||||
nullable=False)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
migration.alter_enum('cisco_network_profiles', 'segment_type', old_type,
|
||||
nullable=False)
|
|
@ -1,109 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""FWaaS Havana-2 model
|
||||
|
||||
Revision ID: 39cf3f799352
|
||||
Revises: e6b16a30d97
|
||||
Create Date: 2013-07-10 16:16:51.302943
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '39cf3f799352'
|
||||
down_revision = 'e6b16a30d97'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.services.firewall.fwaas_plugin.FirewallPlugin',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('firewall_rules')
|
||||
op.drop_table('firewalls')
|
||||
op.drop_table('firewall_policies')
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'firewall_policies',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('description', sa.String(length=1024), nullable=True),
|
||||
sa.Column('shared', sa.Boolean(), autoincrement=False, nullable=True),
|
||||
sa.Column('audited', sa.Boolean(), autoincrement=False,
|
||||
nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'))
|
||||
op.create_table(
|
||||
'firewalls', sa.Column('tenant_id', sa.String(length=255),
|
||||
nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('description', sa.String(length=1024), nullable=True),
|
||||
sa.Column('shared', sa.Boolean(), autoincrement=False, nullable=True),
|
||||
sa.Column('admin_state_up', sa.Boolean(), autoincrement=False,
|
||||
nullable=True),
|
||||
sa.Column('status', sa.String(length=16), nullable=True),
|
||||
sa.Column('firewall_policy_id', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['firewall_policy_id'],
|
||||
['firewall_policies.id'],
|
||||
name='firewalls_ibfk_1'),
|
||||
sa.PrimaryKeyConstraint('id'))
|
||||
op.create_table(
|
||||
'firewall_rules',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('description', sa.String(length=1024), nullable=True),
|
||||
sa.Column('firewall_policy_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('shared', sa.Boolean(), autoincrement=False,
|
||||
nullable=True),
|
||||
sa.Column('protocol', sa.String(length=24), nullable=True),
|
||||
sa.Column('ip_version', sa.Integer(), autoincrement=False,
|
||||
nullable=False),
|
||||
sa.Column('source_ip_address', sa.String(length=46), nullable=True),
|
||||
sa.Column('destination_ip_address', sa.String(length=46),
|
||||
nullable=True),
|
||||
sa.Column('source_port_range_min', sa.Integer(), nullable=True),
|
||||
sa.Column('source_port_range_max', sa.Integer(), nullable=True),
|
||||
sa.Column('destination_port_range_min', sa.Integer(), nullable=True),
|
||||
sa.Column('destination_port_range_max', sa.Integer(), nullable=True),
|
||||
sa.Column('action',
|
||||
sa.Enum('allow', 'deny', name='firewallrules_action'),
|
||||
nullable=True),
|
||||
sa.Column('enabled', sa.Boolean(), autoincrement=False,
|
||||
nullable=True),
|
||||
sa.Column('position', sa.Integer(), autoincrement=False,
|
||||
nullable=True),
|
||||
sa.ForeignKeyConstraint(['firewall_policy_id'],
|
||||
['firewall_policies.id'],
|
||||
name='firewall_rules_ibfk_1'),
|
||||
sa.PrimaryKeyConstraint('id'))
|
|
@ -1,59 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Cisco Nexus multi-switch
|
||||
|
||||
Revision ID: 3a520dd165d0
|
||||
Revises: 2528ceb28230
|
||||
Create Date: 2013-09-28 15:23:38.872682
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3a520dd165d0'
|
||||
down_revision = '2528ceb28230'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.cisco.network_plugin.PluginV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.add_column(
|
||||
'cisco_nexusport_bindings',
|
||||
sa.Column('instance_id', sa.String(length=255), nullable=False))
|
||||
op.add_column(
|
||||
'cisco_nexusport_bindings',
|
||||
sa.Column('switch_ip', sa.String(length=255), nullable=False))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_column('cisco_nexusport_bindings', 'switch_ip')
|
||||
op.drop_column('cisco_nexusport_bindings', 'instance_id')
|
|
@ -1,84 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""NEC plugin sharednet
|
||||
|
||||
Revision ID: 3b54bf9e29f7
|
||||
Revises: 511471cc46b
|
||||
Create Date: 2013-02-17 09:21:48.287134
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3b54bf9e29f7'
|
||||
down_revision = '511471cc46b'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'ofctenantmappings',
|
||||
sa.Column('ofc_id', sa.String(length=255), nullable=False),
|
||||
sa.Column('quantum_id', sa.String(length=36), nullable=False),
|
||||
sa.PrimaryKeyConstraint('quantum_id'),
|
||||
sa.UniqueConstraint('ofc_id')
|
||||
)
|
||||
op.create_table(
|
||||
'ofcnetworkmappings',
|
||||
sa.Column('ofc_id', sa.String(length=255), nullable=False),
|
||||
sa.Column('quantum_id', sa.String(length=36), nullable=False),
|
||||
sa.PrimaryKeyConstraint('quantum_id'),
|
||||
sa.UniqueConstraint('ofc_id')
|
||||
)
|
||||
op.create_table(
|
||||
'ofcportmappings',
|
||||
sa.Column('ofc_id', sa.String(length=255), nullable=False),
|
||||
sa.Column('quantum_id', sa.String(length=36), nullable=False),
|
||||
sa.PrimaryKeyConstraint('quantum_id'),
|
||||
sa.UniqueConstraint('ofc_id')
|
||||
)
|
||||
op.create_table(
|
||||
'ofcfiltermappings',
|
||||
sa.Column('ofc_id', sa.String(length=255), nullable=False),
|
||||
sa.Column('quantum_id', sa.String(length=36), nullable=False),
|
||||
sa.PrimaryKeyConstraint('quantum_id'),
|
||||
sa.UniqueConstraint('ofc_id')
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('ofcfiltermappings')
|
||||
op.drop_table('ofcportmappings')
|
||||
op.drop_table('ofcnetworkmappings')
|
||||
op.drop_table('ofctenantmappings')
|
|
@ -1,103 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""add multiprovider
|
||||
|
||||
Revision ID: 3c6e57a23db4
|
||||
Revises: 86cf4d88bd3
|
||||
Create Date: 2013-07-10 12:43:35.769283
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3c6e57a23db4'
|
||||
down_revision = '86cf4d88bd3'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'nvp_multi_provider_networks',
|
||||
sa.Column('network_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('network_id'),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
op.create_table('rename_nvp_network_bindings',
|
||||
sa.Column('network_id', sa.String(length=36),
|
||||
primary_key=True),
|
||||
sa.Column('binding_type',
|
||||
sa.Enum(
|
||||
'flat', 'vlan', 'stt', 'gre', 'l3_ext',
|
||||
name=(
|
||||
'nvp_network_bindings_binding_type')),
|
||||
nullable=False, primary_key=True),
|
||||
sa.Column('phy_uuid', sa.String(36), primary_key=True,
|
||||
nullable=True),
|
||||
sa.Column('vlan_id', sa.Integer, primary_key=True,
|
||||
nullable=True, autoincrement=False))
|
||||
# copy data from nvp_network_bindings into rename_nvp_network_bindings
|
||||
op.execute("INSERT INTO rename_nvp_network_bindings SELECT network_id, "
|
||||
"binding_type, phy_uuid, vlan_id from nvp_network_bindings")
|
||||
|
||||
op.drop_table('nvp_network_bindings')
|
||||
op.rename_table('rename_nvp_network_bindings', 'nvp_network_bindings')
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
# Delete the multi_provider_network entries from nvp_network_bindings
|
||||
op.execute("DELETE from nvp_network_bindings WHERE network_id IN "
|
||||
"(SELECT network_id from nvp_multi_provider_networks)")
|
||||
|
||||
# create table with previous contains
|
||||
op.create_table(
|
||||
'rename_nvp_network_bindings',
|
||||
sa.Column('network_id', sa.String(length=36), primary_key=True),
|
||||
sa.Column('binding_type',
|
||||
sa.Enum('flat', 'vlan', 'stt', 'gre', 'l3_ext',
|
||||
name=('nvp_network_bindings_binding_type')),
|
||||
nullable=False),
|
||||
sa.Column('phy_uuid', sa.String(36), nullable=True),
|
||||
sa.Column('vlan_id', sa.Integer, nullable=True, autoincrement=False))
|
||||
|
||||
# copy data from nvp_network_bindings into rename_nvp_network_bindings
|
||||
op.execute("INSERT INTO rename_nvp_network_bindings SELECT network_id, "
|
||||
"binding_type, phy_uuid, vlan_id from nvp_network_bindings")
|
||||
|
||||
op.drop_table('nvp_network_bindings')
|
||||
op.rename_table('rename_nvp_network_bindings', 'nvp_network_bindings')
|
||||
op.drop_table('nvp_multi_provider_networks')
|
|
@ -1,63 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Table to track port to host associations
|
||||
|
||||
Revision ID: 3cabb850f4a5
|
||||
Revises: 5918cbddab04
|
||||
Create Date: 2013-06-24 14:30:33.533562
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3cabb850f4a5'
|
||||
down_revision = '5918cbddab04'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.bigswitch.plugin.NeutronRestProxyV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('portlocations',
|
||||
sa.Column('port_id', sa.String(length=255),
|
||||
primary_key=True, nullable=False),
|
||||
sa.Column('host_id',
|
||||
sa.String(length=255), nullable=False)
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('portlocations')
|
||||
### end Alembic commands ###
|
|
@ -1,103 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""security_groups
|
||||
|
||||
Revision ID: 3cb5d900c5de
|
||||
Revises: 48b6f43f7471
|
||||
Create Date: 2013-01-08 00:13:43.051078
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3cb5d900c5de'
|
||||
down_revision = '48b6f43f7471'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.linuxbridge.lb_neutron_plugin.LinuxBridgePluginV2',
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2',
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2',
|
||||
'neutron.plugins.ryu.ryu_neutron_plugin.RyuNeutronPluginV2',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin',
|
||||
'neutron.plugins.oneconvergence.plugin.OneConvergencePluginV2',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
'securitygroups',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('description', sa.String(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table(
|
||||
'securitygrouprules',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('security_group_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('remote_group_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('direction',
|
||||
sa.Enum('ingress', 'egress',
|
||||
name='securitygrouprules_direction'),
|
||||
nullable=True),
|
||||
sa.Column('ethertype', sa.String(length=40), nullable=True),
|
||||
sa.Column('protocol', sa.String(length=40), nullable=True),
|
||||
sa.Column('port_range_min', sa.Integer(), nullable=True),
|
||||
sa.Column('port_range_max', sa.Integer(), nullable=True),
|
||||
sa.Column('remote_ip_prefix', sa.String(length=255), nullable=True),
|
||||
sa.ForeignKeyConstraint(['security_group_id'], ['securitygroups.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['remote_group_id'], ['securitygroups.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table(
|
||||
'securitygroupportbindings',
|
||||
sa.Column('port_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('security_group_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['port_id'], ['ports.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['security_group_id'], ['securitygroups.id']),
|
||||
sa.PrimaryKeyConstraint('port_id', 'security_group_id')
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('securitygroupportbindings')
|
||||
op.drop_table('securitygrouprules')
|
||||
op.drop_table('securitygroups')
|
||||
### end Alembic commands ###
|
|
@ -1,63 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nvp_mac_learning
|
||||
|
||||
Revision ID: 3cbf70257c28
|
||||
Revises: 5ac71e65402c
|
||||
Create Date: 2013-05-15 10:15:50.875314
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3cbf70257c28'
|
||||
down_revision = '5ac71e65402c'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'maclearningstates',
|
||||
sa.Column('port_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('mac_learning_enabled', sa.Boolean(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
['port_id'], ['ports.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('port_id'))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('maclearningstates')
|
|
@ -1,65 +0,0 @@
|
|||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""VMware NSX rebranding
|
||||
|
||||
Revision ID: 3d2585038b95
|
||||
Revises: 157a5d299379
|
||||
Create Date: 2014-02-11 18:18:34.319031
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3d2585038b95'
|
||||
down_revision = '157a5d299379'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.rename_table('nvp_network_bindings', 'tz_network_bindings')
|
||||
op.rename_table('nvp_multi_provider_networks', 'multi_provider_networks')
|
||||
|
||||
engine = op.get_bind().engine
|
||||
if engine.name == 'postgresql':
|
||||
op.execute("ALTER TYPE nvp_network_bindings_binding_type "
|
||||
"RENAME TO tz_network_bindings_binding_type;")
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
engine = op.get_bind().engine
|
||||
if engine.name == 'postgresql':
|
||||
op.execute("ALTER TYPE tz_network_bindings_binding_type "
|
||||
"RENAME TO nvp_network_bindings_binding_type;")
|
||||
|
||||
op.rename_table('multi_provider_networks', 'nvp_multi_provider_networks')
|
||||
op.rename_table('tz_network_bindings', 'nvp_network_bindings')
|
|
@ -1,61 +0,0 @@
|
|||
# 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.
|
||||
#
|
||||
|
||||
"""nsx_switch_mappings
|
||||
|
||||
Revision ID: 3d3cb89d84ee
|
||||
Revises: 1421183d533f
|
||||
Create Date: 2014-01-07 15:37:41.323020
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3d3cb89d84ee'
|
||||
down_revision = '1421183d533f'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
# Create table for network mappings
|
||||
op.create_table(
|
||||
'neutron_nsx_network_mappings',
|
||||
sa.Column('neutron_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('nsx_id', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['neutron_id'], ['networks.id'],
|
||||
ondelete='CASCADE'),
|
||||
# There might be multiple switches for a neutron network
|
||||
sa.PrimaryKeyConstraint('neutron_id', 'nsx_id'),
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('neutron_nsx_network_mappings')
|
|
@ -1,82 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nvp lbaas plugin
|
||||
|
||||
Revision ID: 3d6fae8b70b0
|
||||
Revises: 3ed8f075e38a
|
||||
Create Date: 2013-09-13 19:34:41.522665
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3d6fae8b70b0'
|
||||
down_revision = '3ed8f075e38a'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'vcns_edge_pool_bindings',
|
||||
sa.Column('pool_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('edge_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('pool_vseid', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['pool_id'], ['pools.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('pool_id', 'edge_id')
|
||||
)
|
||||
op.create_table(
|
||||
'vcns_edge_monitor_bindings',
|
||||
sa.Column('monitor_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('edge_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('monitor_vseid', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['monitor_id'], ['healthmonitors.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('monitor_id', 'edge_id')
|
||||
)
|
||||
op.create_table(
|
||||
'vcns_edge_vip_bindings',
|
||||
sa.Column('vip_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('edge_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('vip_vseid', sa.String(length=36), nullable=True),
|
||||
sa.Column('app_profileid', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['vip_id'], ['vips.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('vip_id')
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('vcns_edge_vip_bindings')
|
||||
op.drop_table('vcns_edge_monitor_bindings')
|
||||
op.drop_table('vcns_edge_pool_bindings')
|
|
@ -1,60 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nvp fwaas plugin
|
||||
|
||||
Revision ID: 3ed8f075e38a
|
||||
Revises: 338d7508968c
|
||||
Create Date: 2013-09-13 19:14:25.509033
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3ed8f075e38a'
|
||||
down_revision = '338d7508968c'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'vcns_firewall_rule_bindings',
|
||||
sa.Column('rule_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('edge_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('rule_vseid', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['rule_id'], ['firewall_rules.id'], ),
|
||||
sa.PrimaryKeyConstraint('rule_id', 'edge_id')
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('vcns_firewall_rule_bindings')
|
|
@ -1,194 +0,0 @@
|
|||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""mlnx_initial
|
||||
|
||||
Revision ID: 40b0aff0302e
|
||||
Revises: 49f5e553f61f
|
||||
Create Date: 2014-01-12 14:51:49.273105
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '40b0aff0302e'
|
||||
down_revision = '49f5e553f61f'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.mlnx.mlnx_plugin.MellanoxEswitchPlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'securitygroups',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('description', sa.String(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'segmentation_id_allocation',
|
||||
sa.Column('physical_network', sa.String(length=64), nullable=False),
|
||||
sa.Column('segmentation_id', sa.Integer(), autoincrement=False,
|
||||
nullable=False),
|
||||
sa.Column('allocated', sa.Boolean(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('physical_network', 'segmentation_id'),
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'quotas',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('tenant_id', sa.String(255), index=True),
|
||||
sa.Column('resource', sa.String(255)),
|
||||
sa.Column('limit', sa.Integer()),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'mlnx_network_bindings',
|
||||
sa.Column('network_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('network_type', sa.String(length=32), nullable=False),
|
||||
sa.Column('physical_network', sa.String(length=64), nullable=True),
|
||||
sa.Column('segmentation_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('network_id'),
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'networkdhcpagentbindings',
|
||||
sa.Column('network_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('dhcp_agent_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['dhcp_agent_id'], ['agents.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('network_id', 'dhcp_agent_id'),
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'securitygrouprules',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('security_group_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('remote_group_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('direction',
|
||||
sa.Enum('ingress', 'egress',
|
||||
name='securitygrouprules_direction'),
|
||||
nullable=True),
|
||||
sa.Column('ethertype', sa.String(length=40), nullable=True),
|
||||
sa.Column('protocol', sa.String(length=40), nullable=True),
|
||||
sa.Column('port_range_min', sa.Integer(), nullable=True),
|
||||
sa.Column('port_range_max', sa.Integer(), nullable=True),
|
||||
sa.Column('remote_ip_prefix', sa.String(length=255), nullable=True),
|
||||
sa.ForeignKeyConstraint(['remote_group_id'], ['securitygroups.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['security_group_id'], ['securitygroups.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'port_profile',
|
||||
sa.Column('port_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('vnic_type', sa.String(length=32), nullable=False),
|
||||
sa.ForeignKeyConstraint(['port_id'], ['ports.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('port_id'),
|
||||
)
|
||||
|
||||
op.add_column('routers', sa.Column('enable_snat', sa.Boolean(),
|
||||
nullable=False, default=True))
|
||||
op.create_table(
|
||||
'securitygroupportbindings',
|
||||
sa.Column('port_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('security_group_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['port_id'], ['ports.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['security_group_id'], ['securitygroups.id'],),
|
||||
sa.PrimaryKeyConstraint('port_id', 'security_group_id'),
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'portbindingports',
|
||||
sa.Column('port_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('host', sa.String(length=255), nullable=False),
|
||||
sa.ForeignKeyConstraint(['port_id'], ['ports.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('port_id'),
|
||||
)
|
||||
|
||||
op.rename_table(
|
||||
'routes',
|
||||
'subnetroutes',
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'routerl3agentbindings',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('router_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('l3_agent_id', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['l3_agent_id'], ['agents.id'],
|
||||
ondelete='CASCADE'),
|
||||
|
||||
sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'routerroutes',
|
||||
sa.Column('destination', sa.String(length=64), nullable=False),
|
||||
sa.Column('nexthop', sa.String(length=64), nullable=False),
|
||||
sa.Column('router_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('destination', 'nexthop', 'router_id'),
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.rename_table(
|
||||
'subnetroutes',
|
||||
'routes',
|
||||
)
|
||||
|
||||
op.drop_table('routerroutes')
|
||||
op.drop_table('routerl3agentbindings')
|
||||
op.drop_table('portbindingports')
|
||||
op.drop_table('securitygroupportbindings')
|
||||
op.drop_column('routers', 'enable_snat')
|
||||
op.drop_table('port_profile')
|
||||
op.drop_table('securitygrouprules')
|
||||
op.drop_table('networkdhcpagentbindings')
|
||||
op.drop_table('mlnx_network_bindings')
|
||||
op.drop_table('quotas')
|
||||
op.drop_table('segmentation_id_allocation')
|
||||
op.drop_table('securitygroups')
|
|
@ -1,63 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nvp_dist_router
|
||||
|
||||
Revision ID: 40dffbf4b549
|
||||
Revises: 63afba73813
|
||||
Create Date: 2013-08-21 18:00:26.214923
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '40dffbf4b549'
|
||||
down_revision = '63afba73813'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'nsxrouterextattributess',
|
||||
sa.Column('router_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('distributed', sa.Boolean(), nullable=False),
|
||||
sa.ForeignKeyConstraint(
|
||||
['router_id'], ['routers.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('router_id')
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('nsxrouterextattributess')
|
|
@ -1,94 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nvp_qos
|
||||
|
||||
Revision ID: 45680af419f9
|
||||
Revises: 54c2c487e913
|
||||
Create Date: 2013-02-17 13:27:57.999631
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '45680af419f9'
|
||||
down_revision = '54c2c487e913'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
'qosqueues',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('default', sa.Boolean(), nullable=True),
|
||||
sa.Column('min', sa.Integer(), nullable=False),
|
||||
sa.Column('max', sa.Integer(), nullable=True),
|
||||
sa.Column('qos_marking', sa.Enum('untrusted', 'trusted',
|
||||
name='qosqueues_qos_marking'),
|
||||
nullable=True),
|
||||
sa.Column('dscp', sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table(
|
||||
'networkqueuemappings',
|
||||
sa.Column('network_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('queue_id', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['queue_id'], ['qosqueues.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('network_id')
|
||||
)
|
||||
op.create_table(
|
||||
'portqueuemappings',
|
||||
sa.Column('port_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('queue_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['port_id'], ['ports.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['queue_id'], ['qosqueues.id'], ),
|
||||
sa.PrimaryKeyConstraint('port_id', 'queue_id')
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('portqueuemappings')
|
||||
op.drop_table('networkqueuemappings')
|
||||
op.drop_table('qosqueues')
|
||||
### end Alembic commands ###
|
|
@ -1,89 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""agent scheduler
|
||||
|
||||
Revision ID: 4692d074d587
|
||||
Revises: 3b54bf9e29f7
|
||||
Create Date: 2013-02-21 23:01:50.370306
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '4692d074d587'
|
||||
down_revision = '3b54bf9e29f7'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.brocade.NeutronPlugin.BrocadePluginV2',
|
||||
'neutron.plugins.linuxbridge.lb_neutron_plugin.LinuxBridgePluginV2',
|
||||
'neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2',
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin',
|
||||
'neutron.plugins.oneconvergence.plugin.OneConvergencePluginV2',
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin',
|
||||
'neutron.plugins.bigswitch.plugin.NeutronRestProxyV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
'networkdhcpagentbindings',
|
||||
sa.Column('network_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('dhcp_agent_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['dhcp_agent_id'], ['agents.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('network_id', 'dhcp_agent_id')
|
||||
)
|
||||
op.create_table(
|
||||
'routerl3agentbindings',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('router_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('l3_agent_id', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['l3_agent_id'], ['agents.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('routerl3agentbindings')
|
||||
op.drop_table('networkdhcpagentbindings')
|
||||
### end Alembic commands ###
|
|
@ -1,80 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""cisco_n1kv_multisegment_trunk
|
||||
|
||||
Revision ID: 46a0efbd8f0
|
||||
Revises: 53bbd27ec841
|
||||
Create Date: 2013-08-20 20:44:08.711110
|
||||
|
||||
"""
|
||||
|
||||
revision = '46a0efbd8f0'
|
||||
down_revision = '53bbd27ec841'
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.cisco.network_plugin.PluginV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
new_type = sa.Enum('vlan', 'vxlan', 'trunk', 'multi-segment', name='vlan_type')
|
||||
old_type = sa.Enum('vlan', 'vxlan', name='vlan_type')
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'cisco_n1kv_trunk_segments',
|
||||
sa.Column('trunk_segment_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('segment_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('dot1qtag', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['trunk_segment_id'], ['networks.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('trunk_segment_id', 'segment_id', 'dot1qtag')
|
||||
)
|
||||
op.create_table(
|
||||
'cisco_n1kv_multi_segments',
|
||||
sa.Column('multi_segment_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('segment1_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('segment2_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('encap_profile_name', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['multi_segment_id'], ['networks.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('multi_segment_id', 'segment1_id',
|
||||
'segment2_id')
|
||||
)
|
||||
migration.alter_enum('cisco_network_profiles', 'segment_type', new_type,
|
||||
nullable=False)
|
||||
op.add_column('cisco_network_profiles',
|
||||
sa.Column('sub_type', sa.String(length=255), nullable=True))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('cisco_n1kv_trunk_segments')
|
||||
op.drop_table('cisco_n1kv_multi_segments')
|
||||
migration.alter_enum('cisco_network_profiles', 'segment_type', old_type,
|
||||
nullable=False)
|
||||
op.drop_column('cisco_network_profiles', 'sub_type')
|
|
@ -1,69 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""DB Migration for ML2 VXLAN Type Driver
|
||||
|
||||
Revision ID: 477a4488d3f4
|
||||
Revises: 20ae61555e95
|
||||
Create Date: 2013-07-09 14:14:33.158502
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '477a4488d3f4'
|
||||
down_revision = '20ae61555e95'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'ml2_vxlan_allocations',
|
||||
sa.Column('vxlan_vni', sa.Integer, nullable=False,
|
||||
autoincrement=False),
|
||||
sa.Column('allocated', sa.Boolean, nullable=False),
|
||||
sa.PrimaryKeyConstraint('vxlan_vni')
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'ml2_vxlan_endpoints',
|
||||
sa.Column('ip_address', sa.String(length=64)),
|
||||
sa.Column('udp_port', sa.Integer(), nullable=False,
|
||||
autoincrement=False),
|
||||
sa.PrimaryKeyConstraint('ip_address', 'udp_port')
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('ml2_vxlan_allocations')
|
||||
op.drop_table('ml2_vxlan_endpoints')
|
|
@ -1,76 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""DB support for service types
|
||||
|
||||
Revision ID: 48b6f43f7471
|
||||
Revises: 5a875d0e5c
|
||||
Create Date: 2013-01-07 13:47:29.093160
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '48b6f43f7471'
|
||||
down_revision = '5a875d0e5c'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'*'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
u'servicetypes',
|
||||
sa.Column(u'tenant_id', sa.String(255), nullable=True),
|
||||
sa.Column(u'id', sa.String(36), nullable=False),
|
||||
sa.Column(u'name', sa.String(255), nullable=True),
|
||||
sa.Column(u'description', sa.String(255), nullable=True),
|
||||
sa.Column(u'default', sa.Boolean(),
|
||||
autoincrement=False, nullable=False),
|
||||
sa.Column(u'num_instances', sa.Integer(),
|
||||
autoincrement=False, nullable=True),
|
||||
sa.PrimaryKeyConstraint(u'id'))
|
||||
op.create_table(
|
||||
u'servicedefinitions',
|
||||
sa.Column(u'id', sa.String(36), nullable=False),
|
||||
sa.Column(u'service_class', sa.String(length=255),
|
||||
nullable=False),
|
||||
sa.Column(u'plugin', sa.String(255), nullable=True),
|
||||
sa.Column(u'driver', sa.String(255), nullable=True),
|
||||
sa.Column(u'service_type_id', sa.String(36),
|
||||
nullable=False),
|
||||
sa.ForeignKeyConstraint(['service_type_id'], [u'servicetypes.id'],
|
||||
name=u'servicedefinitions_ibfk_1'),
|
||||
sa.PrimaryKeyConstraint(u'id', u'service_class', u'service_type_id'))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table(u'servicedefinitions')
|
||||
op.drop_table(u'servicetypes')
|
|
@ -1,70 +0,0 @@
|
|||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Brocade ML2 Mech. Driver
|
||||
|
||||
Revision ID: 492a106273f8
|
||||
Revises: fcac4c42e2cc
|
||||
Create Date: 2014-03-03 15:35:46.974523
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '492a106273f8'
|
||||
down_revision = 'fcac4c42e2cc'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'ml2_brocadenetworks',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('vlan', sa.String(length=10), nullable=True),
|
||||
sa.Column('segment_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('network_type', sa.String(length=10), nullable=True),
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'))
|
||||
|
||||
op.create_table(
|
||||
'ml2_brocadeports',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('network_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('admin_state_up', sa.Boolean()),
|
||||
sa.Column('physical_interface', sa.String(length=36), nullable=True),
|
||||
sa.Column('vlan_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('ml2_brocadenetworks')
|
||||
op.drop_table('ml2_brocadeports')
|
|
@ -1,59 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""ryu plugin update
|
||||
|
||||
Revision ID: 49332180ca96
|
||||
Revises: 1149d7de0cfa
|
||||
Create Date: 2013-01-30 07:52:58.472885
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '49332180ca96'
|
||||
down_revision = '1149d7de0cfa'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.ryu.ryu_neutron_plugin.RyuNeutronPluginV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('ofp_server')
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'ofp_server',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('address', sa.String(length=255)),
|
||||
sa.Column('host_type', sa.String(length=255)),
|
||||
sa.PrimaryKeyConstraint(u'id')
|
||||
)
|
|
@ -1,95 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""security_groups
|
||||
|
||||
Revision ID: 49f5e553f61f
|
||||
Revises: 27ef74513d33
|
||||
Create Date: 2013-12-21 19:58:17.071412
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '49f5e553f61f'
|
||||
down_revision = '27ef74513d33'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
'securitygroups',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('description', sa.String(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table(
|
||||
'securitygrouprules',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('security_group_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('remote_group_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('direction',
|
||||
sa.Enum('ingress', 'egress',
|
||||
name='securitygrouprules_direction'),
|
||||
nullable=True),
|
||||
sa.Column('ethertype', sa.String(length=40), nullable=True),
|
||||
sa.Column('protocol', sa.String(length=40), nullable=True),
|
||||
sa.Column('port_range_min', sa.Integer(), nullable=True),
|
||||
sa.Column('port_range_max', sa.Integer(), nullable=True),
|
||||
sa.Column('remote_ip_prefix', sa.String(length=255), nullable=True),
|
||||
sa.ForeignKeyConstraint(['security_group_id'], ['securitygroups.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['remote_group_id'], ['securitygroups.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table(
|
||||
'securitygroupportbindings',
|
||||
sa.Column('port_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('security_group_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['port_id'], ['ports.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['security_group_id'], ['securitygroups.id']),
|
||||
sa.PrimaryKeyConstraint('port_id', 'security_group_id')
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('securitygroupportbindings')
|
||||
op.drop_table('securitygrouprules')
|
||||
op.drop_table('securitygroups')
|
||||
### end Alembic commands ###
|
|
@ -1,70 +0,0 @@
|
|||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""service router
|
||||
|
||||
Revision ID: 4a666eb208c2
|
||||
Revises: 38fc1f6789f8
|
||||
Create Date: 2013-09-03 01:55:57.799217
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '4a666eb208c2'
|
||||
down_revision = '38fc1f6789f8'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
# This migration must apply to both NVP/NSX plugins as it alters a table
|
||||
# used by both of them
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'vcns_router_bindings',
|
||||
sa.Column('status', sa.String(length=16), nullable=False),
|
||||
sa.Column('status_description', sa.String(length=255), nullable=True),
|
||||
sa.Column('router_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('edge_id', sa.String(length=16), nullable=True),
|
||||
sa.Column('lswitch_id', sa.String(length=36), nullable=False),
|
||||
sa.PrimaryKeyConstraint('router_id'),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
op.add_column(
|
||||
u'nsxrouterextattributess',
|
||||
sa.Column('service_router', sa.Boolean(), nullable=False))
|
||||
op.execute("UPDATE nsxrouterextattributess set service_router=False")
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_column(u'nsxrouterextattributess', 'service_router')
|
||||
op.drop_table('vcns_router_bindings')
|
|
@ -1,64 +0,0 @@
|
|||
# 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.
|
||||
#
|
||||
|
||||
"""nsx_router_mappings
|
||||
|
||||
Revision ID: 4ca36cfc898c
|
||||
Revises: 3d3cb89d84ee
|
||||
Create Date: 2014-01-08 10:41:43.373031
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '4ca36cfc898c'
|
||||
down_revision = '3d3cb89d84ee'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
# Create table for router/lrouter mappings
|
||||
op.create_table(
|
||||
'neutron_nsx_router_mappings',
|
||||
sa.Column('neutron_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('nsx_id', sa.String(length=36), nullable=True),
|
||||
sa.ForeignKeyConstraint(['neutron_id'], ['routers.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('neutron_id'),
|
||||
)
|
||||
# Execute statement to a record in nsx_router_mappings for
|
||||
# each record in routers
|
||||
op.execute("INSERT INTO neutron_nsx_router_mappings SELECT id,id "
|
||||
"from routers")
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('neutron_nsx_router_mappings')
|
|
@ -1,59 +0,0 @@
|
|||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Remove ML2 Cisco Credentials DB
|
||||
|
||||
Revision ID: 4eca4a84f08a
|
||||
Revises: 33c3db036fe4
|
||||
Create Date: 2014-04-10 19:32:46.697189
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '4eca4a84f08a'
|
||||
down_revision = '33c3db036fe4'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('cisco_ml2_credentials')
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'cisco_ml2_credentials',
|
||||
sa.Column('credential_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=False),
|
||||
sa.Column('credential_name', sa.String(length=255), nullable=False),
|
||||
sa.Column('user_name', sa.String(length=255), nullable=True),
|
||||
sa.Column('password', sa.String(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint('tenant_id', 'credential_name')
|
||||
)
|
|
@ -1,99 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""ml2 binding:vif_details
|
||||
|
||||
Revision ID: 50d5ba354c23
|
||||
Revises: 27cc183af192
|
||||
Create Date: 2014-02-11 23:21:59.577972
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '50d5ba354c23'
|
||||
down_revision = '27cc183af192'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.add_column('ml2_port_bindings',
|
||||
sa.Column('vif_details', sa.String(length=4095),
|
||||
nullable=False, server_default=''))
|
||||
if op.get_bind().engine.name == 'ibm_db_sa':
|
||||
op.execute(
|
||||
"UPDATE ml2_port_bindings SET"
|
||||
" vif_details = '{\"port_filter\": true}'"
|
||||
" WHERE cap_port_filter = 1")
|
||||
op.execute(
|
||||
"UPDATE ml2_port_bindings SET"
|
||||
" vif_details = '{\"port_filter\": false}'"
|
||||
" WHERE cap_port_filter = 0")
|
||||
else:
|
||||
op.execute(
|
||||
"UPDATE ml2_port_bindings SET"
|
||||
" vif_details = '{\"port_filter\": true}'"
|
||||
" WHERE cap_port_filter = true")
|
||||
op.execute(
|
||||
"UPDATE ml2_port_bindings SET"
|
||||
" vif_details = '{\"port_filter\": false}'"
|
||||
" WHERE cap_port_filter = false")
|
||||
op.drop_column('ml2_port_bindings', 'cap_port_filter')
|
||||
if op.get_bind().engine.name == 'ibm_db_sa':
|
||||
op.execute("CALL SYSPROC.ADMIN_CMD('REORG TABLE ml2_port_bindings')")
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
if op.get_bind().engine.name == 'ibm_db_sa':
|
||||
# Note(xuhanp): DB2 doesn't allow nullable=False Column with
|
||||
# "DEFAULT" clause not specified. So server_default is used.
|
||||
# Using sa.text will result "DEFAULT 0" for cap_port_filter.
|
||||
op.add_column('ml2_port_bindings',
|
||||
sa.Column('cap_port_filter', sa.Boolean(),
|
||||
nullable=False,
|
||||
server_default=sa.text("0")))
|
||||
op.execute(
|
||||
"UPDATE ml2_port_bindings SET"
|
||||
" cap_port_filter = 1"
|
||||
" WHERE vif_details LIKE '%\"port_filter\": true%'")
|
||||
else:
|
||||
op.add_column('ml2_port_bindings',
|
||||
sa.Column('cap_port_filter', sa.Boolean(),
|
||||
nullable=False,
|
||||
server_default=sa.text("false")))
|
||||
op.execute(
|
||||
"UPDATE ml2_port_bindings SET"
|
||||
" cap_port_filter = true"
|
||||
" WHERE vif_details LIKE '%\"port_filter\": true%'")
|
||||
op.drop_column('ml2_port_bindings', 'vif_details')
|
||||
if op.get_bind().engine.name == 'ibm_db_sa':
|
||||
op.execute("CALL SYSPROC.ADMIN_CMD('REORG TABLE ml2_port_bindings')")
|
|
@ -1,82 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""nsx_mappings
|
||||
|
||||
Revision ID: 50e86cb2637a
|
||||
Revises: havana
|
||||
Create Date: 2013-10-26 14:37:30.012149
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '50e86cb2637a'
|
||||
down_revision = '1fcfc149aca4'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table('neutron_nsx_port_mappings',
|
||||
sa.Column('neutron_id', sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('nsx_port_id', sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('nsx_switch_id', sa.String(length=36),
|
||||
nullable=True),
|
||||
sa.ForeignKeyConstraint(['neutron_id'], ['ports.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('neutron_id'))
|
||||
|
||||
op.execute("INSERT INTO neutron_nsx_port_mappings SELECT quantum_id as "
|
||||
"neutron_id, nvp_id as nsx_port_id, null as nsx_switch_id from"
|
||||
" quantum_nvp_port_mapping")
|
||||
op.drop_table('quantum_nvp_port_mapping')
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
# Restore table to pre-icehouse version
|
||||
op.create_table('quantum_nvp_port_mapping',
|
||||
sa.Column('quantum_id', sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('nvp_id', sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.ForeignKeyConstraint(['quantum_id'], ['ports.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('quantum_id'))
|
||||
op.execute("INSERT INTO quantum_nvp_port_mapping SELECT neutron_id as "
|
||||
"quantum_id, nsx_port_id as nvp_id from"
|
||||
" neutron_nsx_port_mappings")
|
||||
op.drop_table('neutron_nsx_port_mappings')
|
|
@ -1,84 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Add agent management extension model support
|
||||
|
||||
Revision ID: 511471cc46b
|
||||
Revises: 363468ac592c
|
||||
Create Date: 2013-02-18 05:09:32.523460
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '511471cc46b'
|
||||
down_revision = '363468ac592c'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.brocade.NeutronPlugin.BrocadePluginV2',
|
||||
'neutron.plugins.linuxbridge.lb_neutron_plugin.LinuxBridgePluginV2',
|
||||
'neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2',
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2',
|
||||
'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2',
|
||||
'neutron.plugins.nicira.NeutronServicePlugin.NvpAdvancedPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxPlugin',
|
||||
'neutron.plugins.vmware.plugin.NsxServicePlugin',
|
||||
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
|
||||
'neutron.plugins.ibm.sdnve_neutron_plugin.SdnvePluginV2',
|
||||
'neutron.plugins.oneconvergence.plugin.OneConvergencePluginV2',
|
||||
'neutron.plugins.mlnx.mlnx_plugin.MellanoxEswitchPlugin',
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
'agents',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('agent_type', sa.String(length=255), nullable=False),
|
||||
sa.Column('binary', sa.String(length=255), nullable=False),
|
||||
sa.Column('topic', sa.String(length=255), nullable=False),
|
||||
sa.Column('host', sa.String(length=255), nullable=False),
|
||||
sa.Column('admin_state_up', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('started_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('heartbeat_timestamp', sa.DateTime(), nullable=False),
|
||||
sa.Column('description', sa.String(length=255), nullable=True),
|
||||
sa.Column('configurations', sa.String(length=4095), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('agents')
|
||||
### end Alembic commands ###
|
|
@ -1,68 +0,0 @@
|
|||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Cisco Nexus ML2 mechanism driver
|
||||
|
||||
Revision ID: 51b4de912379
|
||||
Revises: 66a59a7f516
|
||||
Create Date: 2013-08-20 15:31:40.553634
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '51b4de912379'
|
||||
down_revision = '66a59a7f516'
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'cisco_ml2_nexusport_bindings',
|
||||
sa.Column('binding_id', sa.Integer(), nullable=False),
|
||||
sa.Column('port_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('vlan_id', sa.Integer(), autoincrement=False,
|
||||
nullable=False),
|
||||
sa.Column('switch_ip', sa.String(length=255), nullable=True),
|
||||
sa.Column('instance_id', sa.String(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint('binding_id'),
|
||||
)
|
||||
op.create_table(
|
||||
'cisco_ml2_credentials',
|
||||
sa.Column('credential_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=False),
|
||||
sa.Column('credential_name', sa.String(length=255), nullable=False),
|
||||
sa.Column('user_name', sa.String(length=255), nullable=True),
|
||||
sa.Column('password', sa.String(length=255), nullable=True),
|
||||
sa.PrimaryKeyConstraint('tenant_id', 'credential_name'),
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('cisco_ml2_credentials')
|
||||
op.drop_table('cisco_ml2_nexusport_bindings')
|
|
@ -1,63 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""LBaaS Pool scheduler
|
||||
|
||||
Revision ID: 52c5e4a18807
|
||||
Revises: 2032abe8edac
|
||||
Create Date: 2013-06-14 03:23:47.815865
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '52c5e4a18807'
|
||||
down_revision = '2032abe8edac'
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
'poolloadbalanceragentbindings',
|
||||
sa.Column('pool_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('agent_id', sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.ForeignKeyConstraint(['agent_id'], ['agents.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['pool_id'], ['pools.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('pool_id')
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('poolloadbalanceragentbindings')
|
||||
### end Alembic commands ###
|
|
@ -1,183 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Support for VPNaaS
|
||||
|
||||
Revision ID: 52ff27f7567a
|
||||
Revises: 39cf3f799352
|
||||
Create Date: 2013-07-14 23:04:13.395955
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '52ff27f7567a'
|
||||
down_revision = '39cf3f799352'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.services.vpn.plugin.VPNDriverPlugin',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'ikepolicies',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('description', sa.String(length=255), nullable=True),
|
||||
sa.Column(
|
||||
'auth_algorithm',
|
||||
sa.Enum('sha1', name='vpn_auth_algorithms'), nullable=False),
|
||||
sa.Column(
|
||||
'encryption_algorithm',
|
||||
sa.Enum('3des', 'aes-128', 'aes-256', 'aes-192',
|
||||
name='vpn_encrypt_algorithms'), nullable=False),
|
||||
sa.Column(
|
||||
'phase1_negotiation_mode',
|
||||
sa.Enum('main', name='ike_phase1_mode'), nullable=False),
|
||||
sa.Column(
|
||||
'lifetime_units',
|
||||
sa.Enum('seconds', 'kilobytes', name='vpn_lifetime_units'),
|
||||
nullable=False),
|
||||
sa.Column('lifetime_value', sa.Integer(), nullable=False),
|
||||
sa.Column(
|
||||
'ike_version',
|
||||
sa.Enum('v1', 'v2', name='ike_versions'), nullable=False),
|
||||
sa.Column(
|
||||
'pfs',
|
||||
sa.Enum('group2', 'group5', 'group14', name='vpn_pfs'),
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table(
|
||||
'ipsecpolicies',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('description', sa.String(length=255), nullable=True),
|
||||
sa.Column(
|
||||
'transform_protocol',
|
||||
sa.Enum('esp', 'ah', 'ah-esp', name='ipsec_transform_protocols'),
|
||||
nullable=False),
|
||||
sa.Column(
|
||||
'auth_algorithm',
|
||||
sa.Enum('sha1', name='vpn_auth_algorithms'), nullable=False),
|
||||
sa.Column(
|
||||
'encryption_algorithm',
|
||||
sa.Enum(
|
||||
'3des', 'aes-128',
|
||||
'aes-256', 'aes-192', name='vpn_encrypt_algorithms'),
|
||||
nullable=False),
|
||||
sa.Column(
|
||||
'encapsulation_mode',
|
||||
sa.Enum('tunnel', 'transport', name='ipsec_encapsulations'),
|
||||
nullable=False),
|
||||
sa.Column(
|
||||
'lifetime_units',
|
||||
sa.Enum(
|
||||
'seconds', 'kilobytes',
|
||||
name='vpn_lifetime_units'), nullable=False),
|
||||
sa.Column(
|
||||
'lifetime_value', sa.Integer(), nullable=False),
|
||||
sa.Column(
|
||||
'pfs',
|
||||
sa.Enum(
|
||||
'group2', 'group5', 'group14', name='vpn_pfs'),
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table(
|
||||
'vpnservices',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('description', sa.String(length=255), nullable=True),
|
||||
sa.Column('status', sa.String(length=16), nullable=False),
|
||||
sa.Column('admin_state_up', sa.Boolean(), nullable=False),
|
||||
sa.Column('subnet_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('router_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['router_id'], ['routers.id'], ),
|
||||
sa.ForeignKeyConstraint(['subnet_id'], ['subnets.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table(
|
||||
'ipsec_site_connections',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('description', sa.String(length=255), nullable=True),
|
||||
sa.Column('peer_address', sa.String(length=64), nullable=False),
|
||||
sa.Column('peer_id', sa.String(length=255), nullable=False),
|
||||
sa.Column('route_mode', sa.String(length=8), nullable=False),
|
||||
sa.Column('mtu', sa.Integer(), nullable=False),
|
||||
sa.Column(
|
||||
'initiator',
|
||||
sa.Enum(
|
||||
'bi-directional', 'response-only', name='vpn_initiators'),
|
||||
nullable=False),
|
||||
sa.Column('auth_mode', sa.String(length=16), nullable=False),
|
||||
sa.Column('psk', sa.String(length=255), nullable=False),
|
||||
sa.Column(
|
||||
'dpd_action',
|
||||
sa.Enum(
|
||||
'hold', 'clear', 'restart',
|
||||
'disabled', 'restart-by-peer', name='vpn_dpd_actions'),
|
||||
nullable=False),
|
||||
sa.Column('dpd_interval', sa.Integer(), nullable=False),
|
||||
sa.Column('dpd_timeout', sa.Integer(), nullable=False),
|
||||
sa.Column('status', sa.String(length=16), nullable=False),
|
||||
sa.Column('admin_state_up', sa.Boolean(), nullable=False),
|
||||
sa.Column('vpnservice_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('ipsecpolicy_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('ikepolicy_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['ikepolicy_id'], ['ikepolicies.id']),
|
||||
sa.ForeignKeyConstraint(['ipsecpolicy_id'], ['ipsecpolicies.id']),
|
||||
sa.ForeignKeyConstraint(['vpnservice_id'], ['vpnservices.id']),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table(
|
||||
'ipsecpeercidrs',
|
||||
sa.Column('cidr', sa.String(length=32), nullable=False),
|
||||
sa.Column('ipsec_site_connection_id',
|
||||
sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.ForeignKeyConstraint(['ipsec_site_connection_id'],
|
||||
['ipsec_site_connections.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('cidr', 'ipsec_site_connection_id')
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('ipsecpeercidrs')
|
||||
op.drop_table('ipsec_site_connections')
|
||||
op.drop_table('vpnservices')
|
||||
op.drop_table('ipsecpolicies')
|
||||
op.drop_table('ikepolicies')
|
|
@ -1,65 +0,0 @@
|
|||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""NEC Rename quantum_id to neutron_id
|
||||
|
||||
Revision ID: 538732fa21e1
|
||||
Revises: 2447ad0e9585
|
||||
Create Date: 2014-03-04 05:43:33.660601
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '538732fa21e1'
|
||||
down_revision = '2447ad0e9585'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.nec.nec_plugin.NECPluginV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
for table in ['ofctenantmappings', 'ofcnetworkmappings',
|
||||
'ofcportmappings', 'ofcfiltermappings',
|
||||
'ofcroutermappings',
|
||||
]:
|
||||
op.alter_column(table, 'quantum_id',
|
||||
new_column_name='neutron_id',
|
||||
existing_type=sa.String(length=36),
|
||||
existing_nullable=False)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
for table in ['ofctenantmappings', 'ofcnetworkmappings',
|
||||
'ofcportmappings', 'ofcfiltermappings',
|
||||
'ofcroutermappings',
|
||||
]:
|
||||
op.alter_column(table, 'neutron_id',
|
||||
new_column_name='quantum_id',
|
||||
existing_type=sa.String(length=36),
|
||||
existing_nullable=False)
|
|
@ -1,66 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Extra dhcp opts support
|
||||
|
||||
Revision ID: 53bbd27ec841
|
||||
Revises: 40dffbf4b549
|
||||
Create Date: 2013-05-09 15:36:50.485036
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '53bbd27ec841'
|
||||
down_revision = '40dffbf4b549'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2',
|
||||
'neutron.plugins.ml2.plugin.Ml2Plugin',
|
||||
'neutron.plugins.bigswitch.plugin.NeutronRestProxyV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'extradhcpopts',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('port_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('opt_name', sa.String(length=64), nullable=False),
|
||||
sa.Column('opt_value', sa.String(length=255), nullable=False),
|
||||
sa.ForeignKeyConstraint(['port_id'], ['ports.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('port_id', 'opt_name', name='uidx_portid_optname'))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('extradhcpopts')
|
||||
### end Alembic commands ###
|
|
@ -1,163 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""'DB support for load balancing service
|
||||
|
||||
Revision ID: 54c2c487e913
|
||||
Revises: 38335592a0dc
|
||||
Create Date: 2013-02-04 16:32:32.048731
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '54c2c487e913'
|
||||
down_revision = '38335592a0dc'
|
||||
|
||||
# We need migration_for_plugins to be an empty list to avoid creating tables,
|
||||
# if there's no plugin that implements the LBaaS extension.
|
||||
|
||||
migration_for_plugins = []
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
u'vips',
|
||||
sa.Column(u'tenant_id', sa.String(255), nullable=True),
|
||||
sa.Column(u'id', sa.String(36), nullable=False),
|
||||
sa.Column(u'name', sa.String(255), nullable=True),
|
||||
sa.Column(u'description', sa.String(255), nullable=True),
|
||||
sa.Column(u'port_id', sa.String(36), nullable=True),
|
||||
sa.Column(u'protocol_port', sa.Integer(), nullable=False),
|
||||
sa.Column(u'protocol',
|
||||
sa.Enum("HTTP", "HTTPS", "TCP", name="lb_protocols"),
|
||||
nullable=False),
|
||||
sa.Column(u'pool_id', sa.String(36), nullable=False),
|
||||
sa.Column(u'status', sa.String(16), nullable=False),
|
||||
sa.Column(u'admin_state_up', sa.Boolean(), nullable=False),
|
||||
sa.Column(u'connection_limit', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['port_id'], ['ports.id'], ),
|
||||
sa.UniqueConstraint('pool_id'),
|
||||
sa.PrimaryKeyConstraint(u'id')
|
||||
)
|
||||
op.create_table(
|
||||
u'poolmonitorassociations',
|
||||
sa.Column(u'pool_id', sa.String(36), nullable=False),
|
||||
sa.Column(u'monitor_id', sa.String(36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['monitor_id'], [u'healthmonitors.id'], ),
|
||||
sa.ForeignKeyConstraint(['pool_id'], [u'pools.id'], ),
|
||||
sa.PrimaryKeyConstraint(u'pool_id', u'monitor_id')
|
||||
)
|
||||
op.create_table(
|
||||
u'sessionpersistences',
|
||||
sa.Column(u'vip_id', sa.String(36), nullable=False),
|
||||
sa.Column(u'type',
|
||||
sa.Enum("SOURCE_IP",
|
||||
"HTTP_COOKIE",
|
||||
"APP_COOKIE",
|
||||
name="sesssionpersistences_type"),
|
||||
nullable=False),
|
||||
sa.Column(u'cookie_name', sa.String(1024), nullable=True),
|
||||
sa.ForeignKeyConstraint(['vip_id'], [u'vips.id'], ),
|
||||
sa.PrimaryKeyConstraint(u'vip_id')
|
||||
)
|
||||
op.create_table(
|
||||
u'pools',
|
||||
sa.Column(u'tenant_id', sa.String(255), nullable=True),
|
||||
sa.Column(u'id', sa.String(36), nullable=False),
|
||||
sa.Column(u'vip_id', sa.String(36), nullable=True),
|
||||
sa.Column(u'name', sa.String(255), nullable=True),
|
||||
sa.Column(u'description', sa.String(255), nullable=True),
|
||||
sa.Column(u'subnet_id', sa.String(36), nullable=False),
|
||||
sa.Column(u'protocol',
|
||||
sa.Enum("HTTP", "HTTPS", "TCP", name="lb_protocols"),
|
||||
nullable=False),
|
||||
sa.Column(u'lb_method',
|
||||
sa.Enum("ROUND_ROBIN",
|
||||
"LEAST_CONNECTIONS",
|
||||
"SOURCE_IP",
|
||||
name="pools_lb_method"),
|
||||
nullable=False),
|
||||
sa.Column(u'status', sa.String(16), nullable=False),
|
||||
sa.Column(u'admin_state_up', sa.Boolean(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['vip_id'], [u'vips.id'], ),
|
||||
sa.PrimaryKeyConstraint(u'id')
|
||||
)
|
||||
op.create_table(
|
||||
u'healthmonitors',
|
||||
sa.Column(u'tenant_id', sa.String(255), nullable=True),
|
||||
sa.Column(u'id', sa.String(36), nullable=False),
|
||||
sa.Column(u'type',
|
||||
sa.Enum("PING",
|
||||
"TCP",
|
||||
"HTTP",
|
||||
"HTTPS",
|
||||
name="healthmontiors_type"),
|
||||
nullable=False),
|
||||
sa.Column(u'delay', sa.Integer(), nullable=False),
|
||||
sa.Column(u'timeout', sa.Integer(), nullable=False),
|
||||
sa.Column(u'max_retries', sa.Integer(), nullable=False),
|
||||
sa.Column(u'http_method', sa.String(16), nullable=True),
|
||||
sa.Column(u'url_path', sa.String(255), nullable=True),
|
||||
sa.Column(u'expected_codes', sa.String(64), nullable=True),
|
||||
sa.Column(u'status', sa.String(16), nullable=False),
|
||||
sa.Column(u'admin_state_up', sa.Boolean(), nullable=False),
|
||||
sa.PrimaryKeyConstraint(u'id')
|
||||
)
|
||||
op.create_table(
|
||||
u'members',
|
||||
sa.Column(u'tenant_id', sa.String(255), nullable=True),
|
||||
sa.Column(u'id', sa.String(36), nullable=False),
|
||||
sa.Column(u'pool_id', sa.String(36), nullable=False),
|
||||
sa.Column(u'address', sa.String(64), nullable=False),
|
||||
sa.Column(u'protocol_port', sa.Integer(), nullable=False),
|
||||
sa.Column(u'weight', sa.Integer(), nullable=False),
|
||||
sa.Column(u'status', sa.String(16), nullable=False),
|
||||
sa.Column(u'admin_state_up', sa.Boolean(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['pool_id'], [u'pools.id'], ),
|
||||
sa.PrimaryKeyConstraint(u'id')
|
||||
)
|
||||
op.create_table(
|
||||
u'poolstatisticss',
|
||||
sa.Column(u'pool_id', sa.String(36), nullable=False),
|
||||
sa.Column(u'bytes_in', sa.Integer(), nullable=False),
|
||||
sa.Column(u'bytes_out', sa.Integer(), nullable=False),
|
||||
sa.Column(u'active_connections', sa.Integer(), nullable=False),
|
||||
sa.Column(u'total_connections', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['pool_id'], [u'pools.id'], ),
|
||||
sa.PrimaryKeyConstraint(u'pool_id')
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table(u'poolstatisticss')
|
||||
op.drop_table(u'members')
|
||||
op.drop_table(u'healthmonitors')
|
||||
op.drop_table(u'pools')
|
||||
op.drop_table(u'sessionpersistences')
|
||||
op.drop_table(u'poolmonitorassociations')
|
||||
op.drop_table(u'vips')
|
|
@ -1,54 +0,0 @@
|
|||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""set_not_null_peer_address
|
||||
|
||||
Revision ID: 54f7549a0e5f
|
||||
Revises: 33dd0a9fa487
|
||||
Create Date: 2014-03-17 11:00:17.539028
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '54f7549a0e5f'
|
||||
down_revision = 'icehouse'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.services.vpn.plugin.VPNDriverPlugin'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.alter_column('ipsec_site_connections', 'peer_address',
|
||||
existing_type=sa.String(255), nullable=False)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.alter_column('ipsec_site_connections', 'peer_address', nullable=True,
|
||||
existing_type=sa.String(255))
|
|
@ -1,81 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""New service types framework (service providers)
|
||||
|
||||
Revision ID: 557edfc53098
|
||||
Revises: 52c5e4a18807
|
||||
Create Date: 2013-06-29 21:10:41.283358
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '557edfc53098'
|
||||
down_revision = '52c5e4a18807'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.services.loadbalancer.plugin.LoadBalancerPlugin',
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
op.create_table(
|
||||
'providerresourceassociations',
|
||||
sa.Column('provider_name', sa.String(length=255), nullable=False),
|
||||
sa.Column('resource_id', sa.String(length=36),
|
||||
nullable=False, unique=True),
|
||||
)
|
||||
|
||||
for table in ('servicedefinitions', 'servicetypes'):
|
||||
op.execute("DROP TABLE IF EXISTS %s" % table)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
op.create_table(
|
||||
'servicetypes',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('tenant_id', sa.String(length=255)),
|
||||
sa.Column('name', sa.String(255)),
|
||||
sa.Column('description', sa.String(255)),
|
||||
sa.Column('default', sa.Boolean(), nullable=False, default=False),
|
||||
sa.Column('num_instances', sa.Integer, default=0),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table(
|
||||
'servicedefinitions',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('service_class', sa.String(255)),
|
||||
sa.Column('plugin', sa.String(255)),
|
||||
sa.Column('driver', sa.String(255)),
|
||||
sa.Column('service_type_id', sa.String(36),
|
||||
sa.ForeignKey('servicetypes.id',
|
||||
ondelete='CASCADE')),
|
||||
sa.PrimaryKeyConstraint('id', 'service_class')
|
||||
)
|
||||
op.drop_table('providerresourceassociations')
|
|
@ -1,77 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""metering
|
||||
|
||||
Revision ID: 569e98a8132b
|
||||
Revises: 13de305df56e
|
||||
Create Date: 2013-07-17 15:38:36.254595
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '569e98a8132b'
|
||||
down_revision = 'f9263d6df56'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = ['neutron.services.metering.metering_plugin.'
|
||||
'MeteringPlugin']
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('meteringlabelrules')
|
||||
op.drop_table('meteringlabels')
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table('meteringlabels',
|
||||
sa.Column('tenant_id', sa.String(length=255),
|
||||
nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255),
|
||||
nullable=True),
|
||||
sa.Column('description', sa.String(length=255),
|
||||
nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'))
|
||||
op.create_table('meteringlabelrules',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('direction',
|
||||
sa.Enum('ingress', 'egress',
|
||||
name='meteringlabels_direction'),
|
||||
nullable=True),
|
||||
sa.Column('remote_ip_prefix', sa.String(length=64),
|
||||
nullable=True),
|
||||
sa.Column('metering_label_id', sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('excluded', sa.Boolean(),
|
||||
autoincrement=False, nullable=True),
|
||||
sa.ForeignKeyConstraint(['metering_label_id'],
|
||||
['meteringlabels.id'],
|
||||
name='meteringlabelrules_ibfk_1'),
|
||||
sa.PrimaryKeyConstraint('id'))
|
|
@ -1,71 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""add tables for router rules support
|
||||
|
||||
Revision ID: 5918cbddab04
|
||||
Revises: 3cbf70257c28
|
||||
Create Date: 2013-06-16 02:20:07.024752
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '5918cbddab04'
|
||||
down_revision = '3cbf70257c28'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.bigswitch.plugin.NeutronRestProxyV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table('routerrules',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('source', sa.String(length=64), nullable=False),
|
||||
sa.Column('destination', sa.String(length=64),
|
||||
nullable=False),
|
||||
sa.Column('action', sa.String(length=10), nullable=False),
|
||||
sa.Column('router_id', sa.String(length=36),
|
||||
nullable=True),
|
||||
sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id'))
|
||||
op.create_table('nexthops',
|
||||
sa.Column('rule_id', sa.Integer(), nullable=False),
|
||||
sa.Column('nexthop', sa.String(length=64), nullable=False),
|
||||
sa.ForeignKeyConstraint(['rule_id'], ['routerrules.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('rule_id', 'nexthop'))
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('nexthops')
|
||||
op.drop_table('routerrules')
|
|
@ -1,74 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2012 New Dream Network, LLC (DreamHost)
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# @author: Mark McClain, DreamHost
|
||||
|
||||
"""ryu
|
||||
|
||||
This retroactively provides migration support for
|
||||
https://review.openstack.org/#/c/11204/
|
||||
|
||||
Revision ID: 5a875d0e5c
|
||||
Revises: 2c4af419145b
|
||||
Create Date: 2012-12-18 12:32:04.482477
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '5a875d0e5c'
|
||||
down_revision = '2c4af419145b'
|
||||
|
||||
# Change to ['*'] if this migration applies to all plugins
|
||||
|
||||
migration_for_plugins = [
|
||||
'neutron.plugins.ryu.ryu_neutron_plugin.RyuNeutronPluginV2'
|
||||
]
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from neutron.db import migration
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.create_table(
|
||||
'tunnelkeys',
|
||||
sa.Column('network_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('tunnel_key', sa.Integer(), autoincrement=False,
|
||||
nullable=False),
|
||||
sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
|
||||
ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('tunnel_key')
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'tunnelkeylasts',
|
||||
sa.Column('last_key', sa.Integer(), autoincrement=False,
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('last_key')
|
||||
)
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
if not migration.should_run(active_plugins, migration_for_plugins):
|
||||
return
|
||||
|
||||
op.drop_table('tunnelkeylasts')
|
||||
op.drop_table('tunnelkeys')
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue