Skip to content

Commit b488d52

Browse files
brmcdougskkumaravel
authored andcommitted
Brmcdoug (#17)
* add json classmap * add json pmap and vrf-policy * added swan json snips * updated cli.py with delete-config rpc
1 parent 98f3908 commit b488d52

File tree

6 files changed

+139
-2
lines changed

6 files changed

+139
-2
lines changed

examples/cli.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def main():
4545
if arguments['--file']:
4646
file = arguments['--file']
4747
path = open(file).read()
48-
# path = open('json/' + file).read()
4948
else:
5049
path = 'Error'
5150
print(
@@ -64,7 +63,6 @@ def main():
6463
if arguments['--file']:
6564
file = arguments['--file']
6665
path = open(file).read()
67-
# path = open('json/' + file).read()
6866
else:
6967
path = ""
7068

@@ -112,6 +110,23 @@ def main():
112110
print(
113111
'Unable to connect to local box, check your gRPC destination.')
114112

113+
if RPC == "delete-config":
114+
115+
if arguments['--file']:
116+
file = arguments['--file']
117+
path = open(file).read()
118+
else:
119+
path = 'Error'
120+
print(
121+
'get-oper argument must include --file option and json file to filter yang operational namespace')
122+
try:
123+
err = client.deleteconfig(path)
124+
if err:
125+
print(err)
126+
# print result
127+
except AbortionError:
128+
print(
129+
'Unable to connect to local box, check your gRPC destination.')
115130

116131
if __name__ == '__main__':
117132
main()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"Cisco-IOS-XR-infra-policymgr-cfg:policy-manager": {
3+
"class-maps": {
4+
"class-map": [
5+
{
6+
"type": "traffic"
7+
}
8+
]
9+
}
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"Cisco-IOS-XR-infra-policymgr-cfg:policy-manager": {
3+
"policy-maps": {
4+
"policy-map": [
5+
{
6+
"type": "pbr"
7+
}
8+
]
9+
}
10+
}
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
{
3+
"Cisco-IOS-XR-pbr-vrf-policy-cfg:vrf-policy": [null]
4+
}

examples/json/swan-config.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"Cisco-IOS-XR-infra-policymgr-cfg:policy-manager": {
3+
"class-maps": {
4+
"class-map": [
5+
{
6+
"type": "traffic",
7+
"name": "default",
8+
"class-map-mode-match-all": [
9+
null
10+
],
11+
"match": {
12+
"dscp": [
13+
"0-7",
14+
"9-63"
15+
]
16+
}
17+
},
18+
{
19+
"type": "traffic",
20+
"name": "scavenger",
21+
"class-map-mode-match-all": [
22+
null
23+
],
24+
"match": {
25+
"dscp": [
26+
"8"
27+
]
28+
}
29+
}
30+
]
31+
},
32+
"policy-maps": {
33+
"policy-map": [
34+
{
35+
"type": "pbr",
36+
"name": "swan",
37+
"policy-map-rule": [
38+
{
39+
"class-name": "scavenger",
40+
"class-type": "traffic",
41+
"pbr-redirect": {
42+
"ipv4": {
43+
"ipv4-next-hop": "10.0.0.1"
44+
}
45+
}
46+
},
47+
{
48+
"class-name": "default",
49+
"class-type": "traffic",
50+
"pbr-redirect": {
51+
"ipv4": {
52+
"ipv4-next-hop": "10.0.0.2"
53+
}
54+
}
55+
}
56+
]
57+
}
58+
]
59+
}
60+
},
61+
"Cisco-IOS-XR-pbr-vrf-policy-cfg:vrf-policy": {
62+
"vrf": [
63+
{
64+
"vrf-name": "default",
65+
"afi": [
66+
{
67+
"afi-type": "ipv4",
68+
"service-policy-in": "swan"
69+
}
70+
]
71+
}
72+
]
73+
}
74+
}

examples/json/swan-get-config.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"Cisco-IOS-XR-infra-policymgr-cfg:policy-manager": {
3+
"class-maps": {
4+
"class-map": [
5+
{
6+
"type": "traffic"
7+
}
8+
]
9+
}
10+
},
11+
"Cisco-IOS-XR-infra-policymgr-cfg:policy-manager": {
12+
"policy-maps": {
13+
"policy-map": [
14+
{
15+
"type": "pbr"
16+
}
17+
]
18+
}
19+
},
20+
"Cisco-IOS-XR-pbr-vrf-policy-cfg:vrf-policy": [null]
21+
}
22+

0 commit comments

Comments
 (0)