Add openrc creation per deployment
Change-Id: If8731e7f9fb6baf0a6c1bc939524ae6729abba6c
This commit is contained in:
parent
c30045eecd
commit
c69612e167
3
.gitignore
vendored
3
.gitignore
vendored
@ -56,3 +56,6 @@ ChangeLog
|
|||||||
|
|
||||||
# Configs
|
# Configs
|
||||||
*.conf
|
*.conf
|
||||||
|
|
||||||
|
# openrc files
|
||||||
|
openrc-*
|
||||||
|
@ -281,6 +281,21 @@ def _create_namespace(namespace):
|
|||||||
body={"metadata": {"name": namespace}})
|
body={"metadata": {"name": namespace}})
|
||||||
|
|
||||||
|
|
||||||
|
def _create_openrc(config, namespace):
|
||||||
|
openrc = ["export OS_PROJECT_DOMAIN_NAME=default",
|
||||||
|
"export OS_USER_DOMAIN_NAME=default",
|
||||||
|
"export OS_PROJECT_NAME=%s" % config['openstack_project_name'],
|
||||||
|
"export OS_USERNAME=%s" % config['openstack_user_name'],
|
||||||
|
"export OS_PASSWORD=%s" % config['openstack_user_password'],
|
||||||
|
"export OS_IDENTITY_API_VERSION=3",
|
||||||
|
"export OS_AUTH_URL=http://keystone.%s.svc.cluster.local:%s/v3" %
|
||||||
|
(namespace, config['keystone_public_port'])]
|
||||||
|
with open('openrc-%s' % namespace, 'w') as openrc_file:
|
||||||
|
openrc_file.write("\n".join(openrc))
|
||||||
|
LOG.info("Openrc file for this deployment created at %s/openrc-%s",
|
||||||
|
os.getcwd(), namespace)
|
||||||
|
|
||||||
|
|
||||||
def deploy_components(components=None):
|
def deploy_components(components=None):
|
||||||
if components is None:
|
if components is None:
|
||||||
components = CONF.repositories.names
|
components = CONF.repositories.names
|
||||||
@ -294,3 +309,5 @@ def deploy_components(components=None):
|
|||||||
|
|
||||||
for component in components:
|
for component in components:
|
||||||
deploy_component(component, config)
|
deploy_component(component, config)
|
||||||
|
|
||||||
|
_create_openrc(config, namespace)
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
import filecmp
|
||||||
|
import os
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import yaml
|
import yaml
|
||||||
@ -9,6 +12,10 @@ CONF = cfg.CONF
|
|||||||
|
|
||||||
|
|
||||||
class TestDeploy(base.TestCase):
|
class TestDeploy(base.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestDeploy, self).setUp()
|
||||||
|
self.namespace = "py27_test_delme"
|
||||||
|
|
||||||
def test_fill_cmd(self):
|
def test_fill_cmd(self):
|
||||||
workflow = {}
|
workflow = {}
|
||||||
cmd = {
|
cmd = {
|
||||||
@ -91,6 +98,33 @@ class TestDeploy(base.TestCase):
|
|||||||
}
|
}
|
||||||
self.assertDictEqual(expected, service)
|
self.assertDictEqual(expected, service)
|
||||||
|
|
||||||
|
def test_create_openrc(self):
|
||||||
|
namespace = self.namespace
|
||||||
|
openrc_etalon_file = 'openrc-%s-etalon' % namespace
|
||||||
|
openrc_test_file = 'openrc-%s' % namespace
|
||||||
|
config = {"openstack_project_name": "admin",
|
||||||
|
"openstack_user_name": "admin",
|
||||||
|
"openstack_user_password": "password",
|
||||||
|
"keystone_public_port": 5000}
|
||||||
|
rc = ["export OS_PROJECT_DOMAIN_NAME=default",
|
||||||
|
"export OS_USER_DOMAIN_NAME=default",
|
||||||
|
"export OS_PROJECT_NAME=%s" % config['openstack_project_name'],
|
||||||
|
"export OS_USERNAME=%s" % config['openstack_user_name'],
|
||||||
|
"export OS_PASSWORD=%s" % config['openstack_user_password'],
|
||||||
|
"export OS_IDENTITY_API_VERSION=3",
|
||||||
|
"export OS_AUTH_URL=http://keystone.%s.svc.cluster.local:%s/v3" %
|
||||||
|
(namespace, config['keystone_public_port'])]
|
||||||
|
|
||||||
|
with open(openrc_etalon_file, 'w') as openrc_file:
|
||||||
|
openrc_file.write("\n".join(rc))
|
||||||
|
self.addCleanup(os.remove, openrc_etalon_file)
|
||||||
|
deploy._create_openrc(config, namespace)
|
||||||
|
self.addCleanup(os.remove, openrc_test_file)
|
||||||
|
result = filecmp.cmp(openrc_etalon_file,
|
||||||
|
openrc_test_file,
|
||||||
|
shallow=False)
|
||||||
|
self.assertTrue(result)
|
||||||
|
|
||||||
|
|
||||||
class TestDeployCreateService(base.TestCase):
|
class TestDeployCreateService(base.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user