/* * Copyright (c) Citrix Systems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1) Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2) Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; using Newtonsoft.Json; using Newtonsoft.Json.Converters; namespace XenAPI { /// /// a proxy connects a VM/VIF with a PVS site /// First published in XenServer 7.1. /// public partial class PVS_proxy : XenObject { public PVS_proxy() { } public PVS_proxy(string uuid, XenRef site, XenRef VIF, bool currently_attached, pvs_proxy_status status) { this.uuid = uuid; this.site = site; this.VIF = VIF; this.currently_attached = currently_attached; this.status = status; } /// /// Creates a new PVS_proxy from a Proxy_PVS_proxy. /// /// public PVS_proxy(Proxy_PVS_proxy proxy) { this.UpdateFromProxy(proxy); } public override void UpdateFrom(PVS_proxy update) { uuid = update.uuid; site = update.site; VIF = update.VIF; currently_attached = update.currently_attached; status = update.status; } internal void UpdateFromProxy(Proxy_PVS_proxy proxy) { uuid = proxy.uuid == null ? null : (string)proxy.uuid; site = proxy.site == null ? null : XenRef.Create(proxy.site); VIF = proxy.VIF == null ? null : XenRef.Create(proxy.VIF); currently_attached = (bool)proxy.currently_attached; status = proxy.status == null ? (pvs_proxy_status) 0 : (pvs_proxy_status)Helper.EnumParseDefault(typeof(pvs_proxy_status), (string)proxy.status); } public Proxy_PVS_proxy ToProxy() { Proxy_PVS_proxy result_ = new Proxy_PVS_proxy(); result_.uuid = uuid ?? ""; result_.site = site ?? ""; result_.VIF = VIF ?? ""; result_.currently_attached = currently_attached; result_.status = pvs_proxy_status_helper.ToString(status); return result_; } /// /// Creates a new PVS_proxy from a Hashtable. /// /// public PVS_proxy(Hashtable table) { uuid = Marshalling.ParseString(table, "uuid"); site = Marshalling.ParseRef(table, "site"); VIF = Marshalling.ParseRef(table, "VIF"); currently_attached = Marshalling.ParseBool(table, "currently_attached"); status = (pvs_proxy_status)Helper.EnumParseDefault(typeof(pvs_proxy_status), Marshalling.ParseString(table, "status")); } public bool DeepEquals(PVS_proxy other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Helper.AreEqual2(this._uuid, other._uuid) && Helper.AreEqual2(this._site, other._site) && Helper.AreEqual2(this._VIF, other._VIF) && Helper.AreEqual2(this._currently_attached, other._currently_attached) && Helper.AreEqual2(this._status, other._status); } internal static List ProxyArrayToObjectList(Proxy_PVS_proxy[] input) { var result = new List(); foreach (var item in input) result.Add(new PVS_proxy(item)); return result; } public override string SaveChanges(Session session, string opaqueRef, PVS_proxy server) { if (opaqueRef == null) { System.Diagnostics.Debug.Assert(false, "Cannot create instances of this type on the server"); return ""; } else { throw new InvalidOperationException("This type has no read/write properties"); } } /// /// Get a record containing the current state of the given PVS_proxy. /// First published in XenServer 7.1. /// /// The session /// The opaque_ref of the given pvs_proxy public static PVS_proxy get_record(Session session, string _pvs_proxy) { if (session.JsonRpcClient != null) return session.JsonRpcClient.pvs_proxy_get_record(session.uuid, _pvs_proxy); else return new PVS_proxy((Proxy_PVS_proxy)session.proxy.pvs_proxy_get_record(session.uuid, _pvs_proxy ?? "").parse()); } /// /// Get a reference to the PVS_proxy instance with the specified UUID. /// First published in XenServer 7.1. /// /// The session /// UUID of object to return public static XenRef get_by_uuid(Session session, string _uuid) { if (session.JsonRpcClient != null) return session.JsonRpcClient.pvs_proxy_get_by_uuid(session.uuid, _uuid); else return XenRef.Create(session.proxy.pvs_proxy_get_by_uuid(session.uuid, _uuid ?? "").parse()); } /// /// Get the uuid field of the given PVS_proxy. /// First published in XenServer 7.1. /// /// The session /// The opaque_ref of the given pvs_proxy public static string get_uuid(Session session, string _pvs_proxy) { if (session.JsonRpcClient != null) return session.JsonRpcClient.pvs_proxy_get_uuid(session.uuid, _pvs_proxy); else return (string)session.proxy.pvs_proxy_get_uuid(session.uuid, _pvs_proxy ?? "").parse(); } /// /// Get the site field of the given PVS_proxy. /// First published in XenServer 7.1. /// /// The session /// The opaque_ref of the given pvs_proxy public static XenRef get_site(Session session, string _pvs_proxy) { if (session.JsonRpcClient != null) return session.JsonRpcClient.pvs_proxy_get_site(session.uuid, _pvs_proxy); else return XenRef.Create(session.proxy.pvs_proxy_get_site(session.uuid, _pvs_proxy ?? "").parse()); } /// /// Get the VIF field of the given PVS_proxy. /// First published in XenServer 7.1. /// /// The session /// The opaque_ref of the given pvs_proxy public static XenRef get_VIF(Session session, string _pvs_proxy) { if (session.JsonRpcClient != null) return session.JsonRpcClient.pvs_proxy_get_vif(session.uuid, _pvs_proxy); else return XenRef.Create(session.proxy.pvs_proxy_get_vif(session.uuid, _pvs_proxy ?? "").parse()); } /// /// Get the currently_attached field of the given PVS_proxy. /// First published in XenServer 7.1. /// /// The session /// The opaque_ref of the given pvs_proxy public static bool get_currently_attached(Session session, string _pvs_proxy) { if (session.JsonRpcClient != null) return session.JsonRpcClient.pvs_proxy_get_currently_attached(session.uuid, _pvs_proxy); else return (bool)session.proxy.pvs_proxy_get_currently_attached(session.uuid, _pvs_proxy ?? "").parse(); } /// /// Get the status field of the given PVS_proxy. /// First published in XenServer 7.1. /// /// The session /// The opaque_ref of the given pvs_proxy public static pvs_proxy_status get_status(Session session, string _pvs_proxy) { if (session.JsonRpcClient != null) return session.JsonRpcClient.pvs_proxy_get_status(session.uuid, _pvs_proxy); else return (pvs_proxy_status)Helper.EnumParseDefault(typeof(pvs_proxy_status), (string)session.proxy.pvs_proxy_get_status(session.uuid, _pvs_proxy ?? "").parse()); } /// /// Configure a VM/VIF to use a PVS proxy /// First published in XenServer 7.1. /// /// The session /// PVS site that we proxy for /// VIF for the VM that needs to be proxied public static XenRef create(Session session, string _site, string _vif) { if (session.JsonRpcClient != null) return session.JsonRpcClient.pvs_proxy_create(session.uuid, _site, _vif); else return XenRef.Create(session.proxy.pvs_proxy_create(session.uuid, _site ?? "", _vif ?? "").parse()); } /// /// Configure a VM/VIF to use a PVS proxy /// First published in XenServer 7.1. /// /// The session /// PVS site that we proxy for /// VIF for the VM that needs to be proxied public static XenRef async_create(Session session, string _site, string _vif) { if (session.JsonRpcClient != null) return session.JsonRpcClient.async_pvs_proxy_create(session.uuid, _site, _vif); else return XenRef.Create(session.proxy.async_pvs_proxy_create(session.uuid, _site ?? "", _vif ?? "").parse()); } /// /// remove (or switch off) a PVS proxy for this VM /// First published in XenServer 7.1. /// /// The session /// The opaque_ref of the given pvs_proxy public static void destroy(Session session, string _pvs_proxy) { if (session.JsonRpcClient != null) session.JsonRpcClient.pvs_proxy_destroy(session.uuid, _pvs_proxy); else session.proxy.pvs_proxy_destroy(session.uuid, _pvs_proxy ?? "").parse(); } /// /// remove (or switch off) a PVS proxy for this VM /// First published in XenServer 7.1. /// /// The session /// The opaque_ref of the given pvs_proxy public static XenRef async_destroy(Session session, string _pvs_proxy) { if (session.JsonRpcClient != null) return session.JsonRpcClient.async_pvs_proxy_destroy(session.uuid, _pvs_proxy); else return XenRef.Create(session.proxy.async_pvs_proxy_destroy(session.uuid, _pvs_proxy ?? "").parse()); } /// /// Return a list of all the PVS_proxys known to the system. /// First published in XenServer 7.1. /// /// The session public static List> get_all(Session session) { if (session.JsonRpcClient != null) return session.JsonRpcClient.pvs_proxy_get_all(session.uuid); else return XenRef.Create(session.proxy.pvs_proxy_get_all(session.uuid).parse()); } /// /// Get all the PVS_proxy Records at once, in a single XML RPC call /// First published in XenServer 7.1. /// /// The session public static Dictionary, PVS_proxy> get_all_records(Session session) { if (session.JsonRpcClient != null) return session.JsonRpcClient.pvs_proxy_get_all_records(session.uuid); else return XenRef.Create(session.proxy.pvs_proxy_get_all_records(session.uuid).parse()); } /// /// Unique identifier/object reference /// public virtual string uuid { get { return _uuid; } set { if (!Helper.AreEqual(value, _uuid)) { _uuid = value; Changed = true; NotifyPropertyChanged("uuid"); } } } private string _uuid = ""; /// /// PVS site this proxy is part of /// [JsonConverter(typeof(XenRefConverter))] public virtual XenRef site { get { return _site; } set { if (!Helper.AreEqual(value, _site)) { _site = value; Changed = true; NotifyPropertyChanged("site"); } } } private XenRef _site = new XenRef("OpaqueRef:NULL"); /// /// VIF of the VM using the proxy /// [JsonConverter(typeof(XenRefConverter))] public virtual XenRef VIF { get { return _VIF; } set { if (!Helper.AreEqual(value, _VIF)) { _VIF = value; Changed = true; NotifyPropertyChanged("VIF"); } } } private XenRef _VIF = new XenRef("OpaqueRef:NULL"); /// /// true = VM is currently proxied /// public virtual bool currently_attached { get { return _currently_attached; } set { if (!Helper.AreEqual(value, _currently_attached)) { _currently_attached = value; Changed = true; NotifyPropertyChanged("currently_attached"); } } } private bool _currently_attached = false; /// /// The run-time status of the proxy /// [JsonConverter(typeof(pvs_proxy_statusConverter))] public virtual pvs_proxy_status status { get { return _status; } set { if (!Helper.AreEqual(value, _status)) { _status = value; Changed = true; NotifyPropertyChanged("status"); } } } private pvs_proxy_status _status = pvs_proxy_status.stopped; } }