diff options
author | Ross Brattain <ross.b.brattain@intel.com> | 2017-05-10 15:08:26 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-05-10 15:08:26 +0000 |
commit | e692c1c8fab6447bc1acfcec612a0867a4c877b5 (patch) | |
tree | d3deec4f1fa5c9fead933b152ed150c9ee7ff1c9 | |
parent | 67da8f2ddb5cbf14bbf0df48b10240ba6ebadbe9 (diff) | |
parent | 30e247e585969b29b5a504c0b6bbd23d07ea80c8 (diff) |
Merge "pass user_data to heat template"
-rw-r--r-- | tests/unit/benchmark/contexts/test_model.py | 21 | ||||
-rw-r--r-- | yardstick/benchmark/contexts/model.py | 4 |
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/unit/benchmark/contexts/test_model.py b/tests/unit/benchmark/contexts/test_model.py index 4a10761f7..122f100de 100644 --- a/tests/unit/benchmark/contexts/test_model.py +++ b/tests/unit/benchmark/contexts/test_model.py @@ -251,4 +251,25 @@ class ServerTestCase(unittest.TestCase): ports=['some-server-some-network-port'], user=self.mock_context.user, key_name=self.mock_context.keypair_name, + user_data='', + scheduler_hints='hints') + + @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate') + def test__add_instance_with_user_data(self, mock_template): + user_data = "USER_DATA" + attrs = { + 'image': 'some-image', 'flavor': 'some-flavor', + 'user_data': user_data, + } + test_server = model.Server('foo', self.mock_context, attrs) + + test_server._add_instance(mock_template, 'some-server', + [], 'hints') + + mock_template.add_server.assert_called_with( + 'some-server', 'some-image', 'some-flavor', + ports=[], + user=self.mock_context.user, + key_name=self.mock_context.keypair_name, + user_data=user_data, scheduler_hints='hints') diff --git a/yardstick/benchmark/contexts/model.py b/yardstick/benchmark/contexts/model.py index 71ee1f3c2..816ec7972 100644 --- a/yardstick/benchmark/contexts/model.py +++ b/yardstick/benchmark/contexts/model.py @@ -150,6 +150,7 @@ class Server(Object): # pragma: no cover self.context = context self.public_ip = None self.private_ip = None + self.user_data = '' if attrs is None: attrs = {} @@ -202,6 +203,8 @@ class Server(Object): # pragma: no cover if "flavor" in attrs: self._flavor = attrs["flavor"] + self.user_data = attrs.get('user_data', '') + Server.list.append(self) @property @@ -252,6 +255,7 @@ class Server(Object): # pragma: no cover ports=port_name_list, user=self.user, key_name=self.keypair_name, + user_data=self.user_data, scheduler_hints=scheduler_hints) def add_to_template(self, template, networks, scheduler_hints=None): |