Esempio n. 1
0
    def test_network_config(self):
        mock_client = mock.Mock()
        mock_client.get_network_subnets.return_value = [fakes.fake_subnet]
        subnets_dict = {fakes.fake_subnet.id: fakes.fake_subnet}

        with mock.patch.object(common, '_make_network_config_dict') as nc:
            with mock.patch.object(common, '_interface_config') as ic:
                mock_interface = mock.Mock()
                ic.return_value = mock_interface

                common.network_config(
                    mock_client,
                    fakes.fake_int_port,
                    'ge1',
                    'internal',
                    [])

                ic.assert_called_once_with(
                    'ge1', fakes.fake_int_port, subnets_dict)
                nc.assert_called_once_with(
                    mock_interface,
                    'internal',
                    'int-net',
                    subnets_dict=subnets_dict,
                    network_ports=[])
Esempio n. 2
0
def generate_network_config(client, router, management_port, iface_map):
    retval = [
        common.network_config(
            client,
            management_port,
            iface_map[management_port.network_id],
            MANAGEMENT_NET
        )
    ]

    if router.external_port:
        retval.extend([
            common.network_config(
                client,
                router.external_port,
                iface_map[router.external_port.network_id],
                EXTERNAL_NET)])

    retval.extend(
        common.network_config(
            client,
            p,
            iface_map[p.network_id],
            INTERNAL_NET,
            client.get_network_ports(p.network_id))
        for p in router.internal_ports)

    return retval
Esempio n. 3
0
def build_config(client, loadbalancer, management_port, iface_map):
    LOG.debug('Generating configuration for loadbalancer %s', loadbalancer.id)

    network_config = [
        common.network_config(
            client,
            loadbalancer.vip_port,
            iface_map[loadbalancer.vip_port.network_id],
            'loadbalancer'),

        common.network_config(
            client,
            management_port,
            iface_map[management_port.network_id],
            'management'),
    ]

    out = {
        'hostname': 'ak-loadbalancer-%s' % loadbalancer.tenant_id,
        'tenant_id': loadbalancer.tenant_id,
        'networks': network_config,
        'services': {
            'loadbalancer': loadbalancer.to_dict()
        }
    }
    return out
Esempio n. 4
0
def generate_network_config(client, router, management_port, iface_map):
    retval = [
        common.network_config(client, management_port,
                              iface_map[management_port.network_id],
                              MANAGEMENT_NET)
    ]

    if router.external_port:
        retval.extend([
            common.network_config(client, router.external_port,
                                  iface_map[router.external_port.network_id],
                                  EXTERNAL_NET)
        ])

    retval.extend(
        common.network_config(client, p, iface_map[p.network_id], INTERNAL_NET,
                              client.get_network_ports(p.network_id))
        for p in router.internal_ports)

    return retval
Esempio n. 5
0
    def test_network_config(self):
        mock_client = mock.Mock()
        mock_client.get_network_detail.return_value = fakes.fake_network
        subnets_dict = {fakes.fake_subnet.id: fakes.fake_subnet}

        with mock.patch.object(common, '_make_network_config_dict') as nc:
            with mock.patch.object(common, '_interface_config') as ic:
                mock_interface = mock.Mock()
                ic.return_value = mock_interface

                common.network_config(mock_client, fakes.fake_int_port, 'ge1',
                                      'internal', [])

                ic.assert_called_once_with('ge1', fakes.fake_int_port,
                                           subnets_dict, 1280)
                nc.assert_called_once_with(mock_interface,
                                           'internal',
                                           'int-net',
                                           mtu=1280,
                                           subnets_dict=subnets_dict,
                                           network_ports=[]),