@@ -709,6 +709,11 @@ class NetworkDataPath(str, Enum):
709
709
Sriov = "Sriov"
710
710
711
711
712
+ class IPVersion (str , Enum ):
713
+ IPv4 = "IPv4"
714
+ IPv6 = "IPv6"
715
+
716
+
712
717
_network_data_path_priority : List [NetworkDataPath ] = [
713
718
NetworkDataPath .Sriov ,
714
719
NetworkDataPath .Synthetic ,
@@ -740,6 +745,21 @@ class NetworkInterfaceOptionSettings(FeatureSettings):
740
745
)
741
746
),
742
747
)
748
+ ip_version : Optional [Union [search_space .SetSpace [IPVersion ], IPVersion ]] = (
749
+ field ( # type: ignore
750
+ default_factory = partial (
751
+ search_space .SetSpace ,
752
+ items = [IPVersion .IPv4 , IPVersion .IPv6 ],
753
+ ),
754
+ metadata = field_metadata (
755
+ decoder = partial (
756
+ search_space .decode_nullable_set_space ,
757
+ base_type = IPVersion ,
758
+ default_values = [IPVersion .IPv4 , IPVersion .IPv6 ],
759
+ )
760
+ ),
761
+ )
762
+ )
743
763
# nic_count is used for specifying associated nic count during provisioning vm
744
764
nic_count : search_space .CountSpace = field (
745
765
default_factory = partial (search_space .IntRange , min = 1 ),
@@ -762,14 +782,15 @@ def __eq__(self, o: object) -> bool:
762
782
return (
763
783
self .type == o .type
764
784
and self .data_path == o .data_path
785
+ and self .ip_version == o .ip_version
765
786
and self .nic_count == o .nic_count
766
787
and self .max_nic_count == o .max_nic_count
767
788
)
768
789
769
790
def __repr__ (self ) -> str :
770
791
return (
771
- f"data_path:{ self .data_path } , nic_count :{ self .nic_count } , "
772
- f" max_nic_count:{ self .max_nic_count } "
792
+ f"data_path:{ self .data_path } , ip_version :{ self .ip_version } , "
793
+ f"nic_count: { self . nic_count } , max_nic_count:{ self .max_nic_count } "
773
794
)
774
795
775
796
def __str__ (self ) -> str :
@@ -806,6 +827,11 @@ def check(self, capability: Any) -> search_space.ResultReason:
806
827
"data_path" ,
807
828
)
808
829
830
+ result .merge (
831
+ search_space .check_setspace (self .ip_version , capability .ip_version ),
832
+ "ip_version" ,
833
+ )
834
+
809
835
result .merge (
810
836
search_space .check_countspace (self .max_nic_count , capability .max_nic_count ),
811
837
"max_nic_count" ,
@@ -839,6 +865,7 @@ def _call_requirement_method(
839
865
value .data_path = getattr (search_space , f"{ method .value } _setspace_by_priority" )(
840
866
self .data_path , capability .data_path , _network_data_path_priority
841
867
)
868
+
842
869
return value
843
870
844
871
0 commit comments