Skip to content

Commit cba07ba

Browse files
committed
CP-12093: Add a new field "capabilities" to PIF record
Use fcoe_driver interface to identify fcoe capable NICs. Capabilities field: 1) ["fcoe"] - represents NIC supports fcoe 2) [] - represents NIC doesn't support fcoe Signed-off-by: sharad yadav <[email protected]>
1 parent e274245 commit cba07ba

File tree

7 files changed

+20
-6
lines changed

7 files changed

+20
-6
lines changed

ocaml/client_records/records.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ let pif_record rpc session_id pif =
267267
~get:(fun () -> Record_util.s2sm_to_string "; " (x ()).API.pIF_properties)
268268
~get_map:(fun () -> (x ()).API.pIF_properties)
269269
~set_in_map:(fun k v -> Client.PIF.set_property rpc session_id pif k v) ();
270+
make_field ~name:"capabilities" ~get:(fun () -> String.concat "; " (x ()).API.pIF_capabilities)
271+
~get_set:(fun () -> (x ()).API.pIF_capabilities) ();
270272
make_field ~name:"io_read_kbs" ~get:(fun () ->
271273
try
272274
let host = (x ()).API.pIF_host in

ocaml/idl/datamodel.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4944,6 +4944,7 @@ let pif =
49444944
is managed by xapi. If it is not, then xapi will not configure the interface, the commands PIF.plug/unplug/reconfigure_ip(v6) \
49454945
can not be used, nor can the interface be bonded or have VLANs based on top through xapi." ~default_value:(Some (VBool true));
49464946
field ~lifecycle:[Published, rel_creedence, ""] ~qualifier:DynamicRO ~ty:(Map(String, String)) ~default_value:(Some (VMap [])) "properties" "Additional configuration properties for the interface.";
4947+
field ~lifecycle:[Published, rel_dundee, ""] ~qualifier:DynamicRO ~ty:(Set(String)) ~default_value:(Some (VSet [])) "capabilities" "Additional capabilities on the interface.";
49474948
]
49484949
()
49494950

ocaml/xapi/network.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module Net :
1313
val exists : string -> name:Network_interface.iface -> bool
1414
val get_mac : string -> name:Network_interface.iface -> string
1515
val is_up : string -> name:Network_interface.iface -> bool
16+
val get_capabilities: string -> name:Network_interface.iface -> string list
1617
val get_ipv4_addr :
1718
string ->
1819
name:Network_interface.iface -> (Unix.inet_addr * int) list

