コード例 #1
0
 def test_get_ip_address(self):
     vip = {
         'ipv4': {
             'address': '1.1.1.1'
         },
         'ipv6': {
             'virtual_ip': u'1234:5678:90ab:cdef::1'
         }
     }
     # Check get IPv4 address
     self.assertEqual(vip['ipv4']['address'],
                      resource_utils.get_ip_address(vip, True, 'vip'))
     # Check get IPv6 address
     self.assertEqual(vip['ipv6']['virtual_ip'],
                      resource_utils.get_ip_address(vip, False, 'vip'))
     # Check ip validation
     vip['ipv4']['address'] = 1
     vip['ipv6']['virtual_ip'] = None
     self.assertRaises(ValueError, resource_utils.get_ip_address, vip, True,
                       'vip')
     self.assertRaises(ValueError, resource_utils.get_ip_address, vip,
                       False, 'vip')
     vip['ipv4'] = None
     vip['ipv6'] = None
     self.assertRaises(ValueError, resource_utils.get_ip_address, vip, True,
                       'vip')
     self.assertRaises(ValueError, resource_utils.get_ip_address, vip,
                       False, 'vip')
     vip = {}
     self.assertRaises(ValueError, resource_utils.get_ip_address, vip, True,
                       'vip')
     self.assertRaises(ValueError, resource_utils.get_ip_address, vip,
                       False, 'vip')
     vip = 1244
     self.assertRaises(ValueError, resource_utils.get_ip_address, vip, True,
                       'vip')
     self.assertRaises(ValueError, resource_utils.get_ip_address, vip,
                       False, 'vip')
     vip = None
     self.assertRaises(ValueError, resource_utils.get_ip_address, vip, True,
                       'vip')
     self.assertRaises(ValueError, resource_utils.get_ip_address, vip,
                       False, 'vip')
コード例 #2
0
 def test_get_ip_address(self):
     vip = {
         'ipv4': {'address': '1.1.1.1'},
         'ipv6': {'virtual_ip': u'1234:5678:90ab:cdef::1'}
         }
     # Check get IPv4 address
     self.assertEqual(vip['ipv4']['address'],
                      resource_utils.get_ip_address(vip, True, 'vip'))
     # Check get IPv6 address
     self.assertEqual(vip['ipv6']['virtual_ip'],
                      resource_utils.get_ip_address(vip, False, 'vip'))
     # Check ip validation
     vip['ipv4']['address'] = 1
     vip['ipv6']['virtual_ip'] = None
     self.assertRaises(ValueError, resource_utils.get_ip_address,
                       vip, True, 'vip')
     self.assertRaises(ValueError, resource_utils.get_ip_address,
                       vip, False, 'vip')
     vip['ipv4'] = None
     vip['ipv6'] = None
     self.assertRaises(ValueError, resource_utils.get_ip_address,
                       vip, True, 'vip')
     self.assertRaises(ValueError, resource_utils.get_ip_address,
                       vip, False, 'vip')
     vip = {}
     self.assertRaises(ValueError, resource_utils.get_ip_address,
                       vip, True, 'vip')
     self.assertRaises(ValueError, resource_utils.get_ip_address,
                       vip, False, 'vip')
     vip = 1244
     self.assertRaises(ValueError, resource_utils.get_ip_address,
                       vip, True, 'vip')
     self.assertRaises(ValueError, resource_utils.get_ip_address,
                       vip, False, 'vip')
     vip = None
     self.assertRaises(ValueError, resource_utils.get_ip_address,
                       vip, True, 'vip')
     self.assertRaises(ValueError, resource_utils.get_ip_address,
                       vip, False, 'vip')
