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