Merge "clean up kolla related files"

This commit is contained in:
Jenkins 2016-12-01 20:52:42 +00:00 committed by Gerrit Code Review
commit 1c31349cbe
26 changed files with 2 additions and 2210 deletions

View File

View File

@ -1,39 +0,0 @@
#!/usr/bin/env python
# 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 os
import sys
# NOTE(SamYaple): Update the search path to prefer PROJECT_ROOT as the source
# of packages to import if we are using local tools instead of
# pip installed kolla tools
PROJECT_ROOT = os.path.abspath(os.path.join(
os.path.dirname(os.path.realpath(__file__)), '../..'))
if PROJECT_ROOT not in sys.path:
sys.path.insert(0, PROJECT_ROOT)
from kolla.image import build
def main():
statuses = build.run_build()
if statuses:
bad_results, good_results, unmatched_results = statuses
if bad_results:
return 1
return 0
if __name__ == '__main__':
sys.exit(main())

View File

@ -1,379 +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.
import itertools
from oslo_config import cfg
from oslo_config import types
from kolla.version import version_info as version
BASE_OS_DISTRO = ['centos', 'rhel', 'ubuntu', 'oraclelinux', 'debian']
DISTRO_RELEASE = {
'centos': '7',
'rhel': '7',
'oraclelinux': '7',
'debian': '8',
'ubuntu': '16.04',
}
DELOREAN = ("http://buildlogs.centos.org/centos/7/cloud/x86_64/"
"rdo-trunk-master-tested/delorean.repo")
# TODO(pbourke): update to buildlogs.centos.org once this moves
DELOREAN_DEPS = "http://trunk.rdoproject.org/centos7/delorean-deps.repo"
INSTALL_TYPE_CHOICES = ['binary', 'source', 'rdo', 'rhos']
_PROFILE_OPTS = [
cfg.ListOpt('infra',
default=['ceph', 'cron', 'elasticsearch', 'etcd', 'haproxy',
'heka', 'keepalived', 'kibana', 'kolla-toolbox',
'mariadb', 'memcached', 'mongodb', 'openvswitch',
'rabbitmq', 'tgtd'],
help='Infra images'),
cfg.ListOpt('main',
default=['cinder', 'ceilometer', 'glance', 'heat',
'horizon', 'iscsi', 'keystone', 'neutron', 'nova',
'swift'],
help='Main images'),
cfg.ListOpt('aux',
default=['aodh', 'cloudkitty', 'congress', 'designate',
'freezer', 'gnocchi', 'influxdb', 'ironic', 'kuryr',
'magnum', 'manila', 'mistral', 'murano', 'panko',
'rally', 'sahara', 'searchlight', 'senlin', 'solum',
'telegraf', 'trove', 'zaqar'],
help='Aux Images'),
cfg.ListOpt('default',
default=['chrony', 'cron', 'kolla-toolbox', 'glance',
'haproxy', 'heat', 'horizon', 'keepalived',
'keystone', 'memcached', 'mariadb', 'neutron', 'nova',
'openvswitch', 'rabbitmq', 'heka'],
help='Default images'),
cfg.ListOpt('gate',
default=['chrony', 'cron', 'glance', 'haproxy', 'keepalived',
'keystone', 'kolla-toolbox', 'mariadb', 'memcached',
'neutron', 'nova', 'openvswitch', 'rabbitmq', 'heka'],
help='Gate images')
]
_CLI_OPTS = [
cfg.StrOpt('base', short='b', default='centos',
choices=BASE_OS_DISTRO,
help='The distro type of the base image'),
cfg.StrOpt('base-tag', default='latest',
help='The base distro image tag'),
cfg.StrOpt('base-image',
help='The base image name. Default is the same with base'),
cfg.BoolOpt('debug', short='d', default=False,
help='Turn on debugging log level'),
cfg.DictOpt('build-args',
help='Set docker build time variables'),
cfg.StrOpt('include-header', short='i',
deprecated_for_removal=True,
deprecated_reason=('Use a header block within a template'
' overrides file instead'),
help=('Path to custom file to be added at '
'beginning of base Dockerfile')),
cfg.StrOpt('include-footer', short='I',
deprecated_for_removal=True,
deprecated_reason=('Use a footer block within a template'
' overrides file instead'),
help=('Path to custom file to be added at '
'end of Dockerfiles for final images')),
cfg.BoolOpt('keep', default=False,
help='Keep failed intermediate containers'),
cfg.BoolOpt('list-dependencies', short='l',
help='Show image dependencies (filtering supported)'),
cfg.BoolOpt('list-images',
help='Show all available images'),
cfg.StrOpt('namespace', short='n', default='kolla',
help='The Docker namespace name'),
cfg.BoolOpt('cache', default=True,
help='Use the Docker cache when building',
),
cfg.MultiOpt('profile', types.String(), short='p',
help=('Build a pre-defined set of images, see [profiles]'
' section in config. The default profiles are:'
' {}'.format(', '.join(
[opt.name for opt in _PROFILE_OPTS])
))),
cfg.BoolOpt('push', default=False,
help='Push images after building'),
cfg.IntOpt('push-threads', default=1, min=1,
help=('The number of threads to user while pushing'
' Images. Note: Docker can not handle threading'
' push properly.')),
cfg.IntOpt('retries', short='r', default=3, min=0,
help='The number of times to retry while building'),
cfg.MultiOpt('regex', types.String(), positional=True,
help=('Build only images matching regex and its'
' dependencies')),
cfg.StrOpt('registry',
help=('The docker registry host. The default registry host'
' is Docker Hub')),
cfg.StrOpt('save-dependency',
help=('Path to the file to store the docker image'
' dependency in Graphviz dot format')),
cfg.StrOpt('type', short='t', default='binary',
choices=INSTALL_TYPE_CHOICES,
dest='install_type',
help=('The method of the OpenStack install')),
cfg.IntOpt('threads', short='T', default=8, min=1,
help=('The number of threads to use while building.'
' (Note: setting to one will allow real time'
' logging.)')),
cfg.StrOpt('tag', default=version.cached_version_string(),
help='The Docker tag'),
cfg.BoolOpt('template-only', default=False,
help=("Don't build images. Generate Dockerfile only")),
cfg.IntOpt('timeout', default=120,
help='Time in seconds after which any operation times out'),
cfg.StrOpt('template-override',
help='Path to template override file'),
cfg.StrOpt('logs-dir', help='Path to logs directory'),
]
_BASE_OPTS = [
cfg.StrOpt('maintainer',
default='Kolla Project (https://launchpad.net/kolla)',
help='The MAINTAINER field'),
cfg.ListOpt('rpm_setup_config', default=[DELOREAN, DELOREAN_DEPS],
help=('Comma separated list of .rpm or .repo file(s) '
'or URL(s) to install before building containers')),
cfg.StrOpt('apt_sources_list', help=('Path to custom sources.list')),
cfg.StrOpt('apt_preferences', help=('Path to custom apt/preferences'))
]
SOURCES = {
'openstack-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/requirements/'
'requirements-master.tar.gz')},
'aodh-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/aodh/'
'aodh-master.tar.gz')},
'barbican-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/barbican/'
'barbican-master.tar.gz')},
'bifrost-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/bifrost/'
'bifrost-master.tar.gz')},
'ceilometer-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/ceilometer/'
'ceilometer-master.tar.gz')},
'cinder-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/cinder/'
'cinder-master.tar.gz')},
'congress-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/congress/'
'congress-master.tar.gz')},
'cloudkitty-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/cloudkitty/'
'cloudkitty-master.tar.gz')},
'designate-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/designate/'
'designate-master.tar.gz')},
'freezer-api': {
'type': 'url',
'location': ('http://tarballs.openstack.org/freezer-api/'
'freezer-api-master.tar.gz')},
'freezer-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/freezer/'
'freezer-master.tar.gz')},
'glance-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/glance/'
'glance-master.tar.gz')},
'gnocchi-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/gnocchi/'
'gnocchi-master.tar.gz')},
'heat-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/heat/'
'heat-master.tar.gz')},
'horizon': {
'type': 'url',
'location': ('http://tarballs.openstack.org/horizon/'
'horizon-master.tar.gz')},
'horizon-plugin-neutron-lbaas-dashboard': {
'type': 'url',
'location': ('http://tarballs.openstack.org/neutron-lbaas-dashboard/'
'neutron-lbaas-dashboard-master.tar.gz')},
'ironic-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/ironic/'
'ironic-master.tar.gz')},
'ironic-inspector': {
'type': 'url',
'location': ('http://tarballs.openstack.org/ironic-inspector/'
'ironic-inspector-master.tar.gz')},
'keystone-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/keystone/'
'keystone-master.tar.gz')},
'kuryr-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/kuryr/'
'kuryr-master.tar.gz')},
'kuryr-libnetwork': {
'type': 'url',
'location': ('http://tarballs.openstack.org/kuryr-libnetwork/'
'kuryr-libnetwork-master.tar.gz')},
'magnum-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/magnum/'
'magnum-master.tar.gz')},
'manila-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/manila/'
'manila-master.tar.gz')},
'mistral-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/mistral/'
'mistral-master.tar.gz')},
'murano-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/murano/'
'murano-master.tar.gz')},
'neutron-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/neutron/'
'neutron-master.tar.gz')},
'neutron-lbaas-agent': {
'type': 'url',
'location': ('http://tarballs.openstack.org/neutron-lbaas/'
'neutron-lbaas-master.tar.gz')},
'neutron-sfc-agent': {
'type': 'url',
'location': ('http://tarballs.openstack.org/networking-sfc/'
'networking-sfc-master.tar.gz')},
'neutron-vpnaas-agent': {
'type': 'url',
'location': ('http://tarballs.openstack.org/neutron-vpnaas/'
'neutron-vpnaas-master.tar.gz')},
'nova-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/nova/'
'nova-master.tar.gz')},
'nova-spicehtml5proxy': {
'type': 'url',
'location': ('http://github.com/SPICE/spice-html5/tarball/'
'spice-html5-0.1.6')},
'nova-novncproxy': {
'type': 'url',
'location': ('http://github.com/kanaka/noVNC/tarball/'
'v0.5.1')},
'panko-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/panko/'
'panko-master.tar.gz')},
'rally': {
'type': 'url',
'location': ('http://tarballs.openstack.org/rally/'
'rally-master.tar.gz')},
'sahara-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/sahara/'
'sahara-master.tar.gz')},
'searchlight-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/searchlight/'
'searchlight-1.0.0.tar.gz')},
'senlin-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/senlin/'
'senlin-master.tar.gz')},
'solum-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/solum/'
'solum-master.tar.gz')},
'swift-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/swift/'
'swift-master.tar.gz')},
'tempest': {
'type': 'url',
'location': ('http://tarballs.openstack.org/tempest/'
'tempest-master.tar.gz')},
'trove-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/trove/'
'trove-master.tar.gz')},
'watcher-base': {
'type': 'url',
'location': ('http://tarballs.openstack.org/watcher/'
'watcher-master.tar.gz')},
'zaqar': {
'type': 'url',
'location': ('http://tarballs.openstack.org/zaqar/'
'zaqar-master.tar.gz')}
}
def get_source_opts(type_=None, location=None, reference=None):
return [cfg.StrOpt('type', choices=['local', 'git', 'url'],
default=type_,
help='Source location type'),
cfg.StrOpt('location', default=location,
help='The location for source install'),
cfg.StrOpt('reference', default=reference,
help=('Git reference to pull, commit sha, tag '
'or branch name'))]
def gen_all_source_opts():
for name, params in SOURCES.items():
type_ = params['type']
location = params['location']
reference = params.get('reference')
yield name, get_source_opts(type_, location, reference)
def list_opts():
return itertools.chain([(None, _CLI_OPTS),
(None, _BASE_OPTS),
('profiles', _PROFILE_OPTS)],
gen_all_source_opts(),
)
def parse(conf, args, usage=None, prog=None,
default_config_files=None):
conf.register_cli_opts(_CLI_OPTS)
conf.register_opts(_BASE_OPTS)
conf.register_opts(_PROFILE_OPTS, group='profiles')
for name, opts in gen_all_source_opts():
conf.register_opts(opts, name)
conf(args=args,
project='kolla',
usage=usage,
prog=prog,
version=version.cached_version_string(),
default_config_files=default_config_files)
# NOTE(jeffrey4l): set the default base tag based on the
# base option
conf.set_default('base_tag', DISTRO_RELEASE.get(conf.base))
if not conf.base_image:
conf.base_image = conf.base

