2023-01-24 15:29:31 +01:00
/ * Copyright ( c ) Cloud Software Group , Inc .
2017-09-13 18:14:07 +02:00
*
2016-01-28 22:29:29 +01:00
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions
* are met :
2017-09-13 18:14:07 +02:00
*
2016-01-28 22:29:29 +01:00
* 1 ) Redistributions of source code must retain the above copyright
* notice , this list of conditions and the following disclaimer .
2017-09-13 18:14:07 +02:00
*
2016-01-28 22:29:29 +01:00
* 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 .
2017-09-13 18:14:07 +02:00
*
2016-01-28 22:29:29 +01:00
* 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 ;
2017-09-13 18:14:07 +02:00
using System.ComponentModel ;
using System.Globalization ;
2021-04-13 11:05:38 +02:00
using System.Linq ;
2017-09-13 18:14:07 +02:00
using Newtonsoft.Json ;
2016-01-28 22:29:29 +01:00
namespace XenAPI
{
/// <summary>
/// LVHD SR specific operations
2017-06-28 18:00:22 +02:00
/// First published in XenServer 7.0.
2016-01-28 22:29:29 +01:00
/// </summary>
public partial class LVHD : XenObject < LVHD >
{
2019-06-19 10:11:30 +02:00
#region Constructors
2016-01-28 22:29:29 +01:00
public LVHD ( )
{
}
public LVHD ( string uuid )
{
this . uuid = uuid ;
}
2019-06-19 10:11:30 +02:00
/// <summary>
/// Creates a new LVHD from a Hashtable.
/// Note that the fields not contained in the Hashtable
/// will be created with their default values.
/// </summary>
/// <param name="table"></param>
public LVHD ( Hashtable table )
: this ( )
{
UpdateFrom ( table ) ;
}
2016-01-28 22:29:29 +01:00
/// <summary>
/// Creates a new LVHD from a Proxy_LVHD.
/// </summary>
/// <param name="proxy"></param>
public LVHD ( Proxy_LVHD proxy )
{
2019-06-19 10:11:30 +02:00
UpdateFrom ( proxy ) ;
2016-01-28 22:29:29 +01:00
}
2019-06-19 10:11:30 +02:00
#endregion
2018-02-16 17:27:30 +01:00
/// <summary>
/// Updates each field of this instance with the value of
/// the corresponding field of a given LVHD.
/// </summary>
2021-04-13 11:05:38 +02:00
public override void UpdateFrom ( LVHD record )
2016-01-28 22:29:29 +01:00
{
2021-04-13 11:05:38 +02:00
uuid = record . uuid ;
2016-01-28 22:29:29 +01:00
}
2019-06-19 10:11:30 +02:00
internal void UpdateFrom ( Proxy_LVHD proxy )
2016-01-28 22:29:29 +01:00
{
2018-03-22 13:30:43 +01:00
uuid = proxy . uuid = = null ? null : proxy . uuid ;
2016-01-28 22:29:29 +01:00
}
2018-02-16 17:27:30 +01:00
/// <summary>
/// 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.
2016-01-28 22:29:29 +01:00
/// </summary>
/// <param name="table"></param>
2018-02-16 17:27:30 +01:00
public void UpdateFrom ( Hashtable table )
2016-01-28 22:29:29 +01:00
{
2018-02-16 17:27:30 +01:00
if ( table . ContainsKey ( "uuid" ) )
2018-02-23 17:06:32 +01:00
uuid = Marshalling . ParseString ( table , "uuid" ) ;
2016-01-28 22:29:29 +01:00
}
2021-04-13 11:05:38 +02:00
public Proxy_LVHD ToProxy ( )
{
Proxy_LVHD result_ = new Proxy_LVHD ( ) ;
result_ . uuid = uuid ? ? "" ;
return result_ ;
}
2016-01-28 22:29:29 +01:00
public bool DeepEquals ( LVHD other )
{
if ( ReferenceEquals ( null , other ) )
return false ;
if ( ReferenceEquals ( this , other ) )
return true ;
return Helper . AreEqual2 ( this . _uuid , other . _uuid ) ;
}
public override string SaveChanges ( Session session , string opaqueRef , LVHD server )
{
if ( opaqueRef = = null )
2018-02-14 12:03:48 +01:00
{
System . Diagnostics . Debug . Assert ( false , "Cannot create instances of this type on the server" ) ;
2016-01-28 22:29:29 +01:00
return "" ;
}
else
{
throw new InvalidOperationException ( "This type has no read/write properties" ) ;
}
}
2021-04-13 11:05:38 +02:00
2016-01-28 22:29:29 +01:00
/// <summary>
/// Get a record containing the current state of the given LVHD.
2017-06-28 18:00:22 +02:00
/// First published in XenServer 7.0.
2016-01-28 22:29:29 +01:00
/// </summary>
/// <param name="session">The session</param>
/// <param name="_lvhd">The opaque_ref of the given lvhd</param>
public static LVHD get_record ( Session session , string _lvhd )
{
2017-09-13 18:14:07 +02:00
if ( session . JsonRpcClient ! = null )
2018-02-23 17:06:32 +01:00
return session . JsonRpcClient . lvhd_get_record ( session . opaque_ref , _lvhd ) ;
2017-09-13 18:14:07 +02:00
else
2020-01-30 01:02:24 +01:00
return new LVHD ( session . XmlRpcProxy . lvhd_get_record ( session . opaque_ref , _lvhd ? ? "" ) . parse ( ) ) ;
2016-01-28 22:29:29 +01:00
}
/// <summary>
/// Get a reference to the LVHD instance with the specified UUID.
2017-06-28 18:00:22 +02:00
/// First published in XenServer 7.0.
2016-01-28 22:29:29 +01:00
/// </summary>
/// <param name="session">The session</param>
/// <param name="_uuid">UUID of object to return</param>
public static XenRef < LVHD > get_by_uuid ( Session session , string _uuid )
{
2017-09-13 18:14:07 +02:00
if ( session . JsonRpcClient ! = null )
2018-02-23 17:06:32 +01:00
return session . JsonRpcClient . lvhd_get_by_uuid ( session . opaque_ref , _uuid ) ;
2017-09-13 18:14:07 +02:00
else
2020-01-30 01:02:24 +01:00
return XenRef < LVHD > . Create ( session . XmlRpcProxy . lvhd_get_by_uuid ( session . opaque_ref , _uuid ? ? "" ) . parse ( ) ) ;
2016-01-28 22:29:29 +01:00
}
/// <summary>
/// Get the uuid field of the given LVHD.
2017-06-28 18:00:22 +02:00
/// First published in XenServer 7.0.
2016-01-28 22:29:29 +01:00
/// </summary>
/// <param name="session">The session</param>
/// <param name="_lvhd">The opaque_ref of the given lvhd</param>
public static string get_uuid ( Session session , string _lvhd )
{
2017-09-13 18:14:07 +02:00
if ( session . JsonRpcClient ! = null )
2018-02-23 17:06:32 +01:00
return session . JsonRpcClient . lvhd_get_uuid ( session . opaque_ref , _lvhd ) ;
2017-09-13 18:14:07 +02:00
else
2020-01-30 01:02:24 +01:00
return session . XmlRpcProxy . lvhd_get_uuid ( session . opaque_ref , _lvhd ? ? "" ) . parse ( ) ;
2016-01-28 22:29:29 +01:00
}
/// <summary>
/// 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.
2017-06-28 18:00:22 +02:00
/// First published in XenServer 7.0.
2016-01-28 22:29:29 +01:00
/// </summary>
/// <param name="session">The session</param>
2016-08-30 18:11:47 +02:00
/// <param name="_host">The LVHD Host to upgrade to being thin-provisioned.</param>
2016-01-28 22:29:29 +01:00
/// <param name="_sr">The LVHD SR to upgrade to being thin-provisioned.</param>
/// <param name="_initial_allocation">The initial amount of space to allocate to a newly-created VDI in bytes</param>
/// <param name="_allocation_quantum">The amount of space to allocate to a VDI when it needs to be enlarged in bytes</param>
2016-08-30 18:11:47 +02:00
public static string enable_thin_provisioning ( Session session , string _host , string _sr , long _initial_allocation , long _allocation_quantum )
2016-01-28 22:29:29 +01:00
{
2017-09-13 18:14:07 +02:00
if ( session . JsonRpcClient ! = null )
2018-02-23 17:06:32 +01:00
return session . JsonRpcClient . lvhd_enable_thin_provisioning ( session . opaque_ref , _host , _sr , _initial_allocation , _allocation_quantum ) ;
2017-09-13 18:14:07 +02:00
else
2020-01-30 01:02:24 +01:00
return session . XmlRpcProxy . lvhd_enable_thin_provisioning ( session . opaque_ref , _host ? ? "" , _sr ? ? "" , _initial_allocation . ToString ( ) , _allocation_quantum . ToString ( ) ) . parse ( ) ;
2016-01-28 22:29:29 +01:00
}
/// <summary>
/// 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.
2017-06-28 18:00:22 +02:00
/// First published in XenServer 7.0.
2016-01-28 22:29:29 +01:00
/// </summary>
/// <param name="session">The session</param>
2016-08-30 18:11:47 +02:00
/// <param name="_host">The LVHD Host to upgrade to being thin-provisioned.</param>
2016-01-28 22:29:29 +01:00
/// <param name="_sr">The LVHD SR to upgrade to being thin-provisioned.</param>
/// <param name="_initial_allocation">The initial amount of space to allocate to a newly-created VDI in bytes</param>
/// <param name="_allocation_quantum">The amount of space to allocate to a VDI when it needs to be enlarged in bytes</param>
2016-08-30 18:11:47 +02:00
public static XenRef < Task > async_enable_thin_provisioning ( Session session , string _host , string _sr , long _initial_allocation , long _allocation_quantum )
2016-01-28 22:29:29 +01:00
{
2017-09-13 18:14:07 +02:00
if ( session . JsonRpcClient ! = null )
2018-02-23 17:06:32 +01:00
return session . JsonRpcClient . async_lvhd_enable_thin_provisioning ( session . opaque_ref , _host , _sr , _initial_allocation , _allocation_quantum ) ;
2017-09-13 18:14:07 +02:00
else
2020-01-30 01:02:24 +01:00
return XenRef < Task > . Create ( session . XmlRpcProxy . async_lvhd_enable_thin_provisioning ( session . opaque_ref , _host ? ? "" , _sr ? ? "" , _initial_allocation . ToString ( ) , _allocation_quantum . ToString ( ) ) . parse ( ) ) ;
2016-01-28 22:29:29 +01:00
}
/// <summary>
/// Unique identifier/object reference
/// </summary>
public virtual string uuid
{
get { return _uuid ; }
set
{
if ( ! Helper . AreEqual ( value , _uuid ) )
{
_uuid = value ;
NotifyPropertyChanged ( "uuid" ) ;
}
}
}
2017-09-13 18:14:07 +02:00
private string _uuid = "" ;
2016-01-28 22:29:29 +01:00
}
}