Remove unused namespaces

Change-Id: Ica3174730276c6918aceef85aac1f968bf77ed04
This commit is contained in:
Sergey Kraynev 2016-06-10 15:22:59 +03:00 committed by Alexey Khivin
parent c55d6d3dad
commit 27220928e3
16 changed files with 82 additions and 28 deletions

View File

@ -1,8 +1,6 @@
Namespaces:
=: org.openstack.ci_cd_pipeline_murano_app
std: io.murano
res: io.murano.resources
sys: io.murano.system
ci_cd_pipeline_murano_app: org.openstack.ci_cd_pipeline_murano_app
puppet: org.openstack.ci_cd_pipeline_murano_app.puppet
net: org.openstack.ci_cd_pipeline_murano_app.utils.net
@ -138,4 +136,4 @@ Methods:
- $apps.select($hosts.addHostByInstance($.instance))
- $apps.select($hosts.applyTo($.instance))
- $._environment.reporter.report($this, 'Hosts added.')
- $._environment.reporter.report($this, 'Hosts added.')

View File

@ -1,8 +1,6 @@
Namespaces:
=: org.openstack.ci_cd_pipeline_murano_app.utils
res: io.murano.resources
std: io.murano
sys: io.murano.system
Name: CombinableApplication

View File

@ -12,7 +12,6 @@
Namespaces:
=: io.murano.apps.lbaas
std: io.murano
sys: io.murano.system

View File

@ -1,7 +1,6 @@
Namespaces:
=: org.openstack.ci_cd_pipeline_murano_app
std: io.murano
res: io.murano.resources
sys: io.murano.system
ci_cd_pipeline_murano_app: org.openstack.ci_cd_pipeline_murano_app
puppet: org.openstack.ci_cd_pipeline_murano_app.puppet

View File

@ -12,8 +12,6 @@
Namespaces:
=: org.openstack.murano.lbaas
res: io.murano.resources
conf: io.murano.configuration
sys: io.murano.system
Name: HAProxyPool

View File

@ -1,7 +1,6 @@
Namespaces:
=: org.openstack.ci_cd_pipeline_murano_app
std: io.murano
res: io.murano.resources
sys: io.murano.system
ci_cd_pipeline_murano_app: org.openstack.ci_cd_pipeline_murano_app
puppet: org.openstack.ci_cd_pipeline_murano_app.puppet
@ -238,4 +237,4 @@ Methods:
- $._environment.reporter.report($this, 'Switching to project-config from installed Gerrit...')
- $script: $resources.string('scripts/switch_to_local_project_config.sh')
- $linux.putFile($.instance.agent, $script, '/usr/local/bin/switch_to_local_project_config.sh')
- $linux.runCommand($.instance.agent, 'bash /usr/local/bin/switch_to_local_project_config.sh')
- $linux.runCommand($.instance.agent, 'bash /usr/local/bin/switch_to_local_project_config.sh')

View File

@ -12,7 +12,6 @@
Namespaces:
=: org.openstack.murano.lbaas
std: io.murano
Name: Listener

View File

@ -12,7 +12,6 @@
Namespaces:
=: org.openstack.murano.lbaas
std: io.murano
Name: Pool

View File

@ -1,7 +1,6 @@
Namespaces:
=: org.openstack.ci_cd_pipeline_murano_app
std: io.murano
res: io.murano.resources
sys: io.murano.system
puppet: org.openstack.ci_cd_pipeline_murano_app.puppet

View File

@ -12,9 +12,6 @@
Namespaces:
=: org.openstack.ci_cd_pipeline_murano_app.puppet
res: io.murano.resources
std: io.murano
sys: io.murano.system
Name: Hiera
@ -62,4 +59,4 @@ Methods:
- $tool.update(
$instance,
$this.dataFile.path,
$this.dataFile.data)
$this.dataFile.data)

View File

@ -12,9 +12,6 @@
Namespaces:
=: org.openstack.ci_cd_pipeline_murano_app.puppet
res: io.murano.resources
std: io.murano
sys: io.murano.system
Name: YamlFile

View File

@ -14,7 +14,6 @@
Namespaces:
=: org.openstack.ci_cd_pipeline_murano_app.puppet
res: io.murano.resources
std: io.murano
sys: io.murano.system
Name: YamlTool

View File

@ -1,7 +1,5 @@
Namespaces:
=: org.openstack.ci_cd_pipeline_murano_app.puppet
std: io.murano
res: io.murano.resources
sys: io.murano.system
puppet: org.openstack.ci_cd_pipeline_murano_app.puppet
@ -20,4 +18,4 @@ Methods:
- $template: $resources.yaml('SystemConfig.template')
- $instance.agent.call($template, $resources)
- $instance.setHieraValue( 'project_config_repo', $this.projectConfigRepo)
- $instance.installPuppetModule('reidmv/yamlfile')
- $instance.installPuppetModule('reidmv/yamlfile')

View File

@ -1,9 +1,7 @@
Namespaces:
=: org.openstack.ci_cd_pipeline_murano_app
std: io.murano
res: io.murano.resources
sys: io.murano.system
ci_cd_pipeline_murano_app: org.openstack.ci_cd_pipeline_murano_app
puppet: org.openstack.ci_cd_pipeline_murano_app.puppet
conf: io.murano.configuration

View File

@ -12,7 +12,6 @@
Namespaces:
=: io.murano.apps.lbaas
std: io.murano
sys: io.murano.system

View File

@ -0,0 +1,78 @@
import os
import re
import yaml
class TestNamespaces():
def get_list_of_classes(self):
# TODO: should be fixed future with some common approach for all tests
root_dir = os.path.dirname(os.path.abspath(__file__)).rsplit('/', 1)[0]
apps_dir = os.path.join(root_dir, 'murano-apps')
class_names = []
for path, dirs, files in os.walk(apps_dir):
if path.endswith('Classes'):
names = [os.path.join(path, f)
for f in files if f.endswith('.yaml')]
class_names.extend(names)
return class_names
def get_namespaces(self, cls_name):
# workaround for PyYAML bug: http://pyyaml.org/ticket/221
###############################
class YaqlYamlLoader(yaml.Loader):
pass
def yaql_constructor(loader, node):
return
YaqlYamlLoader.add_constructor(u'!yaql', yaql_constructor)
###############################
# parse file
parsed_data = ''
with open(cls_name) as f:
parsed_data = yaml.load(f, YaqlYamlLoader)
n_spaces = parsed_data.get('Namespaces')
if n_spaces is None:
msg = 'File "%s" does not content "Namespaces" section' % cls_name
raise ValueError(msg)
# get only names of namespaces
names = n_spaces.keys()
# remove main namespace from the list
names.remove('=')
return names
def check_name(self, namespace, cls_name, error_list):
# read file
data = ''
with open(cls_name) as f:
data = f.read()
regexp_str = '%s:[A-Z]+' % namespace
regexp = re.compile(regexp_str)
if len(regexp.findall(data)) == 0:
msg = ('Namespace "%s" is not used in the "%s" and should '
'be removed from list of Namespaces' % (namespace, cls_name))
error_list.append(msg)
def test_namespaces(self):
error_list = []
for cls_name in self.get_list_of_classes():
for ns in self.get_namespaces(cls_name):
self.check_name(ns, cls_name, error_list)
if error_list:
error_string = "\n".join(error_list)
msg = "Test detects follow list of errors: \n%s" % error_string
raise ValueError(msg)
def main():
test = TestNamespaces()
test.test_namespaces()
# to run test just execute command:
# python unittests/test_namespaces.py
main()