View File

@ -1,42 +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.
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class Task(object):
def __init__(self):
self.success = False
@abc.abstractproperty
def name(self):
pass
def reset(self):
self.success = False
@property
def followups(self):
return []
@abc.abstractmethod
def run(self):
pass
@staticmethod
def set_status(status):
# TODO(harlowja): remove this.
pass

View File

@ -1,40 +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.
import re
mutable_default_args = re.compile(r"^\s*def .+\((.+=\{\}|.+=\[\])")
def no_log_warn(logical_line):
"""Disallow 'LOG.warn('
Deprecated LOG.warn(), instead use LOG.warning
https://bugs.launchpad.net/senlin/+bug/1508442
N352
"""
msg = ("N352: LOG.warn is deprecated, please use LOG.warning!")
if "LOG.warn(" in logical_line:
yield (0, msg)
def no_mutable_default_args(logical_line):
msg = "N301: Method's default argument shouldn't be mutable!"
if mutable_default_args.match(logical_line):
yield (0, msg)
def factory(register):
register(no_mutable_default_args)
register(no_log_warn)

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +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.
from kolla.common import config
def list_opts():
return config.list_opts()

View File

@ -1,29 +0,0 @@
#!/usr/bin/env python
# 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 jinja2 import contextfilter
@contextfilter
def customizable(context, val_list, call_type):
name = context['image_name'].replace("-", "_") + "_" + call_type + "_"
if name + "override" in context:
return context[name + "override"]
if name + "append" in context:
val_list.extend(context[name + "append"])
if name + "remove" in context:
for removal in context[name + "remove"]:
if removal in val_list:
val_list.remove(removal)
return val_list

