Ejemplo n.º 1
0
    def test_non_owner_lessee_cannot_attach_volume(self):
        """Tests non owner and non lessee node volume attach functionality.

        Tests that a project which is not set to a node's 'owner' nor
            'lessee' cannot run `esi node volume attach`
            Test steps:
            1) Set node state to 'available'
            2) Transfer volume to project
            4) Project1 creates a port on storage network
            4) Check that the project cannot run
               `esi node volume attach --port <port> <node> <volume>`
            5) (cleanup) Delete the port created in step 4
            6) (cleanup) Transfer volume back to admin

        """

        node = utils.node_show(self.clients['admin'], self.node)
        if node['provision_state'] != 'available':
            utils.node_set_provision_state(self.clients['admin'], node['name'],
                                           'provide')
        utils.volume_transfer_request_create_and_accept(
            self.clients['admin'], self.clients['project1-member'],
            self.volume)
        self.addCleanup(utils.volume_transfer_request_create_and_accept,
                        self.clients['project1-member'], self.clients['admin'],
                        self.volume)
        port = utils.port_create(self.clients['project1-member'],
                                 self.storage_network)
        self.addCleanup(utils.port_delete, self.clients['admin'], port['name'])

        self.assertRaises(exceptions.CommandFailed,
                          utils.esi_node_volume_attach,
                          self.clients['project1-member'], port['name'],
                          node['name'], self.volume)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    def test_nonadmin_no_network_cannot_attach(self):
        """Tests nonadmin no-permission network node operation

        Tests that a nonadmin who is an owner/lessee cannot
        attach a private network that they do not have permission
        to use 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'])

        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'])

        node = utils.node_show(self.clients['project1-member'], self.node)
        utils.node_set_provision_state(self.clients['project1-member'],
                                       self.node, 'manage')
        self.addCleanup(utils.node_set_provision_state,
                        self.clients['admin'],
                        self.node, 'undeploy')

        self.assertRaises(exceptions.CommandFailed,
                          utils.esi_node_network_attach,
                          self.clients['project1-member'],
                          self.node,
                          port['name'])
Ejemplo n.º 4
0
    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'])
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    def test_lessee_can_attach_volume(self):
        """Tests node lessee can attach volume.

        Tests that an lessee with no access to the volume
            cannot run `esi node volume attach`
            Test steps:
            1) Set project1 to the lessee of the node
            2) Transfer volume to project
            3) Project1 creates a port on storage network
            4) Project1 Set node state to 'available'
            5) Project1 runs
               `esi node volume attach --port <port> <node> <volume>`
            6) (cleanup) Undeploy the node
            7) (cleanup) Delete the port created in step 3
            8) (cleanup) Transfer volume back to admin
            9) (cleanup) Reset node lessee

        """

        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'])
        utils.volume_transfer_request_create_and_accept(
            self.clients['admin'], self.clients['project1-member'],
            self.volume)
        self.addCleanup(utils.volume_transfer_request_create_and_accept,
                        self.clients['project1-member'], self.clients['admin'],
                        self.volume)

        port = utils.port_create(self.clients['project1-member'],
                                 self.storage_network)
        self.addCleanup(utils.port_delete, self.clients['admin'], port['name'])

        node = utils.node_show(self.clients['project1-member'], self.node)
        if node['provision_state'] != 'available':
            utils.node_set_provision_state(self.clients['project1-member'],
                                           node['name'], 'provide')

        utils.esi_node_volume_attach(self.clients['project1-member'],
                                     port['name'], node['name'], self.volume)
        self.addCleanup(utils.node_set_provision_state, self.clients['admin'],
                        node['name'], 'undeploy')
Ejemplo n.º 7
0
    def test_lessee_volume_no_access_cannot_attach_volume(self):
        """Tests no volume access node volume attach functionality.

        Tests that an lessee with no access to the volume
            cannot run `esi node volume attach`
            Test steps:
            1) Set node state to 'available'
            2) Set project1 to the lessee of the node
            3) Project2 creates a private volume
            4) Project1 creates a port on storage network
            5) Check that project1 cannot run
               `esi node volume attach --port <port> <node> <volume>`
            6) (cleanup) Delete the port created in step 4
            7) (cleanup) Delete the volume created in step 3
            8) (cleanup) Reset node lessee

        """

        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'] != 'available':
            utils.node_set_provision_state(self.clients['project1-member'],
                                           node['name'], 'provide')
        volume = utils.volume_create(self.clients['project2-member'])
        self.addCleanup(utils.volume_delete, self.clients['admin'],
                        volume['id'])
        port = utils.port_create(self.clients['project1-member'],
                                 self.storage_network)
        self.addCleanup(utils.port_delete, self.clients['admin'], port['name'])

        self.assertRaises(exceptions.CommandFailed,
                          utils.esi_node_volume_attach,
                          self.clients['project1-member'], port['name'],
                          node['name'], volume['name'])