コード例 #3
0
    def create_member(self, name=None, platform='VNIOS',
                      config_addr_type='IPV4', vip=None, mgmt=None, lan2=None,
                      nat_ip=None,
                      ha_pair=False, use_v4_vrrp=True, vrid=None,
                      node1_ha=None, node2_ha=None,
                      node1_lan1=None, node2_lan1=None,
                      node2_mgmt=None, node2_lan2=None, lan2_vrid=None):
        member_data = {'host_name': name, 'platform': platform}
        extra_data = {}

        if ha_pair:
            # For HA pair we use IPv4 or IPv6 address, not both
            node1 = {}
            node2 = {}
            if config_addr_type == 'IPV6':
                ipv4 = False
            elif config_addr_type == 'BOTH':
                ipv4 = use_v4_vrrp
            else:  # default configuration is 'IPV4'
                ipv4 = True
            node1['ha_ip_address'] = resource_utils.get_ip_address(
                node1_ha, ipv4, 'node1_ha')
            node1['mgmt_lan'] = resource_utils.get_ip_address(
                node1_lan1, ipv4, 'node1_lan1')
            node2['ha_ip_address'] = resource_utils.get_ip_address(
                node2_ha, ipv4, 'node2_ha')
            node2['mgmt_lan'] = resource_utils.get_ip_address(
                node2_lan1, ipv4, 'node2_lan1')
            extra_data = {
                'enable_ha': True,
                'router_id': vrid,
                'node_info': [
                    {'lan_ha_port_setting': node1},
                    {'lan_ha_port_setting': node2}
                    ]
                }

        if config_addr_type in ('IPV4', 'BOTH'):
            # Check that IPv4 address available
            resource_utils.get_ip_address(vip, True, 'vip')
            # Copy IPv4 address settings
            extra_data['vip_setting'] = vip['ipv4'].copy()
        if config_addr_type in ('IPV6', 'BOTH'):
            # Check that IPv6 address available
            resource_utils.get_ip_address(vip, False, 'vip')
            # Copy IPv6 address settings
            extra_data['ipv6_setting'] = vip['ipv6'].copy()
        if nat_ip:
            extra_data['nat_setting'] = {
                'enabled': True,
                'external_virtual_ip': nat_ip
            }

        if mgmt:
            if config_addr_type in ('IPV4', 'BOTH'):
                # Check that MGMT IPv4 address available
                resource_utils.get_ip_address(mgmt, True, 'MGMT')
                extra_data['mgmt_port_setting'] = {"enabled": True}
                if ha_pair:
                    # Check that node2 MGMT IPv4 address available
                    resource_utils.get_ip_address(node2_mgmt, True,
                                                  'node2_MGMT')
                    extra_data['node_info'][0] = {
                        'mgmt_network_setting': mgmt['ipv4']}
                    extra_data['node_info'][1] = {
                        'mgmt_network_setting': node2_mgmt['ipv4']}
                else:
                    extra_data['node_info'] = [
                        {'mgmt_network_setting': mgmt['ipv4']}]
            if config_addr_type in ('IPV6', 'BOTH'):
                # Check that IPv6 address available
                resource_utils.get_ip_address(mgmt, False, 'MGMT')
                extra_data['v6_mgmt_network_setting'] = {"enabled": True}
                if ha_pair:
                    # Check that node2 MGMT IPv4 address available
                    resource_utils.get_ip_address(node2_mgmt, True,
                                                  'node2_MGMT')
                    extra_data['node_info'][0] = {
                        'v6_mgmt_network_setting': mgmt['ipv4']}
                    extra_data['node_info'][1] = {
                        'v6_mgmt_network_setting': node2_mgmt['ipv4']}
                else:
                    extra_data['node_info'] = [
                        {'v6_mgmt_network_setting': mgmt['ipv4']}]

        if lan2 and lan2.get('ipv4', None):
            extra_data['lan2_enabled'] = True
            extra_data['lan2_port_setting'] = {
                'enabled': True,
                'network_setting': lan2['ipv4']
            }
            if ha_pair:
                extra_data['virtual_router_id'] = lan2_vrid

        return self._create_infoblox_object('member', member_data, extra_data)
