示例#1
0
    def test_lessee_deploy_node_metalsmith(self):
        """Tests lessee metalsmith node deploy functionality.

        Tests that a project which is set to a node's 'lessee'
            can run `metalsmith deploy <image> <node>`
            Test steps:
            1) Admin sets lessee of node to project1
            2) Project1 checks that the node state is 'available'
            3) Project1 successfully runs
               `metalsmith deploy <image> <node>`
            4) (cleanup) Undeploy the node
            5) (cleanup) Reset the 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')

        utils.metalsmith_deploy(self.metalsmith_clients['project1-member'],
                                self.provisioning_image_ident,
                                self.provisioning_network_ident)
        self.addCleanup(utils.node_set_provision_state, self.clients['admin'],
                        node['name'], 'undeploy')
示例#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)
    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'])
示例#4
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')
示例#5
0
    def test_lessee_can_enable_console(self):
        """Tests lessee console functionality.

        Tests that a lessee can perform the steps to setup an ipmitool-socat
        serial console.

        Test steps:
            1) Set lessee of node to random project
            2) Check that the lessee can run command
                `baremetal node console enable <node>`
            3) Check that lessee can run command
                baremetal node console show <node>`
            4) Check that lessee can run command
                `baremetal node console disable <node>`
            5) (cleanup) Set the lessee back to what it was before test
            6) (cleanup) disable console
        """

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

        utils.node_set(self.clients['admin'], self.node, 'lessee',
                       self.projects['random']['id'])
        self.addCleanup(utils.node_set, self.clients['admin'], self.node,
                        'lessee', node['lessee'])

        utils.node_console_enable(self.clients['random-member'], self.node)
        self.addCleanup(utils.node_console_disable,
                        self.clients['admin'],
                        self.node,
                        fail_ok=True)
        time.sleep(10)
        console = utils.node_console_show(self.clients['random-member'],
                                          self.node)
        assert console['console_enabled']

        utils.node_console_disable(self.clients['random-member'], self.node)
        time.sleep(10)
        console = utils.node_console_show(self.clients['random-member'],
                                          self.node)
        assert not console['console_enabled']
示例#6
0
    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'])
示例#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'])