/* * 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 virtual network /// First published in XenServer 4.0. /// public partial class Network : XenObject { public Network() { } public Network(string uuid, string name_label, string name_description, List allowed_operations, Dictionary current_operations, List> VIFs, List> PIFs, long MTU, Dictionary other_config, string bridge, bool managed, Dictionary> blobs, string[] tags, network_default_locking_mode default_locking_mode, Dictionary, string> assigned_ips, List purpose) { this.uuid = uuid; this.name_label = name_label; this.name_description = name_description; this.allowed_operations = allowed_operations; this.current_operations = current_operations; this.VIFs = VIFs; this.PIFs = PIFs; this.MTU = MTU; this.other_config = other_config; this.bridge = bridge; this.managed = managed; this.blobs = blobs; this.tags = tags; this.default_locking_mode = default_locking_mode; this.assigned_ips = assigned_ips; this.purpose = purpose; } /// /// Creates a new Network from a Proxy_Network. /// /// public Network(Proxy_Network proxy) { this.UpdateFromProxy(proxy); } public override void UpdateFrom(Network update) { uuid = update.uuid; name_label = update.name_label; name_description = update.name_description; allowed_operations = update.allowed_operations; current_operations = update.current_operations; VIFs = update.VIFs; PIFs = update.PIFs; MTU = update.MTU; other_config = update.other_config; bridge = update.bridge; managed = update.managed; blobs = update.blobs; tags = update.tags; default_locking_mode = update.default_locking_mode; assigned_ips = update.assigned_ips; purpose = update.purpose; } internal void UpdateFromProxy(Proxy_Network proxy) { uuid = proxy.uuid == null ? null : (string)proxy.uuid; name_label = proxy.name_label == null ? null : (string)proxy.name_label; name_description = proxy.name_description == null ? null : (string)proxy.name_description; allowed_operations = proxy.allowed_operations == null ? null : Helper.StringArrayToEnumList(proxy.allowed_operations); current_operations = proxy.current_operations == null ? null : Maps.convert_from_proxy_string_network_operations(proxy.current_operations); VIFs = proxy.VIFs == null ? null : XenRef.Create(proxy.VIFs); PIFs = proxy.PIFs == null ? null : XenRef.Create(proxy.PIFs); MTU = proxy.MTU == null ? 0 : long.Parse((string)proxy.MTU); other_config = proxy.other_config == null ? null : Maps.convert_from_proxy_string_string(proxy.other_config); bridge = proxy.bridge == null ? null : (string)proxy.bridge; managed = (bool)proxy.managed; blobs = proxy.blobs == null ? null : Maps.convert_from_proxy_string_XenRefBlob(proxy.blobs); tags = proxy.tags == null ? new string[] {} : (string [])proxy.tags; default_locking_mode = proxy.default_locking_mode == null ? (network_default_locking_mode) 0 : (network_default_locking_mode)Helper.EnumParseDefault(typeof(network_default_locking_mode), (string)proxy.default_locking_mode); assigned_ips = proxy.assigned_ips == null ? null : Maps.convert_from_proxy_XenRefVIF_string(proxy.assigned_ips); purpose = proxy.purpose == null ? null : Helper.StringArrayToEnumList(proxy.purpose); } public Proxy_Network ToProxy() { Proxy_Network result_ = new Proxy_Network(); result_.uuid = uuid ?? ""; result_.name_label = name_label ?? ""; result_.name_description = name_description ?? ""; result_.allowed_operations = (allowed_operations != null) ? Helper.ObjectListToStringArray(allowed_operations) : new string[] {}; result_.current_operations = Maps.convert_to_proxy_string_network_operations(current_operations); result_.VIFs = (VIFs != null) ? Helper.RefListToStringArray(VIFs) : new string[] {}; result_.PIFs = (PIFs != null) ? Helper.RefListToStringArray(PIFs) : new string[] {}; result_.MTU = MTU.ToString(); result_.other_config = Maps.convert_to_proxy_string_string(other_config); result_.bridge = bridge ?? ""; result_.managed = managed; result_.blobs = Maps.convert_to_proxy_string_XenRefBlob(blobs); result_.tags = tags; result_.default_locking_mode = network_default_locking_mode_helper.ToString(default_locking_mode); result_.assigned_ips = Maps.convert_to_proxy_XenRefVIF_string(assigned_ips); result_.purpose = (purpose != null) ? Helper.ObjectListToStringArray(purpose) : new string[] {}; return result_; } /// /// Creates a new Network from a Hashtable. /// /// public Network(Hashtable table) { uuid = Marshalling.ParseString(table, "uuid"); name_label = Marshalling.ParseString(table, "name_label"); name_description = Marshalling.ParseString(table, "name_description"); allowed_operations = Helper.StringArrayToEnumList(Marshalling.ParseStringArray(table, "allowed_operations")); current_operations = Maps.convert_from_proxy_string_network_operations(Marshalling.ParseHashTable(table, "current_operations")); VIFs = Marshalling.ParseSetRef(table, "VIFs"); PIFs = Marshalling.ParseSetRef(table, "PIFs"); MTU = Marshalling.ParseLong(table, "MTU"); other_config = Maps.convert_from_proxy_string_string(Marshalling.ParseHashTable(table, "other_config")); bridge = Marshalling.ParseString(table, "bridge"); managed = Marshalling.ParseBool(table, "managed"); blobs = Maps.convert_from_proxy_string_XenRefBlob(Marshalling.ParseHashTable(table, "blobs")); tags = Marshalling.ParseStringArray(table, "tags"); default_locking_mode = (network_default_locking_mode)Helper.EnumParseDefault(typeof(network_default_locking_mode), Marshalling.ParseString(table, "default_locking_mode")); assigned_ips = Maps.convert_from_proxy_XenRefVIF_string(Marshalling.ParseHashTable(table, "assigned_ips")); purpose = Helper.StringArrayToEnumList(Marshalling.ParseStringArray(table, "purpose")); } public bool DeepEquals(Network other, bool ignoreCurrentOperations) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; if (!ignoreCurrentOperations && !Helper.AreEqual2(this.current_operations, other.current_operations)) return false; return Helper.AreEqual2(this._uuid, other._uuid) && Helper.AreEqual2(this._name_label, other._name_label) && Helper.AreEqual2(this._name_description, other._name_description) && Helper.AreEqual2(this._allowed_operations, other._allowed_operations) && Helper.AreEqual2(this._VIFs, other._VIFs) && Helper.AreEqual2(this._PIFs, other._PIFs) && Helper.AreEqual2(this._MTU, other._MTU) && Helper.AreEqual2(this._other_config, other._other_config) && Helper.AreEqual2(this._bridge, other._bridge) && Helper.AreEqual2(this._managed, other._managed) && Helper.AreEqual2(this._blobs, other._blobs) && Helper.AreEqual2(this._tags, other._tags) && Helper.AreEqual2(this._default_locking_mode, other._default_locking_mode) && Helper.AreEqual2(this._assigned_ips, other._assigned_ips) && Helper.AreEqual2(this._purpose, other._purpose); } internal static List ProxyArrayToObjectList(Proxy_Network[] input) { var result = new List(); foreach (var item in input) result.Add(new Network(item)); return result; } public override string SaveChanges(Session session, string opaqueRef, Network server) { if (opaqueRef == null) { var reference = create(session, this); return reference == null ? null : reference.opaque_ref; } else { if (!Helper.AreEqual2(_name_label, server._name_label)) { Network.set_name_label(session, opaqueRef, _name_label); } if (!Helper.AreEqual2(_name_description, server._name_description)) { Network.set_name_description(session, opaqueRef, _name_description); } if (!Helper.AreEqual2(_MTU, server._MTU)) { Network.set_MTU(session, opaqueRef, _MTU); } if (!Helper.AreEqual2(_other_config, server._other_config)) { Network.set_other_config(session, opaqueRef, _other_config); } if (!Helper.AreEqual2(_tags, server._tags)) { Network.set_tags(session, opaqueRef, _tags); } return null; } } /// /// Get a record containing the current state of the given network. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network public static Network get_record(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_record(session.uuid, _network); else return new Network((Proxy_Network)session.proxy.network_get_record(session.uuid, _network ?? "").parse()); } /// /// Get a reference to the network instance with the specified UUID. /// First published in XenServer 4.0. /// /// The session /// UUID of object to return public static XenRef get_by_uuid(Session session, string _uuid) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_by_uuid(session.uuid, _uuid); else return XenRef.Create(session.proxy.network_get_by_uuid(session.uuid, _uuid ?? "").parse()); } /// /// Create a new network instance, and return its handle. /// First published in XenServer 4.0. /// /// The session /// All constructor arguments public static XenRef create(Session session, Network _record) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_create(session.uuid, _record); else return XenRef.Create(session.proxy.network_create(session.uuid, _record.ToProxy()).parse()); } /// /// Create a new network instance, and return its handle. /// First published in XenServer 4.0. /// /// The session /// All constructor arguments public static XenRef async_create(Session session, Network _record) { if (session.JsonRpcClient != null) return session.JsonRpcClient.async_network_create(session.uuid, _record); else return XenRef.Create(session.proxy.async_network_create(session.uuid, _record.ToProxy()).parse()); } /// /// Destroy the specified network instance. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network public static void destroy(Session session, string _network) { if (session.JsonRpcClient != null) session.JsonRpcClient.network_destroy(session.uuid, _network); else session.proxy.network_destroy(session.uuid, _network ?? "").parse(); } /// /// Destroy the specified network instance. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network public static XenRef async_destroy(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.async_network_destroy(session.uuid, _network); else return XenRef.Create(session.proxy.async_network_destroy(session.uuid, _network ?? "").parse()); } /// /// Get all the network instances with the given label. /// First published in XenServer 4.0. /// /// The session /// label of object to return public static List> get_by_name_label(Session session, string _label) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_by_name_label(session.uuid, _label); else return XenRef.Create(session.proxy.network_get_by_name_label(session.uuid, _label ?? "").parse()); } /// /// Get the uuid field of the given network. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network public static string get_uuid(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_uuid(session.uuid, _network); else return (string)session.proxy.network_get_uuid(session.uuid, _network ?? "").parse(); } /// /// Get the name/label field of the given network. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network public static string get_name_label(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_name_label(session.uuid, _network); else return (string)session.proxy.network_get_name_label(session.uuid, _network ?? "").parse(); } /// /// Get the name/description field of the given network. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network public static string get_name_description(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_name_description(session.uuid, _network); else return (string)session.proxy.network_get_name_description(session.uuid, _network ?? "").parse(); } /// /// Get the allowed_operations field of the given network. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network public static List get_allowed_operations(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_allowed_operations(session.uuid, _network); else return Helper.StringArrayToEnumList(session.proxy.network_get_allowed_operations(session.uuid, _network ?? "").parse()); } /// /// Get the current_operations field of the given network. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network public static Dictionary get_current_operations(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_current_operations(session.uuid, _network); else return Maps.convert_from_proxy_string_network_operations(session.proxy.network_get_current_operations(session.uuid, _network ?? "").parse()); } /// /// Get the VIFs field of the given network. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network public static List> get_VIFs(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_vifs(session.uuid, _network); else return XenRef.Create(session.proxy.network_get_vifs(session.uuid, _network ?? "").parse()); } /// /// Get the PIFs field of the given network. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network public static List> get_PIFs(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_pifs(session.uuid, _network); else return XenRef.Create(session.proxy.network_get_pifs(session.uuid, _network ?? "").parse()); } /// /// Get the MTU field of the given network. /// First published in XenServer 5.6. /// /// The session /// The opaque_ref of the given network public static long get_MTU(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_mtu(session.uuid, _network); else return long.Parse((string)session.proxy.network_get_mtu(session.uuid, _network ?? "").parse()); } /// /// Get the other_config field of the given network. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network public static Dictionary get_other_config(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_other_config(session.uuid, _network); else return Maps.convert_from_proxy_string_string(session.proxy.network_get_other_config(session.uuid, _network ?? "").parse()); } /// /// Get the bridge field of the given network. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network public static string get_bridge(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_bridge(session.uuid, _network); else return (string)session.proxy.network_get_bridge(session.uuid, _network ?? "").parse(); } /// /// Get the managed field of the given network. /// First published in XenServer 7.2. /// /// The session /// The opaque_ref of the given network public static bool get_managed(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_managed(session.uuid, _network); else return (bool)session.proxy.network_get_managed(session.uuid, _network ?? "").parse(); } /// /// Get the blobs field of the given network. /// First published in XenServer 5.0. /// /// The session /// The opaque_ref of the given network public static Dictionary> get_blobs(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_blobs(session.uuid, _network); else return Maps.convert_from_proxy_string_XenRefBlob(session.proxy.network_get_blobs(session.uuid, _network ?? "").parse()); } /// /// Get the tags field of the given network. /// First published in XenServer 5.0. /// /// The session /// The opaque_ref of the given network public static string[] get_tags(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_tags(session.uuid, _network); else return (string [])session.proxy.network_get_tags(session.uuid, _network ?? "").parse(); } /// /// Get the default_locking_mode field of the given network. /// First published in XenServer 6.1. /// /// The session /// The opaque_ref of the given network public static network_default_locking_mode get_default_locking_mode(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_default_locking_mode(session.uuid, _network); else return (network_default_locking_mode)Helper.EnumParseDefault(typeof(network_default_locking_mode), (string)session.proxy.network_get_default_locking_mode(session.uuid, _network ?? "").parse()); } /// /// Get the assigned_ips field of the given network. /// First published in XenServer 6.5. /// /// The session /// The opaque_ref of the given network public static Dictionary, string> get_assigned_ips(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_assigned_ips(session.uuid, _network); else return Maps.convert_from_proxy_XenRefVIF_string(session.proxy.network_get_assigned_ips(session.uuid, _network ?? "").parse()); } /// /// Get the purpose field of the given network. /// First published in XenServer 7.3. /// /// The session /// The opaque_ref of the given network public static List get_purpose(Session session, string _network) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_purpose(session.uuid, _network); else return Helper.StringArrayToEnumList(session.proxy.network_get_purpose(session.uuid, _network ?? "").parse()); } /// /// Set the name/label field of the given network. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network /// New value to set public static void set_name_label(Session session, string _network, string _label) { if (session.JsonRpcClient != null) session.JsonRpcClient.network_set_name_label(session.uuid, _network, _label); else session.proxy.network_set_name_label(session.uuid, _network ?? "", _label ?? "").parse(); } /// /// Set the name/description field of the given network. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network /// New value to set public static void set_name_description(Session session, string _network, string _description) { if (session.JsonRpcClient != null) session.JsonRpcClient.network_set_name_description(session.uuid, _network, _description); else session.proxy.network_set_name_description(session.uuid, _network ?? "", _description ?? "").parse(); } /// /// Set the MTU field of the given network. /// First published in XenServer 5.6. /// /// The session /// The opaque_ref of the given network /// New value to set public static void set_MTU(Session session, string _network, long _mtu) { if (session.JsonRpcClient != null) session.JsonRpcClient.network_set_mtu(session.uuid, _network, _mtu); else session.proxy.network_set_mtu(session.uuid, _network ?? "", _mtu.ToString()).parse(); } /// /// Set the other_config field of the given network. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network /// New value to set public static void set_other_config(Session session, string _network, Dictionary _other_config) { if (session.JsonRpcClient != null) session.JsonRpcClient.network_set_other_config(session.uuid, _network, _other_config); else session.proxy.network_set_other_config(session.uuid, _network ?? "", Maps.convert_to_proxy_string_string(_other_config)).parse(); } /// /// Add the given key-value pair to the other_config field of the given network. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network /// Key to add /// Value to add public static void add_to_other_config(Session session, string _network, string _key, string _value) { if (session.JsonRpcClient != null) session.JsonRpcClient.network_add_to_other_config(session.uuid, _network, _key, _value); else session.proxy.network_add_to_other_config(session.uuid, _network ?? "", _key ?? "", _value ?? "").parse(); } /// /// Remove the given key and its corresponding value from the other_config field of the given network. If the key is not in that Map, then do nothing. /// First published in XenServer 4.0. /// /// The session /// The opaque_ref of the given network /// Key to remove public static void remove_from_other_config(Session session, string _network, string _key) { if (session.JsonRpcClient != null) session.JsonRpcClient.network_remove_from_other_config(session.uuid, _network, _key); else session.proxy.network_remove_from_other_config(session.uuid, _network ?? "", _key ?? "").parse(); } /// /// Set the tags field of the given network. /// First published in XenServer 5.0. /// /// The session /// The opaque_ref of the given network /// New value to set public static void set_tags(Session session, string _network, string[] _tags) { if (session.JsonRpcClient != null) session.JsonRpcClient.network_set_tags(session.uuid, _network, _tags); else session.proxy.network_set_tags(session.uuid, _network ?? "", _tags).parse(); } /// /// Add the given value to the tags field of the given network. If the value is already in that Set, then do nothing. /// First published in XenServer 5.0. /// /// The session /// The opaque_ref of the given network /// New value to add public static void add_tags(Session session, string _network, string _value) { if (session.JsonRpcClient != null) session.JsonRpcClient.network_add_tags(session.uuid, _network, _value); else session.proxy.network_add_tags(session.uuid, _network ?? "", _value ?? "").parse(); } /// /// Remove the given value from the tags field of the given network. If the value is not in that Set, then do nothing. /// First published in XenServer 5.0. /// /// The session /// The opaque_ref of the given network /// Value to remove public static void remove_tags(Session session, string _network, string _value) { if (session.JsonRpcClient != null) session.JsonRpcClient.network_remove_tags(session.uuid, _network, _value); else session.proxy.network_remove_tags(session.uuid, _network ?? "", _value ?? "").parse(); } /// /// Create a placeholder for a named binary blob of data that is associated with this pool /// First published in XenServer 5.0. /// /// The session /// The opaque_ref of the given network /// The name associated with the blob /// The mime type for the data. Empty string translates to application/octet-stream public static XenRef create_new_blob(Session session, string _network, string _name, string _mime_type) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_create_new_blob(session.uuid, _network, _name, _mime_type); else return XenRef.Create(session.proxy.network_create_new_blob(session.uuid, _network ?? "", _name ?? "", _mime_type ?? "").parse()); } /// /// Create a placeholder for a named binary blob of data that is associated with this pool /// First published in XenServer 5.0. /// /// The session /// The opaque_ref of the given network /// The name associated with the blob /// The mime type for the data. Empty string translates to application/octet-stream public static XenRef async_create_new_blob(Session session, string _network, string _name, string _mime_type) { if (session.JsonRpcClient != null) return session.JsonRpcClient.async_network_create_new_blob(session.uuid, _network, _name, _mime_type); else return XenRef.Create(session.proxy.async_network_create_new_blob(session.uuid, _network ?? "", _name ?? "", _mime_type ?? "").parse()); } /// /// Create a placeholder for a named binary blob of data that is associated with this pool /// First published in XenServer 5.0. /// /// The session /// The opaque_ref of the given network /// The name associated with the blob /// The mime type for the data. Empty string translates to application/octet-stream /// True if the blob should be publicly available First published in XenServer 6.1. public static XenRef create_new_blob(Session session, string _network, string _name, string _mime_type, bool _public) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_create_new_blob(session.uuid, _network, _name, _mime_type, _public); else return XenRef.Create(session.proxy.network_create_new_blob(session.uuid, _network ?? "", _name ?? "", _mime_type ?? "", _public).parse()); } /// /// Create a placeholder for a named binary blob of data that is associated with this pool /// First published in XenServer 5.0. /// /// The session /// The opaque_ref of the given network /// The name associated with the blob /// The mime type for the data. Empty string translates to application/octet-stream /// True if the blob should be publicly available First published in XenServer 6.1. public static XenRef async_create_new_blob(Session session, string _network, string _name, string _mime_type, bool _public) { if (session.JsonRpcClient != null) return session.JsonRpcClient.async_network_create_new_blob(session.uuid, _network, _name, _mime_type, _public); else return XenRef.Create(session.proxy.async_network_create_new_blob(session.uuid, _network ?? "", _name ?? "", _mime_type ?? "", _public).parse()); } /// /// Set the default locking mode for VIFs attached to this network /// First published in XenServer 6.1. /// /// The session /// The opaque_ref of the given network /// The default locking mode for VIFs attached to this network. public static void set_default_locking_mode(Session session, string _network, network_default_locking_mode _value) { if (session.JsonRpcClient != null) session.JsonRpcClient.network_set_default_locking_mode(session.uuid, _network, _value); else session.proxy.network_set_default_locking_mode(session.uuid, _network ?? "", network_default_locking_mode_helper.ToString(_value)).parse(); } /// /// Set the default locking mode for VIFs attached to this network /// First published in XenServer 6.1. /// /// The session /// The opaque_ref of the given network /// The default locking mode for VIFs attached to this network. public static XenRef async_set_default_locking_mode(Session session, string _network, network_default_locking_mode _value) { if (session.JsonRpcClient != null) return session.JsonRpcClient.async_network_set_default_locking_mode(session.uuid, _network, _value); else return XenRef.Create(session.proxy.async_network_set_default_locking_mode(session.uuid, _network ?? "", network_default_locking_mode_helper.ToString(_value)).parse()); } /// /// Give a network a new purpose (if not present already) /// First published in XenServer 7.3. /// /// The session /// The opaque_ref of the given network /// The purpose to add public static void add_purpose(Session session, string _network, network_purpose _value) { if (session.JsonRpcClient != null) session.JsonRpcClient.network_add_purpose(session.uuid, _network, _value); else session.proxy.network_add_purpose(session.uuid, _network ?? "", network_purpose_helper.ToString(_value)).parse(); } /// /// Give a network a new purpose (if not present already) /// First published in XenServer 7.3. /// /// The session /// The opaque_ref of the given network /// The purpose to add public static XenRef async_add_purpose(Session session, string _network, network_purpose _value) { if (session.JsonRpcClient != null) return session.JsonRpcClient.async_network_add_purpose(session.uuid, _network, _value); else return XenRef.Create(session.proxy.async_network_add_purpose(session.uuid, _network ?? "", network_purpose_helper.ToString(_value)).parse()); } /// /// Remove a purpose from a network (if present) /// First published in XenServer 7.3. /// /// The session /// The opaque_ref of the given network /// The purpose to remove public static void remove_purpose(Session session, string _network, network_purpose _value) { if (session.JsonRpcClient != null) session.JsonRpcClient.network_remove_purpose(session.uuid, _network, _value); else session.proxy.network_remove_purpose(session.uuid, _network ?? "", network_purpose_helper.ToString(_value)).parse(); } /// /// Remove a purpose from a network (if present) /// First published in XenServer 7.3. /// /// The session /// The opaque_ref of the given network /// The purpose to remove public static XenRef async_remove_purpose(Session session, string _network, network_purpose _value) { if (session.JsonRpcClient != null) return session.JsonRpcClient.async_network_remove_purpose(session.uuid, _network, _value); else return XenRef.Create(session.proxy.async_network_remove_purpose(session.uuid, _network ?? "", network_purpose_helper.ToString(_value)).parse()); } /// /// Return a list of all the networks known to the system. /// First published in XenServer 4.0. /// /// The session public static List> get_all(Session session) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_all(session.uuid); else return XenRef.Create(session.proxy.network_get_all(session.uuid).parse()); } /// /// Get all the network Records at once, in a single XML RPC call /// First published in XenServer 4.0. /// /// The session public static Dictionary, Network> get_all_records(Session session) { if (session.JsonRpcClient != null) return session.JsonRpcClient.network_get_all_records(session.uuid); else return XenRef.Create(session.proxy.network_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 = ""; /// /// a human-readable name /// public virtual string name_label { get { return _name_label; } set { if (!Helper.AreEqual(value, _name_label)) { _name_label = value; Changed = true; NotifyPropertyChanged("name_label"); } } } private string _name_label = ""; /// /// a notes field containing human-readable description /// public virtual string name_description { get { return _name_description; } set { if (!Helper.AreEqual(value, _name_description)) { _name_description = value; Changed = true; NotifyPropertyChanged("name_description"); } } } private string _name_description = ""; /// /// list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. /// public virtual List allowed_operations { get { return _allowed_operations; } set { if (!Helper.AreEqual(value, _allowed_operations)) { _allowed_operations = value; Changed = true; NotifyPropertyChanged("allowed_operations"); } } } private List _allowed_operations = new List() {}; /// /// links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. /// public virtual Dictionary current_operations { get { return _current_operations; } set { if (!Helper.AreEqual(value, _current_operations)) { _current_operations = value; Changed = true; NotifyPropertyChanged("current_operations"); } } } private Dictionary _current_operations = new Dictionary() {}; /// /// list of connected vifs /// [JsonConverter(typeof(XenRefListConverter))] public virtual List> VIFs { get { return _VIFs; } set { if (!Helper.AreEqual(value, _VIFs)) { _VIFs = value; Changed = true; NotifyPropertyChanged("VIFs"); } } } private List> _VIFs = new List>() {}; /// /// list of connected pifs /// [JsonConverter(typeof(XenRefListConverter))] public virtual List> PIFs { get { return _PIFs; } set { if (!Helper.AreEqual(value, _PIFs)) { _PIFs = value; Changed = true; NotifyPropertyChanged("PIFs"); } } } private List> _PIFs = new List>() {}; /// /// MTU in octets /// First published in XenServer 5.6. /// public virtual long MTU { get { return _MTU; } set { if (!Helper.AreEqual(value, _MTU)) { _MTU = value; Changed = true; NotifyPropertyChanged("MTU"); } } } private long _MTU = 1500; /// /// additional configuration /// public virtual Dictionary other_config { get { return _other_config; } set { if (!Helper.AreEqual(value, _other_config)) { _other_config = value; Changed = true; NotifyPropertyChanged("other_config"); } } } private Dictionary _other_config = new Dictionary() {}; /// /// name of the bridge corresponding to this network on the local host /// public virtual string bridge { get { return _bridge; } set { if (!Helper.AreEqual(value, _bridge)) { _bridge = value; Changed = true; NotifyPropertyChanged("bridge"); } } } private string _bridge = ""; /// /// true if the bridge is managed by xapi /// First published in XenServer 7.2. /// public virtual bool managed { get { return _managed; } set { if (!Helper.AreEqual(value, _managed)) { _managed = value; Changed = true; NotifyPropertyChanged("managed"); } } } private bool _managed = true; /// /// Binary blobs associated with this network /// First published in XenServer 5.0. /// [JsonConverter(typeof(StringXenRefMapConverter))] public virtual Dictionary> blobs { get { return _blobs; } set { if (!Helper.AreEqual(value, _blobs)) { _blobs = value; Changed = true; NotifyPropertyChanged("blobs"); } } } private Dictionary> _blobs = new Dictionary>() {}; /// /// user-specified tags for categorization purposes /// First published in XenServer 5.0. /// public virtual string[] tags { get { return _tags; } set { if (!Helper.AreEqual(value, _tags)) { _tags = value; Changed = true; NotifyPropertyChanged("tags"); } } } private string[] _tags = {}; /// /// The network will use this value to determine the behaviour of all VIFs where locking_mode = default /// First published in XenServer 6.1. /// [JsonConverter(typeof(network_default_locking_modeConverter))] public virtual network_default_locking_mode default_locking_mode { get { return _default_locking_mode; } set { if (!Helper.AreEqual(value, _default_locking_mode)) { _default_locking_mode = value; Changed = true; NotifyPropertyChanged("default_locking_mode"); } } } private network_default_locking_mode _default_locking_mode = network_default_locking_mode.unlocked; /// /// The IP addresses assigned to VIFs on networks that have active xapi-managed DHCP /// First published in XenServer 6.5. /// [JsonConverter(typeof(XenRefStringMapConverter))] public virtual Dictionary, string> assigned_ips { get { return _assigned_ips; } set { if (!Helper.AreEqual(value, _assigned_ips)) { _assigned_ips = value; Changed = true; NotifyPropertyChanged("assigned_ips"); } } } private Dictionary, string> _assigned_ips = new Dictionary, string>() {}; /// /// Set of purposes for which the server will use this network /// First published in XenServer 7.3. /// public virtual List purpose { get { return _purpose; } set { if (!Helper.AreEqual(value, _purpose)) { _purpose = value; Changed = true; NotifyPropertyChanged("purpose"); } } } private List _purpose = new List() {}; } }