示例#1
0
    def test_according_to_cidr_distribution_ip_from_range_cidr(self):
        ip_ranges = [
            {
                'start': None,
                'cidr': '112.18.1.1/24',
                'end': None,
                'gateway': '112.18.1.2'
            },
        ]
        network_values = {
            'cluster_id': '737adb89-ee6f-4642-8196-9ee6926fbe50',
            'cidr': '112.18.1.2/25',
            'gateway': '112.18.1.1',
            'ip_ranges': ip_ranges,
            'name': 'physnet1',
            'segmentation_type': 'vxlan',
            'physnet_name': 'physnet_enp2s0',
            'type': 'default',
            'network_type': 'DATAPLANE',
        }
        network_info = api.network_add(self.req.context, network_values)
        network_id = network_info.__dict__['id']

        cluster_id = '737adb89-ee6f-4642-8196-9ee6926fbe50'
        network_plane_name = 'physnet1'
        session = api.get_session()
        distribution_ip1 = api.according_to_cidr_distribution_ip(
            cluster_id, network_plane_name, session)
        self.assertEqual('112.18.1.1', distribution_ip1)
示例#2
0
 def test_get_ip_with_equal_cidr(self, fake_used_ip):
     fake_used_ip.return_value = ['112.18.1.15', '112.18.1.16']
     network_values = {
         'cluster_id': '737adb89-ee6f-4642-8196-9ee6926fbe50',
         'cidr': '112.18.1.1/25',
         'gateway': '112.18.1.1',
         'vlan_id': None,
         'ip_ranges': ip_ranges,
         'name': 'physnet1',
         'segmentation_type': 'vxlan',
         'physnet_name': 'physnet_enp2s0',
         'type': 'default',
         'network_type': 'DATAPLANE',
     }
     network_info = api.network_add(self.req.context, network_values)
     network_id = network_info.__dict__['id']
     # print network_info
     cluster_id = '737adb89-ee6f-4642-8196-9ee6926fbe50'
     network_plane_name = 'physnet1'
     session = api.get_session()
     get_ips = api.get_ip_with_equal_cidr(cluster_id,
                                          network_plane_name,
                                          session,
                                          exclude_ips=[])
     self.assertEqual(['112.18.1.15', '112.18.1.16'], get_ips)
示例#3
0
    def test_according_to_cidr_distribution_ip_from_range_cidr(self):
        ip_ranges = [
            {'start': None,
             'cidr': '112.18.1.1/24',
                     'end': None,
                     'gateway': '112.18.1.2'
             }, ]
        network_values = {
            'cluster_id': '737adb89-ee6f-4642-8196-9ee6926fbe50',
            'cidr': '112.18.1.2/25',
                    'gateway': '112.18.1.1',
                    'ip_ranges': ip_ranges,
                    'name': 'physnet1',
                    'segmentation_type': 'vxlan',
                    'physnet_name': 'physnet_enp2s0',
                    'type': 'default',
                    'network_type': 'DATAPLANE',
        }
        network_info = api.network_add(self.req.context, network_values)
        network_id = network_info.__dict__['id']

        cluster_id = '737adb89-ee6f-4642-8196-9ee6926fbe50'
        network_plane_name = 'physnet1'
        session = api.get_session()
        distribution_ip1 = api.according_to_cidr_distribution_ip(
            cluster_id, network_plane_name, session)
        self.assertEqual('112.18.1.1', distribution_ip1)
示例#4
0
 def test_get_used_ip_in_dataplan_net(self):
     network_values = {
         'cluster_id': '737adb89-ee6f-4642-8196-9ee6926fbe50',
         'cidr': '112.18.1.1/25',
         'gateway': '112.18.1.1',
         'ip_ranges': ip_ranges,
         'name': 'physnet1',
         'segmentation_type': 'vxlan',
         'physnet_name': 'physnet_enp2s0',
         'type': 'default',
         'network_type': 'DATAPLANE',
     }
     network_info = api.network_add(self.req.context, network_values)
     network_id = network_info.__dict__['id']
     # print network_info
     cluster_id = '737adb89-ee6f-4642-8196-9ee6926fbe50'
     network_plane_name = 'physnet1'
     session = api.get_session()
     get_ips = api.get_used_ip_in_dataplan_net(network_id, session)
     self.assertEqual([], get_ips)
示例#5
0
    def test_according_to_cidr_distribution_ip_without_ip(self):
        network_values = {
            'cluster_id': '737adb89-ee6f-4642-8196-9ee6926fbe50',
            'cidr': None,
            'gateway': None,
            'name': 'physnet1',
            'segmentation_type': 'vxlan',
            'physnet_name': 'physnet_enp2s0',
            'type': 'default',
            'network_type': 'DATAPLANE',
        }
        network_info = api.network_add(self.req.context, network_values)
        network_id = network_info.__dict__['id']

        cluster_id = '737adb89-ee6f-4642-8196-9ee6926fbe50'
        network_plane_name = 'physnet1'
        session = api.get_session()
        self.assertRaises(exception.Forbidden,
                          api.according_to_cidr_distribution_ip, cluster_id,
                          network_plane_name, session)
