-
Notifications
You must be signed in to change notification settings - Fork 18
/
api.py
1361 lines (1130 loc) · 51.1 KB
/
api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import abc
from ovsdbapp import api
from ovsdbapp import constants as const
class API(api.API, metaclass=abc.ABCMeta):
"""An API based off of the ovn-nbctl CLI interface
This API basically mirrors the ovn-nbctl operations with these changes:
1. Methods that create objects will return a read-only view of the object
2. Methods which list objects will return a list of read-only view objects
"""
@abc.abstractmethod
def ls_add(self, switch=None, may_exist=False, **columns):
"""Create a logical switch named 'switch'
:param switch: The name of the switch (optional)
:type switch: string or uuid.UUID
:param may_exist: If True, don't fail if the switch already exists
:type may_exist: boolean
:param columns: Additional columns to directly set on the switch
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def ls_del(self, switch, if_exists=False):
"""Delete logical switch 'switch' and all its ports
:param switch: The name or uuid of the switch
:type switch: string or uuid.UUID
:type if_exists: If True, don't fail if the switch doesn't exist
:type if_exists: boolean
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def ls_list(self):
"""Get all logical switches
:returns: :class:`Command` with RowView list result
"""
@abc.abstractmethod
def ls_get(self, switch):
"""Get logical switch for 'switch'
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def ls_set_dns_records(self, switch_uuid, dns_uuids):
"""Sets 'dns_records' column on the switch with uuid 'switch_uuid'
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def ls_clear_dns_records(self, switch):
"""Clears 'dns_records' from the switch with uuid 'switch_uuid'
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def ls_add_dns_record(self, switch_uuid, dns_uuid):
"""Add the 'dns_record' to the switch's 'dns_records' list
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def ls_remove_dns_record(self, switch_uuid, dns_uuid, if_exists=False):
"""Remove the 'dns_record' from the switch's 'dns_records' list
:param switch_uuid: The uuid of the switch
:type switch_uuid: string or uuid.UUID
:param dns_uuid: The uuid of the DNS record
:type dns_uuid: string or uuid.UUID
:param if_exists: If True, don't fail if the DNS record
doesn't exist
:type if_exists: boolean
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def acl_add(self, switch, direction, priority, match, action, log=False):
"""Add an ACL to 'switch'
:param switch: The name or uuid of the switch
:type switch: string or uuid.UUID
:param direction: The traffic direction to match
:type direction: 'from-lport' or 'to-lport'
:param priority: The priority field of the ACL
:type priority: int
:param match: The match rule
:type match: string
:param action: The action to take upon match
:type action: 'allow', 'allow-related', 'allow-stateless', 'drop',
or 'reject'
:param log: If True, enable packet logging for the ACL
:type log: boolean
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def acl_del(self, switch, direction=None, priority=None, match=None):
"""Remove ACLs from 'switch'
If only switch is supplied, all the ACLs from the logical switch are
deleted. If direction is also specified, then all the flows in that
direction will be deleted from the logical switch. If all the fields
are given, then only flows that match all fields will be deleted.
:param switch: The name or uuid of the switch
:type switch: string or uuid.UUID
:param direction: The traffic direction to match
:type direction: 'from-lport' or 'to-lport'
:param priority: The priority field of the ACL
:type priority: int
:param match: The match rule
:type match: string
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def acl_list(self, switch):
"""Get the ACLs for 'switch'
:param switch: The name or uuid of the switch
:type switch: string or uuid.UUID
:returns: :class:`Command` with RowView list result
"""
@abc.abstractmethod
def pg_acl_add(self, port_group, direction, priority, match, action,
log=False, may_exist=False, severity=None, name=None,
meter=None, **external_ids):
"""Add an ACL to 'port_group'
:param port_group: The name or uuid of the port group
:type port_group: string or uuid.UUID
:param direction: The traffic direction to match
:type direction: 'from-lport' or 'to-lport'
:param priority: The priority field of the ACL
:type priority: int
:param match: The match rule
:type match: string
:param action: The action to take upon match
:type action: 'allow', 'allow-related', 'allow-stateless',
'drop', or 'reject'
:param log: If True, enable packet logging for the ACL
:type log: boolean
:param may_exist: If True, don't fail if the ACL already exists
:type may_exist: boolean
:param severity: Logging at alert, debug, info, notice or warning
:type severity: string
:param name: The name of the ACL
:type name: string
:param meter: The meter name to rate limit logging
:type meter: string
:param external_ids: Values to be added as external_id pairs
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def pg_acl_del(self, port_group, direction=None, priority=None,
match=None):
"""Remove ACLs from 'port_group'
If only port_group is supplied, all the ACLs from the logical switch
are deleted. If direction is also specified, then all the flows in
that direction will be deleted from the Port Group. If all the fields
are given, then only flows that match all fields will be deleted.
:param port_group: The name or uuid of the port group
:type port_group: string or uuid.UUID
:param direction: The traffic direction to match
:type direction: 'from-lport' or 'to-lport'
:param priority: The priority field of the ACL
:type priority: int
:param match: The match rule
:type match: string
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def pg_acl_list(self, port_group):
"""Get the ACLs for 'port group'
:param port_group: The name or uuid of the switch
:type port_group: string or uuid.UUID
:returns: :class:`Command` with RowView list result
"""
@abc.abstractmethod
def address_set_add(self, name, addresses=None, may_exist=False):
"""Create a set of addresses named 'name'
:param name: The name of the address set
:type name: string
:param addresses: One or more IP addresses to add to the address set
:type addresses: list of strings
:param may_exist: If True, don't fail if the address set already exists
:type may_exist: boolean
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def address_set_del(self, address_set, if_exists=False):
"""Delete a set of addresses 'address_set'
:param address_set: The name of the address set
:type address_set: string or uuid.UUID
:param if_exists: Do not fail if the Address_set row does not exist
:type if_exists: bool
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def address_set_get(self, address_set):
"""Get a set of addresses for 'address_set'
:param address_set: The name of the address set
:type address_set: string or uuid.UUID
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def address_set_list(self):
"""Get all sets of addresses
:returns: :class:`Command` with RowView list result
"""
@abc.abstractmethod
def address_set_add_addresses(self, address_set, addresses):
"""Add a list of addresses to 'address_set'
:param address_set: The name of the address set
:type address_set: string or uuid.UUID
:param addresses: One or more IP addresses to add to the address set
:type addresses: string or list of strings
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def address_set_remove_addresses(self, address_set, addresses):
"""Remove a list of addresses from 'address_set'
:param address_set: The name of the address set
:type address_set: string or uuid.UUID
:param addresses: One or more IP addresses to remove from address set
:type addresses: string of list of strings
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def qos_add(self, switch, direction, priority, match, rate=None,
burst=None, dscp=None, may_exist=False, **columns):
"""Add an Qos rules to 'switch'
:param switch: The name or uuid of the switch
:type switch: string or uuid.UUID
:param direction: The traffic direction to match
:type direction: 'from-lport' or 'to-lport'
:param priority: The priority field of the QoS
:type priority: int
:param match: The match rule
:type match: string
:param dscp: The dscp mark to take upon match
:type dscp: int
:param rate: The rate limit to take upon match
:type rate: int
:param burst: The burst rate limit to take upon match
:type burst: int
:param may_exist: If True, don't fail if the QoS rule already exists
:type may_exist: boolean
:param columns: Additional columns to directly set on the switch
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def qos_del(self, switch, direction=None, priority=None, match=None,
if_exists=True):
"""Remove Qos rules from 'switch'
If only switch is supplied, all the QoS rules from the logical switch
are deleted. If direction is also specified, then all the flows in
that direction will be deleted from the logical switch. If all the
fields are given, then only flows that match all fields will be
deleted.
:param switch: The name or uuid of the switch
:type switch: string or uuid.UUID
:param direction: The traffic direction to match
:type direction: 'from-lport' or 'to-lport'
:param priority: The priority field of the QoS
:type priority: int
:param match: The match rule
:type match: string
:param if_exists: Do not fail if the Logical_Switch row does not exist
:type if_exists: bool
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def qos_list(self, switch):
"""Get the Qos rules for 'switch'
:param switch: The name or uuid of the switch
:type switch: string or uuid.UUID
:returns: :class:`Command` with RowView list result
"""
@abc.abstractmethod
def qos_del_ext_ids(self, lswitch_name, external_ids, if_exists=True):
"""Delete all QoS rules related to a floating IP.
:param lswitch_name: The unique name of the logical switch
:type lswitch_name: string
:param external_ids: Pairs of key/value to find in the "external_ids"
:type external_ids: dict
:param if_exists: Do not fail if the Logical_Switch row does not exist
:type if_exists: bool
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lsp_add(self, switch, port, parent_name=None, tag=None,
may_exist=False, **columns):
"""Add logical port 'port' on 'switch'
NOTE: for the purposes of testing the existence of the 'port',
'port' is treated as either a name or a uuid, as in ovn-nbctl.
:param switch: The name or uuid of the switch
:type switch: string or uuid.UUID
:param port: The name of the port
:type port: string or uuid.UUID
:param parent_name: The name of the parent port (requires tag)
:type parent_name: string
:param tag: The tag_request field of the port. 0 causes
ovn-northd to assign a unique tag
:type tag: int [0, 4095]
:param may_exist: If True, don't fail if the switch already exists
:type may_exist: boolean
:param columns: Additional columns to directly set on the switch
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def lsp_del(self, port, if_exists=False):
"""Delete 'port' from its attached switch
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:type if_exists: If True, don't fail if the switch doesn't exist
:type if_exists: boolean
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lsp_list(self, switch=None):
"""Get the logical ports on switch or all ports if switch is None
:param switch: The name or uuid of the switch
:type switch: string or uuid.UUID
:returns: :class:`Command` with RowView list result
"""
@abc.abstractmethod
def lsp_get(self, port):
"""Get logical switch port for 'port'
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def lsp_get_parent(self, port):
"""Get the parent of 'port' if set
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:returns: :class:`Command` with port parent string result or
"" if not set
"""
@abc.abstractmethod
def lsp_set_addresses(self, port, addresses):
"""Set addresses for 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:param addresses: One or more addresses in the format:
'unknown', 'router', 'dynamic', or
'ethaddr [ipaddr]...'
:type addresses: string
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lsp_get_addresses(self, port):
"""Return the list of addresses assigned to port
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:returns: A list of string representations of addresses in the
format referenced in lsp_set_addresses
"""
@abc.abstractmethod
def lsp_set_port_security(self, port, addresses):
"""Set port security addresses for 'port'
Sets the port security addresses associated with port to addrs.
Multiple sets of addresses may be set by using multiple addrs
arguments. If no addrs argument is given, port will not have
port security enabled.
Port security limits the addresses from which a logical port may
send packets and to which it may receive packets.
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:param addresses: The addresses in the format 'ethaddr [ipaddr...]'
See `man ovn-nb` and port_security column for details
:type addresses: string
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lsp_get_port_security(self, port):
"""Get port security addresses for 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:returns: :class:`Command` with list of strings described by
lsp_set_port_security result
"""
@abc.abstractmethod
def lsp_get_up(self, port):
"""Get state of port.
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:returns: :class:`Command` with boolean result
"""
@abc.abstractmethod
def lsp_set_enabled(self, port, is_enabled):
"""Set administrative state of 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:param is_enabled: Whether the port should be enabled
:type is_enabled: boolean
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lsp_get_enabled(self, port):
"""Get administrative state of 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:returns: :class:`Command` with boolean result
"""
@abc.abstractmethod
def lsp_set_type(self, port, port_type):
"""Set the type for 'port
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:param port_type: The type of the port
:type port_type: string
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lsp_get_type(self, port):
"""Get the type for 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:returns: :class:`Command` with string result
"""
@abc.abstractmethod
def lsp_set_options(self, port, **options):
"""Set options related to the type of 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:param options: keys and values for the port 'options' dict
:type options: key: string, value: string
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lsp_get_options(self, port):
"""Get the type-specific options for 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:returns: :class:`Command` with dict result
"""
@abc.abstractmethod
def lsp_set_dhcpv4_options(self, port, dhcp_options_uuid):
"""Set the dhcp4 options for 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:param dhcp_options_uuid: The uuid of the dhcp_options row
:type dhcp_options_uuid: uuid.UUID
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lr_add(self, router=None, may_exist=False, **columns):
"""Create a logical router named `router`
:param router: The optional name or uuid of the router
:type router: string or uuid.UUID
:param may_exist: If True, don't fail if the router already exists
:type may_exist: boolean
:param **columns: Additional columns to directly set on the router
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def lr_del(self, router, if_exists=False):
"""Delete 'router' and all its ports
:param router: The name or uuid of the router
:type router: string or uuid.UUID
:param if_exists: If True, don't fail if the router doesn't exist
:type if_exists: boolean
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lr_list(self):
"""Get the UUIDs of all logical routers
:returns: :class:`Command` with RowView list result
"""
@abc.abstractmethod
def lr_get(self, router):
"""Get logical router for 'router'
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def lrp_add(self, router, port, mac, networks, peer=None, may_exist=False,
**columns):
"""Add logical port 'port' on 'router'
:param router: The name or uuid of the router to attach the port
:type router: string or uuid.UUID
:param mac: The MAC address of the port
:type mac: string
:param networks: One or more IP address/netmask to assign to the port
:type networks: list of strings
:param peer: Optional logical router port connected to this one
:param may_exist: If True, don't fail if the port already exists
:type may_exist: boolean
:param **columns: Additional column values to directly set on the port
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def lrp_del(self, port, router=None, if_exists=None):
"""Delete 'port' from its attached router
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:param router: Only delete router if attached to `router`
:type router: string or uuiwhd.UUID
:param if_exists: If True, don't fail if the port doesn't exist
:type if_exists: boolean
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lrp_list(self, router):
"""Get the UUIDs of all ports on 'router'
:param router: The name or uuid of the router
:type router: string or uuid.UUID
:returns: :class:`Command` with RowView list result
"""
@abc.abstractmethod
def lrp_get(self, port):
"""Get logical router port for 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def lrp_set_enabled(self, port, is_enabled):
"""Set administrative state of 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:param is_enabled: True for enabled, False for disabled
:type is_enabled: boolean
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lrp_get_enabled(self, port):
"""Get administrative state of 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:returns:
"""
@abc.abstractmethod
def lrp_set_options(self, port, **options):
"""Set options related to the type of 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:param options: keys and values for the port 'options' dict
:type options: key: string, value: string
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lrp_get_options(self, port):
"""Get the type-specific options for 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:returns: :class:`Command` with dict result
"""
@abc.abstractmethod
def lrp_set_gateway_chassis(self, port, gateway_chassis, priority=0):
"""Set gateway chassis for 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:param gateway_chassis: The name of the gateway chassis
:type gateway_chassis: string
:param priority: The priority of the gateway chassis
:type priority: int
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lrp_get_gateway_chassis(self, port):
"""Get the names of all gateway chassis on 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:type port: int
:returns: :class:`Command` with RowView list result
"""
@abc.abstractmethod
def lrp_del_gateway_chassis(self, port, gateway_chassis, if_exists=False):
"""Delete gateway chassis from 'port'
:param port: The name or uuid of the port
:type port: string or uuid.UUID
:param gateway_chassis: The name of the gateway chassis
:type gateway_chassis: string
:param if_exists: If True, don't fail if the gateway chassis
doesn't exist
:type if_exists: boolean
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lr_route_add(self, router, prefix, nexthop, port=None,
policy='dst-ip', may_exist=False):
"""Add a route to 'router'
:param router: The name or uuid of the router
:type router: string or uuid.UUID
:param prefix: an IPv4/6 prefix for this route, e.g. 192.168.1.0/24
:type prefix: type string
:parm nexthop: The gateway to use for this route, which should be
the IP address of one of `router`'s logical router
ports or the IP address of a logical port
:type nexthop: string
:param port: If specified, packets that match this route will be
sent out this port. Otherwise OVN infers the output
port based on nexthop.
:type port: string
:param policy: the policy used to make routing decisions
:type policy: string, 'dst-ip' or 'src-ip'
:param may_exist: If True, don't fail if the route already exists
:type may_exist: boolean
returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def lr_route_del(self, router, prefix=None, if_exists=False):
"""Remove routes from 'router'
:param router: The name or uuid of the router
:type router: string or uuid.UUID
:param prefix: an IPv4/6 prefix to match, e.g. 192.168.1.0/24
:type prefix: type string
:param if_exists: If True, don't fail if the port doesn't exist
:type if_exists: boolean
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lr_route_list(self, router):
"""Get the UUIDs of static logical routes from 'router'
:param router: The name or uuid of the router
:type router: string or uuid.UUID
:returns: :class:`Command` with RowView list result
"""
@abc.abstractmethod
def lr_nat_add(self, router, nat_type, external_ip, logical_ip,
logical_port=None, external_mac=None, may_exist=False):
"""Add a NAT to 'router'
:param router: The name or uuid of the router
:type router: string or uuid.UUID
:param nat_type: The type of NAT to be done
:type nat_type: NAT_SNAT, NAT_DNAT, or NAT_BOTH
:param external_ip: Externally visible Ipv4 address
:type external_ip: string
:param logical_ip: The logical IPv4 network or address with which
`external_ip` is NATted
:type logical_ip: string
:param logical_port: The name of an existing logical switch port where
the logical_ip resides
:type logical_port: string
:param external_mac: ARP replies for the external_ip return the value
of `external_mac`. Packets transmitted with
source IP address equal to `external_ip` will be
sent using `external_mac`.
:type external_mac: string
:param may_exist: If True, don't fail if the route already exists
and if `logical_port` and `external_mac` are
specified, they will be updated
:type may_exist: boolean
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def lr_nat_del(self, router, nat_type=None, match_ip=None, if_exists=None):
"""Remove NATs from 'router'
:param router: The name or uuid of the router
:type router: string or uuid.UUID
:param nat_type: The type of NAT to match
:type nat_type: NAT_SNAT, NAT_DNAT, or NAT_BOTH
:param match_ip: The IPv4 address to match on. If
`nat_type` is specified and is NAT_SNAT, the IP
should be the logical ip, otherwise the IP should
be the external IP.
:type match_ip: string
:param if_exists: If True, don't fail if the port doesn't exist
:type if_exists: boolean
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lr_nat_list(self, router):
"""Get the NATs on 'router'
:param router: The name or uuid of the router
:type router: string or uuid.UUID
:returns: :class:`Command` with RowView list result
"""
@abc.abstractmethod
def lr_policy_add(self, router, priority, match, action, may_exist=False,
**columns):
"""Add a routing policy (PBR) to 'router'
:param router: The name or uuid of the router
:type router: string or uuid.UUID
:param priority: The priority of the policy
:type priority: int
:param match: The match rule
:type match: string
:param action: The action to take upon match
:type action: POLICY_ACTION_ALLOW, POLICY_ACTION_DROP,
POLICY_ACTION_REROUTE
:param may_exist: If True, don't fail if the policy already exists
and instead update the columns
:type may_exist: boolean
:param columns: Additional columns to directly set on the policy
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def lr_policy_del(self, router, priority=None, match=None,
if_exists=False):
"""Remove routing policies (PBR) from router
:param router: The name or uuid of the router
:type router: string or uuid.UUID
:param priority: The priority of the rule
:type priority: int
:param match: The match condition of the rule. This should only
be specified if priority is specified.
:type match: string
:param if_exists: If True, don't fail if the port doesn't exist
:type if_exists: boolean
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lr_policy_list(self, router):
"""Get the list of routing policies on 'router'
:param router: The name or uuid of the router
:type router: string or uuid.UUID
:returns: :class:`Command` with RowView list result
"""
@abc.abstractmethod
def lb_add(self, lb, vip, ips, protocol=const.PROTO_TCP, may_exist=False,
**columns):
"""Create a load-balancer or add a VIP to an existing load balancer
:param lb: The name or uuid of the load-balancer
:type lb: string or uuid.UUID
:param vip: A virtual IP in the format IP[:PORT]
:type vip: string
:param ips: A list of ips in the form IP[:PORT]
:type ips: string
:param protocol: The IP protocol for load balancing
:type protocol: PROTO_TCP or PROTO_UDP
:param may_exist: If True, don't fail if a LB w/ `vip` exists, and
instead, replace the vips on the LB
:type may_exist: boolean
:param columns: Additional columns to directly set on the load
balancer
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def lb_del(self, lb, vip=None, if_exists=False):
"""Remove a load balancer or just the VIP from a load balancer
If all vips of the load balancer are removed, the load balancer
instance will be removed as well. If vip parameter is 'None'
this will cause all vips (and load balancer) to be removed.
:param lb: The name or uuid of a load balancer
:type lb: string or uuid.UUID
:param vip: The VIP to match. If None, match all vips
:type: string
:param if_exists: If True, don't fail if the lb/vip doesn't exist
:type if_exists: boolean
"""
@abc.abstractmethod
def lb_list(self):
"""Get the UUIDs of all load balanacers"""
@abc.abstractmethod
def lb_get(self, lb):
"""Get load balancer for 'lb'
:returns: :class:`Command` with RowView result
"""
@abc.abstractmethod
def lb_add_health_check(self, lb, vip, **options):
"""Add health check for 'lb'
:param lb: The name or uuid of a load balancer
:type lb: string or uuid.UUID
:param vip: A virtual IP
:type vip: string
:param options: keys and values for the port 'options' dict
:type options: key: string, value: string
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lb_del_health_check(self, lb, hc_uuid, if_exists=False):
"""Remove health check from 'lb'
:param lb: The name or uuid of a load balancer
:type lb: string or uuid.UUID
:param hc_uuid: uuid of a health check
:type hc_uuid: uuid.UUID
:param if_exists: If True, don't fail if the hc_uuid doesn't exist
:type if_exists: boolean
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lb_add_ip_port_mapping(self, lb, endpoint_ip, port_name, source_ip):
"""Add IP port mapping to 'lb'
Maps from endpoint IP to a colon-separated pair of logical port name
and source IP, e.g. port_name:sourc_ip.
:param lb: The name or uuid of a load balancer
:type lb: string or uuid.UUID
:param endpoint_ip: IPv4 address
:type endpoint_ip: string
:param port_name: The name of a logical port
:type port_name: string
:param source_ip: IPv4 address
:type source_ip: string
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lb_del_ip_port_mapping(self, lb, endpoint_ip):
"""Remove IP port mapping from 'lb'
:param lb: The name or uuid of a load balancer
:type lb: string or uuid.UUID
:param endpoint_ip: IPv4 address
:type endpoint_ip: string
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def health_check_set_options(self, hc_uuid, **options):
"""Set options to the 'health_check'
:param hc_uuid: uuid of the health check
:type hc_uuid: uuid.UUID
:param options: keys and values for the port 'options' dict
:type options: key: string, value: string
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def health_check_get_options(self, hc_uuid):
"""Get the options for 'health_check'
:param hc_uuid: uuid of the health check
:type hc_uuid: uuid.UUID
:returns: :class:`Command` with dict result
"""
@abc.abstractmethod
def lr_lb_add(self, router, lb, may_exist=False):
"""Add a load-balancer to 'router'
:param router: The name or uuid of the router
:type router: string or uuid.UUID
:param lb: The name or uuid of the load balancer
:type lb: string or uuid.UUID
:param may_exist: If True, don't fail if lb already assigned to lr
:type may_exist: boolean
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lr_lb_del(self, router, lb=None, if_exists=False):
"""Remove load-balancers from 'router'
:param router: The name or uuid of the router
:type router: string or uuid.UUID
:param lb: The name or uuid of the load balancer to remove. None
to remove all load balancers from the router
:type lb: string or uuid.UUID
:type if_exists: If True, don't fail if the switch doesn't exist
:type if_exists: boolean
:returns: :class:`Command` with no result
"""
@abc.abstractmethod
def lr_lb_list(self, router):
"""Get UUIDs of load-balancers on 'router'