Example #1
0
    def _update_med(self, **kwargs):
        multi_exit_disc = kwargs.get(MULTI_EXIT_DISC, None)
        if multi_exit_disc:
            get_validator(MULTI_EXIT_DISC)(multi_exit_disc)

        if multi_exit_disc != self.multi_exit_disc:
            self._settings[MULTI_EXIT_DISC] = multi_exit_disc
            return True

        return False
Example #2
0
File: vrfs.py Project: AkiraSuu/ryu
    def _update_med(self, **kwargs):
        multi_exit_disc = kwargs.get(MULTI_EXIT_DISC, None)
        if multi_exit_disc:
            get_validator(MULTI_EXIT_DISC)(multi_exit_disc)

        if multi_exit_disc != self.multi_exit_disc:
            self._settings[MULTI_EXIT_DISC] = multi_exit_disc
            return True

        return False
Example #3
0
    def name(self, new_name):
        old_name = self.name
        if not new_name:
            new_name = repr(self)
        else:
            get_validator(ConfWithId.NAME)(new_name)

        if old_name != new_name:
            self._settings[ConfWithId.NAME] = new_name
            self._notify_listeners(ConfWithId.UPDATE_NAME_EVT,
                                   (old_name, self.name))
Example #4
0
    def description(self, new_description):
        old_desc = self.description
        if not new_description:
            new_description = str(self)
        else:
            get_validator(ConfWithId.DESCRIPTION)(new_description)

        if old_desc != new_description:
            self._settings[ConfWithId.DESCRIPTION] = new_description
            self._notify_listeners(ConfWithId.UPDATE_DESCRIPTION_EVT,
                                   (old_desc, self.description))
Example #5
0
    def description(self, new_description):
        old_desc = self.description
        if not new_description:
            new_description = str(self)
        else:
            get_validator(ConfWithId.DESCRIPTION)(new_description)

        if old_desc != new_description:
            self._settings[ConfWithId.DESCRIPTION] = new_description
            self._notify_listeners(ConfWithId.UPDATE_DESCRIPTION_EVT,
                                   (old_desc, self.description))
Example #6
0
    def name(self, new_name):
        old_name = self.name
        if not new_name:
            new_name = repr(self)
        else:
            get_validator(ConfWithId.NAME)(new_name)

        if old_name != new_name:
            self._settings[ConfWithId.NAME] = new_name
            self._notify_listeners(ConfWithId.UPDATE_NAME_EVT,
                                   (old_name, self.name))
Example #7
0
File: vrfs.py Project: AkiraSuu/ryu
    def _update_soo_list(self, **kwargs):
        soo_list = kwargs.get(SITE_OF_ORIGINS, [])
        get_validator(SITE_OF_ORIGINS)(soo_list)
        curr_soos = set(self.soo_list)

        # If given list is different from existing settings, we update it
        if curr_soos.symmetric_difference(soo_list):
            self._settings[SITE_OF_ORIGINS] = soo_list[:]
            return True

        return False
Example #8
0
File: vrfs.py Project: AkiraSuu/ryu
    def _update_export_rts(self, **kwargs):
        export_rts = kwargs.get(EXPORT_RTS)
        get_validator(EXPORT_RTS)(export_rts)
        curr_export_rts = set(self._settings[EXPORT_RTS])

        if curr_export_rts.symmetric_difference(export_rts):
            # Update current RTs and notify listeners.
            self._settings[EXPORT_RTS] = list(export_rts)
            return True

        return False
Example #9
0
    def _update_soo_list(self, **kwargs):
        soo_list = kwargs.get(SITE_OF_ORIGINS, [])
        get_validator(SITE_OF_ORIGINS)(soo_list)
        curr_soos = set(self.soo_list)

        # If given list is different from existing settings, we update it
        if curr_soos.symmetric_difference(soo_list):
            self._settings[SITE_OF_ORIGINS] = soo_list[:]
            return True

        return False
Example #10
0
    def _update_export_rts(self, **kwargs):
        export_rts = kwargs.get(EXPORT_RTS)
        get_validator(EXPORT_RTS)(export_rts)
        curr_export_rts = set(self._settings[EXPORT_RTS])

        if curr_export_rts.symmetric_difference(export_rts):
            # Update current RTs and notify listeners.
            self._settings[EXPORT_RTS] = list(export_rts)
            return True

        return False
