Added action that returns nova-compute node name.

Closes-Bug: #1911012
Change-Id: Id9a7c3a675072ed4da3b9cb9fc997e70895205cb
This commit is contained in:
Martin Kalcok 2021-03-26 16:32:40 +01:00
parent e76484fcd0
commit 38efefccdf
5 changed files with 25 additions and 0 deletions

View File

@ -301,6 +301,7 @@ deployed then see file `actions.yaml`.
* `disable`
* `enable`
* `hugepagereport`
* `node-name`
* `openstack-upgrade`
* `pause`
* `register-to-cloud`

View File

@ -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:

View File

@ -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,
}

1
actions/node-name Symbolic link
View File

@ -0,0 +1 @@
cloud.py

View File

@ -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})