def diff_ifc_asa(self, cli):
        '''
        Override the default implementation in order to simplify the code by turning CLI of the form:
                set connection conn-max 1000 embryonic-conn-max 2000 per-client-max 3000 per-client-embryonic-max 4000 random-sequence-number disable
            into
                set connection conn-max 1000
                set connection embryonic-conn-max 2000
                set connection per-client-max 3000
                set connection per-client-embryonic-max 4000
                set connection random-sequence-number disable
            turning CLI of the form:
                set connection timeout embryonic 1:2:3 half-closed 4:5:6
            into:
                set connection timeout embryonic 1:2:3
                set connection timeout half-closed 4:5:6
        '''

        assert cli.strip().startswith(self.asa_key)

        clis = self.normalize_cli(cli)
        if not clis:
            return
        for cmd in clis:
            translator = self.get_child_translator(cmd)
            if translator:
                translator.diff_ifc_asa(cmd)
Beispiel #2
0
    def diff_ifc_asa(self, cli):
        '''
        Override the default implementation in order to simplify the code by turning CLI of the form:
                set connection conn-max 1000 embryonic-conn-max 2000 per-client-max 3000 per-client-embryonic-max 4000 random-sequence-number disable
            into
                set connection conn-max 1000
                set connection embryonic-conn-max 2000
                set connection per-client-max 3000
                set connection per-client-embryonic-max 4000
                set connection random-sequence-number disable
            turning CLI of the form:
                set connection timeout embryonic 1:2:3 half-closed 4:5:6
            into:
                set connection timeout embryonic 1:2:3
                set connection timeout half-closed 4:5:6
        '''

        assert cli.strip().startswith(self.asa_key)

        clis = self.normalize_cli(cli)
        if not clis:
            return
        for cmd in clis:
            translator = self.get_child_translator(cmd)
            if translator:
                translator.diff_ifc_asa(cmd)
    def diff_ifc_asa(self, cli):
        ''' Need to override this method because in composite type, the config value
            is initialized with empty value.  The function has_ifc_delta_cfg() will
            not return false since the delta_ifc_cfg_value is not NONE.
        '''
        config = util.normalize_param_dict(self.delta_ifc_cfg_value['value'])
        if not self.has_ifc_delta_cfg() or not config:
            if self.is_removable: #delete operation required
                self.delta_ifc_key = self.create_delta_ifc_key(cli)
                self.delta_ifc_cfg_value = {'state': State.DESTROY, 'value': self.parse_cli(cli)}

                "add it to its container's delta_ifc_cfg_value"
                ancestor = self.get_ifc_delta_cfg_ancestor()
                if ancestor:
                    ancestor.delta_ifc_cfg_value['value'][self.delta_ifc_key] =  self.delta_ifc_cfg_value
            return
        if isinstance(cli, str):
            assert cli.strip().startswith(self.get_asa_key())
        elif isinstance(cli, StructuredCommand):
            assert cli.command.startswith(self.get_asa_key())
        'Use dictionary compare instead of CLI compare to take care of optional parameters'
        if self.is_the_same_cli(cli):
            self.set_action(State.NOCHANGE)
        else:
            self.set_action(State.MODIFY)
        if self.get_action() == State.DESTROY:
            return

        for cmd in cli.sub_commands:
            translator = self.get_child_translator(cmd)
            if translator:
                translator.diff_ifc_asa(cmd)
Beispiel #4
0
    def diff_ifc_asa(self, cli):
        ''' Need to override this method because in composite type, the config value
            is initialized with empty value.  The function has_ifc_delta_cfg() will
            not return false since the delta_ifc_cfg_value is not NONE.
        '''
        config = util.normalize_param_dict(self.delta_ifc_cfg_value['value'])
        if not self.has_ifc_delta_cfg() or not config:
            if self.is_removable:  #delete operation required
                self.delta_ifc_key = self.create_delta_ifc_key(cli)
                self.delta_ifc_cfg_value = {
                    'state': State.DESTROY,
                    'value': self.parse_cli(cli)
                }

                "add it to its container's delta_ifc_cfg_value"
                ancestor = self.get_ifc_delta_cfg_ancestor()
                if ancestor:
                    ancestor.delta_ifc_cfg_value['value'][
                        self.delta_ifc_key] = self.delta_ifc_cfg_value
            return
        if isinstance(cli, str):
            assert cli.strip().startswith(self.get_asa_key())
        elif isinstance(cli, StructuredCommand):
            assert cli.command.startswith(self.get_asa_key())
        'Use dictionary compare instead of CLI compare to take care of optional parameters'
        if self.is_the_same_cli(cli):
            self.set_action(State.NOCHANGE)
        else:
            self.set_action(State.MODIFY)
        if self.get_action() == State.DESTROY:
            return

        for cmd in cli.sub_commands:
            translator = self.get_child_translator(cmd)
            if translator:
                translator.diff_ifc_asa(cmd)