diff options
author | spisarski <s.pisarski@cablelabs.com> | 2017-11-28 13:16:54 -0700 |
---|---|---|
committer | spisarski <s.pisarski@cablelabs.com> | 2017-11-28 13:16:54 -0700 |
commit | 530ca566f0554d69ac11dd3b919be25c2e689ed6 (patch) | |
tree | 1a2013266bfaa0ce467b38c7b3ffcf64eac8408d /snaps/openstack/utils/magnum_utils.py | |
parent | 0e06ebe62fcff9b491a0edd89bdf511f88d091e7 (diff) |
Added cluster template creator/state machine class.
Created class and tests for creating and managing cluster templates.
JIRA: SNAPS-235
Change-Id: Ia91aef9507fc39d1814dce03169aab0b784721a6
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/utils/magnum_utils.py')
-rw-r--r-- | snaps/openstack/utils/magnum_utils.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/snaps/openstack/utils/magnum_utils.py b/snaps/openstack/utils/magnum_utils.py index c744666..96ba6d1 100644 --- a/snaps/openstack/utils/magnum_utils.py +++ b/snaps/openstack/utils/magnum_utils.py @@ -35,6 +35,36 @@ def magnum_client(os_creds): session=keystone_utils.keystone_session(os_creds)) +def get_cluster_template(magnum, template_config=None, template_name=None): + """ + Returns the first ClusterTemplate domain object that matches the parameters + :param magnum: the Magnum client + :param template_config: a ClusterTemplateConfig object (optional) + :param template_name: the name of the template to lookup + :return: ClusterTemplate object or None + """ + name = None + if template_config: + name = template_config.name + elif template_name: + name = template_name + + os_templates = magnum.cluster_templates.list() + for os_template in os_templates: + if os_template.name == name: + return __map_os_cluster_template(os_template) + + +def get_cluster_template_by_id(magnum, tmplt_id): + """ + Returns the first ClusterTemplate domain object that matches the parameters + :param magnum: the Magnum client + :param tmplt_id: the template's ID + :return: ClusterTemplate object or None + """ + return __map_os_cluster_template(magnum.cluster_templates.get(tmplt_id)) + + def create_cluster_template(magnum, cluster_template_config): """ Creates a Magnum Cluster Template object in OpenStack |