summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-19 10:52:12 +0000
committerGerrit Code Review <review@openstack.org>2017-06-19 10:52:12 +0000
commit7661a93c79627a91a4b12e2b4ac01831ff80aa25 (patch)
tree375a1dc5d03d0ca1e458cb4cbe4e527d7cbe5965
parenteed524e77143aee9027c1880707712d9fae66fee (diff)
parente23fcfe93aa2755903e4a7f4b1d81ae4612fb88d (diff)
Merge "Use correct user password as occ credential"
-rw-r--r--heat/engine/resources/server_base.py3
-rw-r--r--heat/tests/openstack/nova/test_server.py56
2 files changed, 58 insertions, 1 deletions
diff --git a/heat/engine/resources/server_base.py b/heat/engine/resources/server_base.py
index a75e4f0..7b5174a 100644
--- a/heat/engine/resources/server_base.py
+++ b/heat/engine/resources/server_base.py
@@ -154,7 +154,8 @@ class BaseServer(stack_user.StackUser):
154 154
155 elif (self.transport_poll_server_heat(props) or 155 elif (self.transport_poll_server_heat(props) or
156 self.transport_zaqar_message(props)): 156 self.transport_zaqar_message(props)):
157 self.password = uuid.uuid4().hex 157 if self.password is None:
158 self.password = uuid.uuid4().hex
158 self._create_user() 159 self._create_user()
159 160
160 self._register_access_key() 161 self._register_access_key()
diff --git a/heat/tests/openstack/nova/test_server.py b/heat/tests/openstack/nova/test_server.py
index b6f950c..d414667 100644
--- a/heat/tests/openstack/nova/test_server.py
+++ b/heat/tests/openstack/nova/test_server.py
@@ -1725,6 +1725,62 @@ class ServersTest(common.HeatTestCase):
1725 md['os-collect-config']['request']['metadata_url'] = 'the_url' 1725 md['os-collect-config']['request']['metadata_url'] = 'the_url'
1726 self.assertEqual(expected_md, server.metadata_get()) 1726 self.assertEqual(expected_md, server.metadata_get())
1727 1727
1728 def test_update_transport_heat_to_zaqar(self):
1729 stack, server = self._server_create_software_config_poll_heat()
1730 password = server.password
1731 self.assertEqual({
1732 'os-collect-config': {
1733 'heat': {
1734 'auth_url': 'http://server.test:5000/v2.0',
1735 'password': password,
1736 'project_id': '8888',
1737 'resource_name': 'WebServer',
1738 'stack_id': 'software_config_s/%s' % stack.id,
1739 'user_id': '1234'
1740 },
1741 'collectors': ['ec2', 'heat', 'local'],
1742 },
1743 'deployments': []
1744 }, server.metadata_get())
1745
1746 update_props = self.server_props.copy()
1747 update_props['software_config_transport'] = 'ZAQAR_MESSAGE'
1748 update_template = server.t.freeze(properties=update_props)
1749 zcc = self.patchobject(zaqar.ZaqarClientPlugin, 'create_for_tenant')
1750 zc = mock.Mock()
1751 zcc.return_value = zc
1752 queue = mock.Mock()
1753 zc.queue.return_value = queue
1754
1755 self.rpc_client = mock.MagicMock()
1756 server._rpc_client = self.rpc_client
1757 self.rpc_client.create_software_config.return_value = None
1758 scheduler.TaskRunner(server.update, update_template)()
1759 self.assertEqual((server.UPDATE, server.COMPLETE), server.state)
1760 password_1 = server.password
1761 self.assertEqual(password, password_1)
1762 self.assertEqual({
1763 'os-collect-config': {
1764 'zaqar': {
1765 'user_id': '1234',
1766 'password': password_1,
1767 'auth_url': 'http://server.test:5000/v2.0',
1768 'project_id': '8888',
1769 'queue_id': server.data().get('metadata_queue_id')
1770 },
1771 'heat': {
1772 'auth_url': None,
1773 'password': None,
1774 'project_id': None,
1775 'resource_name': None,
1776 'stack_id': None,
1777 'user_id': None
1778 },
1779 'collectors': ['ec2', 'zaqar', 'local']
1780 },
1781 'deployments': []
1782 }, server.metadata_get())
1783
1728 def test_server_update_nova_metadata(self): 1784 def test_server_update_nova_metadata(self):
1729 return_server = self.fc.servers.list()[1] 1785 return_server = self.fc.servers.list()[1]
1730 server = self._create_test_server(return_server, 1786 server = self._create_test_server(return_server,