コード例 #1
0
 def diff_ifc_asa(self, cli):
     if not self.has_ifc_delta_cfg():
         self.delta_ifc_key = (Type.FOLDER, AccessControlEntry.__name__, cli)
         self.delta_ifc_cfg_value = {'state': State.DESTROY, 'value': ifcize_param_dict(self.values)}
         ancestor = self.get_ifc_delta_cfg_ancestor()
         if ancestor:
             ancestor.delta_ifc_cfg_value['value'][self.delta_ifc_key] =  self.delta_ifc_cfg_value
コード例 #2
0
ファイル: cluster.py プロジェクト: 3pings/aci
    def parse_multi_parameter_cli(self, cli):
        '''
        Override the default implementation in case the CLI does not match asa_gen_template due to optional parameter
        '''
        # The names in template: "ip local pool %(pool_name)s %(start_ip)s-%(end_ip)s"
        names = ['pool_name', 'start_ip', 'end_ip']

        # s is the regular expression for parsing above CLI
        s = 'ip local pool (\S+) (\S+)-(\S+)'

        pattern = re.compile(s)
        m = pattern.match(cli.strip())

        result = {}
        for pos, name in enumerate(names, 1):
            result[name] = m.group(pos)
        result = ifcize_param_dict(result)

        'Take care of the optional parameters'
        tokens = cli.split()

        # If the number of tokens > 6, it has mask option:
        # CLI format: 'ip local pool %(pool_name)s %(start_ip)s-%(end_ip)s mask <mask>'
        if len(tokens) > 6:
            option = tokens[6:]
            if len(option) > 0:
                result[(Type.PARAM, 'mask', '')] = {'state': State.NOCHANGE, 'value': ''}
                result[Type.PARAM, 'mask', '']['value'] = option[0]
        return result
コード例 #3
0
ファイル: nat_rule.py プロジェクト: 3pings/aci
 def diff_ifc_asa(self, cli):
     if not self.has_ifc_delta_cfg():
         self.delta_ifc_key = (Type.FOLDER, NATRule.__name__, cli)
         self.delta_ifc_cfg_value = {
             'state': State.DESTROY,
             'value': ifcize_param_dict(self.values)
         }
         ancestor = self.get_ifc_delta_cfg_ancestor()
         if ancestor:
             ancestor.delta_ifc_cfg_value['value'][
                 self.delta_ifc_key] = self.delta_ifc_cfg_value
コード例 #4
0
    def parse_cli(self, cli):
        'Override the default to handle variations of the command'
        result = {}
        parameters = ' '.join(cli.split()[2:])
        if not parameters:# cli is of the form 'service-object <type>'
            return ifcize_param_dict(result)

        def parse_parameters(items):
            folder = items[0]
            result[folder] = {}
            result[folder]['operator'] = items[1]
            result[folder]['low_port'] = items[2]
            if len(items) == 4:
                result[folder]['high_port'] = items[3]

        pattern = '(source .+) (destination .+)'
        match = re.compile(pattern).match(parameters)
        if match:#cli is of the form 'service-object <type> source <value> destination <value>'
            parse_parameters(match.group(1).split())
            parse_parameters(match.group(2).split())
        else: #of the form 'service-object <type> [source|destination] <value>'
            parse_parameters(parameters.split())
        return ifcize_param_dict(result)
コード例 #5
0
ファイル: service_object_group.py プロジェクト: 3pings/aci
    def parse_cli(self, cli):
        'Override the default to handle variations of the command'
        result = {}
        parameters = ' '.join(cli.split()[2:])
        if not parameters:  # cli is of the form 'service-object <type>'
            return ifcize_param_dict(result)

        def parse_parameters(items):
            folder = items[0]
            result[folder] = {}
            result[folder]['operator'] = items[1]
            result[folder]['low_port'] = items[2]
            if len(items) == 4:
                result[folder]['high_port'] = items[3]

        pattern = '(source .+) (destination .+)'
        match = re.compile(pattern).match(parameters)
        if match:  #cli is of the form 'service-object <type> source <value> destination <value>'
            parse_parameters(match.group(1).split())
            parse_parameters(match.group(2).split())
        else:  #of the form 'service-object <type> [source|destination] <value>'
            parse_parameters(parameters.split())
        return ifcize_param_dict(result)