View File

@ -1,63 +0,0 @@
#!/usr/bin/env python
# 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 debian_package_install(packages):
"""Jinja utility method for building debian-based package install command
apt-get is not capable of installing .deb files from a URL and the
template logic to construct a series of steps to install regular packages
from apt repos as well as .deb files that need to be downloaded, manually
installed, and cleaned up is complicated. This method will contruct the
proper string required to install all packages in a way that's a bit
easier to follow
:param packages: a list of strings that are either packages to install
from an apt repo, or URLs to .deb files
:type packages: list
:returns: string suitable to provide to RUN command in a Dockerfile that
will install the given packages
:rtype: string
"""
cmds = []
# divide the list into two groups, one for regular packages and one for
# URL packages
reg_packages, url_packages = [], []
for package in packages:
if package.startswith('http'):
url_packages.append(package)
else:
reg_packages.append(package)
# handle the apt-get install
if reg_packages:
cmds.append('apt-get -y install --no-install-recommends {}'.format(
' '.join(reg_packages)
))
cmds.append('apt-get clean')
# handle URL packages
for url in url_packages:
# the path portion should be the file name
name = url[url.rfind('/') + 1:]
cmds.extend([
'curl --location {} -o {}'.format(url, name),
'dpkg -i {}'.format(name),
'rm -rf {}'.format(name),
])
# return the list of commands
return ' && '.join(cmds)