ocaml/xapi/xapi_bond.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ let create ~__context ~network ~members ~mAC ~mode ~properties =
398398
~ip_configuration_mode:`None ~iP:"" ~netmask:"" ~gateway:"" ~dNS:"" ~bond_slave_of:Ref.null
399399
~vLAN_master_of:Ref.null ~management:false ~other_config:[] ~disallow_unplug:false
400400
~ipv6_configuration_mode:`None ~iPv6:[""] ~ipv6_gateway:"" ~primary_address_type:`IPv4 ~managed:true
401-
~properties:pif_properties;
401+
~properties:pif_properties ~capabilities:[];
402402
Db.Bond.create ~__context ~ref:bond ~uuid:(Uuid.to_string (Uuid.make_uuid ())) ~master:master ~other_config:[]
403403
~primary_slave ~mode ~properties ~links_up:0L;
404404

ocaml/xapi/xapi_pif.ml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,18 @@ let refresh_internal ~__context ~self =
5656
(Db.PIF.set_MAC)
5757
(fun () -> Net.Interface.get_mac dbg ~name:device)
5858
(id);
59+
5960
maybe_update_database "MTU"
6061
(Db.PIF.get_MTU)
6162
(Db.PIF.set_MTU)
6263
(Int64.of_int ++ (fun () -> Net.Interface.get_mtu dbg ~name:bridge))
63-
(Int64.to_string)
64+
(Int64.to_string);
65+
66+
maybe_update_database "capabilities"
67+
(Db.PIF.get_capabilities)
68+
(Db.PIF.set_capabilities)
69+
(fun () -> Net.Interface.get_capabilities dbg ~name:device)
70+
(String.concat "; ")
6471

6572
let refresh ~__context ~host ~self =
6673
assert (host = Helpers.get_localhost ~__context);
@@ -316,7 +323,7 @@ let pool_introduce
316323
~ip_configuration_mode ~iP ~netmask ~gateway ~dNS
317324
~bond_slave_of:Ref.null ~vLAN_master_of ~management
318325
~other_config ~disallow_unplug ~ipv6_configuration_mode
319-
~iPv6 ~ipv6_gateway ~primary_address_type ~managed ~properties in
326+
~iPv6 ~ipv6_gateway ~primary_address_type ~managed ~properties ~capabilities:[] in
320327
pif_ref
321328

322329
let db_introduce = pool_introduce
@@ -339,6 +346,9 @@ let introduce_internal
339346
| None -> make_pif_metrics ~__context
340347
| Some m -> m
341348
in
349+
let dbg = Context.string_of_task __context in
350+
let capabilities = Net.Interface.get_capabilities dbg device in
351+
342352
let pif = Ref.make () in
343353
debug
344354
"Creating a new record for NIC: %s: %s"
@@ -352,7 +362,7 @@ let introduce_internal
352362
~dNS:"" ~bond_slave_of:Ref.null ~vLAN_master_of ~management:false
353363
~other_config:[] ~disallow_unplug:false ~ipv6_configuration_mode:`None
354364
~iPv6:[] ~ipv6_gateway:"" ~primary_address_type:`IPv4 ~managed
355-
~properties:default_properties in
365+
~properties:default_properties ~capabilities:capabilities in
356366

357367
(* If I'm a pool slave and this pif represents my management
358368
* interface then leave it alone: if the interface goes down

ocaml/xapi/xapi_tunnel.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let create_internal ~__context ~transport_PIF ~network ~host =
4242
~physical:false ~currently_attached:false
4343
~ip_configuration_mode:`None ~iP:"" ~netmask:"" ~gateway:"" ~dNS:"" ~bond_slave_of:Ref.null
4444
~vLAN_master_of:Ref.null ~management:false ~other_config:[] ~disallow_unplug:false ~ipv6_configuration_mode:`None
45-
~iPv6:[""] ~ipv6_gateway:"" ~primary_address_type:`IPv4 ~managed:true ~properties:[];
45+
~iPv6:[""] ~ipv6_gateway:"" ~primary_address_type:`IPv4 ~managed:true ~properties:[] ~capabilities:[];
4646
Db.Tunnel.create ~__context ~ref:tunnel ~uuid:(Uuid.to_string (Uuid.make_uuid ()))
4747
~access_PIF ~transport_PIF ~status:["active", "false"] ~other_config:[];
4848
tunnel, access_PIF

ocaml/xapi/xapi_vlan.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ let create_internal ~__context ~host ~tagged_PIF ~tag ~network ~device =
2929
~ip_configuration_mode:`None ~iP:"" ~netmask:"" ~gateway:"" ~dNS:"" ~bond_slave_of:Ref.null
3030
~vLAN_master_of:vlan ~management:false ~other_config:[] ~disallow_unplug:false
3131
~ipv6_configuration_mode:`None ~iPv6:[""] ~ipv6_gateway:"" ~primary_address_type:`IPv4 ~managed:true
32-
~properties:[];
32+
~properties:[] ~capabilities:[];
3333

3434
let () = Db.VLAN.create ~__context ~ref:vlan ~uuid:vlan_uuid ~tagged_PIF ~untagged_PIF ~tag ~other_config:[] in
3535
vlan, untagged_PIF

0 commit comments

Comments
 (0)