aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSridhar K. N. Rao <sridhar.rao@spirent.com>2021-09-20 12:45:42 +0530
committerSridhar K. N. Rao <sridhar.rao@spirent.com>2021-09-20 12:47:36 +0530
commitbfd37762bdf91a7f89d4ebc259454ddb2f5e7b3d (patch)
treedba519dd11f94e216079c65d43e4166cf8c5fe5a
parent43c4b47a9e0d64ffdaa77a743f0be388f49eb558 (diff)
Cleanup-Update: Remove unused code and update PDF
This patch removes unused code and update the pdf. Signed-off-by: Sridhar K. N. Rao <sridhar.rao@spirent.com> Change-Id: I9785c4301869f7b93ccad074cf0ad6ffc77724a0
-rwxr-xr-xsdv/NwLinksValid/__init__.py17
-rw-r--r--sdv/NwLinksValid/nwlinksvalidator.py34
-rwxr-xr-xsdv/ResourceModelValid/__init__.py17
-rw-r--r--sdv/ResourceModelValid/resmodvalidator.py34
-rwxr-xr-xsdv/SoftwarePostSecurityValid/__init__.py19
-rw-r--r--sdv/SoftwarePostSecurityValid/swpostsecurityvalidator.py36
-rwxr-xr-xsdv/SoftwarePostStateValid/__init__.py19
-rw-r--r--sdv/SoftwarePostStateValid/swpoststatevalidator.py36
-rwxr-xr-xsdv/SoftwarePreConfigValid/__init__.py19
-rw-r--r--sdv/SoftwarePreConfigValid/swpreconfigvalidator.py34
-rwxr-xr-xsdv/SoftwarePreUrlsValid/__init__.py19
-rw-r--r--sdv/SoftwarePreUrlsValid/airship.py155
-rw-r--r--sdv/SoftwarePreUrlsValid/swpreurlsvalidator.py34
-rw-r--r--sdv/__init__.py0
-rw-r--r--sdv/conf/00_common.conf21
-rw-r--r--sdv/conf/01_swpreurlsvalid.conf24
-rw-r--r--sdv/conf/02_swpreconfigvalid.conf20
-rw-r--r--sdv/conf/03_swpoststatevalid.conf26
-rw-r--r--sdv/conf/04_swpostsecurityvalid.conf16
-rw-r--r--sdv/conf/05_nwlinksvalid.conf15
-rw-r--r--sdv/conf/06_resmodvalid.conf15
-rw-r--r--sdv/conf/__init__.py265
-rw-r--r--sdv/core/__init__.py19
-rw-r--r--sdv/core/component_factory.py47
-rw-r--r--sdv/core/loader/__init__.py18
-rw-r--r--sdv/core/loader/loader.py222
-rw-r--r--sdv/core/loader/loader_servant.py183
-rwxr-xr-xsdv/pdf/template/cloud_common.json477
-rwxr-xr-xsdv/pdf/template/cloud_extrapolate.json29
-rwxr-xr-xsdv/pdf/template/cloud_kubernetes.json78
-rwxr-xr-xsdv/pdf/template/cloud_openstack.json111
-rwxr-xr-xsdv/valid276
32 files changed, 695 insertions, 1640 deletions
diff --git a/sdv/NwLinksValid/__init__.py b/sdv/NwLinksValid/__init__.py
deleted file mode 100755
index 99456db..0000000
--- a/sdv/NwLinksValid/__init__.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Nework-Links Validator interface and helpers.
-"""
-
-# flake8: noqa
-from NwLinksValid.nwlinksvalidator import *
diff --git a/sdv/NwLinksValid/nwlinksvalidator.py b/sdv/NwLinksValid/nwlinksvalidator.py
deleted file mode 100644
index 314567b..0000000
--- a/sdv/NwLinksValid/nwlinksvalidator.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-
-"""
-Abstract class for N/W Lnks Prevalidations.
-Implementors, please inherit from this class.
-"""
-
-
-class INwLinksValidator():
- """ Model for a Links Validator """
- def __init__(self):
- """ Initialization of the Interface """
- self._default_nwlinks_validation = None
-
- @property
- def validation_nwlinks_defaults(self):
- """ Default Validation values """
- return True
-
- def validate(self):
- """ Validating Compute Node Links"""
- raise NotImplementedError('Please call an implementation.')
diff --git a/sdv/ResourceModelValid/__init__.py b/sdv/ResourceModelValid/__init__.py
deleted file mode 100755
index b3aebfd..0000000
--- a/sdv/ResourceModelValid/__init__.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Nework-Links Validator interface and helpers.
-"""
-
-# flake8: noqa
-from ResourceModelValid.resmodvalidator import *
diff --git a/sdv/ResourceModelValid/resmodvalidator.py b/sdv/ResourceModelValid/resmodvalidator.py
deleted file mode 100644
index bc2ab9e..0000000
--- a/sdv/ResourceModelValid/resmodvalidator.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-
-"""
-Abstract class for N/W Lnks Prevalidations.
-Implementors, please inherit from this class.
-"""
-
-
-class IResModValidator():
- """ Model for a Links Validator """
- def __init__(self):
- """ Initialization of the Interface """
- self._default_resmod_validation = None
-
- @property
- def validation_resmod_defaults(self):
- """ Default Validation values """
- return True
-
- def validate(self):
- """ Validating Resource Modelling"""
- raise NotImplementedError('Please call an implementation.')
diff --git a/sdv/SoftwarePostSecurityValid/__init__.py b/sdv/SoftwarePostSecurityValid/__init__.py
deleted file mode 100755
index 2d85d6c..0000000
--- a/sdv/SoftwarePostSecurityValid/__init__.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2015 Intel Corporation.
-#
-# 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.
-
-"""Sw Validator interface and helpers.
-"""
-
-# flake8: noqa
-from SoftwarePostSecurityValid.swpostsecurityvalidator import *
diff --git a/sdv/SoftwarePostSecurityValid/swpostsecurityvalidator.py b/sdv/SoftwarePostSecurityValid/swpostsecurityvalidator.py
deleted file mode 100644
index 0f40261..0000000
--- a/sdv/SoftwarePostSecurityValid/swpostsecurityvalidator.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-
-"""
-Abstract class for Software Postvalidations.
-Implementors, please inherit from this class.
-"""
-
-
-class ISwPostSecurityValidator():
- """ Model for a Sw Validator """
- def __init__(self):
- """ Initialization of the Interface """
- self._default_security_validation = None
-
- @property
- def validation_security_defaults(self):
- """ Default Validation values """
- return True
-
- def validate(self):
- """
- Validating Mandatory Configuration
- """
- raise NotImplementedError('Please call an implementation.')
diff --git a/sdv/SoftwarePostStateValid/__init__.py b/sdv/SoftwarePostStateValid/__init__.py
deleted file mode 100755
index 5349f90..0000000
--- a/sdv/SoftwarePostStateValid/__init__.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2015 Intel Corporation.
-#
-# 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.
-
-"""Sw Validator interface and helpers.
-"""
-
-# flake8: noqa
-from SoftwarePostStateValid.swpoststatevalidator import *
diff --git a/sdv/SoftwarePostStateValid/swpoststatevalidator.py b/sdv/SoftwarePostStateValid/swpoststatevalidator.py
deleted file mode 100644
index 0c01034..0000000
--- a/sdv/SoftwarePostStateValid/swpoststatevalidator.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-
-"""
-Abstract class for Software Postvalidations.
-Implementors, please inherit from this class.
-"""
-
-
-class ISwPostStateValidator():
- """ Model for a Sw Validator """
- def __init__(self):
- """ Initialization of the Interface """
- self._default_swpoststate_validation = None
-
- @property
- def validation_swpoststate_defaults(self):
- """ Default Validation values """
- return True
-
- def validate(self):
- """
- Validating State
- """
- raise NotImplementedError('Please call an implementation.')
diff --git a/sdv/SoftwarePreConfigValid/__init__.py b/sdv/SoftwarePreConfigValid/__init__.py
deleted file mode 100755
index 7eb24f9..0000000
--- a/sdv/SoftwarePreConfigValid/__init__.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-
-"""Sw Validator interface and helpers.
-"""
-
-# flake8: noqa
-from SoftwarePreConfigValid.swpreconfigvalidator import *
diff --git a/sdv/SoftwarePreConfigValid/swpreconfigvalidator.py b/sdv/SoftwarePreConfigValid/swpreconfigvalidator.py
deleted file mode 100644
index a423354..0000000
--- a/sdv/SoftwarePreConfigValid/swpreconfigvalidator.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-
-"""
-Abstract class for Software Prevalidations.
-Implementors, please inherit from this class.
-"""
-
-
-class ISwPreConfigValidator():
- """ Model for a Sw Validator """
- def __init__(self):
- """ Initialization of the Interface """
- self._default_swpreconfig_validation = None
-
- @property
- def validation_swpreconfig_defaults(self):
- """ Default Validation values """
- return True
-
- def validate(self):
- """ Validate Mandatory Configurations """
- raise NotImplementedError('Please call an implementation.')
diff --git a/sdv/SoftwarePreUrlsValid/__init__.py b/sdv/SoftwarePreUrlsValid/__init__.py
deleted file mode 100755
index c1f68ac..0000000
--- a/sdv/SoftwarePreUrlsValid/__init__.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-
-"""Sw Validator interface and helpers.
-"""
-
-# flake8: noqa
-from SoftwarePreUrlsValid.swpreurlsvalidator import *
diff --git a/sdv/SoftwarePreUrlsValid/airship.py b/sdv/SoftwarePreUrlsValid/airship.py
deleted file mode 100644
index 324eaf1..0000000
--- a/sdv/SoftwarePreUrlsValid/airship.py
+++ /dev/null
@@ -1,155 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-
-"""
-Airship implementation of Software Predeployment Validation
-"""
-
-import os
-import shutil
-from pathlib import Path
-import git
-import urllib3
-from conf import settings
-from SoftwarePreUrlsValid import swpreurlsvalidator
-
-
-def check_link(link):
- """
- Function the check the availability of Hyperlinks
- """
- timeout = urllib3.util.Timeout(connect=5.0, read=7.0)
- http = urllib3.PoolManager(timeout=timeout)
- try:
- http.request('HEAD', link)
- except urllib3.exceptions.LocationValueError as err:
- print(err.args)
- return False
- except urllib3.exceptions.MaxRetryError as err:
- print(err.args)
- return False
- except urllib3.exceptions.RequestError as err:
- print(err.args)
- return False
- except urllib3.exceptions.ConnectTimeoutError as err:
- print(err.args)
- return False
- except urllib3.exceptions.PoolError as err:
- print(err.args)
- return False
- except urllib3.exceptions.HTTPError as err:
- print(err.args)
- return False
- return True
-
-
-class Airship(swpreurlsvalidator.ISwPreUrlsValidator):
- """
- Ariship Sw Validation
- """
- def __init__(self):
- """ Airship class constructor """
- super().__init__()
- self.url = settings.getValue('AIRSHIP_MANIFEST_URL')
- self.branch = settings.getValue('AIRSHIP_MANIFEST_BRANCH')
- self.dl_path = settings.getValue('AIRSHIP_MANIFEST_DOWNLOAD_PATH')
- self.site_name = settings.getValue('AIRSHIP_MANIFEST_SITE_NAME')
- self.manifest = None
- self.dirpath = Path(self.dl_path, 'airship')
- self.tmdirpath = Path(self.dl_path, 'treasuremap')
- self.locations = []
-
- def clone_repo(self):
- """
- Cloning the repos
- """
- git.Repo.clone_from(self.url,
- self.dirpath,
- branch=self.branch)
- git.Repo.clone_from('https://github.com/airshipit/treasuremap',
- self.tmdirpath,
- branch=settings.getValue(
- 'AIRSHIP_TREASUREMAP_VERSION'))
-
- def cleanup_manifest(self):
- """
- Remove existing manifests
- """
- # Next Remove any manifest files, if it exists
- if self.dirpath.exists() and self.dirpath.is_dir():
- shutil.rmtree(self.dirpath)
- if self.tmdirpath.exists() and self.tmdirpath.is_dir():
- shutil.rmtree(self.tmdirpath)
-
- def manifest_exists_locally(self):
- """
- Check if manifests exists locally
- """
- if self.dirpath.exists() and self.dirpath.is_dir():
- return True
- return False
-
- def validate(self):
- """
- Hyperlink Validation
- """
- self.cleanup_manifest()
- # Next, clone the repo to the provided path.
- self.clone_repo()
-
- if self.dirpath.exists() and self.dirpath.is_dir():
- # Get the file(s) where links are defined.
- self.find_locations(
- os.path.join(self.dirpath, 'type',
- 'cntt', 'software',
- 'config', 'versions.yaml'))
- for location in self.locations:
- if check_link(location):
- print("The Link: %s is VALID" % (location))
- else:
- print("The Link: %s is INVALID" % (location))
-
- # pylint: disable=consider-using-enumerate
- def find_locations(self, yamlfile):
- """
- Find all the hyperlinks in the manifests
- """
- with open(yamlfile, 'r') as filep:
- lines = filep.readlines()
- for index in range(len(lines)):
- line = lines[index].strip()
- if line.startswith('location:'):
- link = line.split(":", 1)[1]
- if "opendev" in link:
- if ((len(lines) > index+1) and
- (lines[index+1].strip().startswith(
- 'reference:'))):
- ref = lines[index+1].split(":", 1)[1]
- link = link + '/commit/' + ref.strip()
- if link.strip() not in self.locations:
- print(link)
- self.locations.append(link.strip())
- if 'docker.' in line:
- link = line.split(":", 1)[1]
- link = link.replace('"', '')
- parts = link.split('/')
- if len(parts) == 3:
- link = ('https://index.' +
- parts[0].strip() +
- '/v1/repositories/' +
- parts[1] + '/' + parts[2].split(':')[0] +
- '/tags/' + parts[2].split(':')[-1])
- if link.strip() not in self.locations:
- print(link)
- self.locations.append(link.strip())
diff --git a/sdv/SoftwarePreUrlsValid/swpreurlsvalidator.py b/sdv/SoftwarePreUrlsValid/swpreurlsvalidator.py
deleted file mode 100644
index 31604ee..0000000
--- a/sdv/SoftwarePreUrlsValid/swpreurlsvalidator.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-
-"""
-Abstract class for Software Prevalidations.
-Implementors, please inherit from this class.
-"""
-
-
-class ISwPreUrlsValidator():
- """ Model for a Sw Validator """
- def __init__(self):
- """ Initialization of the Interface """
- self._default_swpre_validation = None
-
- @property
- def validation_swpreurls_defaults(self):
- """ Default Validation values """
- return True
-
- def validate(self):
- """ Validate Hyperlinks"""
- raise NotImplementedError('Please call an implementation.')
diff --git a/sdv/__init__.py b/sdv/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/sdv/__init__.py
+++ /dev/null
diff --git a/sdv/conf/00_common.conf b/sdv/conf/00_common.conf
deleted file mode 100644
index f5e8a23..0000000
--- a/sdv/conf/00_common.conf
+++ /dev/null
@@ -1,21 +0,0 @@
-import os
-
-# default log output directory for all logs
-LOG_DIR = '/tmp'
-
-# default log for all "small" executables
-LOG_FILE_DEFAULT = 'valid-overall.log'
-
-ROOT_DIR = os.path.normpath(os.path.join(
- os.path.dirname(os.path.realpath(__file__)), '../'))
-SW_PRE_URLS_VALID_DIR = os.path.join(ROOT_DIR, 'SoftwarePreUrlsValid')
-SW_PRE_CONFIG_VALID_DIR = os.path.join(ROOT_DIR, 'SoftwarePreConfigValid')
-SW_POST_STATE_VALID_DIR = os.path.join(ROOT_DIR, 'SoftwarePostStateValid')
-SW_POST_SECURITY_VALID_DIR = os.path.join(ROOT_DIR, 'SoftwarePostSecurityValid')
-NW_LINKS_VALID_DIR = os.path.join(ROOT_DIR, 'NwLinksValid')
-RES_MOD_VALID_DIR = os.path.join(ROOT_DIR, 'ResourceModelValid')
-
-# 'debug', 'info', 'warning', 'error', 'critical'
-VERBOSITY = 'warning'
-
-EXCLUDE_MODULES = ['']
diff --git a/sdv/conf/01_swpreurlsvalid.conf b/sdv/conf/01_swpreurlsvalid.conf
deleted file mode 100644
index ddce229..0000000
--- a/sdv/conf/01_swpreurlsvalid.conf
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-
-# Modify this value to any Installer projects that have
-# manifests (templates and configuration files)
-SW_PRE_URLS_VALIDATOR = 'Airship'
-
-# Airship Specific configurations.
-AIRSHIP_MANIFEST_URL = 'https://gerrit.opnfv.org/gerrit/airship'
-AIRSHIP_MANIFEST_BRANCH = 'master'
-AIRSHIP_MANIFEST_DOWNLOAD_PATH = '/tmp'
-AIRSHIP_MANIFEST_SITE_NAME = 'intel-pod10'
-AIRSHIP_TREASUREMAP_VERSION = 'v1.7'
diff --git a/sdv/conf/02_swpreconfigvalid.conf b/sdv/conf/02_swpreconfigvalid.conf
deleted file mode 100644
index bbadfcc..0000000
--- a/sdv/conf/02_swpreconfigvalid.conf
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-
-SW_PRE_CONFIG_VALIDATOR = 'ConfVal'
-MANIFEST_URL = ""
-MANIFEST_DIR = ""
-PDF_FILE_URL = ""
-PDF_FILE_PATH = ""
-INSTALLER = "Airship"
diff --git a/sdv/conf/03_swpoststatevalid.conf b/sdv/conf/03_swpoststatevalid.conf
deleted file mode 100644
index c98ed98..0000000
--- a/sdv/conf/03_swpoststatevalid.conf
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-
-SW_POST_STATE_VALIDATOR = 'Airship'
-
-# For the K8S based deployment Type
-CLUSTER_INFO_FILE_PATH = ""
-CLUSTER_ACCESS_FILE_PATH = ""
-
-# For Containers-without K8S and VMs based Deployment.
-OVERCLOUD_INFO_FILE_PATH = ""
-OVERCLOUD_ACCESS_FILE_PATH = ""
-
-# Any validation specific information is added in this file.
-VALIDATION_CONFIG_FILE_PATH = ""
diff --git a/sdv/conf/04_swpostsecurityvalid.conf b/sdv/conf/04_swpostsecurityvalid.conf
deleted file mode 100644
index 5482612..0000000
--- a/sdv/conf/04_swpostsecurityvalid.conf
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-#
-
-SW_POST_SECURITY_VALIDATOR = 'Airship'
diff --git a/sdv/conf/05_nwlinksvalid.conf b/sdv/conf/05_nwlinksvalid.conf
deleted file mode 100644
index 755e623..0000000
--- a/sdv/conf/05_nwlinksvalid.conf
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-
-NW_LINKS_VALIDATOR = 'lldpd'
diff --git a/sdv/conf/06_resmodvalid.conf b/sdv/conf/06_resmodvalid.conf
deleted file mode 100644
index 9a1a110..0000000
--- a/sdv/conf/06_resmodvalid.conf
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-
-RES_MOD_VALIDATOR = 'custom'
diff --git a/sdv/conf/__init__.py b/sdv/conf/__init__.py
deleted file mode 100644
index ef97aa7..0000000
--- a/sdv/conf/__init__.py
+++ /dev/null
@@ -1,265 +0,0 @@
-# Copyright 2015-2017 Intel Corporation.
-#
-# 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.
-
-"""Settings and configuration handlers.
-
-Settings will be loaded from several .conf files
-and any user provided settings file.
-"""
-
-# pylint: disable=invalid-name
-
-import copy
-import os
-import re
-import logging
-import pprint
-
-_LOGGER = logging.getLogger(__name__)
-
-# regex to parse configuration macros from 04_vnf.conf
-# it will select all patterns starting with # sign
-# and returns macro parameters and step
-# examples of valid macros:
-# #VMINDEX
-# #MAC(AA:BB:CC:DD:EE:FF) or #MAC(AA:BB:CC:DD:EE:FF,2)
-# #IP(192.168.1.2) or #IP(192.168.1.2,2)
-# #EVAL(2*#VMINDEX)
-_PARSE_PATTERN = r'(#[A-Z]+)(\(([^(),]+)(,([0-9]+))?\))?'
-
-
-class Settings(object):
- """Holding class for settings.
- """
- def __init__(self):
- pass
-
- def _eval_param(self, param):
- # pylint: disable=invalid-name
- """ Helper function for expansion of references to 'valid' parameters
- """
- if isinstance(param, str):
- # evaluate every #PARAM reference inside parameter itself
- macros = re.findall(
- r'#PARAM\((([\w\-]+)(\[[\w\[\]\-\'\"]+\])*)\)',
- param)
- if macros:
- for macro in macros:
- # pylint: disable=eval-used
- try:
- tmp_val = str(
- eval("self.getValue('{}'){}".format(macro[1],
- macro[2])))
- param = param.replace('#PARAM({})'.format(macro[0]),
- tmp_val)
- # silently ignore that option required by
- # PARAM macro can't be evaluated;
- # It is possible, that referred parameter
- # will be constructed during runtime
- # and re-read later.
- except IndexError:
- pass
- except AttributeError:
- pass
- return param
- elif isinstance(param, (list, tuple)):
- tmp_list = []
- for item in param:
- tmp_list.append(self._eval_param(item))
- return tmp_list
- elif isinstance(param, dict):
- tmp_dict = {}
- for (key, value) in param.items():
- tmp_dict[key] = self._eval_param(value)
- return tmp_dict
- else:
- return param
-
- def getValue(self, attr):
- """Return a settings item value
- """
- if attr in self.__dict__:
- if attr == 'TEST_PARAMS':
- return getattr(self, attr)
- else:
- master_value = getattr(self, attr)
- return self._eval_param(master_value)
- else:
- raise AttributeError("%r object has no attribute %r" %
- (self.__class__, attr))
-
- def __setattr__(self, name, value):
- """Set a value
- """
- # skip non-settings. this should exclude built-ins amongst others
- if not name.isupper():
- return
-
- # we can assume all uppercase keys are valid settings
- super(Settings, self).__setattr__(name, value)
-
- def setValue(self, name, value):
- """Set a value
- """
- if name is not None and value is not None:
- super(Settings, self).__setattr__(name, value)
-
- def load_from_file(self, path):
- """Update ``settings`` with values found in module at ``path``.
- """
- import imp
-
- custom_settings = imp.load_source('custom_settings', path)
-
- for key in dir(custom_settings):
- if getattr(custom_settings, key) is not None:
- setattr(self, key, getattr(custom_settings, key))
-
- def load_from_dir(self, dir_path):
- """Update ``settings`` with contents of the .conf files at ``path``.
-
- Each file must be named Nfilename.conf, where N is a single or
- multi-digit decimal number. The files are loaded in ascending order of
- N - so if a configuration item exists in more that one file the setting
- in the file with the largest value of N takes precedence.
-
- :param dir_path: The full path to the dir from which to load the .conf
- files.
-
- :returns: None
- """
- regex = re.compile(
- "^(?P<digit_part>[0-9]+)(?P<alfa_part>[a-z]?)_.*.conf$")
-
- def get_prefix(filename):
- """
- Provide a suitable function for sort's key arg
- """
- match_object = regex.search(os.path.basename(filename))
- return [int(match_object.group('digit_part')),
- match_object.group('alfa_part')]
-
- # get full file path to all files & dirs in dir_path
- file_paths = os.listdir(dir_path)
- file_paths = [os.path.join(dir_path, x) for x in file_paths]
-
- # filter to get only those that are a files, with a leading
- # digit and end in '.conf'
- file_paths = [x for x in file_paths if os.path.isfile(x) and
- regex.search(os.path.basename(x))]
-
- # sort ascending on the leading digits and afla (e.g. 03_, 05a_)
- file_paths.sort(key=get_prefix)
-
- # load settings from each file in turn
- for filepath in file_paths:
- self.load_from_file(filepath)
-
- def load_from_dict(self, conf):
- """
- Update ``settings`` with values found in ``conf``.
-
- Unlike the other loaders, this is case insensitive.
- """
- for key in conf:
- if conf[key] is not None:
- if isinstance(conf[key], dict):
- # recursively update dict items, e.g. TEST_PARAMS
- setattr(self, key.upper(),
- merge_spec(getattr(self, key.upper()), conf[key]))
- else:
- setattr(self, key.upper(), conf[key])
-
- def restore_from_dict(self, conf):
- """
- Restore ``settings`` with values found in ``conf``.
-
- Method will drop all configuration options and restore their
- values from conf dictionary
- """
- self.__dict__.clear()
- tmp_conf = copy.deepcopy(conf)
- for key in tmp_conf:
- self.setValue(key, tmp_conf[key])
-
- def load_from_env(self):
- """
- Update ``settings`` with values found in the environment.
- """
- for key in os.environ:
- setattr(self, key, os.environ[key])
-
- def __str__(self):
- """Provide settings as a human-readable string.
-
- This can be useful for debug.
-
- Returns:
- A human-readable string.
- """
- tmp_dict = {}
- for key in self.__dict__:
- tmp_dict[key] = self.getValue(key)
-
- return pprint.pformat(tmp_dict)
-
- #
- # validation methods used by step driven testcases
- #
- def validate_getValue(self, result, attr):
- """Verifies, that correct value was returned
- """
- # getValue must be called to expand macros and apply
- # values from TEST_PARAM option
- assert result == self.getValue(attr)
- return True
-
- def validate_setValue(self, _dummy_result, name, value):
- """Verifies, that value was correctly set
- """
- assert value == self.__dict__[name]
- return True
-
-
-settings = Settings()
-
-
-def merge_spec(orig, new):
- """Merges ``new`` dict with ``orig`` dict, and returns orig.
-
- This takes into account nested dictionaries. Example:
-
- >>> old = {'foo': 1, 'bar': {'foo': 2, 'bar': 3}}
- >>> new = {'foo': 6, 'bar': {'foo': 7}}
- >>> merge_spec(old, new)
- {'foo': 6, 'bar': {'foo': 7, 'bar': 3}}
-
- You'll notice that ``bar.bar`` is not removed. This is the desired result.
- """
- for key in orig:
- if key not in new:
- continue
-
- # Not allowing derived dictionary types for now
- # pylint: disable=unidiomatic-typecheck
- if type(orig[key]) == dict:
- orig[key] = merge_spec(orig[key], new[key])
- else:
- orig[key] = new[key]
-
- for key in new:
- if key not in orig:
- orig[key] = new[key]
-
- return orig
diff --git a/sdv/core/__init__.py b/sdv/core/__init__.py
deleted file mode 100644
index 2441d38..0000000
--- a/sdv/core/__init__.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2015 Intel Corporation.
-#
-# 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.
-
-"""Core structural interfaces and their implementations
-"""
-
-# flake8: noqa
-import core.component_factory
diff --git a/sdv/core/component_factory.py b/sdv/core/component_factory.py
deleted file mode 100644
index 813c6f2..0000000
--- a/sdv/core/component_factory.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2020 Spirent Communications.
-#
-# 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.
-
-"""
-Create Components.
-"""
-
-
-def create_swpreurlsvalidator(swpreurlsvalidator_class):
- """ Create Pre-Links Validators"""
- return swpreurlsvalidator_class()
-
-
-def create_swpoststatevalidator(swpoststatevalidator_class):
- """ Create Post-State Validators"""
- return swpoststatevalidator_class()
-
-
-def create_nwlinksvalidator(nwlinksvalidator_class):
- """ Create NW Link-Validators"""
- return nwlinksvalidator_class()
-
-
-def create_swpreconfigvalidator(swpreconfigvalidator_class):
- """ Create Pre-Config Validators"""
- return swpreconfigvalidator_class()
-
-
-def create_swpostsecurityvalidator(swpostsecurityvalidator_class):
- """ Create Post-Security Validators"""
- return swpostsecurityvalidator_class()
-
-
-def create_resmodvalidator(resmodvalidator_class):
- """ Create Resource-Model Validators"""
- return resmodvalidator_class()
diff --git a/sdv/core/loader/__init__.py b/sdv/core/loader/__init__.py
deleted file mode 100644
index e86c48e..0000000
--- a/sdv/core/loader/__init__.py
+++ /dev/null
@@ -1,18 +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.
-
-"""
-Core: Loader Component.
-"""
-
-# flake8: noqa
-from .loader import Loader
diff --git a/sdv/core/loader/loader.py b/sdv/core/loader/loader.py
deleted file mode 100644
index 8840f26..0000000
--- a/sdv/core/loader/loader.py
+++ /dev/null
@@ -1,222 +0,0 @@
-# Copyright 2020 Intel Corporation, Spirent Communications.
-#
-# 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.
-
-"""
-Abstract class for Software Prevalidations.
-Implementors, please inherit from this class.
-"""
-
-from conf import settings
-from core.loader.loader_servant import LoaderServant
-from SoftwarePreUrlsValid.swpreurlsvalidator import ISwPreUrlsValidator
-from SoftwarePreConfigValid.swpreconfigvalidator import ISwPreConfigValidator
-from SoftwarePostStateValid.swpoststatevalidator import ISwPostStateValidator
-from SoftwarePostSecurityValid.swpostsecurityvalidator import ISwPostSecurityValidator
-from NwLinksValid.nwlinksvalidator import INwLinksValidator
-from ResourceModelValid.resmodvalidator import IResModValidator
-
-
-# pylint: disable=too-many-public-methods
-class Loader():
- """Loader class - main object context holder.
- """
- _swvalidator_loader = None
-
- def __init__(self):
- """Loader ctor - initialization method.
-
- All data is read from configuration each time Loader instance is
- created. It is up to creator to maintain object life cycle if this
- behavior is unwanted.
- """
- self._swpreurlsvalidator_loader = LoaderServant(
- settings.getValue('SW_PRE_URLS_VALID_DIR'),
- settings.getValue('SW_PRE_URLS_VALIDATOR'),
- ISwPreUrlsValidator)
- self._swpreconfigvalidator_loader = LoaderServant(
- settings.getValue('SW_PRE_CONFIG_VALID_DIR'),
- settings.getValue('SW_PRE_CONFIG_VALIDATOR'),
- ISwPreConfigValidator)
- self._swpoststatevalidator_loader = LoaderServant(
- settings.getValue('SW_POST_STATE_VALID_DIR'),
- settings.getValue('SW_POST_STATE_VALIDATOR'),
- ISwPostStateValidator)
- self._swpostsecurityvalidator_loader = LoaderServant(
- settings.getValue('SW_POST_SECURITY_VALID_DIR'),
- settings.getValue('SW_POST_SECURITY_VALIDATOR'),
- ISwPostSecurityValidator)
- self._nwlinksvalidator_loader = LoaderServant(
- settings.getValue('NW_LINKS_VALID_DIR'),
- settings.getValue('NW_LINKS_VALIDATOR'),
- INwLinksValidator)
- self._resmodvalidator_loader = LoaderServant(
- settings.getValue('RES_MOD_VALID_DIR'),
- settings.getValue('RES_MOD_VALIDATOR'),
- IResModValidator)
-
- def get_swpreurlsvalidator(self):
- """ Returns a new instance configured Software Validator
- :return: ISwPreUrlsValidator implementation if available, None otherwise
- """
- return self._swpreurlsvalidator_loader.get_class()()
-
- def get_swpreurlsvalidator_class(self):
- """Returns type of currently configured Software Validator.
-
- :return: Type of ISwPreUrlsValidator implementation if available.
- None otherwise.
- """
- return self._swpreurlsvalidator_loader.get_class()
-
- def get_swpreurlsvalidators(self):
- """
- Get Prevalidators
- """
- return self._swpreurlsvalidator_loader.get_classes()
-
- def get_swpreurlsvalidators_printable(self):
- """
- Get Prevalidators for printing
- """
- return self._swpreurlsvalidator_loader.get_classes_printable()
-
- def get_swpreconfigvalidator(self):
- """ Returns a new instance configured Software Validator
- :return: ISwPreConfigValidator implementation if available, None otherwise
- """
- return self._swpreconfigvalidator_loader.get_class()()
-
- def get_swpreconfigvalidator_class(self):
- """Returns type of currently configured Software Validator.
-
- :return: Type of ISwPreConfigValidator implementation if available.
- None otherwise.
- """
- return self._swpreconfigvalidator_loader.get_class()
-
- def get_swpreconfigvalidators(self):
- """
- Get Prevalidators
- """
- return self._swpreconfigvalidator_loader.get_classes()
-
- def get_swpreconfigvalidators_printable(self):
- """
- Get Prevalidators for printing
- """
- return self._swpreconfigvalidator_loader.get_classes_printable()
-
- def get_swpoststatevalidator(self):
- """ Returns a new instance configured Software Validator
- :return: ISwPostStateValidator implementation if available, None otherwise
- """
- return self._swpoststatevalidator_loader.get_class()()
-
- def get_swpoststatevalidator_class(self):
- """Returns type of currently configured Software Validator.
-
- :return: Type of ISwPostStateValidator implementation if available.
- None otherwise.
- """
- return self._swpoststatevalidator_loader.get_class()
-
- def get_swpoststatevalidators(self):
- """
- Get Postvalidators
- """
- return self._swpoststatevalidator_loader.get_classes()
-
- def get_swpoststatevalidators_printable(self):
- """
- Get Postvalidators for printing
- """
- return self._swpoststatevalidator_loader.get_classes_printable()
-
- def get_swpostsecurityvalidator(self):
- """ Returns a new instance configured Software Validator
- :return: ISwPostSecurityValidator implementation if available, None otherwise
- """
- return self._swpostsecurityvalidator_loader.get_class()()
-
- def get_swpostsecurityvalidator_class(self):
- """Returns type of currently configured Software Validator.
-
- :return: Type of ISwPostSecurityValidator implementation if available.
- None otherwise.
- """
- return self._swpostsecurityvalidator_loader.get_class()
-
- def get_swpostsecurityvalidators(self):
- """
- Get Postvalidators
- """
- return self._swpostsecurityvalidator_loader.get_classes()
-
- def get_swpostsecurityvalidators_printable(self):
- """
- Get Postvalidators for printing
- """
- return self._swpostsecurityvalidator_loader.get_classes_printable()
-
- def get_nwlinksvalidator(self):
- """ Returns a new instance configured Nw-Links Validator
- :return: INwLinksValidator implementation if available, None otherwise
- """
- return self._nwlinksvalidator_loader.get_class()()
-
- def get_nwlinksvalidator_class(self):
- """Returns type of currently configured Nw-Links Validator.
-
- :return: Type of NwLinksValidator implementation if available.
- None otherwise.
- """
- return self._nwlinksvalidator_loader.get_class()
-
- def get_nwlinksvalidators(self):
- """
- Get Linkvalidators
- """
- return self._nwlinksvalidator_loader.get_classes()
-
- def get_nwlinksvalidators_printable(self):
- """
- Get Linkvalidators for printing
- """
- return self._nwlinksvalidator_loader.get_classes_printable()
-
- def get_resmodvalidator(self):
- """ Returns a new instance configured Nw-Links Validator
- :return: IResModValidator implementation if available, None otherwise
- """
- return self._resmodvalidator_loader.get_class()()
-
- def get_resmodvalidator_class(self):
- """Returns type of currently configured Nw-Links Validator.
-
- :return: Type of ResModValidator implementation if available.
- None otherwise.
- """
- return self._resmodvalidator_loader.get_class()
-
- def get_resmodvalidators(self):
- """
- Get ResoureModelValidators
- """
- return self._resmodvalidator_loader.get_classes()
-
- def get_resmodvalidators_printable(self):
- """
- Get ResoureModelValidators for printing
- """
- return self._resmodvalidator_loader.get_classes_printable()
diff --git a/sdv/core/loader/loader_servant.py b/sdv/core/loader/loader_servant.py
deleted file mode 100644
index 4e55c67..0000000
--- a/sdv/core/loader/loader_servant.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# Copyright 2020 Intel Corporation, Spirent Communications.
-#
-# 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.
-
-"""
-Loader Support Module.
-"""
-
-import os
-from os import sys
-import imp
-import fnmatch
-import logging
-from conf import settings
-
-
-class LoaderServant():
- """Class implements basic dynamic import operations.
- """
- _class_name = None
- _path = None
- _interface = None
-
- def __init__(self, path, class_name, interface):
- """LoaderServant constructor
-
- Intializes all data needed for import operations.
-
- Attributes:
- path: path to directory which contains implementations derived from
- interface.
- class_name: Class name which will be returned in get_class
- method, if such definition exists in directory
- represented by path,
- interface: interface type. Every object which doesn't
- implement this particular interface will be
- filtered out.
- """
- self._class_name = class_name
- self._path = path
- self._interface = interface
-
- def get_class(self):
- """Returns class type based on parameters passed in __init__.
-
- :return: Type of the found class.
- None if class hasn't been found
- """
-
- return self.load_module(path=self._path,
- interface=self._interface,
- class_name=self._class_name)
-
- def get_classes(self):
- """Returns all classes in path derived from interface
-
- :return: Dictionary with following data:
- - key: String representing class name,
- - value: Class type.
- """
- return self.load_modules(path=self._path,
- interface=self._interface)
-
- def get_classes_printable(self):
- """Returns all classes derived from _interface found in path
-
- :return: String - list of classes in printable format.
- """
-
- out = self.load_modules(path=self._path,
- interface=self._interface)
- results = []
-
- # sort modules to produce the same output everytime
- for (name, mod) in sorted(out.items()):
- desc = (mod.__doc__ or 'No description').strip().split('\n')[0]
- results.append((name, desc))
-
- header = 'Classes derived from: ' + self._interface.__name__
- output = [header + '\n' + '=' * len(header) + '\n']
-
- for (name, desc) in results:
- output.append('* %-18s%s' % ('%s:' % name, desc))
-
- output.append('')
-
- output.append('')
-
- return '\n'.join(output)
-
- @staticmethod
- def load_module(path, interface, class_name):
- """Imports everything from given path and returns class type
-
- This is based on following conditions:
- - Class is derived from interface,
- - Class type name matches class_name.
-
- :return: Type of the found class.
- None if class hasn't been found
- """
-
- results = LoaderServant.load_modules(
- path=path, interface=interface)
-
- if class_name in results:
- logging.info(
- "Class found: %s.", class_name)
- return results.get(class_name)
-
- return None
-
- @staticmethod
- def load_modules(path, interface):
- """Returns dictionary of class name/class type found in path
-
- This is based on following conditions:
- - classes found under path are derived from interface.
- - class is not interface itself.
-
- :return: Dictionary with following data:
- - key: String representing class name,
- - value: Class type.
- """
- result = {}
-
- for _, mod in LoaderServant._load_all_modules(path):
- # find all classes derived from given interface, but suppress
- # interface itself and any abstract class starting with iface name
- gens = dict((k, v) for (k, v) in list(mod.__dict__.items())
- if isinstance(v, type) and
- issubclass(v, interface) and
- not k.startswith(interface.__name__))
- if gens:
- for (genname, gen) in list(gens.items()):
- result[genname] = gen
- return result
-
- @staticmethod
- def _load_all_modules(path):
- """Load all modules from ``path`` directory.
-
- This is based on the design used by OFTest:
- https://github.com/floodlight/oftest/blob/master/oft
-
- :param path: Path to a folder of modules.
-
- :return: List of modules in a folder.
- """
- mods = []
-
- for root, _, filenames in os.walk(path):
- # Iterate over each python file
- for filename in fnmatch.filter(filenames, '[!.]*.py'):
- modname = os.path.splitext(os.path.basename(filename))[0]
-
- # skip module load if it is excluded by configuration
- if modname in settings.getValue('EXCLUDE_MODULES'):
- continue
-
- try:
- if modname in sys.modules:
- mod = sys.modules[modname]
- else:
- mod = imp.load_module(
- modname, *imp.find_module(modname, [root]))
- except ImportError:
- logging.error('Could not import file %s', filename)
- raise
-
- mods.append((modname, mod))
-
- return mods
diff --git a/sdv/pdf/template/cloud_common.json b/sdv/pdf/template/cloud_common.json
new file mode 100755
index 0000000..7457308
--- /dev/null
+++ b/sdv/pdf/template/cloud_common.json
@@ -0,0 +1,477 @@
+{
+ "_comment_head": "Maintainer - Sridhar Rao <sridhar.rao@spirent.com>",
+ "_comment_head1": "User should Configure all profiles. Add new, if reqd.",
+ "_comment_head2": "User should Configure the roles",
+ "_comment_head3": "All infos should be filled by the user",
+ "_comment_head4": "The servers data will be automatically generated",
+ "_comment_info1": "All Infos",
+ "management_info": {
+ "owner": "",
+ "area_name": "",
+ "area_center_name": "",
+ "room_id": "",
+ "city": "",
+ "timezone": "",
+ "resource_pool_id": "",
+ "resource_pool_name": "",
+ "resource_pool_type": ""
+ },
+ "user_info": [
+ {
+ "_comment_users1": " Access Type: PIM, VIM, etc.",
+ "_comment_users2": " Endpoint: Server, Switch, VIM, etc.",
+ "access_type": "",
+ "endpoint": "",
+ "auth_type": "",
+ "username": "",
+ "password": "",
+ "pub_key": "",
+ "passphrase": "",
+ "tls_ca_cert": "",
+ "tls_cert": "",
+ "tls_key": "",
+ "email": ""
+ }
+ ],
+ "ntp_info": {
+ "primary_ip": "",
+ "primary_zone": "",
+ "secondary_ip": "",
+ "secondary_zone": ""
+ },
+ "syslog_info": {
+ "server_ip": "",
+ "transport": ""
+ },
+ "dns_info": [
+ {
+ "name": "",
+ "domain": "",
+ "servers": [
+ {
+ "ip": ""
+ }
+ ]
+ }
+ ],
+ "proxy_info": {
+ "address": "",
+ "port": "",
+ "user": "",
+ "password": ""
+ },
+ "ldap_info": {
+ "base_url": "",
+ "url": "",
+ "auth_path": "",
+ "common_name": "",
+ "subdomain": "",
+ "domain": ""
+ },
+ "_comment_deployment": " Type can be OOK or NOOK, block storage method is rbd or iscsi",
+ "deployment_info": {
+ "high_availability": "",
+ "introspection": "",
+ "deployment_type": "",
+ "installer_used": "",
+ "workload_vnf": "",
+ "workload_cnf": "",
+ "sdn_controller": "",
+ "sdn_controller_version": "",
+ "sdn_controller_nbapps": "",
+ "vnfm": "",
+ "vnfm_version": "",
+ "data_plane_used": "",
+ "ironic_deploy_interface": "",
+ "ip_type": "",
+ "external_storage_cluster": "",
+ "blk_str_connect_method": ""
+ },
+ "jumphost_info": {
+ "ip": "",
+ "name": ""
+ },
+ "rack_info": [
+ {
+ "rack_id": "",
+ "rack_details": {
+ "rack_name": "",
+ "rack_description": "",
+ "rack_az": "",
+ "rack_room": "",
+ "rack_raw": "",
+ "rack_number": ""
+ }
+ }
+ ],
+ "storage_cluster_info": {
+ "name": "",
+ "cluster_type": "",
+ "vendor": "",
+ "version": "",
+ "cluster_id": "",
+ "auth_type": "",
+ "username": "",
+ "password": "",
+ "certificate_location": "",
+ "client_key": "",
+ "mon_host_ips": [
+ {
+ "ip": ""
+ }
+ ],
+ "public_cidr": "",
+ "cluster_cidr": "",
+ "nodes": [
+ {
+ "name": "",
+ "id": ""
+ }
+ ],
+ "pools": [
+ {
+ "key": "",
+ "value": ""
+ }
+ ],
+ "max_quota_capacity": "",
+ "az_name": "",
+ "backup_policy": "",
+ "networks": [
+ {
+ "name": ""
+ }
+ ]
+ },
+ "_comment_info2": "End of Information - Except Software-INFO",
+ "bios_profiles": [
+ {
+ "profile_name": "",
+ "bios_info": {
+ "bios_version": "",
+ "bios_mode": "",
+ "bootstrap_proto": "",
+ "hyperthreading_enabled": "",
+ "_comment": "C4_C6_MLC-STR_MLC-SPA_DCU_DCA_RAS_TURBO",
+ "bios_setting": ""
+ }
+ }
+ ],
+ "bmc_profiles": [
+ {
+ "profile_name": "",
+ "bmc_info": {
+ "version": ""
+ }
+ }
+ ],
+ "processor_profiles": [
+ {
+ "profile_name": "",
+ "profile_info": {
+ "manufacturer": "",
+ "generation": "",
+ "speed": "",
+ "model": "",
+ "architecture": "",
+ "cpu_cflags": "",
+ "cache_size": "",
+ "numas": [
+ {
+ "node_id": "",
+ "cpu_set": ""
+ }
+ ]
+ }
+ }
+ ],
+ "disks_profiles": [
+ {
+ "profile_name": "",
+ "profile_info": [
+ {
+ "alias": "",
+ "vendor": "",
+ "address": "",
+ "size": "",
+ "model": "",
+ "dev_type": "",
+ "rotation": "",
+ "bus": "",
+ "logical_name": ""
+ }
+ ]
+ }
+ ],
+ "nic_profiles": [
+ {
+ "profile_name": "",
+ "profile_info": [
+ {
+ "alias": "",
+ "name": "",
+ "address": "",
+ "dev_type": "",
+ "bus": "",
+ "sriov_capable": "",
+ "numa_id": ""
+ }
+ ]
+ }
+ ],
+ "hardware_profiles": [
+ {
+ "profile_name": "",
+ "profile_id": "",
+ "profile_info": {
+ "manufacturer": "",
+ "sku": "",
+ "model": "",
+ "generation": "",
+ "bios_profile": "",
+ "bmc_profile": "",
+ "processor_profile": "",
+ "memory": "",
+ "disks_profile": "",
+ "nics_profile": ""
+ }
+ }
+ ],
+ "switch_profiles": [
+ {
+ "profile_name": "",
+ "profile_id": "",
+ "profile_info": {
+ "manufacturer": "",
+ "sku": "",
+ "model": "",
+ "generation": "",
+ "bios_profile": "",
+ "bmc_profile": "",
+ "nics_profile": ""
+ }
+ }
+ ],
+ "_comment_hw": " Hardware Information is complete",
+ "storage_profile": [
+ {
+ "name": "",
+ "bootdrive": "",
+ "bd_partitions": [
+ {
+ "name": "",
+ "size": "",
+ "bootable": "",
+ "filesystem": {
+ "mountpoint": "",
+ "fstype": "",
+ "mount_options": ""
+ }
+ }
+ ],
+ "data_devices": [
+ {
+ "name": "",
+ "partitions": [
+ {
+ "name": "ceph",
+ "size": "available",
+ "filesystem": {
+ "mountpoint": "/var/lib/ceph",
+ "fstype": "ext4",
+ "mount_options": "defaults"
+ }
+ }
+ ]
+ }
+ ],
+ "journal_devices": [
+ {
+ "name": ""
+ }
+ ]
+ }
+ ],
+ "_comment_nw1": "Network Info, Please include IPMI & Physnets info too",
+ "networks": [
+ {
+ "name": "",
+ "vips": [
+ {
+ "name": "",
+ "ip": ""
+ }
+ ],
+ "tunnel_type": "",
+ "tunnel_id": "",
+ "tunnel_id_range": "",
+ "mtu": "",
+ "routedomain": "",
+ "cidr": "",
+ "dns": "",
+ "routes": [
+ {
+ "subnet": "",
+ "gateway": "",
+ "metric": "",
+ "routedomain": ""
+ }
+ ],
+ "allocation_pools": [
+ {
+ "type": "",
+ "start": "",
+ "end": ""
+ }
+ ],
+ "v6_cidr": "",
+ "v6_allocation_pools": [
+ {
+ "type": "",
+ "start": "",
+ "end": ""
+ }
+ ]
+ }
+ ],
+ "_comment_nw_2": "These are specific to Infrastructure manager",
+ "physical_networks": [
+ {
+ "name": "external",
+ "cidr": "",
+ "type": "flat"
+ }
+ ],
+ "_comment_nw3": " type: trunk (airship), bond, interface, bridge",
+ "network_link": [
+ {
+ "name": "",
+ "type": "",
+ "bonding_mode": "",
+ "mtu": "",
+ "linkspeed": "auto",
+ "trunking_mode": "",
+ "trunking_default_nw": "",
+ "metadata": [
+ {
+ "key": "",
+ "value": ""
+ }
+ ],
+ "members": [
+ {
+ "name": "",
+ "type": ""
+ }
+ ],
+ "vid": "",
+ "vf_count": ""
+ }
+ ],
+ "_comment_nw4": "The link_name could be i/f, bond, bridges",
+ "_comment_nw5": "These profiles are mapped to roles",
+ "link_nw_mapping_profiles": [
+ {
+ "profile_name": "",
+ "profile_data": [
+ {
+ "link_name": "",
+ "link_type": "",
+ "networks": [
+ {
+ "name": ""
+ }
+ ],
+ "use_dhcp": ""
+ }
+ ]
+ }
+ ],
+ "platform_profiles": [
+ {
+ "profile_name": "",
+ "os": "",
+ "rt_kvm": "",
+ "kernel_version": "",
+ "kernel_parameters": "",
+ "isolated_cpus": "",
+ "vnf_cores": "",
+ "os_reserved_cores": " ",
+ "hugepage_count": "",
+ "hugepages": [
+ {
+ "hugepage_count": "",
+ "hugepage_size": ""
+ }
+ ],
+ "iommu": "",
+ "vswitch_daemon_cores": " ",
+ "vswitch_type": "",
+ "vswitch_uio_driver": "",
+ "vswitch_mem_channels": "",
+ "vswitch_socket_memory": "",
+ "vswitch_pmd_cores": "",
+ "vswitch_dpdk_lcores": "",
+ "vswitch_dpdk_rxqs": "",
+ "vswitch_options": ""
+ }
+ ],
+ "switch_topology": [
+ {
+ "top_id": "",
+ "top_name": "",
+ "vertices": [
+ {
+ "vertex_id": "",
+ "node1_id": "",
+ "node1_port": "",
+ "node2_id": "",
+ "node2_port": "",
+ "vertex_type": ""
+ }
+ ]
+ }
+ ],
+ "_comment_role1": "User has to configure this - What profile to use for a role",
+ "_comment_role2": "Based on this server_info will be autogenerated for all servers",
+ "roles": [
+ {
+ "name": "",
+ "hostname_prefix": "",
+ "hostname_suffix": "",
+ "hostname_number_start": "",
+ "count": "",
+ "hardware_profile": "",
+ "interface_mapping": "",
+ "storage_mapping": "",
+ "platform_profile": "",
+ "sw_set_name": "",
+ "metadata": [
+ {
+ "on_count_condition": "",
+ "count": "",
+ "key": "",
+ "value": ""
+ }
+ ]
+ }
+ ]
+ "host_aggregates": [
+ {
+ "aggregate_name": "",
+ "properties": [
+ {
+ "key": "",
+ "value": ""
+ }
+ ],
+ "servers": [
+ {
+ "identifier": "",
+ "ilo_ip": "",
+ "hostname": ""
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/sdv/pdf/template/cloud_extrapolate.json b/sdv/pdf/template/cloud_extrapolate.json
new file mode 100755
index 0000000..d2cc6f7
--- /dev/null
+++ b/sdv/pdf/template/cloud_extrapolate.json
@@ -0,0 +1,29 @@
+{
+ "_comment_head": "Maintainer - Sridhar Rao <sridhar.rao@spirent.com>",
+ "_comment_ex1": "C:City, A:Area, R:Room, N:Unique Number",
+ "_comment_ex2": "All are 2 characters. City-Capitals, Area-Small",
+ "extrapolation_info": {
+ "ilo_password": "CID-AID-RID-NID",
+ "ilo_user": "owner",
+ "ip_increment": ""
+ },
+ "_comment_servers1": "This will be auto generated",
+ "_comment_servers2": "This describes the entire cloud.",
+ "servers": [
+ {
+ "role_name": "",
+ "device_name": "",
+ "az_name": " ",
+ "ha_name": " ",
+ "rack": "",
+ "ilo_info": {
+ "ip": "",
+ "user": "",
+ "password": ""
+ },
+ "service_info": {
+ "service_ip": ""
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/sdv/pdf/template/cloud_kubernetes.json b/sdv/pdf/template/cloud_kubernetes.json
new file mode 100755
index 0000000..269782a
--- /dev/null
+++ b/sdv/pdf/template/cloud_kubernetes.json
@@ -0,0 +1,78 @@
+{
+ "_comment_head": "Maintainer - Sridhar Rao <sridhar.rao@spirent.com>",
+ "vim_info": {
+ "vim_name": " ",
+ "vim_id": " ",
+ "vendor": " ",
+ "version": " ",
+ "installer": "",
+ "deployment_style": "",
+ "container_orchestrator": "",
+ "storage_type": ""
+ },
+ "vim_functional": {
+ "kubevirt_support":"",
+ "ingress_approaches": "",
+ "egress_approaches": "",
+ "prev_mod_containers": "",
+ "hostdir_as_vols": "",
+ "host_ns_use": "",
+ "net_raw_admin_cap": "",
+ "_comment_cpu_manager": "Type could be none or static",
+ "cpu_manager_policy": {
+ "type": "",
+ "kube_reserved": "",
+ "system_reserved": "",
+ "reserved_cpus": "",
+ "full_pcpus_only": ""
+ },
+ "_comment_topo_manager": "Type could be none, best-effort, restricted single-numa-node",
+ "topo_manager_policy": {
+ "scope": "",
+ "type": ""
+ },
+ "use_of_service_mesh": "",
+ "k8s_api_access_from_pod": "",
+ "liveliness_probe": "",
+ "readiness_probe": "",
+ "cnis_supported": "",
+ "device_plugins_supported":"",
+ "scheduler_filters": "",
+ "cpu_allocation_ratio": "",
+ "legacy_helm_support":""
+ },
+ "jumphost_info": {
+ "ip": "",
+ "name": ""
+ },
+ "_comment_sw1": "Software Begins",
+ "kubernetes_sw_profiles": [
+ {
+ "profile_name": "",
+ "sw_list": [
+ {
+ "name": "",
+ "version": ""
+ }
+ ]
+ }
+ ],
+ "infra_sw_profiles": [
+ {
+ "profile_name": "",
+ "sw_list": [
+ {
+ "name": "",
+ "version": ""
+ }
+ ]
+ }
+ ],
+ "software_set": [
+ {
+ "set_name": "",
+ "infrasw_profile": "",
+ "kubernetes_profile": ""
+ }
+ ]
+}
diff --git a/sdv/pdf/template/cloud_openstack.json b/sdv/pdf/template/cloud_openstack.json
new file mode 100755
index 0000000..30b297d
--- /dev/null
+++ b/sdv/pdf/template/cloud_openstack.json
@@ -0,0 +1,111 @@
+{
+ "_comment_head": "Maintainer - Sridhar Rao <sridhar.rao@spirent.com>",
+ "vim_info": {
+ "vim_name": " ",
+ "vim_id": " ",
+ "vendor": " ",
+ "version": " ",
+ "installer": "",
+ "deployment_style": "",
+ "container_orchestrator": "",
+ "storage_type": ""
+ },
+ "vim_functional": {
+ "scheduler_filters": "",
+ "cpu_allocation_ratio": ""
+ },
+ "jumphost_info": {
+ "ip": "",
+ "name": ""
+ },
+ "undercloud_ook": {
+ "dns": {
+ "cluster_domain": "",
+ "service_ip": ""
+ },
+ "etcd": {
+ "service_ip": "",
+ "container_port": "",
+ "haproxy_port": ""
+ },
+ "masters": [
+ {
+ "hostname": ""
+ }
+ ],
+ "networking": {
+ "type": "",
+ "interface_used": "",
+ "api_service_ip": "",
+ "etcd_service_ip": "",
+ "pod_cidr": "",
+ "service_cidr": "",
+ "apiserver_port": "",
+ "haproxy_port": "",
+ "servicenode_port_range": ""
+ },
+ "kvps": [
+ {
+ "key": "",
+ "value": ""
+ }
+ ]
+ },
+ "undercloud_ooo": {
+ "host_name": "",
+ "local_ip": "",
+ "public_host": "",
+ "admin_host": "",
+ "local_interface": "",
+ "inspection_interface": "",
+ "networking": {
+ "ctrlplane_cidr": "",
+ "ctrlplane_ip_start": "",
+ "ctrlplane_ip_end": "",
+ "inspection_range": "",
+ "gateway": ""
+ }
+ },
+ "_comment_sw1": "Software Begins",
+ "undercloud_sw_profiles": [
+ {
+ "profile_name": "",
+ "sw_list": [
+ {
+ "name": "",
+ "version": ""
+ }
+ ]
+ }
+ ],
+ "openstack_sw_profiles": [
+ {
+ "profile_name": "",
+ "sw_list": [
+ {
+ "name": "",
+ "version": ""
+ }
+ ]
+ }
+ ],
+ "infra_sw_profiles": [
+ {
+ "profile_name": "",
+ "sw_list": [
+ {
+ "name": "",
+ "version": ""
+ }
+ ]
+ }
+ ],
+ "software_set": [
+ {
+ "set_name": "",
+ "undercloud_profile": "",
+ "infrasw_profile": "",
+ "openstack_profile": ""
+ }
+ ]
+} \ No newline at end of file
diff --git a/sdv/valid b/sdv/valid
deleted file mode 100755
index e06afdd..0000000
--- a/sdv/valid
+++ /dev/null
@@ -1,276 +0,0 @@
-#!/usr/bin/env python3
-
-# Copyright 2020 Spirent Communications
-#
-# 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.
-
-"""VALID main script.
-"""
-
-import logging
-import os
-import sys
-import argparse
-import time
-import datetime
-from conf import settings
-import core.component_factory as component_factory
-from core.loader import Loader
-
-VERBOSITY_LEVELS = {
- 'debug': logging.DEBUG,
- 'info': logging.INFO,
- 'warning': logging.WARNING,
- 'error': logging.ERROR,
- 'critical': logging.CRITICAL
-}
-
-_CURR_DIR = os.path.dirname(os.path.realpath(__file__))
-_LOGGER = logging.getLogger()
-
-def parse_arguments():
- """
- Parse command line arguments.
- """
- class _SplitValidationTypesAction(argparse.Action):
- """
- Parse and split '--test-params' arguments.
-
- This expects either a single list validation types
- e.g: --validation-type 'configuration, state'
- """
- def __call__(self, parser, namespace, values, option_string=None):
- values = values.strip()
- input_list = values.split(',')
- print(input_list)
- parameter_list = []
- for vtype in input_list:
- vtype = vtype.strip()
- if vtype:
- vtype = vtype.lower()
- parameter_list.append(str(vtype))
- # results = {'_PARAMS_LIST':parameter_list}
- setattr(namespace, self.dest, parameter_list)
-
- parser = argparse.ArgumentParser(prog=__file__, formatter_class=
- argparse.ArgumentDefaultsHelpFormatter)
- parser.add_argument('--version', action='version', version='%(prog)s 0.1')
- parser.add_argument('--list-validations', action='store_true',
- help='list all validations')
- parser.add_argument('--list-vurls', action='store_true',
- help='list all Software pre-dep Hyperlinks validations and exit')
- parser.add_argument('--list-vconfig', action='store_true',
- help='list all Software pre-dep Configuration validations and exit')
- parser.add_argument('--list-vstate', action='store_true',
- help='list all Software post-dep State validations and exit')
- parser.add_argument('--list-vsecurity', action='store_true',
- help='list all Software post-dep Security validations and exit')
- parser.add_argument('--list-vnwlinks', action='store_true',
- help='list all Network-Links validations and exit')
- parser.add_argument('--list-vresmod', action='store_true',
- help='list all Resource-Model validations and exit')
- parser.add_argument('--validation', action=_SplitValidationTypesAction,
- help='The type of Validation to perform - resmod, nwlinks,\
- urls, configuration, state, security')
- args = vars(parser.parse_args())
-
- return args
-
-
-def configure_logging(level):
- """Configure logging.
- """
- name, ext = os.path.splitext(settings.getValue('LOG_FILE_DEFAULT'))
- rename_default = "{name}_{uid}{ex}".format(name=name,
- uid=settings.getValue(
- 'LOG_TIMESTAMP'),
- ex=ext)
- log_file_default = os.path.join(
- settings.getValue('RESULTS_PATH'), rename_default)
- _LOGGER.setLevel(logging.DEBUG)
- stream_logger = logging.StreamHandler(sys.stdout)
- stream_logger.setLevel(VERBOSITY_LEVELS[level])
- stream_logger.setFormatter(logging.Formatter(
- '[%(levelname)-5s] %(asctime)s : (%(name)s) - %(message)s'))
- _LOGGER.addHandler(stream_logger)
- file_logger = logging.FileHandler(filename=log_file_default)
- file_logger.setLevel(logging.DEBUG)
- file_logger.setFormatter(logging.Formatter(
- '%(asctime)s : %(message)s'))
- _LOGGER.addHandler(file_logger)
-
-def handle_list_options(args):
- """ Process --list cli arguments if needed
-
- :param args: A dictionary with all CLI arguments
- """
- if args['list_vurls']:
- print(Loader().get_swpreurlsvalidators_printable())
- sys.exit(0)
-
- if args['list_vconfig']:
- print(Loader().get_swpreconfigvalidators_printable())
- sys.exit(0)
-
- if args['list_vstate']:
- print(Loader().get_swpoststatevalidators_printable())
- sys.exit(0)
-
- if args['list_vsecurity']:
- print(Loader().get_swpostsecurityvalidators_printable())
- sys.exit(0)
-
- if args['list_vnwlinks']:
- print(Loader().get_nwlinksvalidators_printable())
- sys.exit(0)
-
-
-# Sflo: questions/3041986/apt-command-line-interface-like-yes-no-input
-def sanity_check(question, default="yes"):
- """Ask a yes/no question via raw_input() and return their answer.
-
- "question" is a string that is presented to the user.
- "default" is the presumed answer if the user just hits <Enter>.
- It must be "yes" (the default), "no" or None (meaning
- an answer is required of the user).
-
- The "answer" return value is True for "yes" or False for "no".
- """
- valid = {"yes": True, "y": True, "ye": True,
- "no": False, "n": False}
- if default is None:
- prompt = " [y/n] "
- elif default == "yes":
- prompt = " [Y/n] "
- elif default == "no":
- prompt = " [y/N] "
- else:
- raise ValueError("invalid default answer: '%s'" % default)
-
- while True:
- sys.stdout.write(question + prompt)
- choice = input().lower()
- if default is not None and choice == '':
- return valid[default]
- elif choice in valid:
- return valid[choice]
- else:
- sys.stdout.write("Please respond with 'yes' or 'no' "
- "(or 'y' or 'n').\n")
-
-
-def main():
- """Main function.
- """
- args = parse_arguments()
-
- if not sanity_check("Have you configured the testcases ?"):
- print("Please configure testcases and rerun")
- sys.exit(1)
-
- print(args)
-
- # define the timestamp to be used by logs and results
- date = datetime.datetime.fromtimestamp(time.time())
- timestamp = date.strftime('%Y-%m-%d_%H-%M-%S')
- settings.setValue('LOG_TIMESTAMP', timestamp)
-
-
- # configure settings
- settings.load_from_dir(os.path.join(_CURR_DIR, 'conf'))
-
- # if required, handle list-* operations
- handle_list_options(args)
-
- results_dir = "results_" + timestamp
- results_path = os.path.join(settings.getValue('LOG_DIR'), results_dir)
- settings.setValue('RESULTS_PATH', results_path)
- # create results directory
- if not os.path.exists(results_path):
- os.makedirs(results_path)
-
- configure_logging(settings.getValue('VERBOSITY'))
-
- loader = Loader()
- validations = settings.getValue('VALIDATIONS')
-
- # Get the Validation Types.
- if args['validation']:
- validations = args.validation_type
-
- validator_objs = []
- for validation in validations:
- if 'urls' in validation:
- validators = loader.get_swpreurlsvalidators()
- if settings.getValue('SW_PRE_URLS_VALIDATOR') not in validators:
- _LOGGER.error('There are no urls validators matching \'%s\' found in'
- ' \'%s\'. Exiting...', settings.getValue('SW_PRE_URLS_VALIDATOR'),
- settings.getValue('SW_PRE_URLS_VALID_DIR'))
- sys.exit(1)
- validator_ctrl = component_factory.create_swpreurlsvalidator(
- loader.get_swpreurlsvalidator_class())
- validator_objs.append(validator_ctrl)
- if 'configuration' in validation:
- validators = loader.get_swpreconfigvalidators()
- if settings.getValue('SW_PRE_CONFIG_VALIDATOR') not in validators:
- _LOGGER.error('There are no configvalidators matching \'%s\' found in'
- ' \'%s\'. Exiting...', settings.getValue('SW_PRE_CONFIG_VALIDATOR'),
- settings.getValue('SW_PRE_CONFIG_VALID_DIR'))
- sys.exit(1)
- validator_ctrl = component_factory.create_swpreconfigvalidator(
- loader.get_swpreconfigvalidator_class())
- validator_objs.append(validator_ctrl)
- if 'state' in validation:
- validators = loader.get_swpoststatevalidators()
- if settings.getValue('SW_POST_STATE_VALIDATOR') not in validators:
- _LOGGER.error('There are no statevalidators matching \'%s\' found in'
- ' \'%s\'. Exiting...', settings.getValue('SW_POST_STATE_VALIDATOR'),
- settings.getValue('SW_POST_STATE_VALID_DIR'))
- sys.exit(1)
- validator_ctrl = component_factory.create_swpoststatevalidator(
- loader.get_swpoststatevalidator_class())
- validator_objs.append(validator_ctrl)
- if 'security' in validation:
- validators = loader.get_swpostsecurityvalidators()
- if settings.getValue('SW_POST_SECURITY_VALIDATOR') not in validators:
- _LOGGER.error('There are no securityvalidators matching \'%s\' found in'
- ' \'%s\'. Exiting...', settings.getValue('SW_POST_SECURITY_VALIDATOR'),
- settings.getValue('SW_POST_SECURITY_VALID_DIR'))
- sys.exit(1)
- validator_ctrl = component_factory.create_swpostsecurityvalidator(
- loader.get_swpostsecurityvalidator_class())
- validator_objs.append(validator_ctrl)
- if 'nwlinks' in validation:
- validators = loader.get_nwlinksvalidators()
- if settings.getValue('NW_LINKS_VALIDATOR') not in validators:
- _LOGGER.error('There are no nwlinksvalidators matching \'%s\' found in'
- ' \'%s\'. Exiting...', settings.getValue('NW_LINKS_VALIDATOR'),
- settings.getValue('NW_LINKS_VALID_DIR'))
- sys.exit(1)
- validator_ctrl = component_factory.create_nwlinksvalidator(
- loader.get_nwlinksvalidator_class())
- validator_objs.append(validator_ctrl)
- if 'resmod' in validation:
- validators = loader.get_resmodvalidators()
- if settings.getValue('RES_MOD_VALIDATOR') not in validators:
- _LOGGER.error('There are no resmodvalidators matching \'%s\' found in'
- ' \'%s\'. Exiting...', settings.getValue('RES_MOD_VALIDATOR'),
- settings.getValue('RES_MOD_VALID_DIR'))
- sys.exit(1)
- validator_ctrl = component_factory.create_resmodvalidator(
- loader.get_resmodvalidator_class())
- validator_objs.append(validator_ctrl)
-
-
-if __name__ == "__main__":
- main()