/* * Copyright (c) Cloud Software Group, Inc. * * 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 System.Linq; using Newtonsoft.Json; namespace XenAPI { /// /// LVHD SR specific operations /// First published in XenServer 7.0. /// public partial class LVHD : XenObject { #region Constructors public LVHD() { } public LVHD(string uuid) { this.uuid = uuid; } /// /// Creates a new LVHD from a Hashtable. /// Note that the fields not contained in the Hashtable /// will be created with their default values. /// /// public LVHD(Hashtable table) : this() { UpdateFrom(table); } #endregion /// /// Updates each field of this instance with the value of /// the corresponding field of a given LVHD. /// public override void UpdateFrom(LVHD record) { uuid = record.uuid; } /// /// Given a Hashtable with field-value pairs, it updates the fields of this LVHD /// with the values listed in the Hashtable. Note that only the fields contained /// in the Hashtable will be updated and the rest will remain the same. /// /// public void UpdateFrom(Hashtable table) { if (table.ContainsKey("uuid")) uuid = Marshalling.ParseString(table, "uuid"); } public bool DeepEquals(LVHD other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Helper.AreEqual2(_uuid, other._uuid); } public override string SaveChanges(Session session, string opaqueRef, LVHD 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 LVHD. /// First published in XenServer 7.0. /// /// The session /// The opaque_ref of the given lvhd public static LVHD get_record(Session session, string _lvhd) { return session.JsonRpcClient.lvhd_get_record(session.opaque_ref, _lvhd); } /// /// Get a reference to the LVHD instance with the specified UUID. /// First published in XenServer 7.0. /// /// The session /// UUID of object to return public static XenRef get_by_uuid(Session session, string _uuid) { return session.JsonRpcClient.lvhd_get_by_uuid(session.opaque_ref, _uuid); } /// /// Get the uuid field of the given LVHD. /// First published in XenServer 7.0. /// /// The session /// The opaque_ref of the given lvhd public static string get_uuid(Session session, string _lvhd) { return session.JsonRpcClient.lvhd_get_uuid(session.opaque_ref, _lvhd); } /// /// Upgrades an LVHD SR to enable thin-provisioning. Future VDIs created in this SR will be thinly-provisioned, although existing VDIs will be left alone. Note that the SR must be attached to the SRmaster for upgrade to work. /// First published in XenServer 7.0. /// /// The session /// The LVHD Host to upgrade to being thin-provisioned. /// The LVHD SR to upgrade to being thin-provisioned. /// The initial amount of space to allocate to a newly-created VDI in bytes /// The amount of space to allocate to a VDI when it needs to be enlarged in bytes public static string enable_thin_provisioning(Session session, string _host, string _sr, long _initial_allocation, long _allocation_quantum) { return session.JsonRpcClient.lvhd_enable_thin_provisioning(session.opaque_ref, _host, _sr, _initial_allocation, _allocation_quantum); } /// /// Upgrades an LVHD SR to enable thin-provisioning. Future VDIs created in this SR will be thinly-provisioned, although existing VDIs will be left alone. Note that the SR must be attached to the SRmaster for upgrade to work. /// First published in XenServer 7.0. /// /// The session /// The LVHD Host to upgrade to being thin-provisioned. /// The LVHD SR to upgrade to being thin-provisioned. /// The initial amount of space to allocate to a newly-created VDI in bytes /// The amount of space to allocate to a VDI when it needs to be enlarged in bytes public static XenRef async_enable_thin_provisioning(Session session, string _host, string _sr, long _initial_allocation, long _allocation_quantum) { return session.JsonRpcClient.async_lvhd_enable_thin_provisioning(session.opaque_ref, _host, _sr, _initial_allocation, _allocation_quantum); } /// /// Unique identifier/object reference /// public virtual string uuid { get { return _uuid; } set { if (!Helper.AreEqual(value, _uuid)) { _uuid = value; NotifyPropertyChanged("uuid"); } } } private string _uuid = ""; } }