Split NIC BoD script into setup vs intent creation
[nemo.git] / nemo-impl / src / test / resources / nic-bod-setup.py
1 #!/usr/bin/python
2
3 # This script sets up the physical network and NEMO Nodes for the NIC BoD flow.
4 # Use nemo-odl.py to set up the predefined NEMO definitions first.
5
6 import requests,json
7 import argparse, sys
8 from requests.auth import HTTPBasicAuth
9
10 USERNAME='admin'
11 PASSWORD='admin'
12
13 TRANSACTION_BEGIN="http://%s:8181/restconf/operations/nemo-intent:begin-transaction"
14 TRANSACTION_END="http://%s:8181/restconf/operations/nemo-intent:end-transaction"
15 REGISTER_USER="http://%s:8181/restconf/operations/nemo-intent:register-user"
16 STRUCTURE_UPDATE_USERS="http://%s:8181/restconf/operations/nemo-intent:structure-style-nemo-update"
17 PHYSICAL_NETWORK="http://%s:8181/restconf/config/generic-physical-network:physical-network"
18
19 def create_physical_network(contHost):
20         data={
21  "physical-network": {
22          "physical-hosts": {
23                  "physical-host": [
24                          {
25          "host-id": "22282cca-9a13-4d0c-a67e-a933ebb0b0ae",
26                                  "node-id": "openflow:2",
27                                  "host-name": "video-server2",
28                                  "mac-address": "00:00:00:00:00:04",
29                                  "port-id": "openflow:2:2",
30                                  "ip-addresses": {
31                                          "ip-address": [
32                                                  "192.168.12.4"
33                                          ]
34          }
35        },
36        {
37          "host-id": "7b796915-adf4-4356-b5ca-de005ac410c1",
38                "node-id": "openflow:1",
39                "host-name": "video-server1",
40                "mac-address": "00:00:00:00:00:01",
41                "port-id": "openflow:1:1",
42                "ip-addresses": {
43                        "ip-address": [
44                                "192.168.11.2"
45                        ]
46          }
47        },
48        {
49          "host-id": "6c787caa-156a-49ed-8546-547bdccf283c",
50                "node-id": "openflow:2",
51                "host-name": "vm2",
52                "mac-address": "00:00:00:00:00:03",
53                "port-id": "openflow:2:1",
54                "ip-addresses": {
55                        "ip-address": [
56                                "192.168.12.3"
57                        ]
58          }
59        },
60        {
61          "host-id": "1eaf9a67-a171-42a8-9282-71cf702f61dd",
62                "node-id": "openflow:1",
63                "host-name": "vm1",
64                "mac-address": "00:00:00:00:00:02",
65                "port-id": "openflow:1:2",
66                "ip-addresses": {
67                        "ip-address": [
68                                "192.168.12.2"
69                        ]
70          }
71        }
72      ]
73    },
74    "physical-nodes": {
75            "physical-node": [
76                    {
77          "node-id": "openflow:3",
78                            "attribute": [
79                                    {
80              "attribute-name": "location",
81                                            "attribute-value": {
82                                                    "string-value": "openflow:3"
83                                            }
84            }
85          ],
86          "node-type": "router",
87                            "physical-port": [
88                                    {
89              "port-id": "openflow:3:1",
90                                            "attribute": [
91                                                    {
92                  "attribute-name": "location",
93                                                            "attribute-value": {
94                                                                    "string-value": "openflow:3:1"
95                                                            }
96                }
97              ],
98              "port-type": "internal",
99                                            "mac-address": "BE:DB:79:24:0A:B1",
100                                            "bandwidth": 10240
101                                    },
102            {
103              "port-id": "openflow:3:2",
104                    "attribute": [
105                            {
106                  "attribute-name": "location",
107                                    "attribute-value": {
108                                            "string-value": "openflow:3:2"
109                                    }
110                }
111              ],
112              "port-type": "internal",
113                    "mac-address": "06:E7:27:6D:C2:A5",
114                    "bandwidth": 10240
115            },
116            {
117              "port-id": "openflow:3:3",
118                    "attribute": [
119                            {
120                  "attribute-name": "location",
121                                    "attribute-value": {
122                                            "string-value": "openflow:3:3"
123                                    }
124                }
125              ],
126              "port-type": "internal",
127                    "mac-address": "9E:00:76:D7:0C:1D",
128                    "bandwidth": 10240
129            },
130            {
131              "port-id": "openflow:3:4",
132                    "attribute": [
133                            {
134                  "attribute-name": "location",
135                                    "attribute-value": {
136                                            "string-value": "openflow:3:4"
137                                    }
138                }
139              ],
140              "port-type": "external",
141                    "mac-address": "00:00:00:00:03:04",
142                    "bandwidth": 10240
143            }
144          ]
145        },
146        {
147          "node-id": "openflow:4",
148                "attribute": [
149                        {
150              "attribute-name": "location",
151                                "attribute-value": {
152                                        "string-value": "openflow:4"
153                                }
154            }
155          ],
156          "node-type": "router",
157                "physical-port": [
158                        {
159              "port-id": "openflow:4:2",
160                                "attribute": [
161                                        {
162                  "attribute-name": "location",
163                                                "attribute-value": {
164                                                        "string-value": "openflow:4:2"
165                                                }
166                }
167              ],
168              "port-type": "external",
169                                "mac-address": "00:00:00:00:04:02",
170                                "bandwidth": 10240
171                        },
172            {
173              "port-id": "openflow:4:1",
174                    "attribute": [
175                            {
176                  "attribute-name": "location",
177                                    "attribute-value": {
178                                            "string-value": "openflow:4:1"
179                                    }
180                }
181              ],
182              "port-type": "internal",
183                    "mac-address": "4E:93:BE:EF:99:35",
184                    "bandwidth": 10240
185            }
186          ]
187        },
188        {
189          "node-id": "openflow:1",
190                "attribute": [
191                        {
192              "attribute-name": "location",
193                                "attribute-value": {
194                                        "string-value": "openflow:1"
195                                }
196            }
197          ],
198          "node-type": "switch",
199                "physical-port": [
200                        {
201              "port-id": "openflow:1:1",
202                                "attribute": [
203                                        {
204                  "attribute-name": "location",
205                                                "attribute-value": {
206                                                        "string-value": "openflow:1:1"
207                                                }
208                }
209              ],
210              "port-type": "external",
211                                "mac-address": "BA:8C:1F:60:2C:FC",
212                                "bandwidth": 10240
213                        },
214            {
215              "port-id": "openflow:1:2",
216                    "attribute": [
217                            {
218                  "attribute-name": "location",
219                                    "attribute-value": {
220                                            "string-value": "openflow:1:2"
221                                    }
222                }
223              ],
224              "port-type": "external",
225                    "mac-address": "82:ED:57:DE:28:F0",
226                    "bandwidth": 10240
227            },
228            {
229              "port-id": "openflow:1:3",
230                    "attribute": [
231                            {
232                  "attribute-name": "location",
233                                    "attribute-value": {
234                                            "string-value": "openflow:1:3"
235                                    }
236                }
237              ],
238              "port-type": "internal",
239                    "mac-address": "62:D3:F1:80:06:F0",
240                    "bandwidth": 10240
241            }
242          ]
243        },
244        {
245          "node-id": "openflow:2",
246                "attribute": [
247                        {
248              "attribute-name": "location",
249                                "attribute-value": {
250                                        "string-value": "openflow:2"
251                                }
252            }
253          ],
254          "node-type": "switch",
255                "physical-port": [
256                        {
257              "port-id": "openflow:2:3",
258                                "attribute": [
259                                        {
260                  "attribute-name": "location",
261                                                "attribute-value": {
262                                                        "string-value": "openflow:2:3"
263                                                }
264                }
265              ],
266              "port-type": "internal",
267                                "mac-address": "42:33:22:43:EF:02",
268                                "bandwidth": 10240
269                        },
270            {
271              "port-id": "openflow:2:2",
272                    "attribute": [
273                            {
274                  "attribute-name": "location",
275                                    "attribute-value": {
276                                            "string-value": "openflow:2:2"
277                                    }
278                }
279              ],
280              "port-type": "external",
281                    "mac-address": "32:7C:45:B9:ED:18",
282                    "bandwidth": 10240
283            },
284            {
285              "port-id": "openflow:2:1",
286                    "attribute": [
287                            {
288                  "attribute-name": "location",
289                                    "attribute-value": {
290                                            "string-value": "openflow:2:1"
291                                    }
292                }
293              ],
294              "port-type": "external",
295                    "mac-address": "D6:86:A8:54:2B:32",
296                    "bandwidth": 10240
297            }
298          ]
299        }
300      ]
301    },
302    "physical-links": {
303            "physical-link": [
304                    {
305          "link-id": "openflow:4:1",
306                            "loss-rate": 1,
307                            "delay": 1,
308                            "src-port-id": "openflow:4:1",
309                            "dest-node-id": "openflow:3",
310                            "metric": 1,
311                            "dest-port-id": "openflow:3:3",
312                            "bandwidth": 10240,
313                            "src-node-id": "openflow:4"
314                    },
315        {
316          "link-id": "openflow:2:3",
317                "loss-rate": 1,
318                "delay": 1,
319                "src-port-id": "openflow:2:3",
320                "dest-node-id": "openflow:3",
321                "metric": 1,
322                "dest-port-id": "openflow:3:2",
323                "bandwidth": 10240,
324                "src-node-id": "openflow:2"
325        },
326        {
327          "link-id": "openflow:3:1",
328                "loss-rate": 1,
329                "delay": 1,
330                "src-port-id": "openflow:3:1",
331                "dest-node-id": "openflow:1",
332                "metric": 1,
333                "dest-port-id": "openflow:1:3",
334                "bandwidth": 10240,
335                "src-node-id": "openflow:3"
336        },
337        {
338          "link-id": "openflow:1:3",
339                "loss-rate": 1,
340                "delay": 1,
341                "src-port-id": "openflow:1:3",
342                "dest-node-id": "openflow:3",
343                "metric": 1,
344                "dest-port-id": "openflow:3:1",
345                "bandwidth": 10240,
346                "src-node-id": "openflow:1"
347        },
348        {
349          "link-id": "openflow:3:3",
350                "loss-rate": 1,
351                "delay": 1,
352                "src-port-id": "openflow:3:3",
353                "dest-node-id": "openflow:4",
354                "metric": 1,
355                "dest-port-id": "openflow:4:1",
356                "bandwidth": 10240,
357                "src-node-id": "openflow:3"
358        },
359        {
360          "link-id": "openflow:3:2",
361                "loss-rate": 1,
362                "delay": 1,
363                "src-port-id": "openflow:3:2",
364                "dest-node-id": "openflow:2",
365                "metric": 1,
366                "dest-port-id": "openflow:2:3",
367                "bandwidth": 10240,
368                "src-node-id": "openflow:3"
369        }
370      ]
371    }
372  }
373                 }
374         put(PHYSICAL_NETWORK % contHost, data)
375
376
377 def register_user(contHost):
378         data={
379                         "input":{
380                                         "user-id":"14ce424a-3e50-4a2a-ad5c-b29845158c8b",
381                                         "user-name":"user2",
382                                         "user-password":"abc",
383                                         "user-role":"tenant"
384                                         }
385                 }
386         post(REGISTER_USER % contHost, data)
387
388 def transaction_begin(contHost):
389         data={
390                         "input":{
391                                         "user-id":"14ce424a-3e50-4a2a-ad5c-b29845158c8b"
392                                         }
393                 }
394         post(TRANSACTION_BEGIN % contHost, data)
395
396 def transaction_end(contHost):
397         data={
398                         "input":{
399                                         "user-id":"14ce424a-3e50-4a2a-ad5c-b29845158c8b"
400                                         }
401                 }
402         post(TRANSACTION_END % contHost, data)
403
404 def add_server1_host(contHost):
405         data={
406                         "input":{
407                                   "user-id": "14ce424a-3e50-4a2a-ad5c-b29845158c8b",
408                                   "objects":{
409                                                 "node":[
410                                                                 {
411                                                                         "node-name": "server1",
412                                                                         "node-type": "host",
413                                                                         "node-id":"7b796915-adf4-4356-b5ca-de005ac410c1"
414                                                                 }
415                                                         ]
416                                                 }
417                                         }
418                 }
419         post(STRUCTURE_UPDATE_USERS % contHost, data)
420
421 def add_server2_host(contHost):
422         data={
423                         "input":{
424                                   "user-id": "14ce424a-3e50-4a2a-ad5c-b29845158c8b",
425                                   "objects":{
426                                                 "node":[
427                                                                 {
428                                                                         "node-name": "server2",
429                                                                         "node-type": "host",
430                                                                         "node-id":"22282cca-9a13-4d0c-a67e-a933ebb0b0ae"
431                                                                 }
432                                                         ]
433                                                 }
434                                         }
435                 }
436         post(STRUCTURE_UPDATE_USERS % contHost, data)
437
438 def add_vm1_host(contHost):
439         data={
440                         "input":{
441                                   "user-id": "14ce424a-3e50-4a2a-ad5c-b29845158c8b",
442                                   "objects":{
443                                                 "node":[
444                                                                 {
445                                                                         "node-name": "vm1",
446                                                                         "node-type": "host",
447                                                                         "node-id":"1eaf9a67-a171-42a8-9282-71cf702f61dd"
448                                                                 }
449                                                         ]
450                                                 }
451                                         }
452                 }
453         post(STRUCTURE_UPDATE_USERS % contHost, data)
454
455 def add_vm2_host(contHost):
456         data={
457                         "input":{
458                                   "user-id": "14ce424a-3e50-4a2a-ad5c-b29845158c8b",
459                                   "objects":{
460                                                 "node":[
461                                                                 {
462                                                                         "node-name": "vm2",
463                                                                         "node-type": "host",
464                                                                         "node-id":"6c787caa-156a-49ed-8546-547bdccf283c"
465                                                                 }
466                                                         ]
467                                                 }
468                                         }
469                 }
470         post(STRUCTURE_UPDATE_USERS % contHost, data)
471
472 def add_enterpise_node(contHost):
473         data={
474                   "input":{
475                           "user-id": "14ce424a-3e50-4a2a-ad5c-b29845158c8b",
476                           "objects":{
477                           "node":[
478                                           {
479                                                         "node-name": "enterprise",
480                                                         "node-type": "ext-group",
481                                                         "property": [
482                                                                                   {
483                                                                                         "property-name": "location",
484                                                                                         "property-values": {
485                                                                                                           "string-value": [
486                                                                                                                         {
487                                                                                                                           "order": "0",
488                                                                                                                           "value": "openflow:4:2"
489                                                                                                                         }
490                                                                                                                 ]
491                                                                                                         }
492                                                                                   },
493                                                                                   {
494                                                                                         "property-name": "ac-info-network",
495                                                                                         "property-values": {
496                                                                                                           "string-value": [
497                                                                                                                         {
498                                                                                                                           "order": "0",
499                                                                                                                           "value": "layer3"
500                                                                                                                         }
501                                                                                                                 ]
502                                                                                                         }
503                                                                                   },
504                                                                                   {
505                                                                                         "property-name": "ac-info-protocol",
506                                                                                         "property-values": {
507                                                                                                           "string-value": [
508                                                                                                                         {
509                                                                                                                           "order": "0",
510                                                                                                                           "value": "static"
511                                                                                                                         }
512                                                                                                                 ]
513                                                                                                         }
514                                                                                   },
515                                                                                   {
516                                                                                         "property-name": "ip-prefix",
517                                                                                         "property-values": {
518                                                                                                           "string-value": [
519                                                                                                                         {
520                                                                                                                           "order": "0",
521                                                                                                                           "value": "192.168.13.0/24"
522                                                                                                                         }
523                                                                                                                 ]
524                                                                                                         }
525                                                                                   }
526                                                                                 ],
527                                                         "node-id": "94a6fb90-b425-4ffd-9515-c0684aa4c37f"
528                                                   }
529                                         ]
530                           }
531                   }
532                 }
533         post(STRUCTURE_UPDATE_USERS % contHost, data)
534
535 def add_internet_node(contHost):
536         data={
537                   "input":{
538                           "user-id": "14ce424a-3e50-4a2a-ad5c-b29845158c8b",
539                           "objects":{
540                           "node":[
541                                           {
542                                                         "node-name": "internet",
543                                                         "node-type": "ext-group",
544                                                         "property": [
545                                                                                   {
546                                                                                         "property-name": "location",
547                                                                                         "property-values": {
548                                                                                                           "string-value": [
549                                                                                                                         {
550                                                                                                                           "order": "0",
551                                                                                                                           "value": "openflow:3:4"
552                                                                                                                         }
553                                                                                                                 ]
554                                                                                                         }
555                                                                                   },
556                                                                                   {
557                                                                                         "property-name": "ac-info-network",
558                                                                                         "property-values": {
559                                                                                                           "string-value": [
560                                                                                                                         {
561                                                                                                                           "order": "0",
562                                                                                                                           "value": "layer3"
563                                                                                                                         }
564                                                                                                                 ]
565                                                                                                         }
566                                                                                   },
567                                                                                   {
568                                                                                         "property-name": "ac-info-protocol",
569                                                                                         "property-values": {
570                                                                                                                 "string-value": [
571                                                                                                                         {
572                                                                                                                                 "order": "0",
573                                                                                                                                 "value": "static"
574                                                                                                                         }
575                                                                                                                 ]
576                                                                                                         }
577                                                                                   },
578                                                                                   {
579                                                                                         "property-name": "ip-prefix",
580                                                                                         "property-values": {
581                                                                                                           "string-value": [
582                                                                                                                         {
583                                                                                                                           "order": "0",
584                                                                                                                           #wait for external network ip
585                                                                                                                           "value": "172.168.1.0/24"
586                                                                                                                         }
587                                                                                                                 ]
588                                                                                                         }
589                                                                                   }
590                                                                                 ],
591                                                         "node-id": "d463232f-363f-491c-a6f5-097ed0a794d3"
592                                                   }
593                                         ]
594                           }
595                   }
596                 }
597         post(STRUCTURE_UPDATE_USERS % contHost, data)
598
599 def add_dmz_node(contHost):
600         data={
601                   "input":{
602                           "user-id": "14ce424a-3e50-4a2a-ad5c-b29845158c8b",
603                           "objects":{
604                           "node":[
605                                           {
606                                                         "node-name": "dmz",
607                                                         "node-type": "l2-group",
608                                                         "sub-node": [
609                                                                                   {
610                                                                                         "node-id":"7b796915-adf4-4356-b5ca-de005ac410c1",
611                                                                                         "order":"0"
612                                                                                   }
613                                                                 ],
614                                                         "property": [
615                                                                                   {
616                                                                                         "property-name": "location",
617                                                                                         "property-values": {
618                                                                                                           "string-value": [
619                                                                                                                         {
620                                                                                                                           "order": "0",
621                                                                                                                           "value": "openflow:3"
622                                                                                                                         }
623                                                                                                                 ]
624                                                                                                         }
625                                                                                   },
626                                                                                   {
627                                                                                         "property-name": "ip-prefix",
628                                                                                         "property-values": {
629                                                                                                           "string-value": [
630                                                                                                                         {
631                                                                                                                           "order": "0",
632                                                                                                                           "value": "192.168.11.0/24"
633                                                                                                                         }
634                                                                                                                 ]
635                                                                                                         }
636                                                                                   },
637                                                                                   {
638                                                                                         "property-name": "gateway-ip",
639                                                                                         "property-values": {
640                                                                                                           "string-value": [
641                                                                                                                         {
642                                                                                                                           "order": "0",
643                                                                                                                           "value": "192.168.11.1"
644                                                                                                                         }
645                                                                                                                 ]
646                                                                                                         }
647                                                                                   }
648                                                                                 ],
649                                                         "node-id": "b46cfa7f-93a3-43f4-ac20-09307c75feca"
650                                                   }
651                                         ]
652                           }
653                   }
654                 }
655         post(STRUCTURE_UPDATE_USERS % contHost, data)
656
657 def add_interior_node(contHost):
658         data={
659                   "input":{
660                           "user-id": "14ce424a-3e50-4a2a-ad5c-b29845158c8b",
661                           "objects":{
662                           "node":[
663                                           {
664                                                         "node-name": "interior",
665                                                         "node-type": "l2-group",
666                                                         "sub-node": [
667                                                                                   {
668                                                                                         "node-id":"22282cca-9a13-4d0c-a67e-a933ebb0b0ae",
669                                                                                         "order":"0"
670                                                                                   },
671                                                                                   {
672                                                                                         "node-id":"1eaf9a67-a171-42a8-9282-71cf702f61dd",
673                                                                                         "order":"0"
674                                                                                   },
675                                                                                   {
676                                                                                         "node-id":"6c787caa-156a-49ed-8546-547bdccf283c",
677                                                                                         "order":"0"
678                                                                                   }
679                                                                 ],
680                                                         "property": [
681                                                                                   {
682                                                                                         "property-name": "location",
683                                                                                         "property-values": {
684                                                                                                           "string-value": [
685                                                                                                                         {
686                                                                                                                           "order": "0",
687                                                                                                                           "value": "openflow:3"
688                                                                                                                         }
689                                                                                                                 ]
690                                                                                                         }
691                                                                                   },
692                                                                                   {
693                                                                                         "property-name": "ip-prefix",
694                                                                                         "property-values": {
695                                                                                                           "string-value": [
696                                                                                                                         {
697                                                                                                                           "order": "0",
698                                                                                                                           "value": "192.168.12.0/24"
699                                                                                                                         }
700                                                                                                                 ]
701                                                                                                         }
702                                                                                   },
703                                                                                   {
704                                                                                         "property-name": "gateway-ip",
705                                                                                         "property-values": {
706                                                                                                           "string-value": [
707                                                                                                                         {
708                                                                                                                           "order": "0",
709                                                                                                                           "value": "192.168.12.1"
710                                                                                                                         }
711                                                                                                                 ]
712                                                                                                         }
713                                                                                   }
714                                                                                 ],
715                                                         "node-id": "175425f7-c9c9-474a-962c-70cb6c180d4d"
716                                                   }
717                                         ]
718                           }
719                   }
720                 }
721         post(STRUCTURE_UPDATE_USERS % contHost, data)
722
723 def add_enterprise_interior_connection(contHost):
724         data={
725                  "input": {
726                           "user-id": "14ce424a-3e50-4a2a-ad5c-b29845158c8b",
727                           "objects":{
728                                   "connection": [
729                                                   {
730                                                         "connection-name": "c1",
731                                                         "connection-id": "30da6667-608e-4d2f-bb50-79e5cabcc523",
732                                                         "end-node": [
733                                                           {
734                                                                 "order": "0",
735                                                                 "node-id": "94a6fb90-b425-4ffd-9515-c0684aa4c37f"
736                                                           },
737                                                           {
738                                                                 "order": "0",
739                                                                 "node-id": "175425f7-c9c9-474a-962c-70cb6c180d4d"
740                                                           }
741                                                         ],
742                                                         "connection-type": "p2p",
743                                                         "property": [
744                                                                 {
745                                                                         "property-name": "bandwidth",
746                                                                         "property-values": {
747                                                                                                           "int-value": [
748                                                                                                                         {
749                                                                                                                           "order": "0",
750                                                                                                                           "value": "128"
751                                                                                                                         }
752                                                                                                                 ]
753                                                                                                         }
754                                                                 }
755                                                         ]
756                                                 }
757                                         ]
758                                 }
759                   }
760         }
761         post(STRUCTURE_UPDATE_USERS % contHost, data)
762
763 def add_interior_dmz_connection(contHost):
764         data={
765                  "input": {
766                           "user-id": "14ce424a-3e50-4a2a-ad5c-b29845158c8b",
767                           "objects":{
768                                   "connection": [
769                                                   {
770                                                         "connection-name": "c2",
771                                                         "connection-id": "b49e3960-c08d-4fff-b9fc-08b65ebcde2c",
772                                                         "end-node": [
773                                                           {
774                                                                 "order": "0",
775                                                                 "node-id": "175425f7-c9c9-474a-962c-70cb6c180d4d"
776                                                           },
777                                                           {
778                                                                 "order": "0",
779                                                                 "node-id": "b46cfa7f-93a3-43f4-ac20-09307c75feca"
780                                                           }
781                                                         ],
782                                                         "connection-type": "p2p"
783                                                 }
784                                         ]
785                                 }
786                   }
787         }
788         post(STRUCTURE_UPDATE_USERS % contHost, data)
789
790 def add_dmz_internet_connection(contHost):
791         data={
792                  "input": {
793                           "user-id": "14ce424a-3e50-4a2a-ad5c-b29845158c8b",
794                           "objects":{
795                                   "connection": [
796                                                   {
797                                                         "connection-name": "c3",
798                                                         "connection-id": "e0d56fee-7235-4748-a2a1-eb5e3733d866",
799                                                         "end-node": [
800                                                           {
801                                                                 "order": "0",
802                                                                 "node-id": "b46cfa7f-93a3-43f4-ac20-09307c75feca"
803                                                           },
804                                                           {
805                                                                 "order": "0",
806                                                                 "node-id": "d463232f-363f-491c-a6f5-097ed0a794d3"
807                                                           }
808                                                         ],
809                                                         "connection-type": "p2p"
810                                                 }
811                                         ]
812                                 }
813                   }
814         }
815         post(STRUCTURE_UPDATE_USERS % contHost, data)
816
817 def update_enterprise_interior_connection(contHost):
818         data={
819                  "input": {
820                           "user-id": "14ce424a-3e50-4a2a-ad5c-b29845158c8b",
821                           "objects":{
822                                   "connection": [
823                                                   {
824                                                         "connection-name": "c1",
825                                                         "connection-id": "30da6667-608e-4d2f-bb50-79e5cabcc523",
826                                                         "end-node": [
827                                                           {
828                                                                 "order": "0",
829                                                                 "node-id": "94a6fb90-b425-4ffd-9515-c0684aa4c37f"
830                                                           },
831                                                           {
832                                                                 "order": "0",
833                                                                 "node-id": "175425f7-c9c9-474a-962c-70cb6c180d4d"
834                                                           }
835                                                         ],
836                                                         "connection-type": "p2p",
837                                                         "property": [
838                                                                 {
839                                                                         "property-name": "bandwidth",
840                                                                         "property-values": {
841                                                                                                           "int-value": [
842                                                                                                                         {
843                                                                                                                           "order": "0",
844                                                                                                                           "value": "512"
845                                                                                                                         }
846                                                                                                                 ]
847                                                                                                         }
848                                                                 }
849                                                         ]
850                                                 }
851                                         ]
852                                 }
853                   }
854         }
855         post(STRUCTURE_UPDATE_USERS % contHost, data)
856
857 def post(url, data):
858     headers = {'Content-type': 'application/yang.data+json',
859                'Accept': 'application/yang.data+json'}
860     print "POST %s" % url
861     print json.dumps(data, indent=4, sort_keys=True)
862     r = requests.post(url, data=json.dumps(data), headers=headers, auth=HTTPBasicAuth(USERNAME, PASSWORD))
863     print r.text
864     r.raise_for_status()
865
866 def put(url, data):
867     headers = {'Content-type': 'application/yang.data+json',
868                'Accept': 'application/yang.data+json'}
869     print "PUT %s" % url
870     print json.dumps(data, indent=4, sort_keys=True)
871     r = requests.put(url, data=json.dumps(data), headers=headers, auth=HTTPBasicAuth(USERNAME, PASSWORD))
872     print r.text
873     r.raise_for_status()
874
875 def delete(url):
876     headers = {'Content-type': 'application/yang.data+json',
877                'Accept': 'application/yang.data+json'}
878     print "DELETE %s" % url
879     r = requests.delete(url, headers=headers, auth=HTTPBasicAuth(USERNAME, PASSWORD))
880     print r.text
881     r.raise_for_status()
882
883
884 if __name__ == '__main__':
885
886         parser = argparse.ArgumentParser()
887         parser.add_argument('--controller', default='127.0.0.1', help='controller IP')
888         args=parser.parse_args()
889
890
891         create_physical_network(args.controller)
892
893         # CREATE User;
894         register_user(args.controller)
895
896
897         transaction_begin(args.controller)
898
899         # IMPORT Node server1 Type host;
900         add_server1_host(args.controller)
901
902         # IMPORT Node server2 Type host;
903         add_server2_host(args.controller)
904
905         # IMPORT Node vm1 Type host;
906         add_vm1_host(args.controller)
907
908         # IMPORT Node vm2 Type host;
909         add_vm2_host(args.controller)
910
911         # IMPORT Node enterprise Type ext-group Property location:openflow:4:2, ip-prefix:192.18.13.0/24;
912         add_enterpise_node(args.controller)
913
914         # CREATE Node interior Type l2-group Contain server1,vm1,vm2;
915         add_interior_node(args.controller)
916
917         # CREATE Node dmz Type l2-group Contain server2;
918         add_dmz_node(args.controller)
919
920         # IMPORT Node internet Type ext-group Property location:openflow:3:4, ip-prefix:172.168.1.0/24;
921         add_internet_node(args.controller)
922
923         transaction_end(args.controller)
924