Ejemplo n.º 1
0
    def reboot_overcloud_node(self, reactivate_servers=True):
        """Reboot overcloud node

        This method reboots an overcloud node and may start every server which
        changed its provisioning state to SHUTOFF because of that operation.

        :param start_servers (bool): whether or not to start the servers which
            are hosted on the node after the reboot
        """

        if reactivate_servers:
            servers_to_restart = self.get_running_servers()

        self.power_off_overcloud_node()
        self.power_on_overcloud_node()

        if reactivate_servers:
            for server in servers_to_restart:
                nova.wait_for_server_status(server=server.id,
                                            status='SHUTOFF')
                LOG.debug(f'Server {server.name} with ID {server.id} '
                          f'had a SHUTOFF status before being '
                          f'restarted')
                nova.activate_server(server)
                LOG.debug(f'Server {server.name} with ID {server.id} '
                          f'has a {server.status} status after being '
                          f'restarted')
Ejemplo n.º 2
0
    def test_dhcp_lease_served_when_dhcp_agent_down(self):
        '''Test that DHCP lease is correctly served when DHCP agent is down

        Make sure that the VM will receive IP address after the reboot.
        DHCP agent should be down during the VM reboot. VM should receive
        the same IP address that was assigned to it before the reboot.
        '''
        ping.ping_until_received(self.stack.ip_address).assert_replied()

        self.agents = neutron.list_dhcp_agent_hosting_network(
            self.stack.network)
        self.assertNotEqual(
            [], self.agents, "No DHCP agent found serving network "
            f"'{self.stack.network}'")
        pids = self.get_cmd_pids("dnsmasq", self.stack.network)
        self.stop_agent()

        nova.shutoff_server(self.stack.server_id)
        nova.activate_server(self.stack.server_id)
        ping.ping_until_received(self.stack.ip_address).assert_replied()

        self.start_agent()
        self.wait_processes_destroyed(self.stack.network, pids)
        new_pids = self.get_cmd_pids("dnsmasq", self.stack.network)
        self.assertNotEqual(pids, new_pids)
Ejemplo n.º 3
0
 def validate_created_stack(self):
     # (fressi) must wait cloud init to complete Nova
     # server setup before shutting it down so that we ensure all
     # network devices gets persistent after reboots
     stack = super().validate_created_stack()
     nova.activate_server(server=self.server_id)
     self.wait_for_cloud_init_done()
     return stack
Ejemplo n.º 4
0
 def validate_created_stack(self):
     stack = super().validate_created_stack()
     server = nova.get_server(self.server_id)
     if server.status != 'SHUTOFF':
         if server.status != 'ACTIVE':
             try:
                 nova.activate_server(server)
             except nova.WaitForServerStatusTimeout as ex:
                 raise heat.InvalidStackError(name=self.stack_name) from ex
     return stack
Ejemplo n.º 5
0
def power_on_overcloud_node(server: nova.ServerType,
                            timeout: tobiko.Seconds = 120.,
                            sleep_time: tobiko.Seconds = 5.):
    session = _undercloud.undercloud_keystone_session()
    node = getattr(server, 'OS-EXT-SRV-ATTR:hypervisor_hostname', None)
    if node is None:
        client = nova.get_nova_client(session=session)
        nova.activate_server(client=client,
                             server=server,
                             timeout=timeout,
                             sleep_time=sleep_time)
    else:
        client = ironic.get_ironic_client(session=session)
        ironic.power_on_node(client=client,
                             node=node,
                             timeout=timeout,
                             sleep_time=sleep_time)
Ejemplo n.º 6
0
def start_all_instances():
    """try to start all stopped overcloud instances"""
    for instance in nova.list_servers():
        activated_instance = nova.activate_server(instance)
        time.sleep(3)
        instance_info = 'instance {nova_instance} is {state} on {host}'.format(
            nova_instance=activated_instance.name,
            state=activated_instance.status,
            host=activated_instance._info[  # pylint: disable=W0212
                'OS-EXT-SRV-ATTR:hypervisor_hostname'])
        LOG.info(instance_info)
        if activated_instance.status != 'ACTIVE':
            tobiko.fail(instance_info)
Ejemplo n.º 7
0
 def test_get_console_output(self):
     nova.activate_server(self.stack.server_id)
     output = nova.get_console_output(server=self.stack.server_id,
                                      length=50,
                                      timeout=60.)
     self.assertTrue(output)
Ejemplo n.º 8
0
 def test_activate_server(self, initial_status='SHUTOFF'):
     self.stack.ensure_server_status(initial_status)
     server = nova.activate_server(self.stack.server_id)
     self.assertEqual('ACTIVE', server.status)
     ping.assert_reachable_hosts([self.stack.ip_address])