Merge branch 'master' into telco

Conflicts:
	octane/commands/prepare.py
	setup.cfg

Change-Id: I99bc9954f574cf9acd933c04833bb92ae527c935
This commit is contained in:
Ilya Kharin 2015-08-25 17:25:44 +03:00
commit 45adc337b3
10 changed files with 65 additions and 109 deletions

View File

@ -19,14 +19,15 @@ from octane.util import docker
from octane.util import subprocess
def patch_puppet():
def patch_puppet(revert=False):
direction = "-R" if revert else "-N"
puppet_patch_dir = os.path.join(magic_consts.CWD, "patches", "puppet")
for d in os.listdir(puppet_patch_dir):
d = os.path.join(puppet_patch_dir, d)
if not os.path.isdir(d):
continue
with open(os.path.join(d, "patch")) as patch:
subprocess.call(["patch", "-Np3"], stdin=patch,
subprocess.call(["patch", direction, "-p3"], stdin=patch,
cwd=magic_consts.PUPPET_DIR)
@ -42,9 +43,6 @@ def prepare():
os.makedirs(magic_consts.FUEL_CACHE)
subprocess.call(["yum", "-y", "install"] + magic_consts.PACKAGES)
subprocess.call(["pip", "install", "wheel"])
octane_fuelclient = os.path.join(magic_consts.CWD, '..',
'octane_fuelclient')
subprocess.call(["pip", "install", "-U", octane_fuelclient])
# From patch_all_containers
apply_patches()

View File

@ -1,3 +1,15 @@
# 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 fuelclient.commands import base
from fuelclient.commands import environment as env_commands
from fuelclient.common import data_utils
@ -31,34 +43,3 @@ class EnvClone(env_commands.EnvMixIn, base.BaseShowCommand):
)
new_env = data_utils.get_display_data_single(self.columns, new_env)
return (self.columns, new_env)
class EnvRelocateNode(env_commands.EnvMixIn, base.BaseCommand):
"""Update node assignment."""
def get_parser(self, prog_name):
parser = super(EnvRelocateNode, self).get_parser(prog_name)
parser.add_argument('node_id',
type=int,
help='ID of the node to upgrade.')
parser.add_argument('env_id',
type=str,
help='ID of the environment.')
return parser
def take_action(self, parsed_args):
# TODO(akscram): While the clone procedure is not a part of
# fuelclient.objects.Environment the connection
# will be called directly.
self.client._entity_wrapper.connection.post_request(
"clusters/{0}/upgrade/assign".format(parsed_args.env_id),
{
'node_id': parsed_args.node_id,
}
)
msg = ('Node {node_id} successfully relocated to the environment'
' {env_id}.\n'.format(
node_id=parsed_args.node_id,
env_id=parsed_args.env_id,
))
self.app.stdout.write(msg)

View File

@ -0,0 +1,45 @@
# 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 fuelclient.commands import base
from fuelclient.commands import environment as env_commands
class EnvMoveNode(env_commands.EnvMixIn, base.BaseCommand):
"""Update node assignment."""
def get_parser(self, prog_name):
parser = super(EnvMoveNode, self).get_parser(prog_name)
parser.add_argument('node_id',
type=int,
help='ID of the node to upgrade.')
parser.add_argument('env_id',
type=str,
help='ID of the environment.')
return parser
def take_action(self, parsed_args):
# TODO(akscram): While the clone procedure is not a part of
# fuelclient.objects.Environment the connection
# will be called directly.
self.client._entity_wrapper.connection.post_request(
"clusters/{0}/upgrade/assign".format(parsed_args.env_id),
{
'node_id': parsed_args.node_id,
}
)
msg = ('Node {node_id} successfully relocated to the environment'
' {env_id}.\n'.format(
node_id=parsed_args.node_id,
env_id=parsed_args.env_id,
))
self.app.stdout.write(msg)

View File

@ -20,8 +20,8 @@ def test_prepare_parser(mocker, octane_app):
def test_revert_parser(mocker, octane_app):
m = mocker.patch('octane.commands.prepare.apply_patches')
mock_apply = mocker.patch('octane.commands.prepare.apply_patches')
octane_app.run(["revert-prepare"])
assert not octane_app.stdout.getvalue()
assert not octane_app.stderr.getvalue()
m.assert_called_once_with(revert=True)
mock_apply.assert_called_once_with(revert=True)

View File

@ -1,15 +0,0 @@
from setuptools import find_packages
from setuptools import setup
setup(name="octane_fuelclient",
version="0.0.0",
packages=find_packages(),
zip_safe=False,
entry_points={
'fuelclient': [
'env_clone = octaneclient.commands:EnvClone',
'env_move_node = octaneclient.commands:EnvRelocateNode',
]
}
)

View File

@ -1,16 +0,0 @@
#!/bin/bash -ex
host=${1:-"cz5545-fuel"}
branch=${2:-$(git rev-parse --abbrev-ref HEAD)}
remote="$(git remote -v | awk "/$host/ && /fetch/{print \$2}")"
location="${remote#ssh://$host}"
git push --force "$host" "$branch"
ssh $host \
"set -ex;" \
"cd ${location};" \
"git reset --hard $branch;" \
"git clean -x -d -f;" \
"pip install -U ${location}/octane_fuelclient;"

View File

@ -1,40 +0,0 @@
[tox]
minversion = 1.6
skipsdist = True
envlist = py26,py27,pep8
[testenv]
basepython = python2
usedevelop = True
install_command = pip install -U {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
deps = pytest
commands =
py.test {posargs:octaneclient/test}
[tox:jenkins]
downloadcache = ~/cache/pip
[testenv:pep8]
deps = hacking==0.7
usedevelop = False
commands =
flake8 {posargs:octaneclient}
[testenv:cover]
deps = pytest-cov
commands =
py.test --cov-report html --cov-report term-missing --cov octaneclient {posargs:octaneclient/test}
[testenv:venv]
commands = {posargs:}
[flake8]
ignore = H234,H302,H802
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,__init__.py,docs
show-pep8 = True
show-source = True
count = True
[hacking]
import_exceptions = testtools.matchers

View File

@ -35,3 +35,6 @@ octane =
upgrade-db = octane.commands.upgrade_db:UpgradeDBCommand
install-node = octane.commands.install_node:InstallNodeCommand
upgrade-control = octane.commands.upgrade_controlplane:UpgradeControlPlaneCommand
fuelclient =
env_clone = octane.fuelclient.clone_env:EnvClone
env_move_node = octane.fuelclient.move_node:EnvMoveNode