Esempio n. 1
0
    def setUp(self):
        super(TestInstanceManager, self).setUp()
        self.conf = cfg.CONF
        self.fake_driver = fakes.fake_driver()
        self.ctx = fakes.fake_worker_context()

        self.neutron = self.ctx.neutron
        self.config(boot_timeout=30)
        self.config(astara_mgt_service_port=5000)
        self.config(max_retries=3)
        self.addCleanup(mock.patch.stopall)

        self.log = mock.Mock()
        self.update_state_p = mock.patch.object(
            instance_manager.InstanceManager,
            'update_state'
        )

        ports = [fake_int_port, fake_ext_port]

        self.fake_driver.get_interfaces.return_value = [
            {'ifname': 'ge0', 'lladdr': fake_mgt_port.mac_address},
            {'ifname': 'ge1', 'lladdr': fake_ext_port.mac_address},
            {'ifname': 'ge2', 'lladdr': fake_int_port.mac_address},
        ]
        self.fake_driver.ports = ports

        self.INSTANCE_INFO = nova.InstanceInfo(
            instance_id='fake_instance_id',
            name='ak-router-83f16d4c-66d8-11e5-938a-525400cfc326',
            management_port=fake_mgt_port,
            ports=[fake_int_port, fake_ext_port, fake_mgt_port],
            image_uuid='9f3dbe8e-66d8-11e5-9952-525400cfc326',
            status='ACTIVE',
            last_boot=(datetime.utcnow() - timedelta(minutes=15)),
        )

        self.ctx.nova_client.get_instance_info.return_value = (
            self.INSTANCE_INFO)
        self.ctx.neutron.get_ports_for_instance.return_value = (
            fake_mgt_port, [fake_int_port, fake_ext_port])

        self.mock_update_state = self.update_state_p.start()
        self.instance_mgr = instance_manager.InstanceManager(
            self.fake_driver,
            'fake_resource_id',
            self.ctx
        )
        self.instance_mgr.instance_info = self.INSTANCE_INFO

        self.next_state = None

        def next_state(*args, **kwargs):
            if self.next_state:
                self.instance_mgr.state = self.next_state
            return self.instance_mgr.state
        self.mock_update_state.side_effect = next_state
 def setUp(self):
     super(TestInstanceGroupManager, self).setUp()
     self.ctx = fakes.fake_worker_context()
     self.fake_driver = fakes.fake_driver()
     self.group_mgr = instance_manager.InstanceGroupManager(
         log=mock.Mock(), resource=self.fake_driver)
     name = 'ak-resource-' + str(uuid.uuid4())
     self.instance_1 = instance_info(mgt_port=fake_mgt_port,
                                     name=name + '_0')
     self.instance_2 = instance_info(mgt_port=fake_add_port,
                                     name=name + '_1')
     self.instances = [self.instance_1, self.instance_2]
     [self.group_mgr.add_instance(i) for i in self.instances]
Esempio n. 3
0
    def setUp(self):
        super(RouterDriverTest, self).setUp()

        self.router_id = 'fake_router_id'
        self.image_uuid = 'fake_router_image_uuid'
        self.flavor = 'fake_router_flavor'
        self.mgt_port = '5555'
        self.ctx = mock.Mock()

        self.config(group='router', image_uuid=self.image_uuid)
        self.config(group='router', instance_flavor=self.flavor)
        self.config(group='router', mgt_service_port=self.mgt_port)

        self.ctx = fakes.fake_worker_context()
        self.addCleanup(mock.patch.stopall)
Esempio n. 4
0
    def setUp(self):
        super(LoadBalancerDriverTest, self).setUp()

        self.loadbalancer_id = 'fake_loadbalancer_id'
        self.image_uuid = 'fake_loadbalancer_image_uuid'
        self.flavor = 'fake_loadbalancer_flavor'
        self.mgt_port = '5555'
        self.ctx = mock.Mock()

        self.config(group='loadbalancer', image_uuid=self.image_uuid)
        self.config(group='loadbalancer', instance_flavor=self.flavor)
        self.config(group='loadbalancer', mgt_service_port=self.mgt_port)

        self.ctx = fakes.fake_worker_context()
        self.addCleanup(mock.patch.stopall)
    def setUp(self):
        super(TestInstanceManager, self).setUp()
        self.conf = cfg.CONF
        self.fake_driver = fakes.fake_driver()
        self.ctx = fakes.fake_worker_context()

        self.neutron = self.ctx.neutron
        self.neutron.api_client = mock.Mock()
        self.config(boot_timeout=30)
        self.config(astara_mgt_service_port=5000)
        self.config(max_retries=3)
        self.addCleanup(mock.patch.stopall)

        self.log = mock.Mock()
        self.update_state_p = mock.patch.object(
            instance_manager.InstanceManager,
            'update_state'
        )

        ports = [fake_int_port, fake_ext_port]

        self.fake_driver.get_interfaces.return_value = [
            {'ifname': 'ge0', 'lladdr': fake_mgt_port.mac_address},
            {'ifname': 'ge1', 'lladdr': fake_ext_port.mac_address},
            {'ifname': 'ge2', 'lladdr': fake_int_port.mac_address},
        ]
        self.fake_driver.ports = ports

        self.mock_update_state = self.update_state_p.start()
        self.instance_mgr = instance_manager.InstanceManager(
            self.fake_driver,
            self.ctx
        )
        self.instances_patch = mock.patch.object(
            instance_manager, 'InstanceGroupManager', autospec=True)
        self.instance_mgr.instances = self.instances_patch.start()

        self.next_state = None

        def next_state(*args, **kwargs):
            if self.next_state:
                self.instance_mgr.state = self.next_state
            return self.instance_mgr.state
        self.mock_update_state.side_effect = next_state