Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

CA-43250: prevent destruction of the "internal management network" since a bunch of stuff relies on it #13

Merged
1 commit merged into from
Feb 10, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ocaml/idl/api_errors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ let device_detach_rejected = "DEVICE_DETACH_REJECTED"
let operation_not_allowed = "OPERATION_NOT_ALLOWED"
let operation_blocked = "OPERATION_BLOCKED"
let network_already_connected = "NETWORK_ALREADY_CONNECTED"
let cannot_destroy_system_network = "CANNOT_DESTROY_SYSTEM_NETWORK"
let pif_is_physical = "PIF_IS_PHYSICAL"
let pif_is_vlan = "PIF_IS_VLAN"
let pif_vlan_exists = "PIF_VLAN_EXISTS"
Expand Down
2 changes: 2 additions & 0 deletions ocaml/idl/datamodel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ let _ =
(* PIF/VIF/Network errors *)
error Api_errors.network_already_connected ["network"; "connected PIF"]
~doc:"You tried to create a PIF, but the network you tried to attach it to is already attached to some other PIF, and so the creation failed." ();
error Api_errors.cannot_destroy_system_network [ "network" ]
~doc:"You tried to destroy a system network: these cannot be destroyed." ();
error Api_errors.pif_is_physical ["PIF"]
~doc:"You tried to destroy a PIF, but it represents an aspect of the physical host configuration, and so cannot be destroyed. The parameter echoes the PIF handle you gave." ();
error Api_errors.pif_is_vlan ["PIF"]
Expand Down
6 changes: 6 additions & 0 deletions ocaml/xapi/xapi_network.ml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ let destroy ~__context ~self =
let pifs = Db.Network.get_PIFs ~__context ~self in
if pifs <> []
then (raise (Api_errors.Server_error (Api_errors.network_contains_pif,List.map Ref.string_of pifs)));
(* CA-43250: don't let people remove the internal management network *)
let oc = Db.Network.get_other_config ~__context ~self in
if List.mem_assoc Xapi_globs.is_host_internal_management_network oc
&& (try bool_of_string (List.assoc Xapi_globs.is_host_internal_management_network oc) with _ -> false)
then raise (Api_errors.Server_error (Api_errors.cannot_destroy_system_network, [ Ref.string_of self ]));

(* destroy all the VIFs now rather than wait for the GC thread. *)
List.iter (fun vif ->
Helpers.log_exn_continue (Printf.sprintf "destroying VIF: %s" (Ref.string_of vif))
Expand Down