def test_lessee_attach_and_detach(self): """Tests that lessee can attach/detach a network from a node Test steps: 1) Admin sets lessee of node to User 1. 2) User 1 retrieves information about the node. 3) User 1 sets provision state of the node to manageable. 4) User 1 creates a network. 5) User 1 creates a port on the network. 6) User 1 attaches node to network using port. 7) User 1 detaches node from network 8) (cleanup) Delete the port created in step 5. 9) (cleanup) Delete the network created in step 4. 10) (cleanup) Undeploy the node 11) (cleanup) Reset the lessee of the node. """ node = utils.node_show(self.clients['admin'], self.node) utils.node_set(self.clients['admin'], self.node, 'lessee', self.projects['project1']['id']) self.addCleanup(utils.node_set, self.clients['admin'], self.node, 'lessee', node['lessee']) node = utils.node_show(self.clients['project1-member'], self.node) if node['provision_state'] != 'manageable': utils.node_set_provision_state(self.clients['project1-member'], self.node, 'manage') network = utils.network_create(self.clients['project1-member']) self.addCleanup(utils.network_delete, self.clients['admin'], network['name']) port = utils.port_create(self.clients['project1-member'], network['name']) self.addCleanup(utils.port_delete, self.clients['admin'], port['name']) utils.esi_node_network_attach(self.clients['project1-member'], self.node, port['name']) node_network_list = utils.esi_node_network_list( self.clients['project1-member'], params="--node {0}".format(self.node)) self.assertEqual( node_network_list[0]["Network"], "{0} ({1})".format(network['name'], network['provider:segmentation_id'])) utils.esi_node_network_detach(self.clients['project1-member'], self.node, port['name']) node_network_list = utils.esi_node_network_list( self.clients['project1-member'], params="--node {0}".format(self.node)) self.assertEqual(node_network_list[0]["Network"], None)
def test_nonadmin_no_node_cannot_attach_or_detach(self): """Tests nonadmin no node permission node/network operations Tests that a nonadmin who is neither an owner nor an lessee cannot attach or detach a network from a node Test steps: 1) User 1 creates a network. 2) User 1 creates a port on the network. 3) User 1 fails to attach node to network using port. 4) Admin attaches node to network using port. 5) User 1 fails to detach node from network 6) (cleanup) Detach port from node. 7) (cleanup) Delete the port created in step 2. 8) (cleanup) Delete the network created in step 1. 9) (cleanup) Undeploy the node """ node = utils.node_show(self.clients['admin'], self.node) network = utils.network_create(self.clients['project1-member']) self.addCleanup(utils.network_delete, self.clients['admin'], network['name']) port = utils.port_create(self.clients['project1-member'], network['name']) self.addCleanup(utils.port_delete, self.clients['admin'], port['name']) self.assertRaises(exceptions.CommandFailed, utils.esi_node_network_attach, self.clients['project1-member'], self.node, port['name']) if node['provision_state'] != 'manageable': utils.node_set_provision_state(self.clients['admin'], self.node, 'manage') self.addCleanup(utils.node_set_provision_state, self.clients['admin'], self.node, 'undeploy') utils.esi_node_network_attach(self.clients['admin'], self.node, port['name']) self.addCleanup(utils.esi_node_network_detach, self.clients['admin'], self.node, port['name']) self.assertRaises(exceptions.CommandFailed, utils.esi_node_network_detach, self.clients['project1-member'], self.node, port['name'])
def test_admin_attach_and_detach(self): """Tests that an admin can attach and detach a network from a node Test steps: 1) Admin retrieves information about the node. 2) Admin sets provision state of the node to manageable. 3) Admin creates a network. 4) Admin creates a port on the network. 5) Admin attaches node to network using port. 6) Admin detaches node from network 7) (cleanup) Delete the port created in step 5. 8) (cleanup) Delete the network created in step 4. 9) (cleanup) Undeploy the node. """ node = utils.node_show(self.clients['admin'], self.node) if node['provision_state'] != 'manageable': utils.node_set_provision_state(self.clients['admin'], self.node, 'manage') self.addCleanup(utils.node_set_provision_state, self.clients['admin'], self.node, 'undeploy') network = utils.network_create(self.clients['admin']) self.addCleanup(utils.network_delete, self.clients['admin'], network['name']) port = utils.port_create(self.clients['admin'], network['name']) self.addCleanup(utils.port_delete, self.clients['admin'], port['name']) utils.esi_node_network_attach(self.clients['admin'], self.node, port['name']) node_network_list = utils.esi_node_network_list( self.clients['admin'], params="--node {0}".format(self.node)) self.assertEqual(node_network_list[0]["Network"], "{0} ({1})".format( network['name'], network['provider:segmentation_id'])) utils.esi_node_network_detach(self.clients['admin'], self.node, port['name']) node_network_list = utils.esi_node_network_list( self.clients['admin'], params="--node {0}".format(self.node)) self.assertEqual(node_network_list[0]["Network"], None)