Exemplo n.º 1
0
def test_get_nova_node_handle(mocker, node_data, fuel_version, expected_name):
    node = create_node(node_data)
    node.env.data.get.return_value = fuel_version
    if expected_name:
        name = node_util.get_nova_node_handle(node)
        assert name == expected_name
    else:
        with pytest.raises(Exception):
            node_util.get_nova_node_handle(node)
Exemplo n.º 2
0
def test_get_nova_node_handle(mocker, node_data, fuel_version, expected_name):
    node = create_node(node_data)
    node.env.data.get.return_value = fuel_version
    if expected_name:
        name = node_util.get_nova_node_handle(node)
        assert name == expected_name
    else:
        with pytest.raises(Exception):
            node_util.get_nova_node_handle(node)
Exemplo n.º 3
0
 def evacuate_host(self):
     controller = env_util.get_one_controller(self.env)
     with ssh.tempdir(controller) as tempdir:
         local_path = os.path.join(
             magic_consts.CWD, 'bin', 'host_evacuation.sh')
         remote_path = os.path.join(tempdir, 'host_evacuation.sh')
         sftp = ssh.sftp(controller)
         sftp.put(local_path, remote_path)
         sftp.chmod(remote_path, stat.S_IRWXO)
         ssh.call(
             [remote_path, node_util.get_nova_node_handle(self.node)],
             node=controller,
         )
Exemplo n.º 4
0
    def shutoff_vms(self):
        controller = env_util.get_one_controller(self.env)
        node_fqdn = node_util.get_nova_node_handle(self.node)

        if nova.do_nova_instances_exist(controller, node_fqdn, "ERROR"):
            raise Exception(
                "There are instances in ERROR state on {hostname},"
                "please fix this problem and start upgrade_node "
                "command again".format(hostname=node_fqdn))

        for instance_id in nova.get_active_instances(controller, node_fqdn):
            nova.run_nova_cmd(
                ["nova", "stop", instance_id], controller, output=False)
        nova.waiting_for_status_completed(controller, node_fqdn, "ACTIVE")
Exemplo n.º 5
0
 def evacuate_host(self):
     controller = env_util.get_one_controller(self.env)
     with ssh.tempdir(controller) as tempdir:
         local_path = os.path.join(magic_consts.CWD, 'bin',
                                   'host_evacuation.sh')
         remote_path = os.path.join(tempdir, 'host_evacuation.sh')
         sftp = ssh.sftp(controller)
         sftp.put(local_path, remote_path)
         sftp.chmod(remote_path, stat.S_IRWXO)
         ssh.call(
             [remote_path,
              node_util.get_nova_node_handle(self.node)],
             node=controller,
         )
Exemplo n.º 6
0
    def evacuate_host(self):
        controller = env_util.get_one_controller(self.env)

        enabled_computes, disabled_computes = nova.get_compute_lists(
            controller)

        node_fqdn = node_util.get_nova_node_handle(self.node)
        if [node_fqdn] == enabled_computes:
            raise Exception("You try to disable last enabled nova-compute "
                            "service on {hostname} in cluster. "
                            "This leads to disable host evacuation. "
                            "Fix this problem and run unpgrade-node "
                            "command again".format(hostname=node_fqdn))

        if nova.do_nova_instances_exist(controller, node_fqdn, "ERROR"):
            raise Exception(
                "There are instances in ERROR state on {hostname},"
                "please fix this problem and start upgrade_node "
                "command again".format(hostname=node_fqdn))

        if node_fqdn in disabled_computes:
            LOG.warn("Node {0} already disabled".format(node_fqdn))
        else:
            nova.run_nova_cmd(
                ["nova", "service-disable", node_fqdn, "nova-compute"],
                controller, False)
        for instance_id in nova.get_active_instances(controller, node_fqdn):
            nova.run_nova_cmd(
                ["nova", "live-migration", instance_id], controller, False)
            nova.waiting_for_status_completed(
                controller, node_fqdn, "MIGRATING")
        if nova.do_nova_instances_exist(controller, node_fqdn):
            raise Exception(
                "There are instances on {hostname} after host-evacuation, "
                "please fix this problem and start upgrade_node "
                "command again".format(hostname=node_fqdn))