def _configure_vrrp_router(self, vrrp_version, priority, ip_addr, switch_index, vrid): switches = self.switches self.logger.debug('%s', switches.dps) dpid = sorted(switches.dps.keys())[switch_index] self.logger.debug('%s', lib_dpid.dpid_to_str(dpid)) self.logger.debug('%s', switches.port_state) # hack: use the smallest port no to avoid picking OVS local port port_no = sorted(switches.port_state[dpid].keys())[0] self.logger.debug('%d', port_no) port = switches.port_state[dpid][port_no] self.logger.debug('%s', port) mac = port.hw_addr self.logger.debug('%s', mac) interface = vrrp_event.VRRPInterfaceOpenFlow(mac, ip_addr, None, dpid, port_no) self.logger.debug('%s', interface) config = vrrp_event.VRRPConfig( version=vrrp_version, vrid=vrid, priority=priority, ip_addresses=[ip_addr]) self.logger.debug('%s', config) rep = vrrp_api.vrrp_config(self, interface, config) self.logger.debug('%s', rep) return rep
def _configure_vrrp_router(self, vrrp_version, priority, ip_addr, switch_index, vrid): switches = self.switches self.logger.debug('%s', switches.dps) dpid = sorted(switches.dps.keys())[switch_index] self.logger.debug('%s', lib_dpid.dpid_to_str(dpid)) self.logger.debug('%s', switches.port_state) # hack: use the smallest port no to avoid picking OVS local port port_no = sorted(switches.port_state[dpid].keys())[0] self.logger.debug('%d', port_no) port = switches.port_state[dpid][port_no] self.logger.debug('%s', port) mac = port.hw_addr self.logger.debug('%s', mac) interface = vrrp_event.VRRPInterfaceOpenFlow(mac, ip_addr, None, dpid, port_no) self.logger.debug('%s', interface) config = vrrp_event.VRRPConfig(version=vrrp_version, vrid=vrid, priority=priority, ip_addresses=[ip_addr]) self.logger.debug('%s', config) rep = vrrp_api.vrrp_config(self, interface, config) self.logger.debug('%s', rep) return rep
def _configure_vrrp_router(self, vrrp_version, vrrp_priority, primary_ip_address, virtual_ip_address, ifname, vrid, preempt_delay): interface = vrrp_event.VRRPInterfaceNetworkDevice( _VIRTUAL_MAC_ADDRESS, primary_ip_address, None, ifname) ip_addresses = [virtual_ip_address] config = vrrp_event.VRRPConfig( version=vrrp_version, vrid=vrid, priority=vrrp_priority, ip_addresses=ip_addresses, preempt_delay=preempt_delay) config_result = vrrp_api.vrrp_config(self, interface, config) return config_result
def _configure_vrrp_router(self, vrrp_version, priority, primary_ip_address, ifname, vrid): interface = vrrp_event.VRRPInterfaceNetworkDevice( lib_mac.DONTCARE_STR, primary_ip_address, None, ifname) self.logger.debug('%s', interface) vip = '10.0.%d.1' % vrid ip_addresses = [vip] config = vrrp_event.VRRPConfig( version=vrrp_version, vrid=vrid, priority=priority, ip_addresses=ip_addresses) self.logger.debug('%s', config) rep = vrrp_api.vrrp_config(self, interface, config) self.logger.debug('%s', rep) return rep
def _configure_vrrp_router(self, vrrp_version, priority, primary_ip_address, ifname, vrid): interface = vrrp_event.VRRPInterfaceNetworkDevice( lib_mac.DONTCARE_STR, primary_ip_address, None, ifname) self.logger.debug('%s', interface) vip = '10.0.%d.1' % vrid ip_addresses = [vip] config = vrrp_event.VRRPConfig(version=vrrp_version, vrid=vrid, priority=priority, ip_addresses=ip_addresses) self.logger.debug('%s', config) rep = vrrp_api.vrrp_config(self, interface, config) self.logger.debug('%s', rep) return rep
def _config(self, msgid, params): self.logger.debug('handle vrrp_config request') try: param_dict = params[0] except: raise RPCError('parameters are missing') if_params = self._params_to_dict(param_dict, ('primary_ip_address', 'device_name')) # drop vlan support later if_params['vlan_id'] = None if_params['mac_address'] = mac.DONTCARE_STR try: interface = vrrp_event.VRRPInterfaceNetworkDevice(**if_params) except: raise RPCError('parameters are invalid, %s' % (str(param_dict))) config_params = self._params_to_dict( param_dict, ( 'vrid', # mandatory 'ip_addresses', # mandatory 'version', 'admin_state', 'priority', 'advertisement_interval', 'preempt_mode', 'preempt_delay', 'statistics_interval')) try: ip_addr = config_params.pop('ip_addresses') config_params['ip_addresses'] = [ip_addr] config = vrrp_event.VRRPConfig(**config_params) except: raise RPCError('parameters are invalid, %s' % (str(param_dict))) config_result = vrrp_api.vrrp_config(self, interface, config) api_result = [ config_result.config.vrid, config_result.config.priority, str(netaddr.IPAddress(config_result.config.ip_addresses[0])) ] return api_result
def _config(self, msgid, params): self.logger.debug('handle vrrp_config request') try: param_dict = params[0] except: raise RPCError('parameters are missing') if_params = self._params_to_dict(param_dict, ('primary_ip_address', 'device_name')) # drop vlan support later if_params['vlan_id'] = None if_params['mac_address'] = mac.DONTCARE_STR try: interface = vrrp_event.VRRPInterfaceNetworkDevice(**if_params) except: raise RPCError('parameters are invalid, %s' % (str(param_dict))) config_params = self._params_to_dict(param_dict, ('vrid', # mandatory 'ip_addresses', # mandatory 'version', 'admin_state', 'priority', 'advertisement_interval', 'preempt_mode', 'preempt_delay', 'statistics_interval')) try: ip_addr = config_params.pop('ip_addresses') config_params['ip_addresses'] = [ip_addr] config = vrrp_event.VRRPConfig(**config_params) except: raise RPCError('parameters are invalid, %s' % (str(param_dict))) config_result = vrrp_api.vrrp_config(self, interface, config) api_result = [ config_result.config.vrid, config_result.config.priority, str(netaddr.IPAddress(config_result.config.ip_addresses[0]))] return api_result