Merge remote-tracking branch 'origin/telco' into telco
This commit is contained in:
commit
d40a5f9325
@ -55,14 +55,17 @@ def update_node_settings(node, disks_fixture, ifaces_fixture):
|
||||
LOG.warn("To keep custom volumes layout, change DEFAULT_DISKS const "
|
||||
"in magic_consts.py module")
|
||||
|
||||
LOG.info("Updating node %s network settings with fixture: %s",
|
||||
str(node.id), ifaces_fixture)
|
||||
ifaces = node.get_attribute('interfaces')
|
||||
LOG.info("Original node %s network settings: %s",
|
||||
str(node.id), ifaces)
|
||||
new_ifaces = list(copy_ifaces(ifaces_fixture, ifaces))
|
||||
LOG.info("New interfaces info generated: %s", new_ifaces)
|
||||
node.upload_node_attribute('interfaces', new_ifaces)
|
||||
if not magic_consts.DEFAULT_NETS:
|
||||
LOG.info("Updating node %s network settings with fixture: %s",
|
||||
str(node.id), ifaces_fixture)
|
||||
ifaces = node.get_attribute('interfaces')
|
||||
LOG.info("Original node %s network settings: %s",
|
||||
str(node.id), ifaces)
|
||||
new_ifaces = list(copy_ifaces(ifaces_fixture, ifaces))
|
||||
LOG.info("New interfaces info generated: %s", new_ifaces)
|
||||
node.upload_node_attribute('interfaces', new_ifaces)
|
||||
else:
|
||||
LOG.warn("Using default networks for node %s", node)
|
||||
|
||||
|
||||
def install_node(orig_id, seed_id, node_ids, isolated=False):
|
||||
|
94
octane/commands/sync_networks.py
Normal file
94
octane/commands/sync_networks.py
Normal file
@ -0,0 +1,94 @@
|
||||
# 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 __future__ import print_function
|
||||
|
||||
import logging
|
||||
|
||||
from cliff import command as cmd
|
||||
from fuelclient import objects
|
||||
from requests import HTTPError
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
ADMIN_NETWORK_NAME = 'fuelweb_admin'
|
||||
|
||||
|
||||
def get_env_networks(env_id):
|
||||
env = objects.Environment(env_id)
|
||||
network_data = env.get_network_data()
|
||||
return network_data['networks']
|
||||
|
||||
|
||||
def update_env_networks(env_id, networks):
|
||||
fields_to_update = ['meta', 'ip_ranges']
|
||||
env = objects.Environment(env_id)
|
||||
release_id = env.get_fresh_data()['release_id']
|
||||
network_data = env.get_network_data()
|
||||
node_group_id = None
|
||||
|
||||
for ng in network_data['networks']:
|
||||
if ng['name'] == ADMIN_NETWORK_NAME:
|
||||
continue
|
||||
if node_group_id is None:
|
||||
# for now we'll have only one node group
|
||||
# so just take it id from any network
|
||||
node_group_id = ng['group_id']
|
||||
objects.NetworkGroup(ng['id']).delete()
|
||||
|
||||
data_to_update = {}
|
||||
for ng in networks:
|
||||
if ng['name'] == ADMIN_NETWORK_NAME:
|
||||
continue
|
||||
try:
|
||||
objects.NetworkGroup.create(
|
||||
ng['name'],
|
||||
release_id,
|
||||
ng['vlan_start'],
|
||||
ng['cidr'],
|
||||
ng['gateway'],
|
||||
node_group_id
|
||||
)
|
||||
except HTTPError:
|
||||
LOG.error("Cannot sync network '{0}'".format(ng['name']))
|
||||
continue
|
||||
data = {}
|
||||
for key in fields_to_update:
|
||||
data[key] = ng[key]
|
||||
data_to_update[ng['name']] = data
|
||||
|
||||
# now we need to update new networks with
|
||||
# correct ip_ranges and meta
|
||||
network_data = env.get_network_data()
|
||||
for ng in network_data['networks']:
|
||||
if ng['name'] in data_to_update:
|
||||
for k in fields_to_update:
|
||||
ng[k] = data_to_update[ng['name']][k]
|
||||
env.set_network_data(network_data)
|
||||
|
||||
|
||||
class SyncNetworksCommand(cmd.Command):
|
||||
"""Synchronize network groups in original and seed environments"""
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(SyncNetworksCommand, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'original_env', type=int, metavar='ORIGINAL_ENV_ID',
|
||||
help="ID of original environment")
|
||||
parser.add_argument(
|
||||
'seed_env', type=int, metavar='SEED_ENV_ID',
|
||||
help="ID of seed environment")
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
networks = get_env_networks(parsed_args.original_env)
|
||||
update_env_networks(parsed_args.seed_env, networks)
|
@ -56,11 +56,10 @@ class ControllerUpgrade(upgrade.UpgradeHandler):
|
||||
if not info['uid'] == str(self.node.id):
|
||||
continue
|
||||
if self.isolated:
|
||||
gw = get_admin_gateway(self.env)
|
||||
transformations.remove_ports(info)
|
||||
endpoints = deployment_info[0]["network_scheme"]["endpoints"]
|
||||
self.gateway = endpoints["br-ex"]["gateway"]
|
||||
transformations.reset_gw_admin(info, gateway=gw)
|
||||
transformations.reset_gw_admin(info)
|
||||
# From run_ping_checker
|
||||
info['run_ping_checker'] = False
|
||||
transformations.remove_predefined_nets(info)
|
||||
|
@ -22,8 +22,19 @@ from octane.helpers import transformations as ts
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def install_openvswitch(node):
|
||||
ssh.call(['apt-get', 'install', '-y', 'openvswitch-switch'], node=node)
|
||||
def install_openvswitch(node, master_ip):
|
||||
cmds = []
|
||||
cmds.append(
|
||||
['sh', '-c',
|
||||
'echo'
|
||||
' "deb http://{0}:8080/2015.1.0-7.0/ubuntu/x86_64 mos7.0'
|
||||
' main restricted" >> /etc/apt/sources.list'.format(master_ip)])
|
||||
cmds.append(['apt-get', 'update'])
|
||||
cmds.append(
|
||||
['apt-get', 'install', '-y', '--force-yes', 'openvswitch-switch'])
|
||||
cmds.append(['sh', '-c', 'sed -i 1,2d /etc/apt/sources.list'])
|
||||
for cmd in cmds:
|
||||
ssh.call(cmd, node=node)
|
||||
|
||||
|
||||
def set_bridge_mtu(node, bridge):
|
||||
@ -110,12 +121,13 @@ def create_bridges(node, env, deployment_info):
|
||||
actions = ts.get_actions(info)
|
||||
LOG.info("Network scheme actions for node %s: %s",
|
||||
node.id, actions)
|
||||
master_ip = info["master_ip"]
|
||||
for bridge in magic_consts.BRIDGES:
|
||||
provider = ts.get_bridge_provider(actions, bridge)
|
||||
LOG.info("Found provider for bridge %s: %s", bridge, provider)
|
||||
if provider == 'ovs' and bridge == magic_consts.BRIDGES[0]:
|
||||
LOG.info("Installing openvswitch to node %s", node.id)
|
||||
install_openvswitch(node)
|
||||
install_openvswitch(node, master_ip)
|
||||
create_bridge = create_bridge_providers[provider]
|
||||
create_bridge(node, bridge)
|
||||
|
||||
|
@ -23,3 +23,4 @@ SSH_KEYS = ['/root/.ssh/id_rsa', '/root/.ssh/bootstrap.rsa']
|
||||
OS_SERVICES = ["nova", "keystone", "heat", "neutron", "cinder", "glance"]
|
||||
BRIDGES = ['br-ex', 'br-mgmt']
|
||||
DEFAULT_DISKS = True
|
||||
DEFAULT_NETS = True
|
||||
|
25
octane/tests/test_sync_networks.py
Normal file
25
octane/tests/test_sync_networks.py
Normal file
@ -0,0 +1,25 @@
|
||||
# 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.
|
||||
|
||||
|
||||
def test_parser(mocker, octane_app):
|
||||
networks = [{'key': 'value'}]
|
||||
|
||||
m1 = mocker.patch('octane.commands.sync_networks.get_original_networks')
|
||||
m1.return_value = networks
|
||||
|
||||
m2 = mocker.patch('octane.commands.sync_networks.update_seed_networks')
|
||||
octane_app.run(["sync-networks", "1", "2"])
|
||||
assert not octane_app.stdout.getvalue()
|
||||
assert not octane_app.stderr.getvalue()
|
||||
m1.assert_called_once_with(1)
|
||||
m2.assert_called_once_with(2, networks)
|
@ -35,6 +35,7 @@ octane =
|
||||
upgrade-db = octane.commands.upgrade_db:UpgradeDBCommand
|
||||
install-node = octane.commands.install_node:InstallNodeCommand
|
||||
upgrade-control = octane.commands.upgrade_controlplane:UpgradeControlPlaneCommand
|
||||
sync-networks = octane.commands.sync_networks:SyncNetworksCommand
|
||||
sync-images = octane.commands.sync_images:SyncImagesCommand
|
||||
update-plugin-settings = octane.commands.update_plugin_settings:UpdatePluginSettingsCommand
|
||||
octane.handlers.upgrade =
|
||||
|
Loading…
Reference in New Issue
Block a user