From 177fbea79a1babdcd4e8230341380d373eef6df4 Mon Sep 17 00:00:00 2001 From: Jeffrey Zhang Date: Wed, 15 Feb 2017 11:51:52 +0800 Subject: Rename kolla namespace to kolla_ansible * Rename kolla namespace to kolla_ansible * remove oslo.config.opts entry points which is uesless * delete useless tools/version-check.py script Change-Id: I005dd7223ff23afbb2ce8cbfd0ebec0969102798 --- doc/conf.py | 4 +- kolla/__init__.py | 22 ------ kolla/cmd/__init__.py | 0 kolla/cmd/genpwd.py | 106 ---------------------------- kolla/cmd/mergepwd.py | 39 ---------- kolla/version.py | 15 ---- kolla_ansible/__init__.py | 22 ++++++ kolla_ansible/cmd/__init__.py | 0 kolla_ansible/cmd/genpwd.py | 106 ++++++++++++++++++++++++++++ kolla_ansible/cmd/mergepwd.py | 39 ++++++++++ kolla_ansible/version.py | 15 ++++ releasenotes/source/conf.py | 2 +- setup.cfg | 34 +++++---- tools/generate_passwords.py | 2 +- tools/merge_passwords.py | 2 +- tools/version-check.py | 160 ------------------------------------------ 16 files changed, 203 insertions(+), 365 deletions(-) delete mode 100644 kolla/__init__.py delete mode 100644 kolla/cmd/__init__.py delete mode 100755 kolla/cmd/genpwd.py delete mode 100755 kolla/cmd/mergepwd.py delete mode 100644 kolla/version.py create mode 100644 kolla_ansible/__init__.py create mode 100644 kolla_ansible/cmd/__init__.py create mode 100755 kolla_ansible/cmd/genpwd.py create mode 100755 kolla_ansible/cmd/mergepwd.py create mode 100644 kolla_ansible/version.py delete mode 100755 tools/version-check.py diff --git a/doc/conf.py b/doc/conf.py index da18af32c..0a39ce7aa 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -36,7 +36,7 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'kolla' +project = u'kolla-ansible' copyright = u'2013, OpenStack Foundation' # The version info for the project you're documenting, acts as replacement for @@ -44,7 +44,7 @@ copyright = u'2013, OpenStack Foundation' # built documents. # # The short X.Y version. -from kolla.version import version_info as kolla_version +from kolla_ansible.version import version_info as kolla_version # The full version, including alpha/beta/rc tags. release = kolla_version.version_string_with_vcs() # The short X.Y version. diff --git a/kolla/__init__.py b/kolla/__init__.py deleted file mode 100644 index 255a27b78..000000000 --- a/kolla/__init__.py +++ /dev/null @@ -1,22 +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 threading - -import pbr.version - - -__version__ = pbr.version.VersionInfo( - 'kolla-ansible').version_string() - -# Make a project global TLS trace storage repository -TLS = threading.local() diff --git a/kolla/cmd/__init__.py b/kolla/cmd/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/kolla/cmd/genpwd.py b/kolla/cmd/genpwd.py deleted file mode 100755 index 11d15fbd8..000000000 --- a/kolla/cmd/genpwd.py +++ /dev/null @@ -1,106 +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 argparse -import hmac -import os -import random -import string -import sys - -from Crypto.PublicKey import RSA -from hashlib import md5 -from oslo_utils import uuidutils -import yaml - -# 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) - - -def generate_RSA(bits=4096): - new_key = RSA.generate(bits, os.urandom) - private_key = new_key.exportKey("PEM") - public_key = new_key.publickey().exportKey("OpenSSH") - return private_key, public_key - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument( - '-p', '--passwords', type=str, - default=os.path.abspath('/etc/kolla/passwords.yml'), - help=('Path to the passwords yml file')) - - args = parser.parse_args() - passwords_file = os.path.expanduser(args.passwords) - - # These keys should be random uuids - uuid_keys = ['ceph_cluster_fsid', 'rbd_secret_uuid', - 'gnocchi_project_id', 'gnocchi_resource_id', - 'gnocchi_user_id', 'designate_pool_id', - 'karbor_openstack_infra_id'] - - # SSH key pair - ssh_keys = ['kolla_ssh_key', 'nova_ssh_key', - 'keystone_ssh_key', 'bifrost_ssh_key'] - - # If these keys are None, leave them as None - blank_keys = ['docker_registry_password'] - - # HMAC-MD5 keys - hmac_md5_keys = ['designate_rndc_key'] - - # length of password - length = 40 - - with open(passwords_file, 'r') as f: - passwords = yaml.safe_load(f.read()) - - for k, v in passwords.items(): - if (k in ssh_keys and - (v is None - or v.get('public_key') is None - and v.get('private_key') is None)): - private_key, public_key = generate_RSA() - passwords[k] = { - 'private_key': private_key, - 'public_key': public_key - } - continue - if v is None: - if k in blank_keys and v is None: - continue - if k in uuid_keys: - passwords[k] = uuidutils.generate_uuid() - elif k in hmac_md5_keys: - passwords[k] = (hmac.new( - uuidutils.generate_uuid(), '', md5) - .digest().encode('base64')[:-1]) - else: - passwords[k] = ''.join([ - random.SystemRandom().choice( - string.ascii_letters + string.digits) - for n in range(length) - ]) - - with open(passwords_file, 'w') as f: - f.write(yaml.dump(passwords, default_flow_style=False)) - -if __name__ == '__main__': - main() diff --git a/kolla/cmd/mergepwd.py b/kolla/cmd/mergepwd.py deleted file mode 100755 index 44053f8e1..000000000 --- a/kolla/cmd/mergepwd.py +++ /dev/null @@ -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 argparse -import yaml - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument("--old", help="old password file", required=True) - parser.add_argument("--new", help="new password file", required=True) - parser.add_argument("--final", help="merged password file", required=True) - args = parser.parse_args() - - with open(args.old, "r") as old_file: - old_passwords = yaml.safe_load(old_file) - - with open(args.new, "r") as new_file: - new_passwords = yaml.safe_load(new_file) - - new_passwords.update(old_passwords) - - with open(args.final, "w") as destination: - yaml.dump(new_passwords, destination, default_flow_style=False) - - -if __name__ == '__main__': - main() diff --git a/kolla/version.py b/kolla/version.py deleted file mode 100644 index e8a998936..000000000 --- a/kolla/version.py +++ /dev/null @@ -1,15 +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 pbr.version - -version_info = pbr.version.VersionInfo('kolla-ansible') diff --git a/kolla_ansible/__init__.py b/kolla_ansible/__init__.py new file mode 100644 index 000000000..255a27b78 --- /dev/null +++ b/kolla_ansible/__init__.py @@ -0,0 +1,22 @@ +# 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 threading + +import pbr.version + + +__version__ = pbr.version.VersionInfo( + 'kolla-ansible').version_string() + +# Make a project global TLS trace storage repository +TLS = threading.local() diff --git a/kolla_ansible/cmd/__init__.py b/kolla_ansible/cmd/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/kolla_ansible/cmd/genpwd.py b/kolla_ansible/cmd/genpwd.py new file mode 100755 index 000000000..11d15fbd8 --- /dev/null +++ b/kolla_ansible/cmd/genpwd.py @@ -0,0 +1,106 @@ +#!/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 argparse +import hmac +import os +import random +import string +import sys + +from Crypto.PublicKey import RSA +from hashlib import md5 +from oslo_utils import uuidutils +import yaml + +# 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) + + +def generate_RSA(bits=4096): + new_key = RSA.generate(bits, os.urandom) + private_key = new_key.exportKey("PEM") + public_key = new_key.publickey().exportKey("OpenSSH") + return private_key, public_key + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + '-p', '--passwords', type=str, + default=os.path.abspath('/etc/kolla/passwords.yml'), + help=('Path to the passwords yml file')) + + args = parser.parse_args() + passwords_file = os.path.expanduser(args.passwords) + + # These keys should be random uuids + uuid_keys = ['ceph_cluster_fsid', 'rbd_secret_uuid', + 'gnocchi_project_id', 'gnocchi_resource_id', + 'gnocchi_user_id', 'designate_pool_id', + 'karbor_openstack_infra_id'] + + # SSH key pair + ssh_keys = ['kolla_ssh_key', 'nova_ssh_key', + 'keystone_ssh_key', 'bifrost_ssh_key'] + + # If these keys are None, leave them as None + blank_keys = ['docker_registry_password'] + + # HMAC-MD5 keys + hmac_md5_keys = ['designate_rndc_key'] + + # length of password + length = 40 + + with open(passwords_file, 'r') as f: + passwords = yaml.safe_load(f.read()) + + for k, v in passwords.items(): + if (k in ssh_keys and + (v is None + or v.get('public_key') is None + and v.get('private_key') is None)): + private_key, public_key = generate_RSA() + passwords[k] = { + 'private_key': private_key, + 'public_key': public_key + } + continue + if v is None: + if k in blank_keys and v is None: + continue + if k in uuid_keys: + passwords[k] = uuidutils.generate_uuid() + elif k in hmac_md5_keys: + passwords[k] = (hmac.new( + uuidutils.generate_uuid(), '', md5) + .digest().encode('base64')[:-1]) + else: + passwords[k] = ''.join([ + random.SystemRandom().choice( + string.ascii_letters + string.digits) + for n in range(length) + ]) + + with open(passwords_file, 'w') as f: + f.write(yaml.dump(passwords, default_flow_style=False)) + +if __name__ == '__main__': + main() diff --git a/kolla_ansible/cmd/mergepwd.py b/kolla_ansible/cmd/mergepwd.py new file mode 100755 index 000000000..44053f8e1 --- /dev/null +++ b/kolla_ansible/cmd/mergepwd.py @@ -0,0 +1,39 @@ +#!/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 argparse +import yaml + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--old", help="old password file", required=True) + parser.add_argument("--new", help="new password file", required=True) + parser.add_argument("--final", help="merged password file", required=True) + args = parser.parse_args() + + with open(args.old, "r") as old_file: + old_passwords = yaml.safe_load(old_file) + + with open(args.new, "r") as new_file: + new_passwords = yaml.safe_load(new_file) + + new_passwords.update(old_passwords) + + with open(args.final, "w") as destination: + yaml.dump(new_passwords, destination, default_flow_style=False) + + +if __name__ == '__main__': + main() diff --git a/kolla_ansible/version.py b/kolla_ansible/version.py new file mode 100644 index 000000000..e8a998936 --- /dev/null +++ b/kolla_ansible/version.py @@ -0,0 +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. + +import pbr.version + +version_info = pbr.version.VersionInfo('kolla-ansible') diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index f4a3215a7..6c7d3581c 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -16,7 +16,7 @@ import os import sys -from kolla.version import version_info as kolla_version +from kolla_ansible.version import version_info as kolla_version sys.path.insert(0, os.path.abspath('../..')) diff --git a/setup.cfg b/setup.cfg index 5bc85d75a..e29ff547b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,7 +5,7 @@ description-file = README.rst author = OpenStack author-email = openstack-dev@lists.openstack.org -home-page = http://docs.openstack.org/developer/kolla/ +home-page = http://docs.openstack.org/developer/kolla-ansible/ license = Apache License, Version 2.0 classifier = Environment :: OpenStack @@ -22,30 +22,28 @@ classifier = [files] packages = - kolla + kolla_ansible data_files = - share/kolla/ansible = ansible/* - share/kolla/tools = tools/validate-docker-execute.sh - share/kolla/tools = tools/cleanup-containers - share/kolla/tools = tools/cleanup-host - share/kolla/tools = tools/cleanup-images - share/kolla/tools = tools/stop-containers - share/kolla/doc = doc/* - share/kolla/etc_examples = etc/* - share/kolla = tools/init-runonce - share/kolla = tools/init-vpn - share/kolla = tools/openrc-example - share/kolla = setup.cfg + share/kolla-ansible/ansible = ansible/* + share/kolla-ansible/tools = tools/validate-docker-execute.sh + share/kolla-ansible/tools = tools/cleanup-containers + share/kolla-ansible/tools = tools/cleanup-host + share/kolla-ansible/tools = tools/cleanup-images + share/kolla-ansible/tools = tools/stop-containers + share/kolla-ansible/doc = doc/* + share/kolla-ansible/etc_examples = etc/* + share/kolla-ansible = tools/init-runonce + share/kolla-ansible = tools/init-vpn + share/kolla-ansible = tools/openrc-example + share/kolla-ansible = setup.cfg scripts = tools/kolla-ansible [entry_points] console_scripts = - kolla-genpwd = kolla.cmd.genpwd:main - kolla-mergepwd = kolla.cmd.mergepwd:main -oslo.config.opts = - kolla = kolla.opts:list_opts + kolla-genpwd = kolla_ansible.cmd.genpwd:main + kolla-mergepwd = kolla_ansible.cmd.mergepwd:main [global] setup-hooks = diff --git a/tools/generate_passwords.py b/tools/generate_passwords.py index e157963a3..767790216 120000 --- a/tools/generate_passwords.py +++ b/tools/generate_passwords.py @@ -1 +1 @@ -../kolla/cmd/genpwd.py \ No newline at end of file +../kolla_ansible/cmd/genpwd.py \ No newline at end of file diff --git a/tools/merge_passwords.py b/tools/merge_passwords.py index ce2431d00..b184c91c7 120000 --- a/tools/merge_passwords.py +++ b/tools/merge_passwords.py @@ -1 +1 @@ -../kolla/cmd/mergepwd.py \ No newline at end of file +../kolla_ansible/cmd/mergepwd.py \ No newline at end of file diff --git a/tools/version-check.py b/tools/version-check.py deleted file mode 100755 index 58aa03e6e..000000000 --- a/tools/version-check.py +++ /dev/null @@ -1,160 +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 collections -import logging -import os -import re -import sys - -import bs4 -from oslo_config import cfg -import pkg_resources -import prettytable -import requests - -# 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.common import config as common_config - -logging.basicConfig(format="%(message)s") -LOG = logging.getLogger('version-check') - -# Filter list for non-projects -NOT_PROJECTS = [ - 'nova-novncproxy', - 'nova-spicehtml5proxy', - 'openstack-base', - 'profiles' -] -TARBALLS_BASE_URL = 'http://tarballs.openstack.org' -VERSIONS = {'local': dict()} - - -def retrieve_upstream_versions(): - upstream_versions = dict() - for project in VERSIONS['local']: - winner = None - series = VERSIONS['local'][project].split('.')[0] - base = '{}/{}'.format(TARBALLS_BASE_URL, project) - LOG.debug("Getting latest version for project %s from %s", - project, base) - r = requests.get(base) - s = bs4.BeautifulSoup(r.text, 'html.parser') - - for link in s.find_all('a'): - version = link.get('href') - if (version.endswith('.tar.gz') and - version.startswith('{}-{}'.format(project, series))): - split = '{}-|.tar.gz'.format(project) - candidate = re.split(split, version)[1] - # Ignore 2014, 2015 versions as they are older - if candidate.startswith('201'): - continue - if not winner or more_recent(candidate, winner): - winner = candidate - - if not winner: - LOG.warning("Could not find a version for %s", project) - continue - - if '-' in winner: - winner = winner.split('-')[1] - upstream_versions[project] = winner - LOG.debug("Found latest version %s for project %s", winner, project) - - VERSIONS['upstream'] = collections.OrderedDict( - sorted(upstream_versions.items())) - - -def retrieve_local_versions(conf): - for section in common_config.SOURCES: - if section in NOT_PROJECTS: - continue - - project = section.split('-')[0] - - if section not in conf.list_all_sections(): - LOG.debug("Project %s not found in configuration file, using " - "default from kolla.common.config", project) - raw_version = common_config.SOURCES[section]['location'] - else: - raw_version = getattr(conf, section).location - - version = raw_version.split('/')[-1].split('.tar.gz')[0] - if '-' in version: - version = version.split('-')[1] - - LOG.debug("Use local version %s for project %s", version, project) - VERSIONS['local'][project] = version - - -def more_recent(candidate, reference): - return pkg_resources.parse_version(candidate) > \ - pkg_resources.parse_version(reference) - - -def diff_link(project, old_ref, new_ref): - return "https://github.com/openstack/{}/compare/{}...{}".format( - project, old_ref, new_ref) - - -def compare_versions(): - up_to_date = True - result = prettytable.PrettyTable(["Project", "Current version", - "Latest version", "Comparing changes"]) - result.align = "l" - - for project in VERSIONS['upstream']: - if project not in VERSIONS['local']: - continue - - upstream_version = VERSIONS['upstream'][project] - local_version = VERSIONS['local'][project] - - if more_recent(upstream_version, local_version): - result.add_row([ - project, - VERSIONS['local'][project], - VERSIONS['upstream'][project], - diff_link(project, local_version, upstream_version) - ]) - up_to_date = False - - if up_to_date: - result = "Everything is up to date" - - print(result) - - -def main(): - conf = cfg.ConfigOpts() - common_config.parse(conf, sys.argv[1:], prog='version-check') - - if conf.debug: - LOG.setLevel(logging.DEBUG) - - retrieve_local_versions(conf) - retrieve_upstream_versions() - - compare_versions() - -if __name__ == '__main__': - main() -- cgit v1.2.3