diff --git a/README.md b/README.md index 6b0a34aa..8b0b2728 100644 --- a/README.md +++ b/README.md @@ -301,6 +301,7 @@ deployed then see file `actions.yaml`. * `disable` * `enable` * `hugepagereport` +* `node-name` * `openstack-upgrade` * `pause` * `register-to-cloud` diff --git a/actions.yaml b/actions.yaml index 55826e8d..2c885164 100644 --- a/actions.yaml +++ b/actions.yaml @@ -12,6 +12,8 @@ register-to-cloud: README.md, section 'Cloud downscaling'. openstack-upgrade: description: Perform openstack upgrades. Config option action-managed-upgrade must be set to True. +node-name: + description: Return nova-compute node name. This can be used to identify this unit in the list of nova-compute services. pause: description: Pause the nova_compute unit. This action will stop nova_compute services. resume: diff --git a/actions/cloud.py b/actions/cloud.py index d2534139..f02fb78e 100755 --- a/actions/cloud.py +++ b/actions/cloud.py @@ -136,11 +136,16 @@ def register_to_cloud(): }) +def node_name(): + function_set({'node-name': cloud_utils.service_hostname()}) + + ACTIONS = { 'disable': disable, 'enable': enable, 'remove-from-cloud': remove_from_cloud, 'register-to-cloud': register_to_cloud, + 'node-name': node_name, } diff --git a/actions/node-name b/actions/node-name new file mode 120000 index 00000000..126acea1 --- /dev/null +++ b/actions/node-name @@ -0,0 +1 @@ +cloud.py \ No newline at end of file diff --git a/unit_tests/test_actions_cloud.py b/unit_tests/test_actions_cloud.py index b2cbdf4d..81d89da7 100644 --- a/unit_tests/test_actions_cloud.py +++ b/unit_tests/test_actions_cloud.py @@ -231,3 +231,19 @@ class TestRegisterToCloud(_ActionTestCase): cloud.service_resume.assert_called_with('nova-compute') cloud.function_fail.assert_not_called() + + +class TestNodeName(_ActionTestCase): + NAME = 'node-name' + + def setUp(self, to_mock=None): + super(TestNodeName, self).setUp() + + def test_get_compute_name(self): + """Test action 'node-name'""" + hostname = 'compute0.cloud' + cloud.cloud_utils.service_hostname.return_value = hostname + + self.call_action() + + cloud.function_set.assert_called_with({'node-name': hostname})