View File

@ -1,44 +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.
import os
import fixtures
import mock
from oslo_config import cfg
from oslotest import base as oslotest_base
from kolla.common import config as common_config
TESTS_ROOT = os.path.dirname(os.path.abspath(__file__))
class TestCase(oslotest_base.BaseTestCase):
'''All unit test should inherit from this class'''
config_file = None
def setUp(self):
super(TestCase, self).setUp()
self.conf = cfg.ConfigOpts()
default_config_files = self.get_default_config_files()
common_config.parse(self.conf, [],
default_config_files=default_config_files)
# NOTE(jeffrey4l): mock the _get_image_dir method to return a fake
# docker images dir
self.useFixture(fixtures.MockPatch(
'kolla.image.build.KollaWorker._get_images_dir',
mock.Mock(return_value=os.path.join(TESTS_ROOT, 'docker'))))
def get_default_config_files(self):
if self.config_file:
return [os.path.join(TESTS_ROOT, 'etc', self.config_file)]

View File

@ -1,20 +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.
from kolla.tests import base
class ConfigTest(base.TestCase):
config_file = 'default.conf'
def test_debug_opt(self):
self.assertTrue(self.conf.debug)

View File

@ -1 +0,0 @@
FROM {{ base_distro }}:{{ base_distro_tag }}

