diff --git a/.gitignore b/.gitignore index ecf222b..1b7f122 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ __pycache__ dist *.egg-info +build diff --git a/README.md b/README.md index 8f6ff19..f56162b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # vtds-cluster-common + The common vTDS Cluster layer plugin implementation + ## Description + This repository contains the implementation of a vTDS Cluster layer plugin that should be usable by any vTDS configuration to create a vTDS cluster. The plugin includes an implementation of the vTDS diff --git a/vtds_cluster_common/base_config.py b/vtds_cluster_common/base_config.py index 1b3db45..e099c6f 100644 --- a/vtds_cluster_common/base_config.py +++ b/vtds_cluster_common/base_config.py @@ -20,8 +20,8 @@ # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -"""Public API for the common platform layer base configuration data, this -gives callers access to the Platform's BaseConfig API and prevents +"""Public API for the common cluster layer base configuration data, this +gives callers access to the Cluster's BaseConfig API and prevents them from seeing the private implementation of the API. """ @@ -31,7 +31,7 @@ class BaseConfig: """BaseConfig class presents operations on the base configuration - of the platform layer to callers. + of the cluster layer to callers. """ def __init__(self): @@ -41,7 +41,7 @@ def __init__(self): self.private = PrivateBaseConfig() def get_base_config(self): - """Retrieve the base configuration for the platform in the + """Retrieve the base configuration for the cluster in the form of a python data structure for use in composing and overall vTDS configuration. @@ -59,7 +59,7 @@ def get_base_config_text(self): def get_test_overlay(self): """Retrieve a pre-defined test overlay configuration in the form of a python data structure for use in composing vTDS - configurations for testing with this platform layer. + configurations for testing with this cluster layer. """ return self.private.get_test_overlay() diff --git a/vtds_cluster_common/cluster.py b/vtds_cluster_common/cluster.py index 7b31d8d..a0ce908 100644 --- a/vtds_cluster_common/cluster.py +++ b/vtds_cluster_common/cluster.py @@ -20,9 +20,9 @@ # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -"""Public API module for the GCP provider layer, this gives callers -access to the Provider API and prevents them from seeing the private -GCP specific implementation of the API. +"""Public API module for the common cluster layer, this gives callers +access to the Cluster API and prevents them from seeing the private +implementation of the API. """ @@ -31,15 +31,15 @@ class LayerAPI: - """ Provider class presents the Provider API to callers. + """ Presents the Cluster API to callers. """ def __init__(self, stack, config, build_dir): """Constructor. Constructs the public API to be used for - building and interacting with a provider layer based on the + building and interacting with a cluster layer based on the full stack of vTDS layers loaded, the 'config' data structure provided and an absolute path to the 'build_dir' which is a - scratch area provided by the caller for any provider layer + scratch area provided by the caller for any cluster layer build activities to take place. """ @@ -52,20 +52,20 @@ def __init__(self, stack, config, build_dir): self.private = PrivateCluster(stack, cluster_config, build_dir) def prepare(self): - """Prepare the provider for deployment. + """Prepare the cluster for deployment. """ self.private.prepare() def validate(self): """Run any configuration validation that may be appropriate - for the provider layer. + for the cluster layer. """ self.private.validate() def deploy(self): - """Deploy the provider (must call prepare() prior to this + """Deploy the cluster (must call prepare() prior to this call. """ @@ -73,7 +73,7 @@ def deploy(self): def remove(self): """Remove operation. This will remove all resources - provisioned for the provider layer. + provisioned for the cluster layer. """ self.private.remove() diff --git a/vtds_cluster_common/private/config.py b/vtds_cluster_common/private/config.py index e6d241f..c5b0f0a 100644 --- a/vtds_cluster_common/private/config.py +++ b/vtds_cluster_common/private/config.py @@ -20,88 +20,21 @@ # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -"""Private layer implementation module for the common cluster layer base -configuration. +"""Private layer implementation module for the layer base configuration. """ - -import os.path -import yaml -from vtds_base import ContextualError +from vtds_base import BaseConfiguration from . import CONFIG_DIR -class PrivateBaseConfig: +# pylint: disable=too-few-public-methods +class PrivateBaseConfig(BaseConfiguration): """BaseConfig class presents operations on the base configuration - of the provider layer to callers. + of the layer to callers. """ def __init__(self): """Constructor """ - - def get_base_config(self): - """Retrieve the base configuration for the provider in the - form of a python data structure for use in composing and - overall vTDS configuration. - - """ - config = os.path.join(CONFIG_DIR, "config.yaml") - try: - with open(config, 'r', encoding='UTF-8') as config_stream: - return yaml.safe_load(config_stream) - except OSError as err: - raise ContextualError( - "cannot open common cluster base config file '%s' - %s" % ( - config, str(err) - ) - ) from err - except yaml.YAMLError as err: - raise ContextualError( - "error parsing common cluster base config file '%s' - %s" % ( - config, str(err) - ) - ) from err - - def get_base_config_text(self): - """Retrieve the text of the base configuration file as a text - string (UTF-8 encoded) for use in displaying the configuration - to users. - - """ - config = os.path.join(CONFIG_DIR, "config.yaml") - try: - with open(config, 'r', encoding='UTF-8') as config_stream: - return config_stream.read() - except OSError as err: - raise ContextualError( - "cannot open common cluster base config file '%s' - %s" % ( - config, str(err) - ) - ) from err - - def get_test_overlay(self): - """Retrieve a pre-defined test overlay configuration in the - form of a python data structure for use in composing vTDS - configurations for testing with this provider layer. - - """ - config = os.path.join(CONFIG_DIR, "test_overlay.yaml") - try: - with open(config, 'r', encoding='UTF-8') as config_stream: - return yaml.safe_load(config_stream) - except OSError as err: - raise ContextualError( - "cannot open common cluster test config overlay file " - "'%s' - %s" % ( - config, str(err) - ) - ) from err - except yaml.YAMLError as err: - raise ContextualError( - "error parsing common cluster test config overlay file " - "'%s' - %s" % ( - config, str(err) - ) - ) from err + super().__init__("common cluster", CONFIG_DIR) diff --git a/vtds_cluster_common/private/config/config.yaml b/vtds_cluster_common/private/config/config.yaml index ff44c3b..2fa81ad 100644 --- a/vtds_cluster_common/private/config/config.yaml +++ b/vtds_cluster_common/private/config/config.yaml @@ -1,21 +1,2 @@ cluster: - source: - # This identifies the python module containing the common platform - # layer for vTDS, its version and the URL of the pip index. Any - # necessary authentication is assumed to be handled by a '.netrc' - # or may be injected using ARTIFACTORY_USER and - # ARTIFACTORY_PASSWORD environments. - # - # This is included in the base configuration not to be used from - # there, but as an example of what it would look like in your - # first system configuration overlay to import this provider layer - # implementation into your vTDS system. You must put something - # like this in the first system configuration overlay your - # deployment uses. Without it there will be no provider layer in - # your vTDS build. The layer sources are the only special pieces - # of the configuration because they are needed to get the process - # going. - index_url: "https://artifactory.algol60.net/artifactory/csm-python-modules/simple" - package: vtds-cluster-common - version: "latest" # Any version or "latest" to take the latest version nodes: {} diff --git a/vtds_cluster_common/private/private_cluster.py b/vtds_cluster_common/private/private_cluster.py index 1ff614c..dbd6905 100644 --- a/vtds_cluster_common/private/private_cluster.py +++ b/vtds_cluster_common/private/private_cluster.py @@ -20,7 +20,7 @@ # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -"""Private layer implementation module for the GCP cluster. +"""Private layer implementation module for the common cluster. """