@@ -338,6 +338,110 @@ Restart a service only if it is already running.
338
338
$ xe host-call-plugin host-uuid<uuid> plugin=service.py fn=try_restart_service args:service=<service>
339
339
```
340
340
341
+
342
+ ### ` sdncontroller `
343
+
344
+ Add, delete rules and dump openflow rules.
345
+
346
+ #### Add rule
347
+
348
+ Parameters for adding a rule:
349
+ - * bridge* : The name of the bridge to add rule to.
350
+ - * priority* (optional): A number between 0 and 65535 for the rule priority.
351
+ - * mac* (optional): The MAC address of the VIF to create the rule for, if not
352
+ specified, a network-wide rule will be created.
353
+ - * iprange* : An IP or range of IPs in CIDR notation, for example ` 192.168.1.0/24 ` .
354
+ - * direction* : can be ** from** , ** to** or ** from/to**
355
+ - * to* : means the parameters for ** port** and ** iprange** are to be used as destination
356
+ - * from* : means they will be use as source
357
+ - * from/to* : 2 rules will be created, one per direction
358
+ - * protocol* : IP, TCP, UDP, ICMP or ARP
359
+ - * port* : required for TCP/UDP protocol
360
+ - * allow* : If set to false the packets are dropped.
361
+
362
+ ```
363
+ $ xe host-call-plugin host-uuid<uuid> plugin=sdncontroller.py \
364
+ fn=add-rule \
365
+ args:bridge="xenbr0" \
366
+ args:priority="100" \
367
+ args:mac="6e:0b:9e:72:ab:c6" \
368
+ args:iprange="192.168.1.0/24" \
369
+ args:direction="from/to" \
370
+ args:protocol="tcp" \
371
+ args:port="22" \
372
+ args:allow="false"
373
+ ```
374
+
375
+ ##### Delete rule
376
+
377
+ Parameters for removing a rule:
378
+ - * bridge* : The name of the bridge to delete the rule from.
379
+ - * mac* (optional): The MAC address of the VIF to delete the rule for.
380
+ - * iprange* : An IP or range of IPs in CIDR notation, for example ` 192.168.1.0/24 ` .
381
+ - * direction* : can be ** from** , ** to** or ** from/to**
382
+ - * to* : means the parameters for ** port** and ** iprange** are to be used as destination
383
+ - * from* : means they will be use as source
384
+ - * from/to* : 2 rules will be created, one per direction
385
+ - * protocol* : IP, TCP, UDP, ICMP or ARP
386
+ - * port* : required for TCP/UDP protocol
387
+
388
+ ```
389
+ $ xe host-call-plugin host-uuid<uuid> plugin=sdncontroller.py \
390
+ fn=del-rule \
391
+ args:bridge="xenbr0" \
392
+ args:mac="6e:0b:9e:72:ab:c6" \
393
+ args:iprange="192.168.1.0/24" \
394
+ args:direction="from/to" \
395
+ args:protocol="tcp" \
396
+ args:port="22"
397
+ ```
398
+
399
+ ##### Dump flows
400
+
401
+ - This command will return all flows entries in the bridge passed as a parameter.
402
+ ```
403
+ $ xe host-call-plugin host-uuid=<uuid> plugin=sdncontroller.py fn=dump-flows args:bridge=xenbr0 | jq .
404
+ {
405
+ "returncode": 0,
406
+ "command": [
407
+ "ovs-ofctl",
408
+ "dump-flows",
409
+ "xenbr0"
410
+ ],
411
+ "stderr": "",
412
+ "stdout": "NXST_FLOW reply (xid=0x4):\n cookie=0x0, duration=248977.339s, table=0, n_packets=24591786, n_bytes=3278442075, idle_age=0, hard_age=65534, priority=0 actions=NORMAL\n"
413
+ }
414
+ ```
415
+
416
+ - This error is raised when the bridge parameter is missing:
417
+ ```
418
+ $ xe host-call-plugin host-uuid=<uuid> plugin=sdncontroller.py fn=dump-flows | jq .
419
+ {
420
+ "returncode": 1,
421
+ "command": [
422
+ "ovs-ofctl",
423
+ "dump-flows"
424
+ ],
425
+ "stderr": "bridge parameter is missing",
426
+ "stdout": ""
427
+ }
428
+ ```
429
+
430
+ - If the bridge is unknown, the following error will occur:
431
+ ```
432
+ $ xe host-call-plugin host-uuid=<uuid> plugin=sdncontroller.py args:bridge=xenbr10 fn=dump-flows | jq .
433
+ {
434
+ "returncode": 1,
435
+ "command": [
436
+ "ovs-ofctl",
437
+ "dump-flows",
438
+ "xenbr10"
439
+ ],
440
+ "stderr": "ovs-ofctl: xenbr10 is not a bridge or a socket\n",
441
+ "stdout": ""
442
+ }
443
+ ```
444
+
341
445
## Tests
342
446
343
447
To run the plugins' unit tests you'll need to install ` pytest ` , ` pyfakefs ` and ` mock ` .
0 commit comments