View File

@ -1 +0,0 @@
FROM {{ namespace }}/{{ image_prefix }}base:{{ tag }}

View File

@ -1,16 +0,0 @@
[DEFAULT]
debug=True
[neutron-server-plugin-networking-arista]
reference = master
location = https://git.openstack.org/openstack/networking-arista
type = git
[neutron-base-plugin-neutron-fwaas]
reference = master
location = https://git.openstack.org/openstack/neutron-fwaas
type = git
[profiles]
default = image-base
all = image-base,image-child

View File

@ -1,287 +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.
import fixtures
import itertools
import mock
import os
import requests
from kolla.cmd import build as build_cmd
from kolla.image import build
from kolla.tests import base
FAKE_IMAGE = build.Image(
'image-base', 'image-base:latest',
'/fake/path', parent_name=None,
parent=None, status=build.STATUS_MATCHED)
FAKE_IMAGE_CHILD = build.Image(
'image-child', 'image-child:latest',
'/fake/path2', parent_name='image-base',
parent=FAKE_IMAGE, status=build.STATUS_MATCHED)
class TasksTest(base.TestCase):
def setUp(self):
super(TasksTest, self).setUp()
self.image = FAKE_IMAGE.copy()
# NOTE(jeffrey4l): use a real, temporary dir
self.image.path = self.useFixture(fixtures.TempDir()).path
@mock.patch.dict(os.environ, clear=True)
@mock.patch('docker.Client')
def test_push_image(self, mock_client):
pusher = build.PushTask(self.conf, self.image)
pusher.run()
mock_client().push.assert_called_once_with(
self.image.canonical_name, stream=True, insecure_registry=True)
@mock.patch.dict(os.environ, clear=True)
@mock.patch('docker.Client')
def test_build_image(self, mock_client):
push_queue = mock.Mock()
builder = build.BuildTask(self.conf, self.image, push_queue)
builder.run()
mock_client().build.assert_called_once_with(
path=self.image.path, tag=self.image.canonical_name,
nocache=False, rm=True, pull=True, forcerm=True,
buildargs=None)
self.assertTrue(builder.success)
@mock.patch.dict(os.environ, clear=True)
@mock.patch('docker.Client')
def test_build_image_with_build_arg(self, mock_client):
build_args = {
'HTTP_PROXY': 'http://localhost:8080',
'NO_PROXY': '127.0.0.1'
}
self.conf.set_override('build_args', build_args)
push_queue = mock.Mock()
builder = build.BuildTask(self.conf, self.image, push_queue)
builder.run()
mock_client().build.assert_called_once_with(
path=self.image.path, tag=self.image.canonical_name,
nocache=False, rm=True, pull=True, forcerm=True,
buildargs=build_args)
self.assertTrue(builder.success)
@mock.patch.dict(os.environ, {'http_proxy': 'http://FROM_ENV:8080'},
clear=True)
@mock.patch('docker.Client')
def test_build_arg_from_env(self, mock_client):
push_queue = mock.Mock()
build_args = {
'http_proxy': 'http://FROM_ENV:8080',
}
builder = build.BuildTask(self.conf, self.image, push_queue)
builder.run()
mock_client().build.assert_called_once_with(
path=self.image.path, tag=self.image.canonical_name,
nocache=False, rm=True, pull=True, forcerm=True,
buildargs=build_args)
self.assertTrue(builder.success)
@mock.patch.dict(os.environ, {'http_proxy': 'http://FROM_ENV:8080'},
clear=True)
@mock.patch('docker.Client')
def test_build_arg_precedence(self, mock_client):
build_args = {
'http_proxy': 'http://localhost:8080',
}
self.conf.set_override('build_args', build_args)
push_queue = mock.Mock()
builder = build.BuildTask(self.conf, self.image, push_queue)
builder.run()
mock_client().build.assert_called_once_with(
path=self.image.path, tag=self.image.canonical_name,
nocache=False, rm=True, pull=True, forcerm=True,
buildargs=build_args)
self.assertTrue(builder.success)
@mock.patch('docker.Client')
@mock.patch('requests.get')
def test_requests_get_timeout(self, mock_get, mock_client):
self.image.source = {
'source': 'http://fake/source',
'type': 'url',
'name': 'fake-image-base'
}
push_queue = mock.Mock()
builder = build.BuildTask(self.conf, self.image, push_queue)
mock_get.side_effect = requests.exceptions.Timeout
get_result = builder.process_source(self.image, self.image.source)
self.assertIsNone(get_result)
self.assertEqual(self.image.status, build.STATUS_ERROR)
mock_get.assert_called_once_with(self.image.source['source'],
timeout=120)
self.assertFalse(builder.success)
class KollaWorkerTest(base.TestCase):
config_file = 'default.conf'
def setUp(self):
super(KollaWorkerTest, self).setUp()
image = FAKE_IMAGE.copy()
image.status = None
image_child = FAKE_IMAGE_CHILD.copy()
image_child.status = None
self.images = [image, image_child]
def test_supported_base_type(self):
rh_base = ['centos', 'oraclelinux', 'rhel']
rh_type = ['source', 'binary', 'rdo', 'rhos']
deb_base = ['ubuntu', 'debian']
deb_type = ['source', 'binary']
for base_distro, install_type in itertools.chain(
itertools.product(rh_base, rh_type),
itertools.product(deb_base, deb_type)):
self.conf.set_override('base', base_distro)
self.conf.set_override('install_type', install_type)
# should no exception raised
build.KollaWorker(self.conf)
def test_unsupported_base_type(self):
for base_distro, install_type in itertools.product(
['ubuntu', 'debian'], ['rdo', 'rhos']):
self.conf.set_override('base', base_distro)
self.conf.set_override('install_type', install_type)
self.assertRaises(build.KollaMismatchBaseTypeException,
build.KollaWorker, self.conf)
def test_build_image_list_adds_plugins(self):
self.conf.set_override('install_type', 'source')
kolla = build.KollaWorker(self.conf)
kolla.setup_working_dir()
kolla.find_dockerfiles()
kolla.create_dockerfiles()
kolla.build_image_list()
expected_plugin = {
'name': 'neutron-server-plugin-networking-arista',
'reference': 'master',
'source': 'https://git.openstack.org/openstack/networking-arista',
'type': 'git'
}
for image in kolla.images:
if image.name == 'neutron-server':
self.assertEqual(image.plugins[0], expected_plugin)
break
else:
self.fail('Can not find the expected neutron arista plugin')
def test_build_image_list_plugin_parsing(self):
"""Ensure regex used to parse plugins adds them to the correct image"""
self.conf.set_override('install_type', 'source')
kolla = build.KollaWorker(self.conf)
kolla.setup_working_dir()
kolla.find_dockerfiles()
kolla.create_dockerfiles()
kolla.build_image_list()
for image in kolla.images:
if image.name == 'base':
self.assertEqual(len(image.plugins), 0,
'base image should not have any plugins '
'registered')
break
else:
self.fail('Expected to find the base image in this test')
def _get_matched_images(self, images):
return [image for image in images
if image.status == build.STATUS_MATCHED]
def test_without_profile(self):
kolla = build.KollaWorker(self.conf)
kolla.images = self.images
kolla.filter_images()
self.assertEqual(2, len(self._get_matched_images(kolla.images)))
def test_pre_defined_exist_profile(self):
# default profile include the fake image: image-base
self.conf.set_override('profile', ['default'])
kolla = build.KollaWorker(self.conf)
kolla.images = self.images
kolla.filter_images()
self.assertEqual(1, len(self._get_matched_images(kolla.images)))
def test_pre_defined_exist_profile_not_include(self):
# infra profile do not include the fake image: image-base
self.conf.set_override('profile', ['infra'])
kolla = build.KollaWorker(self.conf)
kolla.images = self.images
kolla.filter_images()
self.assertEqual(0, len(self._get_matched_images(kolla.images)))
def test_pre_defined_not_exist_profile(self):
# NOTE(jeffrey4l): not exist profile will raise ValueError
self.conf.set_override('profile', ['not_exist'])
kolla = build.KollaWorker(self.conf)
kolla.images = self.images
self.assertRaises(ValueError,
kolla.filter_images)
@mock.patch('pprint.pprint')
def test_list_dependencies(self, pprint_mock):
self.conf.set_override('profile', ['all'])
kolla = build.KollaWorker(self.conf)
kolla.images = self.images
kolla.filter_images()
kolla.list_dependencies()
pprint_mock.assert_called_once_with(mock.ANY)
@mock.patch.object(build, 'run_build')
class MainTest(base.TestCase):
def test_images_built(self, mock_run_build):
image_statuses = ({}, {'img': 'built'}, {})
mock_run_build.return_value = image_statuses
result = build_cmd.main()
self.assertEqual(0, result)
def test_images_unmatched(self, mock_run_build):
image_statuses = ({}, {}, {'img': 'unmatched'})
mock_run_build.return_value = image_statuses
result = build_cmd.main()
self.assertEqual(0, result)
def test_no_images_built(self, mock_run_build):
mock_run_build.return_value = None
result = build_cmd.main()
self.assertEqual(0, result)
def test_bad_images(self, mock_run_build):
image_statuses = ({'img': 'error'}, {}, {})
mock_run_build.return_value = image_statuses
result = build_cmd.main()
self.assertEqual(1, result)

