Esempio n. 1
0
 def test_ex_create_pool_member(self):
     pool = DimensionDataPool(
         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 = DimensionDataVIPNode(
         id='2344',
         name='test',
         status=State.RUNNING,
         ip='123.23.3.2'
     )
     member = self.driver.ex_create_pool_member(
         pool=pool,
         node=node,
         port=80
     )
     self.assertEqual(member.id, '3dd806a2-c2c8-4c0c-9a4f-5219ea9266c0')
     self.assertEqual(member.name, '10.0.3.13')
     self.assertEqual(member.ip, '123.23.3.2')
Esempio n. 2
0
 def test_ex_create_pool_member(self):
     pool = DimensionDataPool(id='4d360b1f-bc2c-4ab7-9884-1f03ba2768f7',
                              name='test',
                              description='test',
                              status=State.RUNNING)
     node = DimensionDataVIPNode(id='2344',
                                 name='test',
                                 status=State.RUNNING,
                                 ip='123.23.3.2')
     member = self.driver.ex_create_pool_member(pool=pool,
                                                node=node,
                                                port=80)
     self.assertEqual(member.id, '3dd806a2-c2c8-4c0c-9a4f-5219ea9266c0')
     self.assertEqual(member.name, '10.0.3.13')
     self.assertEqual(member.ip, '123.23.3.2')
Esempio n. 3
0
    def _to_node(self, element):
        ipaddress = findtext(element, 'ipv4Address', TYPES_URN)
        if ipaddress is None:
            ipaddress = findtext(element, 'ipv6Address', TYPES_URN)

        name = findtext(element, 'name', TYPES_URN)

        node = DimensionDataVIPNode(id=element.get('id'),
                                    name=name,
                                    status=self._VALUE_TO_STATE_MAP.get(
                                        findtext(element, 'state', TYPES_URN),
                                        State.UNKNOWN),
                                    ip=ipaddress)

        return node
Esempio n. 4
0
    def _to_node(self, element):
        ipaddress = findtext(element, "ipv4Address", TYPES_URN)
        if ipaddress is None:
            ipaddress = findtext(element, "ipv6Address", TYPES_URN)

        name = findtext(element, "name", TYPES_URN)

        node = DimensionDataVIPNode(
            id=element.get("id"),
            name=name,
            status=self._VALUE_TO_STATE_MAP.get(
                findtext(element, "state", TYPES_URN), State.UNKNOWN),
            connection_rate_limit=findtext(element, "connectionRateLimit",
                                           TYPES_URN),
            connection_limit=findtext(element, "connectionLimit", TYPES_URN),
            ip=ipaddress,
        )

        return node
Esempio n. 5
0
    def ex_create_node(self,
                       network_domain_id,
                       name,
                       ip,
                       ex_description,
                       connection_limit=25000,
                       connection_rate_limit=2000):
        """
        Create a new node

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

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

        :param ip: IPv4 address of the node (required)
        :type  ip: ``str``

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

        :param connection_limit: Maximum number
                of concurrent connections per sec
        :type  connection_limit: ``int``

        :param connection_rate_limit: Maximum number of concurrent sessions
        :type  connection_rate_limit: ``int``

        :return: Instance of ``DimensionDataVIPNode``
        :rtype: ``DimensionDataVIPNode``
        """
        create_node_elm = ET.Element('createNode', {'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, "ipv4Address").text = ip
        ET.SubElement(create_node_elm, "status").text = 'ENABLED'
        ET.SubElement(create_node_elm, "connectionLimit") \
            .text = str(connection_limit)
        ET.SubElement(create_node_elm, "connectionRateLimit") \
            .text = str(connection_rate_limit)

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

        node_id = None
        node_name = None
        for info in findall(response, 'info', TYPES_URN):
            if info.get('name') == 'nodeId':
                node_id = info.get('value')
            if info.get('name') == 'name':
                node_name = info.get('value')
        return DimensionDataVIPNode(id=node_id,
                                    name=node_name,
                                    status=State.RUNNING,
                                    ip=ip)