Ejemplo n.º 1
0
    def get_create_health_monitor_flow(self):
        """Create a flow to create a health monitor

        :returns: The flow for creating a health monitor
        """
        create_hm_flow = linear_flow.Flow(constants.CREATE_HEALTH_MONITOR_FLOW)
        create_hm_flow.add(
            lifecycle_tasks.HealthMonitorToErrorOnRevertTask(requires=[
                constants.HEALTH_MON, constants.LISTENERS,
                constants.LOADBALANCER
            ]))
        create_hm_flow.add(
            database_tasks.MarkHealthMonitorPendingCreateInDB(
                requires=constants.HEALTH_MON))
        create_hm_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        create_hm_flow.add(
            health_monitor_tasks.CreateAndAssociateHealthMonitor(requires=[
                constants.LISTENERS, constants.HEALTH_MON,
                a10constants.VTHUNDER
            ]))
        create_hm_flow.add(
            database_tasks.MarkHealthMonitorActiveInDB(
                requires=constants.HEALTH_MON))
        create_hm_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        create_hm_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return create_hm_flow
 def test_health_monitor_create_task(self):
     hm_task = task.CreateAndAssociateHealthMonitor()
     hm_task.axapi_client = self.client_mock
     mock_hm = copy.deepcopy(HM)
     hm_task.execute(LISTENERS, mock_hm, VTHUNDER)
     self.client_mock.slb.hm.create.assert_called_with(
         a10constants.MOCK_HM_ID,
         self.client_mock.slb.hm.TCP,
         mock_hm.delay,
         mock_hm.timeout,
         mock_hm.rise_threshold,
         method=None,
         port=mock.ANY,
         url=None,
         expect_code=None,
         post_data=None,
         **ARGS)
     self.conf.config(group=a10constants.HEALTH_MONITOR_SECTION,
                      post_data='abc=1')
     mock_hm = copy.deepcopy(HM)
     hm_task.execute(LISTENERS, mock_hm, VTHUNDER)
     self.client_mock.slb.hm.create.assert_called_with(
         a10constants.MOCK_HM_ID,
         self.client_mock.slb.hm.TCP,
         mock_hm.delay,
         mock_hm.timeout,
         mock_hm.rise_threshold,
         method=None,
         port=mock.ANY,
         url=None,
         expect_code=None,
         post_data='abc=1',
         **ARGS)
 def test_health_monitor_create_with_flavor_and_config(self):
     flavor = {
         "health_monitor": {
             "retry": 5,
             "method": {
                 "http": {
                     "http_response_code": "201"
                 }
             }
         }
     }
     hm_task = task.CreateAndAssociateHealthMonitor()
     hm_task.axapi_client = self.client_mock
     mock_hm = copy.deepcopy(HM)
     mock_hm.delay = 30
     mock_hm.name = "hm1"
     self.conf.config(group=a10constants.HEALTH_MONITOR_SECTION,
                      post_data='abc=1')
     hm_task.execute(LISTENERS, mock_hm, VTHUNDER, flavor)
     self.client_mock.slb.hm.create.assert_called_with(
         a10constants.MOCK_HM_ID,
         self.client_mock.slb.hm.TCP,
         mock_hm.delay,
         mock_hm.timeout,
         mock_hm.rise_threshold,
         method=None,
         port=mock.ANY,
         url=None,
         post_data='abc=1',
         expect_code=None,
         **FLAVOR_ARGS)
Ejemplo n.º 4
0
    def get_create_health_monitor_flow(self, topology):
        """Create a flow to create a health monitor

        :returns: The flow for creating a health monitor
        """
        create_hm_flow = linear_flow.Flow(constants.CREATE_HEALTH_MONITOR_FLOW)
        create_hm_flow.add(
            lifecycle_tasks.HealthMonitorToErrorOnRevertTask(requires=[
                constants.HEALTH_MON, constants.LISTENERS,
                constants.LOADBALANCER
            ]))
        create_hm_flow.add(
            vthunder_tasks.VthunderInstanceBusy(
                requires=a10constants.COMPUTE_BUSY))

        create_hm_flow.add(
            database_tasks.MarkHealthMonitorPendingCreateInDB(
                requires=constants.HEALTH_MON))
        create_hm_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        if topology == constants.TOPOLOGY_ACTIVE_STANDBY:
            create_hm_flow.add(
                vthunder_tasks.GetMasterVThunder(
                    name=a10constants.GET_MASTER_VTHUNDER,
                    requires=a10constants.VTHUNDER,
                    provides=a10constants.VTHUNDER))
        create_hm_flow.add(
            a10_database_tasks.GetFlavorData(
                rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
                provides=constants.FLAVOR))
        create_hm_flow.add(
            health_monitor_tasks.CreateAndAssociateHealthMonitor(requires=[
                constants.LISTENERS, constants.HEALTH_MON,
                a10constants.VTHUNDER, constants.FLAVOR
            ]))
        create_hm_flow.add(
            database_tasks.MarkHealthMonitorActiveInDB(
                requires=constants.HEALTH_MON))
        create_hm_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        create_hm_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        create_hm_flow.add(
            vthunder_tasks.WriteMemory(
                name=a10constants.WRITE_MEM_FOR_LOCAL_PARTITION,
                requires=(a10constants.VTHUNDER)))
        create_hm_flow.add(
            vthunder_tasks.WriteMemory(
                name=a10constants.WRITE_MEM_FOR_SHARED_PARTITION,
                requires=(a10constants.VTHUNDER,
                          a10constants.WRITE_MEM_SHARED_PART)))
        create_hm_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                requires=(a10constants.VTHUNDER)))
        return create_hm_flow
 def test_health_monitor_create_task(self):
     mock_hm = task.CreateAndAssociateHealthMonitor()
     mock_hm.axapi_client = self.client_mock
     mock_hm.execute(LISTENERS, HM, VTHUNDER)
     self.client_mock.slb.hm.create.assert_called_with(
         a10constants.MOCK_HM_ID,
         self.client_mock.slb.hm.TCP,
         HM.delay,
         HM.timeout,
         HM.rise_threshold,
         method=None,
         port=mock.ANY,
         url=None,
         expect_code=None,
         axapi_args=ARGS)
 def test_health_monitor_create_with_regex_overwrite_flavor_task(self):
     flavor = {
         "health_monitor": {
             "retry":
             5,
             "timeout":
             90,
             "method": {
                 "http": {
                     "http_response_code": "201"
                 }
             },
             "name_expressions": [{
                 "regex": "hm1",
                 "json": {
                     "timeout": 8,
                     "method": {
                         "http": {
                             "http_host": "my.test.com"
                         }
                     }
                 }
             }]
         }
     }
     hm_task = task.CreateAndAssociateHealthMonitor()
     hm_task.axapi_client = self.client_mock
     mock_hm = copy.deepcopy(HM)
     mock_hm.delay = 30
     mock_hm.name = "hm1"
     hm_task.execute(LISTENERS, mock_hm, VTHUNDER, flavor)
     self.client_mock.slb.hm.create.assert_called_with(
         a10constants.MOCK_HM_ID,
         self.client_mock.slb.hm.TCP,
         mock_hm.delay,
         mock_hm.timeout,
         mock_hm.rise_threshold,
         method=None,
         port=mock.ANY,
         url=None,
         expect_code=None,
         post_data=None,
         **FLAVOR_WITH_REGEX_ARGS)