diff --git a/XenModel/Actions/VM/CreateVMAction.cs b/XenModel/Actions/VM/CreateVMAction.cs index 188804dde..0cd7e83ce 100644 --- a/XenModel/Actions/VM/CreateVMAction.cs +++ b/XenModel/Actions/VM/CreateVMAction.cs @@ -226,7 +226,10 @@ namespace XenAdmin.Actions.VMActions private void ApplyRecommendationsForVendorDevice() { - if (Template.HasVendorDeviceRecommendation && !Helpers.FeatureForbidden(VM, Host.RestrictVendorDevice)) + var pool = Helpers.GetPoolOfOne(Connection); + bool poolPolicyNoVendorDevice = pool == null || pool.policy_no_vendor_device; + + if (Template.HasVendorDeviceRecommendation && !poolPolicyNoVendorDevice && !Helpers.FeatureForbidden(VM, Host.RestrictVendorDevice)) { log.DebugFormat("Recommendation (has-vendor-device = true) has been found on the template ({0}) and the host is licensed, so applying it on VM ({1}) being created.", Template.opaque_ref, VM.opaque_ref); VM.set_has_vendor_device(Connection.Session, VM.opaque_ref, true); @@ -236,10 +239,13 @@ namespace XenAdmin.Actions.VMActions log.DebugFormat("Recommendation (has-vendor-device = true) has not been applied on the VM ({0}) being created.", VM.opaque_ref); if (!Template.HasVendorDeviceRecommendation) - log.InfoFormat("Recommendation (has-vendor-device) is not set or false on the template ({0}).", Template.opaque_ref); + log.DebugFormat("Recommendation (has-vendor-device) is not set or false on the template ({0}).", Template.opaque_ref); + + if (poolPolicyNoVendorDevice) + log.DebugFormat("pool.policy_no_vendor_device returned {0}", poolPolicyNoVendorDevice); if (Helpers.FeatureForbidden(VM, Host.RestrictVendorDevice)) - log.InfoFormat("Helpers.FeatureForbidden(VM, Host.RestrictVendorDevice) returned {0}", Helpers.FeatureForbidden(VM, Host.RestrictVendorDevice)); + log.DebugFormat("Helpers.FeatureForbidden(VM, Host.RestrictVendorDevice) returned {0}", Helpers.FeatureForbidden(VM, Host.RestrictVendorDevice)); } } diff --git a/XenModel/XenAPI/Pool.cs b/XenModel/XenAPI/Pool.cs index f58e86b7e..f98c24653 100644 --- a/XenModel/XenAPI/Pool.cs +++ b/XenModel/XenAPI/Pool.cs @@ -80,7 +80,8 @@ namespace XenAPI List allowed_operations, Dictionary current_operations, Dictionary guest_agent_config, - Dictionary cpu_info) + Dictionary cpu_info, + bool policy_no_vendor_device) { this.uuid = uuid; this.name_label = name_label; @@ -115,6 +116,7 @@ namespace XenAPI this.current_operations = current_operations; this.guest_agent_config = guest_agent_config; this.cpu_info = cpu_info; + this.policy_no_vendor_device = policy_no_vendor_device; } /// @@ -161,6 +163,7 @@ namespace XenAPI current_operations = update.current_operations; guest_agent_config = update.guest_agent_config; cpu_info = update.cpu_info; + policy_no_vendor_device = update.policy_no_vendor_device; } internal void UpdateFromProxy(Proxy_Pool proxy) @@ -198,6 +201,7 @@ namespace XenAPI current_operations = proxy.current_operations == null ? null : Maps.convert_from_proxy_string_pool_allowed_operations(proxy.current_operations); guest_agent_config = proxy.guest_agent_config == null ? null : Maps.convert_from_proxy_string_string(proxy.guest_agent_config); cpu_info = proxy.cpu_info == null ? null : Maps.convert_from_proxy_string_string(proxy.cpu_info); + policy_no_vendor_device = (bool)proxy.policy_no_vendor_device; } public Proxy_Pool ToProxy() @@ -236,6 +240,7 @@ namespace XenAPI result_.current_operations = Maps.convert_to_proxy_string_pool_allowed_operations(current_operations); result_.guest_agent_config = Maps.convert_to_proxy_string_string(guest_agent_config); result_.cpu_info = Maps.convert_to_proxy_string_string(cpu_info); + result_.policy_no_vendor_device = policy_no_vendor_device; return result_; } @@ -278,6 +283,7 @@ namespace XenAPI current_operations = Maps.convert_from_proxy_string_pool_allowed_operations(Marshalling.ParseHashTable(table, "current_operations")); guest_agent_config = Maps.convert_from_proxy_string_string(Marshalling.ParseHashTable(table, "guest_agent_config")); cpu_info = Maps.convert_from_proxy_string_string(Marshalling.ParseHashTable(table, "cpu_info")); + policy_no_vendor_device = Marshalling.ParseBool(table, "policy_no_vendor_device"); } public bool DeepEquals(Pool other, bool ignoreCurrentOperations) @@ -321,7 +327,8 @@ namespace XenAPI Helper.AreEqual2(this._ha_cluster_stack, other._ha_cluster_stack) && Helper.AreEqual2(this._allowed_operations, other._allowed_operations) && Helper.AreEqual2(this._guest_agent_config, other._guest_agent_config) && - Helper.AreEqual2(this._cpu_info, other._cpu_info); + Helper.AreEqual2(this._cpu_info, other._cpu_info) && + Helper.AreEqual2(this._policy_no_vendor_device, other._policy_no_vendor_device); } public override string SaveChanges(Session session, string opaqueRef, Pool server) @@ -381,6 +388,10 @@ namespace XenAPI { Pool.set_wlb_verify_cert(session, opaqueRef, _wlb_verify_cert); } + if (!Helper.AreEqual2(_policy_no_vendor_device, server._policy_no_vendor_device)) + { + Pool.set_policy_no_vendor_device(session, opaqueRef, _policy_no_vendor_device); + } return null; } @@ -770,6 +781,17 @@ namespace XenAPI return Maps.convert_from_proxy_string_string(session.proxy.pool_get_cpu_info(session.uuid, (_pool != null) ? _pool : "").parse()); } + /// + /// Get the policy_no_vendor_device field of the given pool. + /// First published in XenServer Dundee. + /// + /// The session + /// The opaque_ref of the given pool + public static bool get_policy_no_vendor_device(Session session, string _pool) + { + return (bool)session.proxy.pool_get_policy_no_vendor_device(session.uuid, (_pool != null) ? _pool : "").parse(); + } + /// /// Set the name_label field of the given pool. /// First published in XenServer 4.0. @@ -1013,6 +1035,18 @@ namespace XenAPI session.proxy.pool_set_wlb_verify_cert(session.uuid, (_pool != null) ? _pool : "", _wlb_verify_cert).parse(); } + /// + /// Set the policy_no_vendor_device field of the given pool. + /// First published in XenServer Dundee. + /// + /// The session + /// The opaque_ref of the given pool + /// New value to set + public static void set_policy_no_vendor_device(Session session, string _pool, bool _policy_no_vendor_device) + { + session.proxy.pool_set_policy_no_vendor_device(session.uuid, (_pool != null) ? _pool : "", _policy_no_vendor_device).parse(); + } + /// /// Instruct host to join a new pool /// First published in XenServer 4.0. @@ -2646,5 +2680,24 @@ namespace XenAPI } } private Dictionary _cpu_info; + + /// + /// The pool-wide policy for clients on whether to use the vendor device or not on newly created VMs. This field will also be consulted if the 'has_vendor_device' field is not specified in the VM.create call. + /// First published in XenServer Dundee. + /// + public virtual bool policy_no_vendor_device + { + get { return _policy_no_vendor_device; } + set + { + if (!Helper.AreEqual(value, _policy_no_vendor_device)) + { + _policy_no_vendor_device = value; + Changed = true; + NotifyPropertyChanged("policy_no_vendor_device"); + } + } + } + private bool _policy_no_vendor_device; } } diff --git a/XenModel/XenAPI/Proxy.cs b/XenModel/XenAPI/Proxy.cs index cf58d4c34..0161f6697 100644 --- a/XenModel/XenAPI/Proxy.cs +++ b/XenModel/XenAPI/Proxy.cs @@ -592,6 +592,10 @@ namespace XenAPI Response pool_get_cpu_info(string session, string _pool); + [XmlRpcMethod("pool.get_policy_no_vendor_device")] + Response + pool_get_policy_no_vendor_device(string session, string _pool); + [XmlRpcMethod("pool.set_name_label")] Response pool_set_name_label(string session, string _pool, string _name_label); @@ -672,6 +676,10 @@ namespace XenAPI Response pool_set_wlb_verify_cert(string session, string _pool, bool _wlb_verify_cert); + [XmlRpcMethod("pool.set_policy_no_vendor_device")] + Response + pool_set_policy_no_vendor_device(string session, string _pool, bool _policy_no_vendor_device); + [XmlRpcMethod("pool.join")] Response pool_join(string session, string _master_address, string _master_username, string _master_password); @@ -6954,6 +6962,7 @@ namespace XenAPI public Object current_operations; public Object guest_agent_config; public Object cpu_info; + public bool policy_no_vendor_device; } [XmlRpcMissingMapping(MappingAction.Ignore)]