Example #11
0
def compute_optional_conf(conf_name, default_value, **all_config):
    """Returns *conf_name* settings if provided in *all_config*, else returns
     *default_value*.

    Validates *conf_name* value if provided.
    """
    conf_value = all_config.get(conf_name)
    if conf_value is not None:
        # Validate configuration value.
        get_validator(conf_name)(conf_value)
    else:
        conf_value = default_value
    return conf_value
Example #12
0
    def _update_import_rts(self, **kwargs):
        import_rts = kwargs.get(IMPORT_RTS)
        get_validator(IMPORT_RTS)(import_rts)
        curr_import_rts = set(self._settings[IMPORT_RTS])

        import_rts = set(import_rts)
        if not import_rts.symmetric_difference(curr_import_rts):
            return None, None

        # Get the difference between current and new RTs
        new_import_rts = import_rts - curr_import_rts
        old_import_rts = curr_import_rts - import_rts

        # Update current RTs and notify listeners.
        self._settings[IMPORT_RTS] = import_rts
        return new_import_rts, old_import_rts
Example #13
0
File: vrfs.py Project: AkiraSuu/ryu
    def _update_import_rts(self, **kwargs):
        import_rts = kwargs.get(IMPORT_RTS)
        get_validator(IMPORT_RTS)(import_rts)
        curr_import_rts = set(self._settings[IMPORT_RTS])

        import_rts = set(import_rts)
        if not import_rts.symmetric_difference(curr_import_rts):
            return (None, None)

        # Get the difference between current and new RTs
        new_import_rts = import_rts - curr_import_rts
        old_import_rts = curr_import_rts - import_rts

        # Update current RTs and notify listeners.
        self._settings[IMPORT_RTS] = import_rts
        return (new_import_rts, old_import_rts)
Example #14
0
 def _init_req_settings(self, **kwargs):
     for req_attr in self._req_settings:
         req_attr_value = kwargs.get(req_attr)
         if req_attr_value is None:
             raise MissingRequiredConf(conf_name=req_attr_value)
         # Validate attribute value
         req_attr_value = get_validator(req_attr)(req_attr_value)
         self._settings[req_attr] = req_attr_value
Example #15
0
 def _init_req_settings(self, **kwargs):
     for req_attr in self._req_settings:
         req_attr_value = kwargs.get(req_attr)
         if req_attr_value is None:
             raise MissingRequiredConf(conf_name=req_attr_value)
         # Validate attribute value
         req_attr_value = get_validator(req_attr)(req_attr_value)
         self._settings[req_attr] = req_attr_value
Example #16
0
 def stats_time(self, stats_time):
     get_validator(ConfWithStats.STATS_TIME)(stats_time)
     if stats_time != self.stats_time:
         self._settings[ConfWithStats.STATS_TIME] = stats_time
         self._notify_listeners(ConfWithStats.UPDATE_STATS_TIME_EVT,
                                stats_time)
Example #17
0
 def stats_log_enabled(self, enabled):
     get_validator(ConfWithStats.STATS_LOG_ENABLED)(enabled)
     if enabled != self.stats_log_enabled:
         self._settings[ConfWithStats.STATS_LOG_ENABLED] = enabled
         self._notify_listeners(ConfWithStats.UPDATE_STATS_LOG_ENABLED_EVT,
                                enabled)
Example #18
0
 def stats_log_enabled(self, enabled):
     get_validator(ConfWithStats.STATS_LOG_ENABLED)(enabled)
     if enabled != self.stats_log_enabled:
         self._settings[ConfWithStats.STATS_LOG_ENABLED] = enabled
         self._notify_listeners(ConfWithStats.UPDATE_STATS_LOG_ENABLED_EVT,
                                enabled)
Example #19
0
 def stats_time(self, stats_time):
     get_validator(ConfWithStats.STATS_TIME)(stats_time)
     if stats_time != self.stats_time:
         self._settings[ConfWithStats.STATS_TIME] = stats_time
         self._notify_listeners(ConfWithStats.UPDATE_STATS_TIME_EVT,
                                stats_time)