diff --git a/ocaml/client_records/records.ml b/ocaml/client_records/records.ml index a0345461718..09585881347 100644 --- a/ocaml/client_records/records.ml +++ b/ocaml/client_records/records.ml @@ -267,6 +267,8 @@ let pif_record rpc session_id pif = ~get:(fun () -> Record_util.s2sm_to_string "; " (x ()).API.pIF_properties) ~get_map:(fun () -> (x ()).API.pIF_properties) ~set_in_map:(fun k v -> Client.PIF.set_property rpc session_id pif k v) (); + make_field ~name:"capabilities" ~get:(fun () -> String.concat "; " (x ()).API.pIF_capabilities) + ~get_set:(fun () -> (x ()).API.pIF_capabilities) (); make_field ~name:"io_read_kbs" ~get:(fun () -> try let host = (x ()).API.pIF_host in diff --git a/ocaml/idl/datamodel.ml b/ocaml/idl/datamodel.ml index a9d274f1b7f..9a0892fcf99 100644 --- a/ocaml/idl/datamodel.ml +++ b/ocaml/idl/datamodel.ml @@ -4896,6 +4896,7 @@ let pif = is managed by xapi. If it is not, then xapi will not configure the interface, the commands PIF.plug/unplug/reconfigure_ip(v6) \ can not be used, nor can the interface be bonded or have VLANs based on top through xapi." ~default_value:(Some (VBool true)); field ~lifecycle:[Published, rel_creedence, ""] ~qualifier:DynamicRO ~ty:(Map(String, String)) ~default_value:(Some (VMap [])) "properties" "Additional configuration properties for the interface."; + field ~lifecycle:[Published, rel_dundee, ""] ~qualifier:DynamicRO ~ty:(Set(String)) ~default_value:(Some (VSet [])) "capabilities" "Additional capabilities on the interface."; ] () diff --git a/ocaml/xapi/network.mli b/ocaml/xapi/network.mli index 5a595973f05..59301dd6875 100644 --- a/ocaml/xapi/network.mli +++ b/ocaml/xapi/network.mli @@ -13,6 +13,7 @@ module Net : val exists : string -> name:Network_interface.iface -> bool val get_mac : string -> name:Network_interface.iface -> string val is_up : string -> name:Network_interface.iface -> bool + val get_capabilities: string -> name:Network_interface.iface -> string list val get_ipv4_addr : string -> name:Network_interface.iface -> (Unix.inet_addr * int) list diff --git a/ocaml/xapi/xapi_bond.ml b/ocaml/xapi/xapi_bond.ml index 77e1521a280..b47a62c1505 100644 --- a/ocaml/xapi/xapi_bond.ml +++ b/ocaml/xapi/xapi_bond.ml @@ -398,7 +398,7 @@ let create ~__context ~network ~members ~mAC ~mode ~properties = ~ip_configuration_mode:`None ~iP:"" ~netmask:"" ~gateway:"" ~dNS:"" ~bond_slave_of:Ref.null ~vLAN_master_of:Ref.null ~management:false ~other_config:[] ~disallow_unplug:false ~ipv6_configuration_mode:`None ~iPv6:[""] ~ipv6_gateway:"" ~primary_address_type:`IPv4 ~managed:true - ~properties:pif_properties; + ~properties:pif_properties ~capabilities:[]; Db.Bond.create ~__context ~ref:bond ~uuid:(Uuid.to_string (Uuid.make_uuid ())) ~master:master ~other_config:[] ~primary_slave ~mode ~properties ~links_up:0L; diff --git a/ocaml/xapi/xapi_pif.ml b/ocaml/xapi/xapi_pif.ml index f0c0d8fa684..af4c24b1a58 100644 --- a/ocaml/xapi/xapi_pif.ml +++ b/ocaml/xapi/xapi_pif.ml @@ -56,11 +56,18 @@ let refresh_internal ~__context ~self = (Db.PIF.set_MAC) (fun () -> Net.Interface.get_mac dbg ~name:device) (id); + maybe_update_database "MTU" (Db.PIF.get_MTU) (Db.PIF.set_MTU) (Int64.of_int ++ (fun () -> Net.Interface.get_mtu dbg ~name:bridge)) - (Int64.to_string) + (Int64.to_string); + + maybe_update_database "capabilities" + (Db.PIF.get_capabilities) + (Db.PIF.set_capabilities) + (fun () -> Net.Interface.get_capabilities dbg ~name:device) + (String.concat "; ") let refresh ~__context ~host ~self = assert (host = Helpers.get_localhost ~__context); @@ -316,7 +323,7 @@ let pool_introduce ~ip_configuration_mode ~iP ~netmask ~gateway ~dNS ~bond_slave_of:Ref.null ~vLAN_master_of ~management ~other_config ~disallow_unplug ~ipv6_configuration_mode - ~iPv6 ~ipv6_gateway ~primary_address_type ~managed ~properties in + ~iPv6 ~ipv6_gateway ~primary_address_type ~managed ~properties ~capabilities:[] in pif_ref let db_introduce = pool_introduce @@ -339,6 +346,9 @@ let introduce_internal | None -> make_pif_metrics ~__context | Some m -> m in + let dbg = Context.string_of_task __context in + let capabilities = Net.Interface.get_capabilities dbg device in + let pif = Ref.make () in debug "Creating a new record for NIC: %s: %s" @@ -352,7 +362,7 @@ let introduce_internal ~dNS:"" ~bond_slave_of:Ref.null ~vLAN_master_of ~management:false ~other_config:[] ~disallow_unplug:false ~ipv6_configuration_mode:`None ~iPv6:[] ~ipv6_gateway:"" ~primary_address_type:`IPv4 ~managed - ~properties:default_properties in + ~properties:default_properties ~capabilities:capabilities in (* If I'm a pool slave and this pif represents my management * interface then leave it alone: if the interface goes down diff --git a/ocaml/xapi/xapi_tunnel.ml b/ocaml/xapi/xapi_tunnel.ml index 24817258000..f4194fbd0a9 100644 --- a/ocaml/xapi/xapi_tunnel.ml +++ b/ocaml/xapi/xapi_tunnel.ml @@ -42,7 +42,7 @@ let create_internal ~__context ~transport_PIF ~network ~host = ~physical:false ~currently_attached:false ~ip_configuration_mode:`None ~iP:"" ~netmask:"" ~gateway:"" ~dNS:"" ~bond_slave_of:Ref.null ~vLAN_master_of:Ref.null ~management:false ~other_config:[] ~disallow_unplug:false ~ipv6_configuration_mode:`None - ~iPv6:[""] ~ipv6_gateway:"" ~primary_address_type:`IPv4 ~managed:true ~properties:[]; + ~iPv6:[""] ~ipv6_gateway:"" ~primary_address_type:`IPv4 ~managed:true ~properties:[] ~capabilities:[]; Db.Tunnel.create ~__context ~ref:tunnel ~uuid:(Uuid.to_string (Uuid.make_uuid ())) ~access_PIF ~transport_PIF ~status:["active", "false"] ~other_config:[]; tunnel, access_PIF diff --git a/ocaml/xapi/xapi_vlan.ml b/ocaml/xapi/xapi_vlan.ml index 1b43955e31c..6f433b3b332 100644 --- a/ocaml/xapi/xapi_vlan.ml +++ b/ocaml/xapi/xapi_vlan.ml @@ -29,7 +29,7 @@ let create_internal ~__context ~host ~tagged_PIF ~tag ~network ~device = ~ip_configuration_mode:`None ~iP:"" ~netmask:"" ~gateway:"" ~dNS:"" ~bond_slave_of:Ref.null ~vLAN_master_of:vlan ~management:false ~other_config:[] ~disallow_unplug:false ~ipv6_configuration_mode:`None ~iPv6:[""] ~ipv6_gateway:"" ~primary_address_type:`IPv4 ~managed:true - ~properties:[]; + ~properties:[] ~capabilities:[]; let () = Db.VLAN.create ~__context ~ref:vlan ~uuid:vlan_uuid ~tagged_PIF ~untagged_PIF ~tag ~other_config:[] in vlan, untagged_PIF