Ejemplo n.º 1
0
    def handle_vrid_for_member_subflow(self):
        handle_vrid_for_member_subflow = linear_flow.Flow(
            a10constants.HANDLE_VRID_MEMBER_SUBFLOW)
        handle_vrid_for_member_subflow.add(
            a10_network_tasks.GetLBResourceSubnet(
                rebind={a10constants.LB_RESOURCE: constants.MEMBER},
                provides=constants.SUBNET))
        handle_vrid_for_member_subflow.add(
            a10_database_tasks.GetChildProjectsOfParentPartition(
                rebind={a10constants.LB_RESOURCE: constants.MEMBER},
                provides=a10constants.PARTITION_PROJECT_LIST))
        handle_vrid_for_member_subflow.add(
            a10_database_tasks.GetVRIDForLoadbalancerResource(
                requires=a10constants.PARTITION_PROJECT_LIST,
                provides=a10constants.VRID_LIST))
        handle_vrid_for_member_subflow.add(
            a10_network_tasks.HandleVRIDFloatingIP(
                requires=[
                    a10constants.VTHUNDER, a10constants.VRID_LIST,
                    constants.SUBNET
                ],
                rebind={a10constants.LB_RESOURCE: constants.MEMBER},
                provides=a10constants.VRID_LIST))
        handle_vrid_for_member_subflow.add(
            a10_database_tasks.UpdateVRIDForLoadbalancerResource(
                requires=a10constants.VRID_LIST,
                rebind={a10constants.LB_RESOURCE: constants.MEMBER}))

        return handle_vrid_for_member_subflow
 def test_update_vrid_for_project_member_with_port_and_no_vrid(self):
     mock_vrid_entry = task.UpdateVRIDForLoadbalancerResource()
     mock_vrid_entry.vrid_repo = mock.Mock()
     mock_vrid_entry.vrid_repo.exists.return_value = False
     mock_vrid_entry.execute(MEMBER_1, [VRID])
     mock_vrid_entry.vrid_repo.create.assert_called_once_with(
         mock.ANY,
         project_id=MEMBER_1.project_id,
         vrid=VRID.vrid,
         vrid_floating_ip=VRID.vrid_floating_ip,
         vrid_port_id=VRID.vrid_port_id,
         subnet_id=VRID.subnet_id)
     mock_vrid_entry.vrid_repo.update.assert_not_called()
Ejemplo n.º 3
0
 def test_update_vrid_for_project_member_with_port_and_with_vrid(self):
     thunder = copy.deepcopy(HW_THUNDER)
     mock_vrid_entry = task.UpdateVRIDForLoadbalancerResource()
     mock_vrid_entry.vrid_repo = mock.Mock()
     mock_vrid_entry.vrid_repo.exists.return_value = True
     mock_vrid_entry.execute(MEMBER_1, [VRID], thunder)
     mock_vrid_entry.vrid_repo.update.assert_called_once_with(
         mock.ANY,
         VRID.id,
         vrid=VRID.vrid,
         vrid_floating_ip=VRID.vrid_floating_ip,
         vrid_port_id=VRID.vrid_port_id,
         subnet_id=VRID.subnet_id)
     mock_vrid_entry.vrid_repo.create.assert_not_called()
Ejemplo n.º 4
0
    def test_update_vrid_for_project_member_delete_vrid(self):
        thunder = copy.deepcopy(HW_THUNDER)
        thunder.vrid_floating_ip = VRID.vrid_floating_ip
        hardware_device_conf = self._generate_hardware_device_conf(thunder)
        self.conf.config(group=a10constants.HARDWARE_THUNDER_CONF_SECTION,
                         devices=[hardware_device_conf])
        self.conf.conf.hardware_thunder.devices = {
            a10constants.MOCK_PROJECT_ID: thunder
        }
        utils.get_vrid_floating_ip_for_project.CONF = self.conf

        mock_vrid_entry = task.UpdateVRIDForLoadbalancerResource()
        mock_vrid_entry.vrid_repo = mock.Mock()
        mock_vrid_entry.execute(MEMBER_1, [], thunder)
        mock_vrid_entry.vrid_repo.delete.assert_called_once_with(
            mock.ANY, owner=thunder.ip_address + "_" + thunder.partition_name)