def test_admin_can_node_power_on_off(self): """Tests admin power functionality. Tests that an admin project which is not set to a node's 'owner' nor 'lessee' can run `baremetal node power on <node>` and `baremetal node power off <node>. Test steps: 1) Create a node 2) Check that the project can run `node power on` and `node power off` 3) (cleanup) Delete the node created in step 1. """ node = utils.node_create(self.clients['admin'], name="owned") self.addCleanup(utils.node_delete, self.clients['admin'], node['name']) utils.node_power_on(self.clients['admin'], node['name']) utils.node_power_off(self.clients['admin'], node['name'])
def test_non_owner_lessee_cannot_node_power_on_off(self): """Tests non owner and non lessee power functionality. Tests that a project which is not set to a node's 'owner' nor 'lessee' cannot run `baremetal node power on <node>` or `baremetal node power off <node>. Test steps: 1) Create a node 2) Check that the project cannot run `node power on` or `node power off` 3) (cleanup) Delete the node created in step 1. """ node = utils.node_create(self.clients['admin']) self.addCleanup(utils.node_delete, self.clients['admin'], node['name']) self.assertRaises(exceptions.CommandFailed, utils.node_power_on, self.clients['random-member'], node['name']) self.assertRaises(exceptions.CommandFailed, utils.node_power_off, self.clients['random-member'], node['name'])
def test_lessee_can_node_power_on_off(self): """Tests lessee power funcitonality. Tests that a node's 'lessee' can `baremetal node power on <node>` and `baremetal node power off <node>. Test steps: 1) Create a node and set its 'lessee' field to project_id of a a random project. 2) Check that the project can run `node power on` and `node power off` 3) (cleanup) Delete the node created in step 1. """ node = utils.node_create(self.clients['admin']) self.addCleanup(utils.node_delete, self.clients['admin'], node['name']) utils.node_set(self.clients['admin'], node['name'], 'lessee', self.projects['random']['id']) utils.node_power_on(self.clients['random-member'], node['name']) utils.node_power_off(self.clients['random-member'], node['name'])