Python-Textfsm-Fortigate-解析名称:,有效期自:,有效期至:

时间:2018-07-17 16:49:14

标签: python python-textfsm

我正在尝试使用Textfsm来获取输出:

名称: 有效期自: 有效期:

我认为问题是我的模板中要在== [Fortinet_CA_SSL]之后搜索的位置,但是希望获得帮助。

输出:

== [ Fortinet_CA_SSL ]
        Name:        Fortinet_CA_SSL
        Subject:     C = US, ST = California, L = Sunnyvale, O = Fortinet, OU = Certificate Authority, CN = FG200D3913804332, emailAddress = support@fortinet.com
        Issuer:      C = US, ST = California, L = Sunnyvale, O = Fortinet, OU = Certificate Authority, CN = FG200D3913804332, emailAddress = support@fortinet.com
        Valid from:  2018-02-08 16:43:27  GMT
        Valid to:    2028-02-09 16:43:27  GMT
        Fingerprint: 78:DA:31:59:9D:A6:D7:98:79:51:1F:EE:0E:C0:C6:45
        Serial Num:  25:4d:55:ca:b8:e6:b5:54

模板:

Value Name (\S*)
Value Valid_from (\S*)
Value Valid_to (\S*)

Start
  ^Name: ${Name}
  ^Valid from: ${Valid_from}
  ^Valid to: ${Valid_to}

1 个答案:

答案 0 :(得分:0)

知道了

模板:

>>> def pad_with(vector, pad_width, iaxis, kwargs):
...     pad_value = kwargs.get('padder', 10)
...     print(vector[:pad_width[0]])
...     print(vector[-pad_width[1]:])
...     vector[:pad_width[0]] = pad_value
...     vector[-pad_width[1]:] = pad_value
...     return vector
...
>>> arr = np.arange(6).reshape(3, 2)

>>> np.pad(arr, 1, pad_with)
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[10]
[10]
[0]
[0]
[0]
[0]
[0]
[0]
[10]
[10]
array([[10, 10, 10, 10],
       [10,  0,  1, 10],
       [10,  2,  3, 10],
       [10,  4,  5, 10],
       [10, 10, 10, 10]])