let openvswitch_not_active = "OPENVSWITCH_NOT_ACTIVE"
let transport_pif_not_configured = "TRANSPORT_PIF_NOT_CONFIGURED"
let is_tunnel_access_pif = "IS_TUNNEL_ACCESS_PIF"
+let pif_tunnel_still_exists = "PIF_TUNNEL_STILL_EXISTS"
let vlan_tag_invalid = "VLAN_TAG_INVALID"
let vm_bad_power_state = "VM_BAD_POWER_STATE"
~doc:"The tunnel transport PIF has no IP configuration set." ();
error Api_errors.is_tunnel_access_pif ["PIF"]
~doc:"You tried to create a VLAN or tunnel on top of a tunnel access PIF - use the underlying transport PIF instead." ();
+ error Api_errors.pif_tunnel_still_exists ["PIF"]
+ ~doc:"Operation cannot proceed while a tunnel exists on this interface." ();
(* VM specific errors *)
error Api_errors.vm_is_protected [ "vm" ]
~params:[Ref _pif, "self", "the PIF object to plug"]
~in_product_since:rel_miami
~allowed_roles:_R_POOL_OP
+ ~errs:[Api_errors.transport_pif_not_configured]
()
let pif_unplug = call
~params:[Ref _pif, "self", "The PIF object to destroy"]
~in_product_since:rel_miami
~allowed_roles:_R_POOL_OP
+ ~errs:[Api_errors.pif_tunnel_still_exists]
()
let pif_introduce_params first_rel =
if Db.PIF.get_VLAN ~__context ~self <> (-1L) && not (Xapi_fist.allow_forget_of_vlan_pif ())
then raise (Api_errors.Server_error (Api_errors.pif_vlan_still_exists, [ Ref.string_of self ]))
+let assert_no_tunnels ~__context ~self =
+ (* Disallow if this is a transport interface of any existing tunnel *)
+ let tunnels = Db.PIF.get_tunnel_transport_PIF_of ~__context ~self in
+ debug "PIF %s assert_no_tunnels = [ %s ]"
+ (Db.PIF.get_uuid ~__context ~self) (String.concat "; " (List.map Ref.string_of tunnels));
+ if tunnels <> [] then begin
+ debug "PIF has associated tunnels: [ %s ]"
+ (String.concat "; " (List.map (fun self -> Db.Tunnel.get_uuid ~__context ~self) tunnels));
+ raise (Api_errors.Server_error (Api_errors.pif_tunnel_still_exists, [ Ref.string_of self ]))
+ end;
+ (* Disallow if this is an access interface of a tunnel *)
+ if Db.PIF.get_tunnel_access_PIF_of ~__context ~self <> []
+ then raise (Api_errors.Server_error (Api_errors.pif_tunnel_still_exists, [ Ref.string_of self ]))
+
let assert_not_management_pif ~__context ~self =
if Db.PIF.get_currently_attached ~__context ~self
&& Db.PIF.get_management ~__context ~self then
let forget ~__context ~self =
assert_not_in_bond ~__context ~self;
assert_no_vlans ~__context ~self;
+ assert_no_tunnels ~__context ~self;
assert_not_slave_management_pif ~__context ~self;
assert_no_protection_enabled ~__context ~self;