View File

@ -1,6 +1,6 @@
[metadata]
name = kolla
summary = Kolla OpenStack Deployment
name = kolla-ansible
summary = Ansible Deployment of Kolla containers
description-file =
README.rst
author = OpenStack
@ -25,7 +25,6 @@ packages =
kolla
data_files =
share/kolla/ansible = ansible/*
share/kolla/docker = docker/*
share/kolla/tools = tools/validate-docker-execute.sh
share/kolla/tools = tools/cleanup-containers
share/kolla/tools = tools/cleanup-host
@ -42,7 +41,6 @@ scripts =
[entry_points]
console_scripts =
kolla-build = kolla.cmd.build:main
kolla-genpwd = kolla.cmd.genpwd:main
kolla-mergepwd = kolla.cmd.mergepwd:main
oslo.config.opts =

View File

@ -1,188 +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.
import abc
import os
import sys
from mock import patch
from oslo_log import fixture as log_fixture
from oslo_log import log as logging
from oslotest import base
import testtools
sys.path.append(
os.path.abspath(os.path.join(os.path.dirname(__file__), '../tools')))
from kolla.image import build
LOG = logging.getLogger(__name__)
class BuildTest(object):
excluded_images = abc.abstractproperty()
def setUp(self):
super(BuildTest, self).setUp()
self.useFixture(log_fixture.SetLogLevel([__name__],
logging.logging.INFO))
self.build_args = [__name__, "--debug", '--threads', '4']
@testtools.skipUnless(os.environ.get('DOCKER_BUILD_TEST'),
'Skip the docker build test')
def runTest(self):
with patch.object(sys, 'argv', self.build_args):
LOG.info("Running with args %s", self.build_args)
bad_results, good_results, unmatched_results = build.run_build()
failures = 0
for image, result in bad_results.items():
if image in self.excluded_images:
if result is 'error':
continue
failures = failures + 1
LOG.warning(">>> Expected image '%s' to fail, please update"
" the excluded_images in source file above if the"
" image build has been fixed.", image)
else:
if result is not 'error':
continue
failures = failures + 1
LOG.critical(">>> Expected image '%s' to succeed!", image)
for image in unmatched_results.keys():
LOG.warning(">>> Image '%s' was not matched", image)
self.assertEqual(failures, 0, "%d failure(s) occurred" % failures)
class BuildTestCentosBinary(BuildTest, base.BaseTestCase):
excluded_images = ["kuryr-base",
"neutron-sfc-agent",
"searchlight-base",
"senlin-base",
"solum-base",
"vmtp",
"manila-data",
"watcher-base",
"congress-base",
"bifrost-base",
"cloudkitty-base",
"freezer-base"]
def setUp(self):
super(BuildTestCentosBinary, self).setUp()
self.build_args.extend(["--base", "centos",
"--type", "binary"])
class BuildTestCentosSource(BuildTest, base.BaseTestCase):
excluded_images = ["mistral-base"]
def setUp(self):
super(BuildTestCentosSource, self).setUp()
self.build_args.extend(["--base", "centos",
"--type", "source"])
class BuildTestUbuntuBinary(BuildTest, base.BaseTestCase):
excluded_images = ["kuryr-base",
"neutron-sfc-agent",
"searchlight-base",
"senlin-base",
"solum-base",
"vmtp",
"zaqar",
"watcher-base",
"congress-base",
"bifrost-base",
"cloudkitty-base",
"freezer-base",
"panko-base"]
def setUp(self):
super(BuildTestUbuntuBinary, self).setUp()
self.build_args.extend(["--base", "ubuntu",
"--type", "binary"])
class BuildTestUbuntuSource(BuildTest, base.BaseTestCase):
excluded_images = []
def setUp(self):
super(BuildTestUbuntuSource, self).setUp()
self.build_args.extend(["--base", "ubuntu",
"--type", "source"])
class BuildTestOracleLinuxBinary(BuildTest, base.BaseTestCase):
excluded_images = ["kuryr-base",
"neutron-sfc-agent",
"searchlight-base",
"senlin-base",
"solum-base",
"vmtp",
"manila-data",
"watcher-base",
"congress-base",
"bifrost-base",
"cloudkitty-base",
"freezer-base"]
def setUp(self):
super(BuildTestOracleLinuxBinary, self).setUp()
self.build_args.extend(["--base", "oraclelinux",
"--type", "binary"])
class BuildTestOracleLinuxSource(BuildTest, base.BaseTestCase):
excluded_images = []
def setUp(self):
super(BuildTestOracleLinuxSource, self).setUp()
self.build_args.extend(["--base", "oraclelinux",
"--type", "source"])
class DeployTestCentosBinary(BuildTestCentosBinary):
def setUp(self):
super(DeployTestCentosBinary, self).setUp()
self.build_args.extend(["--profile", "gate"])
class DeployTestCentosSource(BuildTestCentosSource):
def setUp(self):
super(DeployTestCentosSource, self).setUp()
self.build_args.extend(["--profile", "gate"])
class DeployTestOracleLinuxBinary(BuildTestOracleLinuxBinary):
def setUp(self):
super(DeployTestOracleLinuxBinary, self).setUp()
self.build_args.extend(["--profile", "gate"])
class DeployTestOracleLinuxSource(BuildTestOracleLinuxSource):
def setUp(self):
super(DeployTestOracleLinuxSource, self).setUp()
self.build_args.extend(["--profile", "gate"])
class DeployTestUbuntuBinary(BuildTestUbuntuBinary):
def setUp(self):
super(DeployTestUbuntuBinary, self).setUp()
self.build_args.extend(["--profile", "gate"])
class DeployTestUbuntuSource(BuildTestUbuntuSource):
def setUp(self):
super(DeployTestUbuntuSource, self).setUp()
self.build_args.extend(["--profile", "gate"])

View File

@ -1 +0,0 @@
../kolla/cmd/build.py

View File

@ -1,11 +0,0 @@
#!/bin/bash
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
find docker -name Dockerfile.j2 -print0 |
xargs -0 tools/validate-maintainer.sh || exit 1
find docker -name Dockerfile.j2 -print0 |
xargs -0 tools/validate-install-command.sh || exit 1

View File

@ -25,7 +25,6 @@ commands = oslo_debug_helper {posargs}
commands =
{toxinidir}/tools/run-bashate.sh
flake8 {posargs}
{toxinidir}/tools/validate-all-dockerfiles.sh
python {toxinidir}/tools/validate-all-file.py
bandit -r ansible/library kolla tests tools
@ -58,6 +57,3 @@ commands =
[flake8]
show-source = True
exclude=.eggs,.git,.tox,doc
[hacking]
local-check-factory = kolla.hacking.checks.factory