def test_ex_destroy_pool(driver):
    response = driver.ex_destroy_pool(
        pool=NttCisPool(id='4d360b1f-bc2c-4ab7-9884-1f03ba2768f7',
                        name='test',
                        description='test',
                        status=State.RUNNING,
                        health_monitor_id=None,
                        load_balance_method=None,
                        service_down_action=None,
                        slow_ramp_time=None))
    assert response is True
Esempio n. 2
0
 def _to_pool(self, element):
     pool = NttCisPool(
         id=element.get('id'),
         name=findtext(element, 'name', TYPES_URN),
         status=findtext(element, 'state', TYPES_URN),
         description=findtext(element, 'description', TYPES_URN),
         load_balance_method=findtext(element, 'loadBalanceMethod',
                                      TYPES_URN),
         health_monitor_id=findtext(element, 'healthMonitorId', TYPES_URN),
         service_down_action=findtext(element, 'serviceDownAction',
                                      TYPES_URN),
         slow_ramp_time=findtext(element, 'slowRampTime', TYPES_URN),
     )
     return pool
def test_ex_create_virtual_listener_without_port(driver):
    listener = driver.ex_create_virtual_listener(network_domain_id='12345',
                                                 name='test',
                                                 ex_description='test',
                                                 pool=NttCisPool(
                                                     id='1234',
                                                     name='test',
                                                     description='test',
                                                     status=State.RUNNING,
                                                     health_monitor_id=None,
                                                     load_balance_method=None,
                                                     service_down_action=None,
                                                     slow_ramp_time=None))
    assert listener.id == '8334f461-0df0-42d5-97eb-f4678eb26bea'
    assert listener.name == 'test'
def test_ex_create_pool_member(driver):
    pool = NttCisPool(id='4d360b1f-bc2c-4ab7-9884-1f03ba2768f7',
                      name='test',
                      description='test',
                      status=State.RUNNING,
                      health_monitor_id=None,
                      load_balance_method=None,
                      service_down_action=None,
                      slow_ramp_time=None)
    node = NttCisVIPNode(id='2344',
                         name='test',
                         status=State.RUNNING,
                         ip='123.23.3.2')
    member = driver.ex_create_pool_member(pool=pool, node=node, port=80)
    assert member.id == '3dd806a2-c2c8-4c0c-9a4f-5219ea9266c0'
    assert member.name == '10.0.3.13'
    assert member.ip == '123.23.3.2'
Esempio n. 5
0
def test_ex_create_virtual_listener_unusual_port(driver):
    listener = driver.ex_create_virtual_listener(
        network_domain_id="12345",
        name="test",
        ex_description="test",
        port=8900,
        pool=NttCisPool(
            id="1234",
            name="test",
            description="test",
            status=State.RUNNING,
            health_monitor_id=None,
            load_balance_method=None,
            service_down_action=None,
            slow_ramp_time=None,
        ),
    )
    assert listener.id == "8334f461-0df0-42d5-97eb-f4678eb26bea"
    assert listener.name == "test"
Esempio n. 6
0
    def ex_create_pool(self,
                       network_domain_id,
                       name,
                       balancer_method,
                       ex_description,
                       health_monitors=None,
                       service_down_action='NONE',
                       slow_ramp_time=30):
        """
        Create a new pool

        :param network_domain_id: Network Domain ID (required)
        :type  name: ``str``

        :param name: name of the node (required)
        :type  name: ``str``

        :param balancer_method: The load balancer algorithm (required)
        :type  balancer_method: ``str``

        :param ex_description: Description of the node (required)
        :type  ex_description: ``str``

        :param health_monitors: A list of health monitors to use for the pool.
        :type  health_monitors: ``list`` of
            :class:`NttCisDefaultHealthMonitor`

        :param service_down_action: What to do when node
                                    is unavailable NONE, DROP or RESELECT
        :type  service_down_action: ``str``

        :param slow_ramp_time: Number of seconds to stagger ramp up of nodes
        :type  slow_ramp_time: ``int``

        :return: Instance of ``NttCisPool``
        :rtype: ``NttCisPool``
        """
        # Names cannot contain spaces.
        name.replace(' ', '_')
        create_node_elm = ET.Element('createPool', {'xmlns': TYPES_URN})
        ET.SubElement(create_node_elm, "networkDomainId") \
            .text = network_domain_id
        ET.SubElement(create_node_elm, "name").text = name
        ET.SubElement(create_node_elm, "description").text \
            = str(ex_description)
        ET.SubElement(create_node_elm, "loadBalanceMethod") \
            .text = str(balancer_method)

        if health_monitors is not None:
            for monitor in health_monitors:
                ET.SubElement(create_node_elm, "healthMonitorId") \
                    .text = str(monitor.id)

        ET.SubElement(create_node_elm, "serviceDownAction") \
            .text = service_down_action
        ET.SubElement(create_node_elm, "slowRampTime").text \
            = str(slow_ramp_time)

        response = self.connection.request_with_orgId_api_2(
            action='networkDomainVip/createPool',
            method='POST',
            data=ET.tostring(create_node_elm)).object

        pool_id = None
        for info in findall(response, 'info', TYPES_URN):
            if info.get('name') == 'poolId':
                pool_id = info.get('value')

        return NttCisPool(id=pool_id,
                          name=name,
                          description=ex_description,
                          status=State.RUNNING,
                          load_balance_method=str(balancer_method),
                          health_monitor_id=None,
                          service_down_action=service_down_action,
                          slow_ramp_time=str(slow_ramp_time))