Exemple #1
0
    def setUp(self):
        conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
        self.conf = conf
        self.net_name = "lb-mgmt-net"
        conf.config(group="controller_worker",
                    amp_boot_network_list=['1', '2'])
        self.conf = conf

        self.amphora = models.Amphora(compute_id=uuidutils.generate_uuid(),
                                      status='ACTIVE',
                                      lb_network_ip='10.0.0.1',
                                      image_id=uuidutils.generate_uuid())

        self.nova_response = mock.Mock()
        self.nova_response.id = self.amphora.compute_id
        self.nova_response.status = 'ACTIVE'
        self.nova_response.fault = 'FAKE_FAULT'
        setattr(self.nova_response, 'OS-EXT-AZ:availability_zone', None)
        self.nova_response.image = {'id': self.amphora.image_id}

        self.interface_list = mock.MagicMock()
        self.interface_list.net_id = '1'
        self.interface_list.fixed_ips = [mock.MagicMock()]
        self.interface_list.fixed_ips[0] = {'ip_address': '10.0.0.1'}

        self.loadbalancer_id = uuidutils.generate_uuid()
        self.server_group_policy = constants.ANTI_AFFINITY
        self.server_group_id = uuidutils.generate_uuid()

        self.manager = nova_common.VirtualMachineManager()
        self.manager.manager = mock.MagicMock()
        self.manager.server_groups = mock.MagicMock()
        self.manager._nova_client = mock.MagicMock()

        self.nova_response.interface_list.side_effect = [[self.interface_list]]
        self.manager.manager.get.return_value = self.nova_response
        self.manager.manager.create.return_value = self.nova_response
        self.manager.server_groups.create.return_value = mock.Mock()

        self.nova_response.addresses = {self.net_name: [{'addr': '10.0.0.1'}]}

        self.nova_network = mock.Mock()
        self.nova_network.label = self.net_name

        self.server_group_name = 'octavia-lb-' + self.loadbalancer_id
        self.server_group_kwargs = {
            'name': self.server_group_name,
            'policies': [self.server_group_policy]
        }

        self.server_group_mock = mock.Mock()
        self.server_group_mock.name = self.server_group_name
        self.server_group_mock.policy = self.server_group_policy
        self.server_group_mock.id = self.server_group_id

        self.port_id = uuidutils.generate_uuid()
        self.compute_id = uuidutils.generate_uuid()
        self.network_id = uuidutils.generate_uuid()

        super(TestNovaClient, self).setUp()
Exemple #2
0
    def setUp(self):
        net_name = "lb-mgmt-net"
        CONF.set_override(group='networking',
                          name='lb_network_name',
                          override=net_name)
        CONF.set_override(group='keystone_authtoken',
                          name='auth_version',
                          override='2')
        self.amphora = models.Amphora(compute_id=uuidutils.generate_uuid(),
                                      status='ACTIVE',
                                      lb_network_ip='10.0.0.1')

        self.nova_response = mock.Mock()
        self.nova_response.id = self.amphora.compute_id
        self.nova_response.status = 'ACTIVE'
        self.nova_response.addresses = {net_name: [{'addr': '10.0.0.1'}]}

        self.nova_network = mock.Mock()
        self.nova_network.label = net_name

        self.manager = nova_common.VirtualMachineManager()
        self.manager.manager = mock.MagicMock()
        self.manager._nova_client = mock.MagicMock()

        self.manager._nova_client.networks.get.return_value = self.nova_network
        self.manager.manager.get.return_value = self.nova_response
        self.manager.manager.create.return_value = self.nova_response

        super(TestNovaClient, self).setUp()
    def setUp(self):
        CONF.set_override(group='keystone_authtoken',
                          name='auth_version',
                          override='2',
                          enforce_type=True)
        self.net_name = "lb-mgmt-net"
        CONF.set_override(group='networking',
                          name='lb_network_name',
                          override=self.net_name,
                          enforce_type=True)
        CONF.set_override(group='controller_worker',
                          name='amp_boot_network_list',
                          override=[1, 2],
                          enforce_type=True)

        self.amphora = models.Amphora(compute_id=uuidutils.generate_uuid(),
                                      status='ACTIVE',
                                      lb_network_ip='10.0.0.1')

        self.nova_response = mock.Mock()
        self.nova_response.id = self.amphora.compute_id
        self.nova_response.status = 'ACTIVE'

        self.interface_list = mock.MagicMock()
        self.interface_list.net_id = 1
        self.interface_list.fixed_ips = [mock.MagicMock()]
        self.interface_list.fixed_ips[0] = {'ip_address': '10.0.0.1'}

        self.loadbalancer_id = uuidutils.generate_uuid()
        self.server_group_policy = constants.ANTI_AFFINITY
        self.server_group_id = uuidutils.generate_uuid()

        self.manager = nova_common.VirtualMachineManager()
        self.manager.manager = mock.MagicMock()
        self.manager.server_groups = mock.MagicMock()
        self.manager._nova_client = mock.MagicMock()

        self.nova_response.interface_list.side_effect = [[self.interface_list]]
        self.manager.manager.get.return_value = self.nova_response
        self.manager.manager.create.return_value = self.nova_response
        self.manager.server_groups.create.return_value = mock.Mock()

        self.nova_response.addresses = {self.net_name: [{'addr': '10.0.0.1'}]}

        self.nova_network = mock.Mock()
        self.nova_network.label = self.net_name

        self.server_group_name = 'octavia-lb-' + self.loadbalancer_id
        self.server_group_kwargs = {
            'name': self.server_group_name,
            'policies': [self.server_group_policy]
        }

        self.server_group_mock = mock.Mock()
        self.server_group_mock.name = self.server_group_name
        self.server_group_mock.policy = self.server_group_policy
        self.server_group_mock.id = self.server_group_id

        super(TestNovaClient, self).setUp()
        mgmt_port = get_vm_mgmt_port(net_driver, amp.compute_id,
                                     amp.lb_network_ip)
        disable_port(net_driver, mgmt_port)

    return lb_amp_dict


if __name__ == '__main__':
    raw_input('First, please stop octavia house_keeping process, then press '
              'any key to continue...')

    service.prepare_service(sys.argv)
    session = db_api.get_session()
    amp_repo = repo.AmphoraRepository()
    amphealth_repo = repo.AmphoraHealthRepository()
    nova_manager = nova_driver.VirtualMachineManager()
    net_driver = allowed_address_pairs.AllowedAddressPairsDriver()

    # Delete all the amp vms in spare pool and corresponding db records.
    amps = get_spare_amphoras(session)
    LOG.debug("Step 1: Clean up %d amphorae vms in spare pool.", len(amps))

    for amp in amps:
        delete_amp(nova_manager, session, amp_repo, amphealth_repo, amp)

    raw_input('Now, please start octavia house_keeping process, then press '
              'any key to continue...')

    # Wait for filling up the spare pool.
    LOG.debug("Step 2: Waiting for spare pool to fill up again...")
    check_spare_pool(amp_repo, session)