Remove service to muranorepository
Add venv support Update requirements
This commit is contained in:
parent
28cbd26187
commit
c46bfbde86
2
AUTHORS
2
AUTHORS
@ -0,0 +1,2 @@
|
||||
efedorova <efedorova@mirantis.com>
|
||||
EkaterinaFedorova <efedorova@mirantis.com>
|
101
ChangeLog
Normal file
101
ChangeLog
Normal file
@ -0,0 +1,101 @@
|
||||
commit 28cbd261871038cf1fc4fa67d36c26ae9e9a4747
|
||||
Author: efedorova <efedorova@mirantis.com>
|
||||
Date: Mon Oct 14 13:27:09 2013 +0400
|
||||
|
||||
Fix bug with subfolder copying
|
||||
|
||||
Save path in manifest object in relative way, not in absolute
|
||||
|
||||
commit e98258043d9acbbf8f13d3017eebba9e04066cc9
|
||||
Author: efedorova <efedorova@mirantis.com>
|
||||
Date: Mon Oct 14 11:07:48 2013 +0400
|
||||
|
||||
Add wsgi support.
|
||||
|
||||
Add config file
|
||||
Fix interacting with consts
|
||||
Change section names in manifests to correspond data_type
|
||||
|
||||
commit f40fe7372c220fbf6c29acd80186c34a515f9792
|
||||
Author: efedorova <efedorova@mirantis.com>
|
||||
Date: Fri Oct 11 13:17:35 2013 +0400
|
||||
|
||||
Add api versioning
|
||||
|
||||
commit eb3b446a9f0535709c393620680f9c0c005a6eff
|
||||
Author: efedorova <efedorova@mirantis.com>
|
||||
Date: Thu Oct 10 19:29:15 2013 +0400
|
||||
|
||||
Unite root_dir with data_type root_dir
|
||||
|
||||
commit 31472fb11b498b99d34b1d48a75643785729f451
|
||||
Author: efedorova <efedorova@mirantis.com>
|
||||
Date: Thu Oct 10 18:14:56 2013 +0400
|
||||
|
||||
All api calls implemented
|
||||
|
||||
commit e1b704c61d76d204ce30c9822c9daa9fcda86c8c
|
||||
Author: efedorova <efedorova@mirantis.com>
|
||||
Date: Thu Oct 10 14:40:17 2013 +0400
|
||||
|
||||
Add test.py with api calls
|
||||
|
||||
commit b0c04f614e04f02a36e4435ff8d9e27f42271828
|
||||
Author: efedorova <efedorova@mirantis.com>
|
||||
Date: Thu Oct 10 14:33:57 2013 +0400
|
||||
|
||||
First version of murano Api added
|
||||
|
||||
commit ac04b4e1b74868ebb2b71ef22008e886e3be01fe
|
||||
Author: efedorova <efedorova@mirantis.com>
|
||||
Date: Wed Oct 9 12:05:20 2013 +0400
|
||||
|
||||
Update the result archive structure
|
||||
|
||||
commit 63bd68cc2a87e961874eabf240be58912d6ec23a
|
||||
Author: efedorova <efedorova@mirantis.com>
|
||||
Date: Tue Oct 8 20:09:29 2013 +0400
|
||||
|
||||
Add initial Archiver
|
||||
|
||||
commit 7266c3b98c5851db00c7207bbdff60bdd9e71350
|
||||
Author: efedorova <efedorova@mirantis.com>
|
||||
Date: Tue Oct 8 16:29:06 2013 +0400
|
||||
|
||||
Fixed typos
|
||||
|
||||
Add full manifest class defenition
|
||||
|
||||
commit 8f18a1b75b68d8c97efd57673b160a9ceda608a3
|
||||
Author: efedorova <efedorova@mirantis.com>
|
||||
Date: Tue Oct 8 16:25:07 2013 +0400
|
||||
|
||||
Add Manifest class
|
||||
|
||||
Add valid fields if all files specified in manifests exists
|
||||
|
||||
commit 77cefffbf829ed8b5de0db24d2d4479ec6ce1223
|
||||
Author: efedorova <efedorova@mirantis.com>
|
||||
Date: Tue Oct 8 14:55:48 2013 +0400
|
||||
|
||||
Add new files
|
||||
|
||||
commit 20fafd31acfe062c1a06eeb299ef38ed27bbbbe7
|
||||
Author: efedorova <efedorova@mirantis.com>
|
||||
Date: Tue Oct 8 12:12:37 2013 +0400
|
||||
|
||||
Update service manifests
|
||||
|
||||
Add parser.py
|
||||
|
||||
commit 3c2b1b65f16b93b7bd3c542844aa4c70f48c3ec3
|
||||
Author: efedorova <efedorova@mirantis.com>
|
||||
Date: Mon Oct 7 15:30:11 2013 +0400
|
||||
|
||||
Initial commit
|
||||
|
||||
commit 87ce33fcf7b03e2722a636e641eb72ea87d9f38d
|
||||
Author: EkaterinaFedorova <efedorova@mirantis.com>
|
||||
Date: Mon Oct 7 04:10:43 2013 -0700
|
||||
|
||||
Initial commit
|
@ -1,4 +1,4 @@
|
||||
nclude AUTHORS
|
||||
include AUTHORS
|
||||
include README.rst
|
||||
include ChangeLog
|
||||
include LICENSE
|
||||
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
tox -edocs
|
@ -1,9 +0,0 @@
|
||||
This generate_sample.sh tool is used to generate etc/savanna/savanna.conf.sample-full
|
||||
|
||||
Run it from the top-level working directory i.e.
|
||||
|
||||
$> ./tools/conf/generate_sample.sh
|
||||
|
||||
Watch out for warnings about modules like libvirt, qpid and zmq not
|
||||
being found - these warnings are significant because they result
|
||||
in options not appearing in the generated config file.
|
@ -1,273 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2012 SINA Corporation
|
||||
# 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: Zhongyue Luo, SINA Corporation.
|
||||
#
|
||||
|
||||
# stolen from the OpenStack Nova
|
||||
|
||||
"""Extracts OpenStack config option info from module(s)."""
|
||||
|
||||
import imp
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
#from nova.openstack.common import importutils
|
||||
|
||||
|
||||
STROPT = "StrOpt"
|
||||
BOOLOPT = "BoolOpt"
|
||||
INTOPT = "IntOpt"
|
||||
FLOATOPT = "FloatOpt"
|
||||
LISTOPT = "ListOpt"
|
||||
MULTISTROPT = "MultiStrOpt"
|
||||
|
||||
OPT_TYPES = {
|
||||
STROPT: 'string value',
|
||||
BOOLOPT: 'boolean value',
|
||||
INTOPT: 'integer value',
|
||||
FLOATOPT: 'floating point value',
|
||||
LISTOPT: 'list value',
|
||||
MULTISTROPT: 'multi valued',
|
||||
}
|
||||
|
||||
OPTION_COUNT = 0
|
||||
OPTION_REGEX = re.compile(r"(%s)" % "|".join([STROPT, BOOLOPT, INTOPT,
|
||||
FLOATOPT, LISTOPT,
|
||||
MULTISTROPT]))
|
||||
|
||||
PY_EXT = ".py"
|
||||
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))
|
||||
WORDWRAP_WIDTH = 60
|
||||
|
||||
|
||||
def main(srcfiles):
|
||||
mods_by_pkg = dict()
|
||||
for filepath in srcfiles:
|
||||
pkg_name = filepath.split(os.sep)[1]
|
||||
mod_str = '.'.join(['.'.join(filepath.split(os.sep)[:-1]),
|
||||
os.path.basename(filepath).split('.')[0]])
|
||||
mods_by_pkg.setdefault(pkg_name, list()).append(mod_str)
|
||||
# NOTE(lzyeval): place top level modules before packages
|
||||
pkg_names = filter(lambda x: x.endswith(PY_EXT), mods_by_pkg.keys())
|
||||
pkg_names.sort()
|
||||
ext_names = filter(lambda x: x not in pkg_names, mods_by_pkg.keys())
|
||||
ext_names.sort()
|
||||
pkg_names.extend(ext_names)
|
||||
|
||||
# opts_by_group is a mapping of group name to an options list
|
||||
# The options list is a list of (module, options) tuples
|
||||
opts_by_group = {'DEFAULT': []}
|
||||
|
||||
for pkg_name in pkg_names:
|
||||
mods = mods_by_pkg.get(pkg_name)
|
||||
mods.sort()
|
||||
for mod_str in mods:
|
||||
if mod_str.endswith('.__init__'):
|
||||
mod_str = mod_str[:mod_str.rfind(".")]
|
||||
|
||||
mod_obj = _import_module(mod_str)
|
||||
if not mod_obj:
|
||||
continue
|
||||
|
||||
for group, opts in _list_opts(mod_obj):
|
||||
opts_by_group.setdefault(group, []).append((mod_str, opts))
|
||||
|
||||
print_group_opts('DEFAULT', opts_by_group.pop('DEFAULT', []))
|
||||
for group, opts in opts_by_group.items():
|
||||
print_group_opts(group, opts)
|
||||
|
||||
print "# Total option count: %d" % OPTION_COUNT
|
||||
|
||||
|
||||
def _import_module(mod_str):
|
||||
try:
|
||||
if mod_str.startswith('bin.'):
|
||||
imp.load_source(mod_str[4:], os.path.join('bin', mod_str[4:]))
|
||||
return sys.modules[mod_str[4:]]
|
||||
else:
|
||||
__import__(mod_str)
|
||||
return sys.modules[mod_str]
|
||||
#return importutils.import_module(mod_str)
|
||||
except (ValueError, AttributeError), err:
|
||||
return None
|
||||
except ImportError, ie:
|
||||
sys.stderr.write("%s\n" % str(ie))
|
||||
return None
|
||||
except Exception, e:
|
||||
return None
|
||||
|
||||
|
||||
def _guess_groups(opt, mod_obj):
|
||||
groups = []
|
||||
|
||||
# is it in the DEFAULT group?
|
||||
if (opt.dest in cfg.CONF and
|
||||
not isinstance(cfg.CONF[opt.dest], cfg.CONF.GroupAttr)):
|
||||
groups.append('DEFAULT')
|
||||
|
||||
# what other groups is it in?
|
||||
for key, value in cfg.CONF.items():
|
||||
if not isinstance(value, cfg.CONF.GroupAttr):
|
||||
continue
|
||||
if opt.dest not in value:
|
||||
continue
|
||||
groups.append(key)
|
||||
|
||||
if len(groups) == 1:
|
||||
return groups[0]
|
||||
|
||||
group = None
|
||||
for g in groups:
|
||||
if g in mod_obj.__name__:
|
||||
group = g
|
||||
break
|
||||
|
||||
if group is None and 'DEFAULT' in groups:
|
||||
sys.stderr.write("Guessing that " + opt.dest +
|
||||
" in " + mod_obj.__name__ +
|
||||
" is in DEFAULT group out of " +
|
||||
','.join(groups) + "\n")
|
||||
return 'DEFAULT'
|
||||
|
||||
if group is None:
|
||||
sys.stderr.write("Unable to guess what group " + opt.dest +
|
||||
" in " + mod_obj.__name__ +
|
||||
" is in out of " + ','.join(groups) + "\n")
|
||||
sys.exit(1)
|
||||
|
||||
sys.stderr.write("Guessing that " + opt.dest +
|
||||
" in " + mod_obj.__name__ +
|
||||
" is in the " + group +
|
||||
" group out of " + ','.join(groups) + "\n")
|
||||
return group
|
||||
|
||||
|
||||
def _list_opts(obj):
|
||||
def is_opt(o):
|
||||
return (isinstance(o, cfg.Opt) and
|
||||
not isinstance(o, cfg.SubCommandOpt))
|
||||
|
||||
opts = list()
|
||||
for attr_str in dir(obj):
|
||||
attr_obj = getattr(obj, attr_str)
|
||||
if is_opt(attr_obj):
|
||||
opts.append(attr_obj)
|
||||
elif (isinstance(attr_obj, list) and
|
||||
all(map(lambda x: is_opt(x), attr_obj))):
|
||||
opts.extend(attr_obj)
|
||||
|
||||
ret = {}
|
||||
for opt in opts:
|
||||
ret.setdefault(_guess_groups(opt, obj), []).append(opt)
|
||||
return ret.items()
|
||||
|
||||
|
||||
def print_group_opts(group, opts_by_module):
|
||||
print "[%s]" % group
|
||||
print
|
||||
global OPTION_COUNT
|
||||
for mod, opts in opts_by_module:
|
||||
OPTION_COUNT += len(opts)
|
||||
print '#'
|
||||
print '# Options defined in %s' % mod
|
||||
print '#'
|
||||
print
|
||||
for opt in opts:
|
||||
_print_opt(opt)
|
||||
print
|
||||
|
||||
|
||||
def _get_my_ip():
|
||||
try:
|
||||
csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
csock.connect(('8.8.8.8', 80))
|
||||
(addr, port) = csock.getsockname()
|
||||
csock.close()
|
||||
return addr
|
||||
except socket.error:
|
||||
return None
|
||||
|
||||
|
||||
def _sanitize_default(s):
|
||||
"""Set up a reasonably sensible default for pybasedir, my_ip and host."""
|
||||
if s.startswith(BASEDIR):
|
||||
return s.replace(BASEDIR, '/usr/lib/python/site-packages')
|
||||
elif BASEDIR in s:
|
||||
return s.replace(BASEDIR, '')
|
||||
elif s == _get_my_ip():
|
||||
return '10.0.0.1'
|
||||
elif s == socket.getfqdn():
|
||||
return 'savanna'
|
||||
elif s.strip() != s:
|
||||
return '"%s"' % s
|
||||
return s
|
||||
|
||||
|
||||
def _print_opt(opt):
|
||||
opt_name, opt_default, opt_help = opt.dest, opt.default, opt.help
|
||||
if not opt_help:
|
||||
sys.stderr.write('WARNING: "%s" is missing help string.\n' % opt_name)
|
||||
opt_type = None
|
||||
try:
|
||||
opt_type = OPTION_REGEX.search(str(type(opt))).group(0)
|
||||
except (ValueError, AttributeError), err:
|
||||
sys.stderr.write("%s\n" % str(err))
|
||||
sys.exit(1)
|
||||
opt_help += ' (' + OPT_TYPES[opt_type] + ')'
|
||||
print '#', "\n# ".join(textwrap.wrap(opt_help, WORDWRAP_WIDTH))
|
||||
try:
|
||||
if opt_default is None:
|
||||
print '#%s=<None>' % opt_name
|
||||
elif opt_type == STROPT:
|
||||
assert(isinstance(opt_default, basestring))
|
||||
print '#%s=%s' % (opt_name, _sanitize_default(opt_default))
|
||||
elif opt_type == BOOLOPT:
|
||||
assert(isinstance(opt_default, bool))
|
||||
print '#%s=%s' % (opt_name, str(opt_default).lower())
|
||||
elif opt_type == INTOPT:
|
||||
assert(isinstance(opt_default, int) and
|
||||
not isinstance(opt_default, bool))
|
||||
print '#%s=%s' % (opt_name, opt_default)
|
||||
elif opt_type == FLOATOPT:
|
||||
assert(isinstance(opt_default, float))
|
||||
print '#%s=%s' % (opt_name, opt_default)
|
||||
elif opt_type == LISTOPT:
|
||||
assert(isinstance(opt_default, list))
|
||||
print '#%s=%s' % (opt_name, ','.join(opt_default))
|
||||
elif opt_type == MULTISTROPT:
|
||||
assert(isinstance(opt_default, list))
|
||||
if not opt_default:
|
||||
opt_default = ['']
|
||||
for default in opt_default:
|
||||
print '#%s=%s' % (opt_name, default)
|
||||
print
|
||||
except Exception:
|
||||
sys.stderr.write('Error in option "%s"\n' % opt_name)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 2:
|
||||
print "usage: python %s [srcfile]...\n" % sys.argv[0]
|
||||
sys.exit(0)
|
||||
main(sys.argv[1:])
|
@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2012 SINA Corporation
|
||||
# All Rights Reserved.
|
||||
# Author: Zhongyue Luo <lzyeval@gmail.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.
|
||||
|
||||
# stolen from the OpenStack Nova
|
||||
|
||||
FILES=$(find savanna -type f -name "*.py" ! -path "savanna/tests/*" -exec \
|
||||
grep -l "Opt(" {} \; | sort -u)
|
||||
BINS=$(echo bin/savanna-*)
|
||||
|
||||
PYTHONPATH=./:${PYTHONPATH} \
|
||||
tools/with_venv python $(dirname "$0")/extract_opts.py ${FILES} ${BINS} > \
|
||||
etc/savanna/savanna.conf.sample-full
|
||||
|
||||
# Remove compiled files created by imp.import_source()
|
||||
for bin in ${BINS}; do
|
||||
[ -f ${bin}c ] && rm ${bin}c
|
||||
done
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
tox -evenv -- python $(dirname $0)/get_auth_token.py $*
|
@ -1,89 +0,0 @@
|
||||
# Copyright (c) 2013 Mirantis Inc.
|
||||
#
|
||||
# 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
|
||||
|
||||
from keystoneclient.v2_0 import Client as keystone_client
|
||||
from oslo.config import cfg
|
||||
|
||||
|
||||
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
||||
os.pardir,
|
||||
os.pardir))
|
||||
if os.path.exists(os.path.join(possible_topdir,
|
||||
'savanna',
|
||||
'__init__.py')):
|
||||
sys.path.insert(0, possible_topdir)
|
||||
|
||||
cli_opts = [
|
||||
cfg.StrOpt('username', default='',
|
||||
help='set username'),
|
||||
cfg.StrOpt('password', default='',
|
||||
help='set password'),
|
||||
cfg.StrOpt('tenant', default='',
|
||||
help='set tenant'),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('os_admin_username', 'savanna.main')
|
||||
CONF.import_opt('os_admin_password', 'savanna.main')
|
||||
CONF.import_opt('os_admin_tenant_name', 'savanna.main')
|
||||
CONF.register_cli_opts(cli_opts)
|
||||
|
||||
|
||||
def main():
|
||||
dev_conf = os.path.join(possible_topdir,
|
||||
'etc',
|
||||
'savanna',
|
||||
'savanna.conf')
|
||||
config_files = None
|
||||
if os.path.exists(dev_conf):
|
||||
config_files = [dev_conf]
|
||||
|
||||
CONF(sys.argv[1:], project='get_auth_token',
|
||||
default_config_files=config_files)
|
||||
|
||||
user = CONF.username or CONF.os_admin_username
|
||||
password = CONF.password or CONF.os_admin_password
|
||||
tenant = CONF.tenant or CONF.os_admin_tenant_name
|
||||
|
||||
protocol = CONF.os_auth_protocol
|
||||
host = CONF.os_auth_host
|
||||
port = CONF.os_auth_port
|
||||
|
||||
auth_url = "%s://%s:%s/v2.0/" % (protocol, host, port)
|
||||
|
||||
print "User: %s" % user
|
||||
print "Password: %s" % password
|
||||
print "Tenant: %s" % tenant
|
||||
print "Auth URL: %s" % auth_url
|
||||
|
||||
keystone = keystone_client(
|
||||
username=user,
|
||||
password=password,
|
||||
tenant_name=tenant,
|
||||
auth_url=auth_url
|
||||
)
|
||||
|
||||
result = keystone.authenticate()
|
||||
|
||||
print "Auth succeed: %s" % result
|
||||
print "Auth token: %s" % keystone.auth_token
|
||||
print "Tenant [%s] id: %s" % (tenant, keystone.tenant_id)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
tox -vvv -evenv -- python --version
|
@ -1,200 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright (c) 2012, AT&T Labs, Yun Mao <yunmao@gmail.com>
|
||||
# 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.
|
||||
|
||||
# Stolen from OpenStack Nova
|
||||
|
||||
"""pylint error checking."""
|
||||
|
||||
import cStringIO as StringIO
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
|
||||
from pylint import lint
|
||||
from pylint.reporters import text
|
||||
|
||||
# Note(maoy): E1103 is error code related to partial type inference
|
||||
ignore_codes = ["E1103"]
|
||||
# Note(maoy): the error message is the pattern of E0202. It should be ignored
|
||||
# for savanna.tests modules
|
||||
ignore_messages = ["An attribute affected in savanna.tests"]
|
||||
# We ignore all errors in openstack.common because it should be checked
|
||||
# elsewhere.
|
||||
ignore_modules = ["savanna/openstack/common/"]
|
||||
|
||||
KNOWN_PYLINT_EXCEPTIONS_FILE = "tools/pylint_exceptions"
|
||||
|
||||
|
||||
class LintOutput(object):
|
||||
|
||||
_cached_filename = None
|
||||
_cached_content = None
|
||||
|
||||
def __init__(self, filename, lineno, line_content, code, message,
|
||||
lintoutput):
|
||||
self.filename = filename
|
||||
self.lineno = lineno
|
||||
self.line_content = line_content
|
||||
self.code = code
|
||||
self.message = message
|
||||
self.lintoutput = lintoutput
|
||||
|
||||
@classmethod
|
||||
def from_line(cls, line):
|
||||
m = re.search(r"(\S+):(\d+): \[(\S+)(, \S+)?] (.*)", line)
|
||||
matched = m.groups()
|
||||
filename, lineno, code, message = (matched[0], int(matched[1]),
|
||||
matched[2], matched[-1])
|
||||
if cls._cached_filename != filename:
|
||||
with open(filename) as f:
|
||||
cls._cached_content = list(f.readlines())
|
||||
cls._cached_filename = filename
|
||||
line_content = cls._cached_content[lineno - 1].rstrip()
|
||||
return cls(filename, lineno, line_content, code, message,
|
||||
line.rstrip())
|
||||
|
||||
@classmethod
|
||||
def from_msg_to_dict(cls, msg):
|
||||
"""From the output of pylint msg, to a dict, where each key
|
||||
is a unique error identifier, value is a list of LintOutput
|
||||
"""
|
||||
result = {}
|
||||
for line in msg.splitlines():
|
||||
obj = cls.from_line(line)
|
||||
if obj.is_ignored():
|
||||
continue
|
||||
key = obj.key()
|
||||
if key not in result:
|
||||
result[key] = []
|
||||
result[key].append(obj)
|
||||
return result
|
||||
|
||||
def is_ignored(self):
|
||||
if self.code in ignore_codes:
|
||||
return True
|
||||
if any(self.filename.startswith(name) for name in ignore_modules):
|
||||
return True
|
||||
if any(msg in self.message for msg in ignore_messages):
|
||||
return True
|
||||
return False
|
||||
|
||||
def key(self):
|
||||
if self.code in ["E1101", "E1103"]:
|
||||
# These two types of errors are like Foo class has no member bar.
|
||||
# We discard the source code so that the error will be ignored
|
||||
# next time another Foo.bar is encountered.
|
||||
return self.message, ""
|
||||
return self.message, self.line_content.strip()
|
||||
|
||||
def json(self):
|
||||
return json.dumps(self.__dict__)
|
||||
|
||||
def review_str(self):
|
||||
return ("File %(filename)s\nLine %(lineno)d:%(line_content)s\n"
|
||||
"%(code)s: %(message)s" % self.__dict__)
|
||||
|
||||
|
||||
class ErrorKeys(object):
|
||||
|
||||
@classmethod
|
||||
def print_json(cls, errors, output=sys.stdout):
|
||||
print >>output, "# automatically generated by tools/lintstack.py"
|
||||
for i in sorted(errors.keys()):
|
||||
print >>output, json.dumps(i)
|
||||
|
||||
@classmethod
|
||||
def from_file(cls, filename):
|
||||
keys = set()
|
||||
for line in open(filename):
|
||||
if line and line[0] != "#":
|
||||
d = json.loads(line)
|
||||
keys.add(tuple(d))
|
||||
return keys
|
||||
|
||||
|
||||
def run_pylint():
|
||||
buff = StringIO.StringIO()
|
||||
reporter = text.ParseableTextReporter(output=buff)
|
||||
args = ["--include-ids=y", "-E", "savanna"]
|
||||
lint.Run(args, reporter=reporter, exit=False)
|
||||
val = buff.getvalue()
|
||||
buff.close()
|
||||
return val
|
||||
|
||||
|
||||
def generate_error_keys(msg=None):
|
||||
print "Generating", KNOWN_PYLINT_EXCEPTIONS_FILE
|
||||
if msg is None:
|
||||
msg = run_pylint()
|
||||
errors = LintOutput.from_msg_to_dict(msg)
|
||||
with open(KNOWN_PYLINT_EXCEPTIONS_FILE, "w") as f:
|
||||
ErrorKeys.print_json(errors, output=f)
|
||||
|
||||
|
||||
def validate(newmsg=None):
|
||||
print "Loading", KNOWN_PYLINT_EXCEPTIONS_FILE
|
||||
known = ErrorKeys.from_file(KNOWN_PYLINT_EXCEPTIONS_FILE)
|
||||
if newmsg is None:
|
||||
print "Running pylint. Be patient..."
|
||||
newmsg = run_pylint()
|
||||
errors = LintOutput.from_msg_to_dict(newmsg)
|
||||
|
||||
print "Unique errors reported by pylint: was %d, now %d." \
|
||||
% (len(known), len(errors))
|
||||
passed = True
|
||||
for err_key, err_list in errors.items():
|
||||
for err in err_list:
|
||||
if err_key not in known:
|
||||
print err.lintoutput
|
||||
print
|
||||
passed = False
|
||||
if passed:
|
||||
print "Congrats! pylint check passed."
|
||||
redundant = known - set(errors.keys())
|
||||
if redundant:
|
||||
print "Extra credit: some known pylint exceptions disappeared."
|
||||
for i in sorted(redundant):
|
||||
print json.dumps(i)
|
||||
print "Consider regenerating the exception file if you will."
|
||||
else:
|
||||
print ("Please fix the errors above. If you believe they are false"
|
||||
" positives, run 'tools/lintstack.py generate' to overwrite.")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def usage():
|
||||
print """Usage: tools/lintstack.py [generate|validate]
|
||||
To generate pylint_exceptions file: tools/lintstack.py generate
|
||||
To validate the current commit: tools/lintstack.py
|
||||
"""
|
||||
|
||||
|
||||
def main():
|
||||
option = "validate"
|
||||
if len(sys.argv) > 1:
|
||||
option = sys.argv[1]
|
||||
if option == "generate":
|
||||
generate_error_keys()
|
||||
elif option == "validate":
|
||||
validate()
|
||||
else:
|
||||
usage()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -1,61 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (c) 2012-2013, AT&T Labs, Yun Mao <yunmao@gmail.com>
|
||||
# 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.
|
||||
|
||||
# Stolen from OpenStack Nova
|
||||
|
||||
# Use lintstack.py to compare pylint errors.
|
||||
# We run pylint twice, once on HEAD, once on the code before the latest
|
||||
# commit for review.
|
||||
set -e
|
||||
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
||||
# Get the current branch name.
|
||||
GITHEAD=`git rev-parse --abbrev-ref HEAD`
|
||||
if [[ "$GITHEAD" == "HEAD" ]]; then
|
||||
# In detached head mode, get revision number instead
|
||||
GITHEAD=`git rev-parse HEAD`
|
||||
echo "Currently we are at commit $GITHEAD"
|
||||
else
|
||||
echo "Currently we are at branch $GITHEAD"
|
||||
fi
|
||||
|
||||
cp -f $TOOLS_DIR/lintstack.py $TOOLS_DIR/lintstack.head.py
|
||||
|
||||
if git rev-parse HEAD^2 2>/dev/null; then
|
||||
# The HEAD is a Merge commit. Here, the patch to review is
|
||||
# HEAD^2, the master branch is at HEAD^1, and the patch was
|
||||
# written based on HEAD^2~1.
|
||||
PREV_COMMIT=`git rev-parse HEAD^2~1`
|
||||
git checkout HEAD~1
|
||||
# The git merge is necessary for reviews with a series of patches.
|
||||
# If not, this is a no-op so won't hurt either.
|
||||
git merge $PREV_COMMIT
|
||||
else
|
||||
# The HEAD is not a merge commit. This won't happen on gerrit.
|
||||
# Most likely you are running against your own patch locally.
|
||||
# We assume the patch to examine is HEAD, and we compare it against
|
||||
# HEAD~1
|
||||
git checkout HEAD~1
|
||||
fi
|
||||
|
||||
# First generate tools/pylint_exceptions from HEAD~1
|
||||
$TOOLS_DIR/lintstack.head.py generate
|
||||
# Then use that as a reference to compare against HEAD
|
||||
git checkout $GITHEAD
|
||||
$TOOLS_DIR/lintstack.head.py
|
||||
echo "Check passed. FYI: the pylint exceptions are:"
|
||||
cat $TOOLS_DIR/pylint_exceptions
|
||||
|
@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
tools/run_pep8
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
tox -e integration
|
@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
tox -epep8
|
@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
tox -epylint
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
tox -epy27
|
@ -24,16 +24,17 @@ from oslo.config import cfg
|
||||
# so that it will override what happens to be installed in
|
||||
# /usr/(local/)lib/python...
|
||||
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(__file__),
|
||||
os.pardir, os.pardir))
|
||||
|
||||
os.pardir,
|
||||
os.pardir,
|
||||
os.pardir))
|
||||
if os.path.exists(os.path.join(possible_topdir,
|
||||
'metadata_service',
|
||||
'muranorepository',
|
||||
'__init__.py')):
|
||||
sys.path.insert(0, possible_topdir)
|
||||
|
||||
from metadata_service import config
|
||||
import metadata_service.main as server
|
||||
from metadata_service.openstack.common import log
|
||||
from muranorepository import config
|
||||
import muranorepository.main as server
|
||||
from muranorepository.openstack.common import log
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
@ -42,14 +43,14 @@ LOG = log.getLogger(__name__)
|
||||
def main():
|
||||
dev_conf = os.path.join(possible_topdir,
|
||||
'etc',
|
||||
'murano-repository.conf')
|
||||
'muranorepository.conf')
|
||||
config_files = None
|
||||
if os.path.exists(dev_conf):
|
||||
config_files = [dev_conf]
|
||||
|
||||
config.parse_configs(sys.argv[1:], config_files)
|
||||
|
||||
log.setup('metadata-service')
|
||||
log.setup('muranorepository')
|
||||
|
||||
app = server.make_app()
|
||||
|
@ -13,12 +13,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from oslo.config import cfg
|
||||
from metadata_service.openstack.common import log
|
||||
from metadata_service.consts import *
|
||||
from muranorepository.openstack.common import log
|
||||
from muranorepository.consts import *
|
||||
|
||||
server_opts = [
|
||||
cfg.StrOpt('host', default='127.0.0.1'),
|
||||
cfg.IntOpt('port', default='5000'),
|
||||
cfg.IntOpt('port', default=5000),
|
||||
]
|
||||
|
||||
type_dirs_opts = [cfg.StrOpt(x) for x in DATA_TYPES]
|
@ -24,7 +24,7 @@ context or provide additional information in their specific WSGI pipeline.
|
||||
|
||||
import itertools
|
||||
|
||||
from metadata_service.openstack.common import uuidutils
|
||||
from muranorepository.openstack.common import uuidutils
|
||||
|
||||
|
||||
def generate_request_id():
|
@ -19,8 +19,8 @@ import base64
|
||||
from Crypto.Hash import HMAC
|
||||
from Crypto import Random
|
||||
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import importutils
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import importutils
|
||||
|
||||
|
||||
class CryptoutilsException(Exception):
|
@ -31,8 +31,8 @@ import eventlet.backdoor
|
||||
import greenlet
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import log as logging
|
||||
|
||||
help_for_backdoor_port = (
|
||||
"Acceptable values are 0, <port>, and <start>:<end>, where 0 results "
|
@ -21,7 +21,7 @@ Exceptions common to OpenStack projects
|
||||
|
||||
import logging
|
||||
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
|
||||
_FATAL_EXCEPTION_FORMAT_ERRORS = False
|
||||
|
@ -26,7 +26,7 @@ import traceback
|
||||
|
||||
import six
|
||||
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
|
||||
|
||||
class save_and_reraise_exception(object):
|
@ -20,9 +20,9 @@ import contextlib
|
||||
import errno
|
||||
import os
|
||||
|
||||
from metadata_service.openstack.common import excutils
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from muranorepository.openstack.common import excutils
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -21,7 +21,7 @@ gettext for openstack-common modules.
|
||||
|
||||
Usual usage in an openstack.common module:
|
||||
|
||||
from metadata_service.openstack.common.gettextutils import _
|
||||
from muranorepository.openstack.common.gettextutils import _
|
||||
"""
|
||||
|
||||
import copy
|
@ -46,9 +46,9 @@ except ImportError:
|
||||
|
||||
import six
|
||||
|
||||
from metadata_service.openstack.common import gettextutils
|
||||
from metadata_service.openstack.common import importutils
|
||||
from metadata_service.openstack.common import timeutils
|
||||
from muranorepository.openstack.common import gettextutils
|
||||
from muranorepository.openstack.common import importutils
|
||||
from muranorepository.openstack.common import timeutils
|
||||
|
||||
netaddr = importutils.try_import("netaddr")
|
||||
|
@ -26,10 +26,10 @@ import weakref
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common import fileutils
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import local
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from muranorepository.openstack.common import fileutils
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import local
|
||||
from muranorepository.openstack.common import log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
@ -41,10 +41,10 @@ import traceback
|
||||
from oslo.config import cfg
|
||||
from six import moves
|
||||
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import importutils
|
||||
from metadata_service.openstack.common import jsonutils
|
||||
from metadata_service.openstack.common import local
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import importutils
|
||||
from muranorepository.openstack.common import jsonutils
|
||||
from muranorepository.openstack.common import local
|
||||
|
||||
|
||||
_DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
|
||||
@ -425,7 +425,7 @@ def _setup_logging_from_conf():
|
||||
|
||||
if CONF.publish_errors:
|
||||
handler = importutils.import_object(
|
||||
"metadata_service.openstack.common.log_handler.PublishErrorsHandler",
|
||||
"muranorepository.openstack.common.log_handler.PublishErrorsHandler",
|
||||
logging.ERROR)
|
||||
log_root.addHandler(handler)
|
||||
|
@ -22,9 +22,9 @@ import sys
|
||||
from eventlet import event
|
||||
from eventlet import greenthread
|
||||
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from metadata_service.openstack.common import timeutils
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import log as logging
|
||||
from muranorepository.openstack.common import timeutils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -20,7 +20,7 @@ import sys
|
||||
|
||||
import webob.dec
|
||||
|
||||
from metadata_service.openstack.common.middleware import base
|
||||
from muranorepository.openstack.common.middleware import base
|
||||
|
||||
|
||||
class Debug(base.Middleware):
|
@ -18,12 +18,12 @@ import uuid
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common import context
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import importutils
|
||||
from metadata_service.openstack.common import jsonutils
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from metadata_service.openstack.common import timeutils
|
||||
from muranorepository.openstack.common import context
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import importutils
|
||||
from muranorepository.openstack.common import jsonutils
|
||||
from muranorepository.openstack.common import log as logging
|
||||
from muranorepository.openstack.common import timeutils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
@ -15,8 +15,8 @@
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common import jsonutils
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from muranorepository.openstack.common import jsonutils
|
||||
from muranorepository.openstack.common import log as logging
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
@ -32,6 +32,6 @@ def notify(_context, message):
|
||||
CONF.default_notification_level)
|
||||
priority = priority.lower()
|
||||
logger = logging.getLogger(
|
||||
'metadata_service.openstack.common.notification.%s' %
|
||||
'muranorepository.openstack.common.notification.%s' %
|
||||
message['event_type'])
|
||||
getattr(logger, priority)(jsonutils.dumps(message))
|
@ -15,10 +15,10 @@
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common import context as req_context
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from metadata_service.openstack.common import rpc
|
||||
from muranorepository.openstack.common import context as req_context
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import log as logging
|
||||
from muranorepository.openstack.common import rpc
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common import context as req_context
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from metadata_service.openstack.common import rpc
|
||||
from muranorepository.openstack.common import context as req_context
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import log as logging
|
||||
from muranorepository.openstack.common import rpc
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -18,9 +18,9 @@ import time
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from metadata_service.openstack.common import timeutils
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import log as logging
|
||||
from muranorepository.openstack.common import timeutils
|
||||
|
||||
|
||||
periodic_opts = [
|
@ -28,8 +28,8 @@ import signal
|
||||
from eventlet.green import subprocess
|
||||
from eventlet import greenthread
|
||||
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
@ -21,7 +21,7 @@
|
||||
A remote procedure call (rpc) abstraction.
|
||||
|
||||
For some wrappers that add message versioning to rpc, see:
|
||||
rpc.dimetadata_servicespatcher
|
||||
rpc.dimuranorepositoryspatcher
|
||||
rpc.proxy
|
||||
"""
|
||||
|
||||
@ -29,10 +29,10 @@ import inspect
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import importutils
|
||||
from metadata_service.openstack.common import local
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import importutils
|
||||
from muranorepository.openstack.common import local
|
||||
from muranorepository.openstack.common import log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
@ -36,11 +36,11 @@ from eventlet import queue
|
||||
from eventlet import semaphore
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common import excutils
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import local
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from metadata_service.openstack.common.rpc import common as rpc_common
|
||||
from muranorepository.openstack.common import excutils
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import local
|
||||
from muranorepository.openstack.common import log as logging
|
||||
from muranorepository.openstack.common.rpc import common as rpc_common
|
||||
|
||||
|
||||
amqp_opts = [
|
@ -24,11 +24,11 @@ import traceback
|
||||
from oslo.config import cfg
|
||||
import six
|
||||
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import importutils
|
||||
from metadata_service.openstack.common import jsonutils
|
||||
from metadata_service.openstack.common import local
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import importutils
|
||||
from muranorepository.openstack.common import jsonutils
|
||||
from muranorepository.openstack.common import local
|
||||
from muranorepository.openstack.common import log as logging
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
@ -83,8 +83,8 @@ On the client side, the same changes should be made as in example 1. The
|
||||
minimum version that supports the new parameter should be specified.
|
||||
"""
|
||||
|
||||
from metadata_service.openstack.common.rpc import common as rpc_common
|
||||
from metadata_service.openstack.common.rpc import serializer as rpc_serializer
|
||||
from muranorepository.openstack.common.rpc import common as rpc_common
|
||||
from muranorepository.openstack.common.rpc import serializer as rpc_serializer
|
||||
|
||||
|
||||
class RpcDispatcher(object):
|
@ -27,7 +27,7 @@ import time
|
||||
|
||||
import eventlet
|
||||
|
||||
from metadata_service.openstack.common.rpc import common as rpc_common
|
||||
from muranorepository.openstack.common.rpc import common as rpc_common
|
||||
|
||||
CONSUMERS = {}
|
||||
|
@ -29,12 +29,12 @@ import kombu.entity
|
||||
import kombu.messaging
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common import excutils
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import network_utils
|
||||
from metadata_service.openstack.common.rpc import amqp as rpc_amqp
|
||||
from metadata_service.openstack.common.rpc import common as rpc_common
|
||||
from metadata_service.openstack.common import sslutils
|
||||
from muranorepository.openstack.common import excutils
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import network_utils
|
||||
from muranorepository.openstack.common.rpc import amqp as rpc_amqp
|
||||
from muranorepository.openstack.common.rpc import common as rpc_common
|
||||
from muranorepository.openstack.common import sslutils
|
||||
|
||||
kombu_opts = [
|
||||
cfg.StrOpt('kombu_ssl_version',
|
@ -24,13 +24,13 @@ import eventlet
|
||||
import greenlet
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common import excutils
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import importutils
|
||||
from metadata_service.openstack.common import jsonutils
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from metadata_service.openstack.common.rpc import amqp as rpc_amqp
|
||||
from metadata_service.openstack.common.rpc import common as rpc_common
|
||||
from muranorepository.openstack.common import excutils
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import importutils
|
||||
from muranorepository.openstack.common import jsonutils
|
||||
from muranorepository.openstack.common import log as logging
|
||||
from muranorepository.openstack.common.rpc import amqp as rpc_amqp
|
||||
from muranorepository.openstack.common.rpc import common as rpc_common
|
||||
|
||||
qpid_codec = importutils.try_import("qpid.codec010")
|
||||
qpid_messaging = importutils.try_import("qpid.messaging")
|
@ -26,11 +26,11 @@ import eventlet
|
||||
import greenlet
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common import excutils
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import importutils
|
||||
from metadata_service.openstack.common import jsonutils
|
||||
from metadata_service.openstack.common.rpc import common as rpc_common
|
||||
from muranorepository.openstack.common import excutils
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import importutils
|
||||
from muranorepository.openstack.common import jsonutils
|
||||
from muranorepository.openstack.common.rpc import common as rpc_common
|
||||
|
||||
zmq = importutils.try_import('eventlet.green.zmq')
|
||||
|
||||
@ -51,7 +51,7 @@ zmq_opts = [
|
||||
# The module.Class to use for matchmaking.
|
||||
cfg.StrOpt(
|
||||
'rpc_zmq_matchmaker',
|
||||
default=('metadata_service.openstack.common.rpc.'
|
||||
default=('muranorepository.openstack.common.rpc.'
|
||||
'matchmaker.MatchMakerLocalhost'),
|
||||
help='MatchMaker driver',
|
||||
),
|
@ -23,8 +23,8 @@ import contextlib
|
||||
import eventlet
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import log as logging
|
||||
|
||||
|
||||
matchmaker_opts = [
|
@ -20,9 +20,9 @@ return keys for direct exchanges, per (approximate) AMQP parlance.
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common import importutils
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from metadata_service.openstack.common.rpc import matchmaker as mm_common
|
||||
from muranorepository.openstack.common import importutils
|
||||
from muranorepository.openstack.common import log as logging
|
||||
from muranorepository.openstack.common.rpc import matchmaker as mm_common
|
||||
|
||||
redis = importutils.try_import('redis')
|
||||
|
@ -23,9 +23,9 @@ import json
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from metadata_service.openstack.common.rpc import matchmaker as mm
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import log as logging
|
||||
from muranorepository.openstack.common.rpc import matchmaker as mm
|
||||
|
||||
|
||||
matchmaker_opts = [
|
@ -22,9 +22,9 @@ For more information about rpc API version numbers, see:
|
||||
"""
|
||||
|
||||
|
||||
from metadata_service.openstack.common import rpc
|
||||
from metadata_service.openstack.common.rpc import common as rpc_common
|
||||
from metadata_service.openstack.common.rpc import serializer as rpc_serializer
|
||||
from muranorepository.openstack.common import rpc
|
||||
from muranorepository.openstack.common.rpc import common as rpc_common
|
||||
from muranorepository.openstack.common.rpc import serializer as rpc_serializer
|
||||
|
||||
|
||||
class RpcProxy(object):
|
@ -24,9 +24,9 @@ import requests
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common.crypto import utils as cryptoutils
|
||||
from metadata_service.openstack.common import jsonutils
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from muranorepository.openstack.common.crypto import utils as cryptoutils
|
||||
from muranorepository.openstack.common import jsonutils
|
||||
from muranorepository.openstack.common import log as logging
|
||||
|
||||
secure_message_opts = [
|
||||
cfg.BoolOpt('enabled', default=True,
|
@ -17,11 +17,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from metadata_service.openstack.common import rpc
|
||||
from metadata_service.openstack.common.rpc import dispatcher as rpc_dispatcher
|
||||
from metadata_service.openstack.common import service
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import log as logging
|
||||
from muranorepository.openstack.common import rpc
|
||||
from muranorepository.openstack.common.rpc import dispatcher as rpc_dispatcher
|
||||
from muranorepository.openstack.common import service
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
@ -22,9 +22,9 @@ import sys
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from metadata_service.openstack.common import rpc
|
||||
from metadata_service.openstack.common.rpc import impl_zmq
|
||||
from muranorepository.openstack.common import log as logging
|
||||
from muranorepository.openstack.common import rpc
|
||||
from muranorepository.openstack.common.rpc import impl_zmq
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(rpc.rpc_opts)
|
@ -31,14 +31,14 @@ from eventlet import event
|
||||
import logging as std_logging
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common import eventlet_backdoor
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from metadata_service.openstack.common import importutils
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from metadata_service.openstack.common import threadgroup
|
||||
from muranorepository.openstack.common import eventlet_backdoor
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common import importutils
|
||||
from muranorepository.openstack.common import log as logging
|
||||
from muranorepository.openstack.common import threadgroup
|
||||
|
||||
|
||||
rpc = importutils.try_import('metadata_service.openstack.common.rpc')
|
||||
rpc = importutils.try_import('muranorepository.openstack.common.rpc')
|
||||
CONF = cfg.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -19,7 +19,7 @@ import ssl
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from metadata_service.openstack.common.gettextutils import _ # noqa
|
||||
from muranorepository.openstack.common.gettextutils import _ # noqa
|
||||
|
||||
|
||||
ssl_opts = [
|
@ -29,7 +29,7 @@ class BaseTestCase(testtools.TestCase):
|
||||
super(BaseTestCase, self).setUp()
|
||||
self._set_timeout()
|
||||
self._fake_output()
|
||||
self.useFixture(fixtures.FakeLogger('metadata_service.openstack.common'))
|
||||
self.useFixture(fixtures.FakeLogger('muranorepository.openstack.common'))
|
||||
self.useFixture(fixtures.NestedTempfile())
|
||||
|
||||
def _set_timeout(self):
|
@ -18,8 +18,8 @@ import eventlet
|
||||
from eventlet import greenpool
|
||||
from eventlet import greenthread
|
||||
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from metadata_service.openstack.common import loopingcall
|
||||
from muranorepository.openstack.common import log as logging
|
||||
from muranorepository.openstack.common import loopingcall
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
@ -24,11 +24,11 @@ import datetime
|
||||
from xml.dom import minidom
|
||||
from xml.parsers import expat
|
||||
|
||||
from metadata_service.openstack.common import exception
|
||||
from metadata_service.openstack.common.gettextutils import _
|
||||
from metadata_service.openstack.common import jsonutils
|
||||
from metadata_service.openstack.common import log as logging
|
||||
from metadata_service.openstack.common import xmlutils
|
||||
from muranorepository.openstack.common import exception
|
||||
from muranorepository.openstack.common.gettextutils import _
|
||||
from muranorepository.openstack.common import jsonutils
|
||||
from muranorepository.openstack.common import log as logging
|
||||
from muranorepository.openstack.common import xmlutils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -17,7 +17,7 @@ import tempfile
|
||||
import shutil
|
||||
import logging as log
|
||||
from oslo.config import cfg
|
||||
from metadata_service.consts import DATA_TYPES
|
||||
from muranorepository.consts import DATA_TYPES
|
||||
OUTPUT_CONF = cfg.CONF.output
|
||||
CONF = cfg.CONF
|
||||
|
@ -16,8 +16,8 @@ import os
|
||||
import yaml
|
||||
from oslo.config import cfg
|
||||
import logging as log
|
||||
from metadata_service.manifest import Manifest
|
||||
from metadata_service.consts import DATA_TYPES, MANIFEST
|
||||
from muranorepository.utils.manifest import Manifest
|
||||
from muranorepository.consts import DATA_TYPES, MANIFEST
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ class ManifestParser(object):
|
||||
exc))
|
||||
continue
|
||||
|
||||
#check for existence files specified in manifests
|
||||
#check files specified in manifests for existence
|
||||
for key, value in service_manifest_data.iteritems():
|
||||
valid_file_info = True
|
||||
if key in DATA_TYPES:
|
@ -1,3 +1,11 @@
|
||||
flask
|
||||
flask-restfull
|
||||
eventlet
|
||||
d2to1>=0.2.10,<0.3
|
||||
pbr>=0.5.21,<1.0
|
||||
eventlet>=0.13.0
|
||||
Flask>=0.10,<1.0
|
||||
oslo.config>=1.2.0
|
||||
PyYAML
|
||||
|
||||
#openstack-common requires
|
||||
iso8601>=0.1.4
|
||||
kombu>=2.4.8
|
||||
Babel>=1.3
|
63
setup.cfg
Normal file
63
setup.cfg
Normal file
@ -0,0 +1,63 @@
|
||||
# Copyright (c) 2013 Mirantis, Inc.
|
||||
#
|
||||
# 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.
|
||||
|
||||
[metadata]
|
||||
name = muranorepository
|
||||
version = 0.1
|
||||
summary = Murano Metadata Repository
|
||||
description-file = README.rst
|
||||
license = Apache Software License
|
||||
classifiers =
|
||||
Programming Language :: Python
|
||||
Programming Language :: Python :: 2
|
||||
Programming Language :: Python :: 2.7
|
||||
Environment :: OpenStack
|
||||
Intended Audience :: Information Technology
|
||||
Intended Audience :: System Administrators
|
||||
License :: OSI Approved :: Apache Software License
|
||||
Operating System :: POSIX :: Linux
|
||||
author = Mirantis, Inc.
|
||||
author-email = openstack-dev@lists.openstack.org
|
||||
home-page = https://launchpad.net/murano
|
||||
|
||||
[global]
|
||||
setup-hooks = pbr.hooks.setup_hook
|
||||
|
||||
[files]
|
||||
packages =
|
||||
muranorepository
|
||||
|
||||
|
||||
[entry_points]
|
||||
console_scripts =
|
||||
murano-repository-api = muranorepository.cmd.run:main
|
||||
|
||||
[build_sphinx]
|
||||
all_files = 1
|
||||
build-dir = doc/build
|
||||
source-dir = doc/source
|
||||
|
||||
[egg_info]
|
||||
tag_build =
|
||||
tag_date = 0
|
||||
tag_svn_revision = 0
|
||||
|
||||
[compile_catalog]
|
||||
directory = murano-repository/locale
|
||||
domain = murano-repository
|
||||
|
||||
[extract_messages]
|
||||
keywords = _ gettext ngettext l_ lazy_gettext
|
||||
mapping_file = babel.cfg
|
||||
output_file = murano-repository/locale/muranorepository.pot
|
25
setup.py
Normal file
25
setup.py
Normal file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2013 Mirantis, Inc.
|
||||
#
|
||||
# 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 setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=[
|
||||
'd2to1>=0.2.10,<0.3',
|
||||
'pbr>=0.5,<0.6'
|
||||
],
|
||||
d2to1=True,
|
||||
)
|
17
test-requirements.txt
Normal file
17
test-requirements.txt
Normal file
@ -0,0 +1,17 @@
|
||||
# Fix versions for pep8/pyflakes/flake8/hacking
|
||||
pep8==1.4.5
|
||||
pyflakes>=0.7.2,<0.7.4
|
||||
flake8==2.0
|
||||
hacking>=0.5.6,<0.8
|
||||
|
||||
coverage>=3.6
|
||||
docutils==0.9.1
|
||||
fixtures>=0.3.14
|
||||
mock>=1.0
|
||||
nose
|
||||
openstack.nose_plugin>=0.7
|
||||
oslo.sphinx
|
||||
pylint==0.25.2
|
||||
sphinx>=1.1.2
|
||||
sphinxcontrib-httpdomain
|
||||
unittest2
|
69
tools/config/generate_sample.sh
Executable file
69
tools/config/generate_sample.sh
Executable file
@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
print_hint() {
|
||||
echo "Try \`${0##*/} --help' for more information." >&2
|
||||
}
|
||||
|
||||
PARSED_OPTIONS=$(getopt -n "${0##*/}" -o hb:p:o: \
|
||||
--long help,base-dir:,package-name:,output-dir: -- "$@")
|
||||
|
||||
if [ $? != 0 ] ; then print_hint ; exit 1 ; fi
|
||||
|
||||
eval set -- "$PARSED_OPTIONS"
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
echo "${0##*/} [options]"
|
||||
echo ""
|
||||
echo "options:"
|
||||
echo "-h, --help show brief help"
|
||||
echo "-b, --base-dir=DIR Project base directory (required)"
|
||||
echo "-p, --package-name=NAME Project package name"
|
||||
echo "-o, --output-dir=DIR File output directory"
|
||||
exit 0
|
||||
;;
|
||||
-b|--base-dir)
|
||||
shift
|
||||
BASEDIR=`echo $1 | sed -e 's/\/*$//g'`
|
||||
shift
|
||||
;;
|
||||
-p|--package-name)
|
||||
shift
|
||||
PACKAGENAME=`echo $1`
|
||||
shift
|
||||
;;
|
||||
-o|--output-dir)
|
||||
shift
|
||||
OUTPUTDIR=`echo $1 | sed -e 's/\/*$//g'`
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z $BASEDIR ] || ! [ -d $BASEDIR ]
|
||||
then
|
||||
echo "${0##*/}: missing project base directory" >&2 ; print_hint ; exit 1
|
||||
fi
|
||||
|
||||
PACKAGENAME=${PACKAGENAME:-${BASEDIR##*/}}
|
||||
|
||||
OUTPUTDIR=${OUTPUTDIR:-$BASEDIR/etc}
|
||||
if ! [ -d $OUTPUTDIR ]
|
||||
then
|
||||
echo "${0##*/}: cannot access \`$OUTPUTDIR': No such file or directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BASEDIRESC=`echo $BASEDIR | sed -e 's/\//\\\\\//g'`
|
||||
FILES=$(find $BASEDIR/$PACKAGENAME -type f -name "*.py" ! -path "*/tests/*" \
|
||||
-exec grep -l "Opt(" {} + | sed -e "s/^$BASEDIRESC\///g" | sort -u)
|
||||
|
||||
export EVENTLET_NO_GREENDNS=yes
|
||||
|
||||
MODULEPATH=murano-repository.openstack.common.config.generator
|
||||
OUTPUTFILE=$OUTPUTDIR/$PACKAGENAME.conf.sample
|
||||
python -m $MODULEPATH $FILES > $OUTPUTFILE
|
77
tools/install_venv.py
Normal file
77
tools/install_venv.py
Normal file
@ -0,0 +1,77 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2010 United States Government as represented by the
|
||||
# Administrator of the National Aeronautics and Space Administration.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Copyright 2010 OpenStack Foundation
|
||||
# Copyright 2013 IBM Corp.
|
||||
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
||||
#
|
||||
# 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 ConfigParser
|
||||
import os
|
||||
import sys
|
||||
|
||||
import install_venv_common as install_venv # flake8: noqa
|
||||
|
||||
|
||||
def print_help(project, venv, root):
|
||||
help = """
|
||||
%(project)s development environment setup is complete.
|
||||
|
||||
%(project)s development uses virtualenv to track and manage Python
|
||||
dependencies while in development and testing.
|
||||
|
||||
To activate the %(project)s virtualenv for the extent of your current
|
||||
shell session you can run:
|
||||
|
||||
$ source %(venv)s/bin/activate
|
||||
|
||||
Or, if you prefer, you can run commands in the virtualenv on a case by
|
||||
case basis by running:
|
||||
|
||||
$ %(root)s/tools/with_venv.sh <your command>
|
||||
"""
|
||||
print help % dict(project=project, venv=venv, root=root)
|
||||
|
||||
|
||||
def main(argv):
|
||||
root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
||||
|
||||
if os.environ.get('tools_path'):
|
||||
root = os.environ['tools_path']
|
||||
venv = os.path.join(root, '.venv')
|
||||
if os.environ.get('venv'):
|
||||
venv = os.environ['venv']
|
||||
|
||||
pip_requires = os.path.join(root, 'requirements.txt')
|
||||
test_requires = os.path.join(root, 'test-requirements.txt')
|
||||
py_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
|
||||
setup_cfg = ConfigParser.ConfigParser()
|
||||
setup_cfg.read('setup.cfg')
|
||||
project = setup_cfg.get('metadata', 'name')
|
||||
|
||||
install = install_venv.InstallVenv(
|
||||
root, venv, pip_requires, test_requires, py_version, project)
|
||||
options = install.parse_args(argv)
|
||||
install.check_python_version()
|
||||
install.check_dependencies()
|
||||
install.create_virtualenv(no_site_packages=options.no_site_packages)
|
||||
install.install_dependencies()
|
||||
install.post_process()
|
||||
print_help(project, venv, root)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv)
|
212
tools/install_venv_common.py
Normal file
212
tools/install_venv_common.py
Normal file
@ -0,0 +1,212 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
# Copyright 2013 IBM Corp.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Provides methods needed by installation script for OpenStack development
|
||||
virtual environments.
|
||||
|
||||
Since this script is used to bootstrap a virtualenv from the system's Python
|
||||
environment, it should be kept strictly compatible with Python 2.6.
|
||||
|
||||
Synced in from openstack-common
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import optparse
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
class InstallVenv(object):
|
||||
|
||||
def __init__(self, root, venv, requirements,
|
||||
test_requirements, py_version,
|
||||
project):
|
||||
self.root = root
|
||||
self.venv = venv
|
||||
self.requirements = requirements
|
||||
self.test_requirements = test_requirements
|
||||
self.py_version = py_version
|
||||
self.project = project
|
||||
|
||||
def die(self, message, *args):
|
||||
print(message % args, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
def check_python_version(self):
|
||||
if sys.version_info < (2, 6):
|
||||
self.die("Need Python Version >= 2.6")
|
||||
|
||||
def run_command_with_code(self, cmd, redirect_output=True,
|
||||
check_exit_code=True):
|
||||
"""Runs a command in an out-of-process shell.
|
||||
|
||||
Returns the output of that command. Working directory is self.root.
|
||||
"""
|
||||
if redirect_output:
|
||||
stdout = subprocess.PIPE
|
||||
else:
|
||||
stdout = None
|
||||
|
||||
proc = subprocess.Popen(cmd, cwd=self.root, stdout=stdout)
|
||||
output = proc.communicate()[0]
|
||||
if check_exit_code and proc.returncode != 0:
|
||||
self.die('Command "%s" failed.\n%s', ' '.join(cmd), output)
|
||||
return (output, proc.returncode)
|
||||
|
||||
def run_command(self, cmd, redirect_output=True, check_exit_code=True):
|
||||
return self.run_command_with_code(cmd, redirect_output,
|
||||
check_exit_code)[0]
|
||||
|
||||
def get_distro(self):
|
||||
if (os.path.exists('/etc/fedora-release') or
|
||||
os.path.exists('/etc/redhat-release')):
|
||||
return Fedora(
|
||||
self.root, self.venv, self.requirements,
|
||||
self.test_requirements, self.py_version, self.project)
|
||||
else:
|
||||
return Distro(
|
||||
self.root, self.venv, self.requirements,
|
||||
self.test_requirements, self.py_version, self.project)
|
||||
|
||||
def check_dependencies(self):
|
||||
self.get_distro().install_virtualenv()
|
||||
|
||||
def create_virtualenv(self, no_site_packages=True):
|
||||
"""Creates the virtual environment and installs PIP.
|
||||
|
||||
Creates the virtual environment and installs PIP only into the
|
||||
virtual environment.
|
||||
"""
|
||||
if not os.path.isdir(self.venv):
|
||||
print('Creating venv...', end=' ')
|
||||
if no_site_packages:
|
||||
self.run_command(['virtualenv', '-q', '--no-site-packages',
|
||||
self.venv])
|
||||
else:
|
||||
self.run_command(['virtualenv', '-q', self.venv])
|
||||
print('done.')
|
||||
else:
|
||||
print("venv already exists...")
|
||||
pass
|
||||
|
||||
def pip_install(self, *args):
|
||||
self.run_command(['tools/with_venv.sh',
|
||||
'pip', 'install', '--upgrade'] + list(args),
|
||||
redirect_output=False)
|
||||
|
||||
def install_dependencies(self):
|
||||
print('Installing dependencies with pip (this can take a while)...')
|
||||
|
||||
# First things first, make sure our venv has the latest pip and
|
||||
# setuptools.
|
||||
self.pip_install('pip>=1.3')
|
||||
self.pip_install('setuptools')
|
||||
|
||||
self.pip_install('-r', self.requirements)
|
||||
self.pip_install('-r', self.test_requirements)
|
||||
|
||||
def post_process(self):
|
||||
self.get_distro().post_process()
|
||||
|
||||
def parse_args(self, argv):
|
||||
"""Parses command-line arguments."""
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option('-n', '--no-site-packages',
|
||||
action='store_true',
|
||||
help="Do not inherit packages from global Python "
|
||||
"install")
|
||||
return parser.parse_args(argv[1:])[0]
|
||||
|
||||
|
||||
class Distro(InstallVenv):
|
||||
|
||||
def check_cmd(self, cmd):
|
||||
return bool(self.run_command(['which', cmd],
|
||||
check_exit_code=False).strip())
|
||||
|
||||
def install_virtualenv(self):
|
||||
if self.check_cmd('virtualenv'):
|
||||
return
|
||||
|
||||
if self.check_cmd('easy_install'):
|
||||
print('Installing virtualenv via easy_install...', end=' ')
|
||||
if self.run_command(['easy_install', 'virtualenv']):
|
||||
print('Succeeded')
|
||||
return
|
||||
else:
|
||||
print('Failed')
|
||||
|
||||
self.die('ERROR: virtualenv not found.\n\n%s development'
|
||||
' requires virtualenv, please install it using your'
|
||||
' favorite package management tool' % self.project)
|
||||
|
||||
def post_process(self):
|
||||
"""Any distribution-specific post-processing gets done here.
|
||||
|
||||
In particular, this is useful for applying patches to code inside
|
||||
the venv.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class Fedora(Distro):
|
||||
"""This covers all Fedora-based distributions.
|
||||
|
||||
Includes: Fedora, RHEL, CentOS, Scientific Linux
|
||||
"""
|
||||
|
||||
def check_pkg(self, pkg):
|
||||
return self.run_command_with_code(['rpm', '-q', pkg],
|
||||
check_exit_code=False)[1] == 0
|
||||
|
||||
def apply_patch(self, originalfile, patchfile):
|
||||
self.run_command(['patch', '-N', originalfile, patchfile],
|
||||
check_exit_code=False)
|
||||
|
||||
def install_virtualenv(self):
|
||||
if self.check_cmd('virtualenv'):
|
||||
return
|
||||
|
||||
if not self.check_pkg('python-virtualenv'):
|
||||
self.die("Please install 'python-virtualenv'.")
|
||||
|
||||
super(Fedora, self).install_virtualenv()
|
||||
|
||||
def post_process(self):
|
||||
"""Workaround for a bug in eventlet.
|
||||
|
||||
This currently affects RHEL6.1, but the fix can safely be
|
||||
applied to all RHEL and Fedora distributions.
|
||||
|
||||
This can be removed when the fix is applied upstream.
|
||||
|
||||
Nova: https://bugs.launchpad.net/nova/+bug/884915
|
||||
Upstream: https://bitbucket.org/eventlet/eventlet/issue/89
|
||||
RHEL: https://bugzilla.redhat.com/958868
|
||||
"""
|
||||
|
||||
# Install "patch" program if it's not there
|
||||
if not self.check_pkg('patch'):
|
||||
self.die("Please install 'patch'.")
|
||||
|
||||
# Apply the eventlet patch
|
||||
self.apply_patch(os.path.join(self.venv, 'lib', self.py_version,
|
||||
'site-packages',
|
||||
'eventlet/green/subprocess.py'),
|
||||
'contrib/redhat-eventlet.patch')
|
4
tools/with_venv.sh
Executable file
4
tools/with_venv.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
TOOLS=`dirname $0`
|
||||
VENV=$TOOLS/../.venv
|
||||
source $VENV/bin/activate && $@
|
58
tox.ini
Normal file
58
tox.ini
Normal file
@ -0,0 +1,58 @@
|
||||
[tox]
|
||||
envlist = py26,py27,pep8,pyflakes
|
||||
|
||||
[testenv]
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
NOSE_WITH_OPENSTACK=1
|
||||
NOSE_OPENSTACK_COLOR=1
|
||||
NOSE_OPENSTACK_RED=0.05
|
||||
NOSE_OPENSTACK_YELLOW=0.025
|
||||
NOSE_OPENSTACK_SHOW_ELAPSED=1
|
||||
deps = -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
commands = nosetests
|
||||
|
||||
[testenv:pep8]
|
||||
deps = pep8==1.3.3
|
||||
commands = pep8 --repeat --show-source murano-repository setup.py
|
||||
|
||||
[testenv:venv]
|
||||
commands = {posargs}
|
||||
|
||||
[testenv:cover]
|
||||
commands = nosetests --cover-erase --cover-package=murano-repository --with-xcoverage
|
||||
|
||||
[tox:jenkins]
|
||||
downloadcache = ~/cache/pip
|
||||
|
||||
[testenv:jenkins26]
|
||||
basepython = python2.6
|
||||
setenv = NOSE_WITH_XUNIT=1
|
||||
deps = file://{toxinidir}/.cache.bundle
|
||||
|
||||
[testenv:jenkins27]
|
||||
basepython = python2.7
|
||||
setenv = NOSE_WITH_XUNIT=1
|
||||
deps = file://{toxinidir}/.cache.bundle
|
||||
|
||||
[testenv:jenkinscover]
|
||||
deps = file://{toxinidir}/.cache.bundle
|
||||
setenv = NOSE_WITH_XUNIT=1
|
||||
commands = nosetests --cover-erase --cover-package=muranoapi --with-xcoverage
|
||||
|
||||
[testenv:jenkinsvenv]
|
||||
deps = file://{toxinidir}/.cache.bundle
|
||||
setenv = NOSE_WITH_XUNIT=1
|
||||
commands = {posargs}
|
||||
|
||||
[testenv:pyflakes]
|
||||
deps = flake8
|
||||
commands = flake8
|
||||
|
||||
[flake8]
|
||||
# H301 one import per line
|
||||
# H302 import only modules
|
||||
ignore = H301,H302
|
||||
show-source = true
|
||||
builtins = _
|
||||
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools
|
Loading…
Reference in New Issue
Block a user