Ejemplo n.º 1
0
    def setUp(self):
        super(ASR1kRoutingDriver, self).setUp()

        cfg.CONF.set_override('enable_multi_region', False, 'multi_region')

        device_params = self.prepare_hosting_device_params()
        self.driver = driver.ASR1kRoutingDriver(**device_params)
        self.driver._ncc_connection = mock.MagicMock()
        self.driver._check_response = mock.MagicMock(return_value=True)
        self.driver._check_acl = mock.MagicMock(return_value=False)
    def setUp(self):
        super(ASR1kRoutingDriver, self).setUp()

        cfg.CONF.set_override('enable_multi_region', False, 'multi_region')

        device_params = {
            'management_ip_address': 'fake_ip',
            'protocol_port': 22,
            'credentials': {
                "user_name": "stack",
                "password": "******"
            },
            'timeout': None,
            'id': '0000-1',
            'device_id': 'ASR-1'
        }
        self.driver = driver.ASR1kRoutingDriver(**device_params)
        self.driver._ncc_connection = mock.MagicMock()
        self.driver._check_response = mock.MagicMock(return_value=True)
        self.driver._check_acl = mock.MagicMock(return_value=False)

        self.vrf = ('nrouter-' +
                    FAKE_ID)[:iosxe_driver.IosXeRoutingDriver.DEV_NAME_LEN]
        self.driver._get_vrfs = mock.Mock(return_value=[self.vrf])
        self.ex_gw_ip = '20.0.0.31'
        # VIP is same as gw_ip for user visible router
        self.ex_gw_ip_vip = self.ex_gw_ip
        self.ex_gw_prefixlen = 24
        self.ex_gw_cidr = '20.0.0.30/24'
        self.ex_gw_ip_mask = '255.255.255.0'
        self.ex_gw_ha_group = 1500
        self.ex_gw_ha_info = {
            'group': self.ex_gw_ha_group,
            'ha_port': {
                'fixed_ips': [{
                    'ip_address': self.ex_gw_ip_vip,
                    'prefixlen': self.ex_gw_prefixlen
                }]
            }
        }
        self.ex_gw_gateway_ip = '20.0.0.1'
        self.vlan_ext = 317
        self.phy_infc = 'GigabitEthernet0/0/0'

        self.ex_gw_port = {
            'id':
            _uuid(),
            'network_id':
            _uuid(),
            'fixed_ips': [{
                'ip_address': self.ex_gw_ip,
                'prefixlen': self.ex_gw_prefixlen,
                'subnet_id': _uuid()
            }],
            'subnets': [{
                'cidr': self.ex_gw_cidr,
                'gateway_ip': self.ex_gw_gateway_ip
            }],
            'device_owner':
            l3_constants.DEVICE_OWNER_ROUTER_GW,
            'mac_address':
            'ca:fe:de:ad:be:ef',
            'admin_state_up':
            True,
            'hosting_info': {
                'physical_interface': self.phy_infc,
                'segmentation_id': self.vlan_ext
            },
            HA_INFO:
            self.ex_gw_ha_info
        }

        self.vlan_int = 314
        self.hosting_info = {
            'physical_interface': self.phy_infc,
            'segmentation_id': self.vlan_ext
        }
        self.gw_ip_cidr = '10.0.3.0/24'
        self.gw_prefixlen = 24
        self.gw_ip = '10.0.3.3'
        self.gw_ip_vip = '10.0.3.1'
        self.gw_ip_mask = '255.255.255.0'
        self.gw_ha_group = 1621
        self.gw_ha_info = {
            'group': self.gw_ha_group,
            'ha_port': {
                'fixed_ips': [{
                    'ip_address': self.gw_ip_vip,
                    'prefixlen': self.gw_prefixlen
                }]
            }
        }
        self.port = {
            'id': PORT_ID,
            'ip_cidr': self.gw_ip_cidr,
            'fixed_ips': [{
                'ip_address': self.gw_ip
            }],
            'subnets': [{
                'cidr': self.gw_ip_cidr,
                'gateway_ip': self.gw_ip
            }],
            'hosting_info': {
                'physical_interface': self.phy_infc,
                'segmentation_id': self.vlan_int
            },
            HA_INFO: self.gw_ha_info
        }
        int_ports = [self.port]
        self.floating_ip = '20.0.0.35'
        self.fixed_ip = '10.0.3.5'
        self.ha_priority = 10
        self.cisco_ha_details = {
            'priority':
            self.ha_priority,
            'redundancy_level':
            1,
            'redundancy_routers': [{
                'id': _uuid(),
                'priority': 20,
                'state': 'STANDBY'
            }],
            'state':
            'ACTIVE',
            'type':
            'HSRP'
        }
        self.router = {
            'id': FAKE_ID,
            l3_constants.INTERFACE_KEY: int_ports,
            'enable_snat': True,
            'admin_state_up': True,
            'routes': [],
            routerrole.ROUTER_ROLE_ATTR: 'Logical',
            ha.ENABLED: True,
            ha.DETAILS: self.cisco_ha_details,
            'gw_port': self.ex_gw_port
        }

        self.ri = routing_svc_helper.RouterInfo(FAKE_ID, self.router)
        self.ri.internal_ports = int_ports
        # Global router
        self.global_router = copy.deepcopy(self.router)
        self.global_router[routerrole.ROUTER_ROLE_ATTR] = (
            cisco_constants.ROUTER_ROLE_GLOBAL)
        self.cisco_ha_details_global = {
            'priority':
            self.ha_priority,
            'redundancy_level':
            2,
            'redundancy_routers': [{
                'priority': 10,
                'state': 'STANDBY',
                'id': FAKE_ID
            }, {
                'id': _uuid(),
                'priority': 20,
                'state': 'STANDBY'
            }],
            'state':
            'ACTIVE',
            'type':
            'HSRP'
        }
        self.global_router[ha.DETAILS] = self.cisco_ha_details_global
        self.global_router['gw_port'][HA_INFO]['ha_port']['fixed_ips'][0][
            'ip_address'] = self.ex_gw_ip_vip
        self.ri_global = routing_svc_helper.RouterInfo(FAKE_ID,
                                                       self.global_router)
        self.ri_global.internal_ports = int_ports
Ejemplo n.º 3
0
if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)
    device_params = {
        'management_ip_address': '10.86.7.178',
        'protocol_port': 22,
        'timeout': 30,
        "credentials": {
            'username': "******",
            'password': '******'
        }
    }
    router = {'id': 'dummy', 'name': 'router1'}
    ri = RouterInfo("dummy", router)
    port = {
        'ip_cidr': '10.0.2.1/24',
        'hosting_info': {
            'hosting_mac': 'fa:16:3e:b3:0e:48',
            'hosting_port_id': 'dummy_id',
            'hosting_port_name': u't2_p:1',
            'segmentation_id': 101,
            'physical_interface': 'GigabitEthernet0/0/0'
        }
    }
    driver = asr_driver.ASR1kRoutingDriver(**device_params)
    if driver._get_connection():
        logging.info('Connection Established!')
        driver.router_added(ri)
        driver.internal_network_added(ri, port)
        driver.internal_network_removed(ri, port)
        driver.router_removed(ri)