示例#6
0
    def test_according_to_cidr_distribution_ip_without_ip(self):
        network_values = {
            'cluster_id': '737adb89-ee6f-4642-8196-9ee6926fbe50',
            'cidr': None,
            'gateway': None,
            'name': 'physnet1',
                    'segmentation_type': 'vxlan',
                    'physnet_name': 'physnet_enp2s0',
                    'type': 'default',
                    'network_type': 'DATAPLANE',
        }
        network_info = api.network_add(self.req.context, network_values)
        network_id = network_info.__dict__['id']

        cluster_id = '737adb89-ee6f-4642-8196-9ee6926fbe50'
        network_plane_name = 'physnet1'
        session = api.get_session()
        self.assertRaises(exception.Forbidden,
                          api.according_to_cidr_distribution_ip, cluster_id,
                          network_plane_name, session)
示例#7
0
 def test_get_used_ip_in_dataplan_net(self):
     network_values = {
         'cluster_id': '737adb89-ee6f-4642-8196-9ee6926fbe50',
         'cidr': '112.18.1.1/25',
                 'gateway': '112.18.1.1',
                 'ip_ranges': ip_ranges,
                 'name': 'physnet1',
                 'segmentation_type': 'vxlan',
                 'physnet_name': 'physnet_enp2s0',
                 'type': 'default',
                 'network_type': 'DATAPLANE',
     }
     network_info = api.network_add(self.req.context, network_values)
     network_id = network_info.__dict__['id']
     # print network_info
     cluster_id = '737adb89-ee6f-4642-8196-9ee6926fbe50'
     network_plane_name = 'physnet1'
     session = api.get_session()
     get_ips = api.get_used_ip_in_dataplan_net(network_id, session)
     self.assertEqual([], get_ips)
示例#8
0
 def test_get_ip_with_equal_cidr_nomarl(self, fake_used_ip):
     fake_used_ip.return_value = ['112.18.1.15', '112.18.1.16']
     network_values = {
         'cluster_id': '737adb89-ee6f-4642-8196-9ee6926fbe50',
         'cidr': '112.18.1.1/25',
                 'gateway': '112.18.1.1',
                 'vlan_id': None,
                 'ip_ranges': ip_ranges,
                 'capability': 'high',
                 'name': 'STORAGE',
                 'type': 'default',
                 'network_type': 'STORAGE',
     }
     network_info = api.network_add(self.req.context, network_values)
     cluster_id = '737adb89-ee6f-4642-8196-9ee6926fbe50'
     network_plane_name = 'STORAGE'
     session = api.get_session()
     get_ips = api.get_ip_with_equal_cidr(
         cluster_id, network_plane_name, session, exclude_ips=[])
     self.assertEqual([], get_ips)
示例#9
0
 def test_get_ip_with_equal_cidr_nomarl(self, fake_used_ip):
     fake_used_ip.return_value = ['112.18.1.15', '112.18.1.16']
     network_values = {
         'cluster_id': '737adb89-ee6f-4642-8196-9ee6926fbe50',
         'cidr': '112.18.1.1/25',
         'gateway': '112.18.1.1',
         'vlan_id': None,
         'ip_ranges': ip_ranges,
         'capability': 'high',
         'name': 'STORAGE',
         'type': 'default',
         'network_type': 'STORAGE',
     }
     network_info = api.network_add(self.req.context, network_values)
     cluster_id = '737adb89-ee6f-4642-8196-9ee6926fbe50'
     network_plane_name = 'STORAGE'
     session = api.get_session()
     get_ips = api.get_ip_with_equal_cidr(cluster_id,
                                          network_plane_name,
                                          session,
                                          exclude_ips=[])
     self.assertEqual([], get_ips)
示例#10
0
 def test_get_ip_with_equal_cidr(self, fake_used_ip):
     fake_used_ip.return_value = ['112.18.1.15', '112.18.1.16']
     network_values = {
         'cluster_id': '737adb89-ee6f-4642-8196-9ee6926fbe50',
         'cidr': '112.18.1.1/25',
                 'gateway': '112.18.1.1',
                 'vlan_id': None,
                 'ip_ranges': ip_ranges,
                 'name': 'physnet1',
                 'segmentation_type': 'vxlan',
                 'physnet_name': 'physnet_enp2s0',
                 'type': 'default',
                 'network_type': 'DATAPLANE',
     }
     network_info = api.network_add(self.req.context, network_values)
     network_id = network_info.__dict__['id']
     # print network_info
     cluster_id = '737adb89-ee6f-4642-8196-9ee6926fbe50'
     network_plane_name = 'physnet1'
     session = api.get_session()
     get_ips = api.get_ip_with_equal_cidr(
         cluster_id, network_plane_name, session, exclude_ips=[])
     self.assertEqual(['112.18.1.15', '112.18.1.16'], get_ips)
    def save(self, session=None):
        from daisy.db.sqlalchemy import api as db_api

        super(ArtifactBase, self).save(session or db_api.get_session())
示例#12
0
 def save(self, session=None):
     from daisy.db.sqlalchemy import api as db_api
     super(DaisyBase, self).save(session or db_api.get_session())