コード例 #4
0
    def create_member(self,
                      name=None,
                      platform='VNIOS',
                      config_addr_type='IPV4',
                      vip=None,
                      mgmt=None,
                      lan2=None,
                      nat_ip=None,
                      ha_pair=False,
                      use_v4_vrrp=True,
                      vrid=None,
                      node1_ha=None,
                      node2_ha=None,
                      node1_lan1=None,
                      node2_lan1=None,
                      node2_mgmt=None,
                      node2_lan2=None,
                      lan2_vrid=None):
        member_data = {'host_name': name, 'platform': platform}
        extra_data = {}

        if ha_pair:
            # For HA pair we use IPv4 or IPv6 address, not both
            node1 = {}
            node2 = {}
            if config_addr_type == 'IPV6':
                ipv4 = False
            elif config_addr_type == 'BOTH':
                ipv4 = use_v4_vrrp
            else:  # default configuration is 'IPV4'
                ipv4 = True
            node1['ha_ip_address'] = resource_utils.get_ip_address(
                node1_ha, ipv4, 'node1_ha')
            node1['mgmt_lan'] = resource_utils.get_ip_address(
                node1_lan1, ipv4, 'node1_lan1')
            node2['ha_ip_address'] = resource_utils.get_ip_address(
                node2_ha, ipv4, 'node2_ha')
            node2['mgmt_lan'] = resource_utils.get_ip_address(
                node2_lan1, ipv4, 'node2_lan1')
            extra_data = {
                'enable_ha':
                True,
                'router_id':
                vrid,
                'node_info': [{
                    'lan_ha_port_setting': node1
                }, {
                    'lan_ha_port_setting': node2
                }]
            }

        if config_addr_type in ('IPV4', 'BOTH'):
            # Check that IPv4 address available
            resource_utils.get_ip_address(vip, True, 'vip')
            # Copy IPv4 address settings
            extra_data['vip_setting'] = vip['ipv4'].copy()
        if config_addr_type in ('IPV6', 'BOTH'):
            # Check that IPv6 address available
            resource_utils.get_ip_address(vip, False, 'vip')
            # Copy IPv6 address settings
            extra_data['ipv6_setting'] = vip['ipv6'].copy()
        if nat_ip:
            extra_data['nat_setting'] = {
                'enabled': True,
                'external_virtual_ip': nat_ip
            }

        if mgmt:
            if config_addr_type in ('IPV4', 'BOTH'):
                # Check that MGMT IPv4 address available
                resource_utils.get_ip_address(mgmt, True, 'MGMT')
                extra_data['mgmt_port_setting'] = {"enabled": True}
                if ha_pair:
                    # Check that node2 MGMT IPv4 address available
                    resource_utils.get_ip_address(node2_mgmt, True,
                                                  'node2_MGMT')
                    extra_data['node_info'][0] = {
                        'mgmt_network_setting': mgmt['ipv4']
                    }
                    extra_data['node_info'][1] = {
                        'mgmt_network_setting': node2_mgmt['ipv4']
                    }
                else:
                    extra_data['node_info'] = [{
                        'mgmt_network_setting':
                        mgmt['ipv4']
                    }]
            if config_addr_type in ('IPV6', 'BOTH'):
                # Check that IPv6 address available
                resource_utils.get_ip_address(mgmt, False, 'MGMT')
                extra_data['v6_mgmt_network_setting'] = {"enabled": True}
                if ha_pair:
                    # Check that node2 MGMT IPv4 address available
                    resource_utils.get_ip_address(node2_mgmt, True,
                                                  'node2_MGMT')
                    extra_data['node_info'][0] = {
                        'v6_mgmt_network_setting': mgmt['ipv4']
                    }
                    extra_data['node_info'][1] = {
                        'v6_mgmt_network_setting': node2_mgmt['ipv4']
                    }
                else:
                    extra_data['node_info'] = [{
                        'v6_mgmt_network_setting':
                        mgmt['ipv4']
                    }]

        if lan2 and lan2.get('ipv4', None):
            extra_data['lan2_enabled'] = True
            extra_data['lan2_port_setting'] = {
                'enabled': True,
                'network_setting': lan2['ipv4']
            }
            if ha_pair:
                extra_data['virtual_router_id'] = lan2_vrid

        return self._create_infoblox_object('member', member_data, extra_data)