### Install XenAPI SDK Dependencies Source: https://github.com/xapi-project/xen-api-sdk/blob/master/README.md Installs external dependencies and OPAM packages required for building the XenAPI SDK. Ensure you have added the xs-opam repository first. ```bash opam depext -y xen-api-sdk opam install -y --deps-only xen-api-sdk ``` -------------------------------- ### Get XenAPI Object by Name Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Retrieves a XenAPI object, such as a host, by its name. If no parameters are specified, all objects of the type are returned. ```powershell PS> Get-XenHost -Name "Demo Host" ``` -------------------------------- ### Get XenAPI PIF Property Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Retrieves the value of a specific property for a XenAPI Physical Interface (PIF) object. The object is identified by its reference and the property by name. ```powershell PS> Get-XenPIFProperty -Ref OpaqueRef:f433bf7b-2b0c-5f53-7018-7d195addb3ca \ -XenProperty Network ``` -------------------------------- ### Connect to XenServer Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Opens a session to a XenServer. Use -Url, -UserName, and -Password to authenticate. ```powershell PS> Connect-XenServer -Url https:// -UserName user -Password pwd ``` -------------------------------- ### Connecting to XenServer Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Use the Connect-XenServer cmdlet to open a session to a XenServer host. You can specify the server URL, username, and password. ```APIDOC ## Connect-XenServer ### Description Opens a session to a XenServer host. ### Method Cmdlet ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **Url** (string) - The URL of the XenServer host. - **UserName** (string) - The username for authentication. - **Password** (string) - The password for authentication. - **Server** (string) - Alias for Url. - **SetDefaultSession** (switch) - Sets the current session as the default. ### Request Example ```powershell Connect-XenServer -Url https:// -UserName user -Password pwd ``` ### Response #### Success Response (200) Represents an active XenServer session. #### Response Example N/A ``` -------------------------------- ### Create New XenAPI VBD Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Creates a new XenAPI Virtual Block Device (VBD). Requires specifying VM, VDI, and other parameters like device type and mode. ```powershell $vm = Get-XenVM -Name "Demo VM" PS> New-XenVBD -VM $vm -VDI $null -Userdevice 3 -Bootable $false -Mode RO \ -Type CD -Unpluggable $true -Empty $true -OtherConfig @{} \ -QosAlgorithmType "" -QosAlgorithmParams @{} ``` -------------------------------- ### Managing XenServer Sessions Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Cmdlets for managing XenServer sessions, including listing and disconnecting. ```APIDOC ## Get-XenSession ### Description Retrieves a list of all open XenServer sessions. ### Method Cmdlet ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters - **Server** (string) - Optional. Filters sessions by server. #### Request Body None ### Request Example ```powershell Get-XenSession ``` ## Disconnect-XenServer ### Description Closes one or more XenServer sessions. ### Method Cmdlet ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **SessionOpaqueRef** (string) - The opaque reference of the session to disconnect. If not specified, all sessions are disconnected. ### Request Example ```powershell Get-XenSession | Disconnect-XenServer ``` ``` -------------------------------- ### Generate XenAPI SDK Source Code Source: https://github.com/xapi-project/xen-api-sdk/blob/master/README.md Generates SDK source code for specified programming languages (c, java, csharp, powershell) or all supported languages. Follow instructions in respective README files to compile. ```bash make ``` ```bash make ``` -------------------------------- ### Managing XenAPI Objects Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Cmdlets for retrieving, creating, removing, and modifying XenAPI objects. ```APIDOC ## Get-XenT ### Description Retrieves XenAPI objects of a specified class. ### Method Cmdlet ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters - **Ref** (string) - The opaque reference of the object. - **Name** (string) - The name of the object. - **Uuid** (string) - The UUID of the object. ### Request Example ```powershell Get-XenHost -Name "Demo Host" ``` ## New-XenT ### Description Creates a new XenAPI object of a specified class. ### Method Cmdlet ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters - **T** (string) - The XenAPI class name. - **[Field]** (type) - Parameters corresponding to the fields of the object to be created. ### Request Example ```powershell $vm = Get-XenVM -Name "Demo VM" New-XenVBD -VM $vm -VDI $null -Userdevice 3 -Bootable $false -Mode RO \ -Type CD -Unpluggable $true -Empty $true -OtherConfig @{} \ -QosAlgorithmType "" -QosAlgorithmParams @{} ``` ## Remove-XenT ### Description Removes a XenAPI object. ### Method Cmdlet ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters - **T** (string) - The XenAPI class name. - **Ref** (string) - The opaque reference of the object. - **UUID** (string) - The UUID of the object. - **Name** (string) - The name of the object. ### Request Example ```powershell Get-XenSR -Name "Demo SR" | Remove-XenSR ``` ## Set-XenT ### Description Sets fields of a XenAPI object. ### Method Cmdlet ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters - **T** (string) - The XenAPI class name. - **Ref** (string) - The opaque reference of the object. - **UUID** (string) - The UUID of the object. - **Name** (string) - The name of the object. - **[Field]** (type) - Parameters corresponding to the fields to be set. ### Request Example ```powershell Get-XenVM -Name "Demo VM" |` Set-XenVM -NameLabel "New name" -NameDescription "New description" ``` ## Add-XenT ### Description Adds an element to a field of a XenAPI object. ### Method Cmdlet ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters - **T** (string) - The XenAPI class name. - **Ref** (string) - The opaque reference of the object. - **UUID** (string) - The UUID of the object. - **Name** (string) - The name of the object. - **[Field]** (type) - Parameters corresponding to the fields to which elements will be added. ### Request Example ```powershell Add-XenHost -Name "Demo Host" -Tags "Tag1" ``` ## Remove-XenTProperty ### Description Removes an element from a field of a XenAPI object. ### Method Cmdlet ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters - **T** (string) - The XenAPI class name. - **Ref** (string) - The opaque reference of the object. - **UUID** (string) - The UUID of the object. - **Name** (string) - The name of the object. - **[Field]** (type) - Parameters corresponding to the fields from which elements will be removed. ### Request Example ```powershell Remove-XenHostProperty -Name "myHost" -Tags "tag1" -OtherConfig "myKey" ``` ## Get-XenTProperty ### Description Retrieves the value of a field of a XenAPI object. ### Method Cmdlet ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters - **T** (string) - The XenAPI class name. - **Ref** (string) - The opaque reference of the object. - **XenProperty** (enum) - The name of the property to retrieve. ### Request Example ```powershell Get-XenPIFProperty -Ref OpaqueRef:f433bf7b-2b0c-5f53-7018-7d195addb3ca \ -XenProperty Network ``` ``` -------------------------------- ### Set XenAPI VM Properties Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Updates properties of a XenAPI Virtual Machine (VM) object, such as its name label and description. Multiple fields can be set in one call. ```powershell PS> Get-XenVM -Name "Demo VM" |\ Set-XenVM -NameLabel "New name" -NameDescription "New description" ``` -------------------------------- ### Run XenServer Cmdlet Asynchronously Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Executes a XenServer cmdlet asynchronously using the -Async parameter. This is useful for long-running operations. Note limitations for setters, adders, and removers when using -Async. ```powershell PS> Invoke-XenVM -Name $vm_name -XenAction Start -Async -PassThru | Wait-XenTask -ShowProgress ``` -------------------------------- ### Specify XenServer Session Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Specifies which XenServer session to use for a cmdlet. This is useful when multiple sessions are open. ```powershell PS> Verb-Noun [-SessionOpaqueRef []] ``` -------------------------------- ### Set Default XenServer Session Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Sets the default XenServer session for subsequent commands. This can be done directly or by retrieving a session object. ```powershell PS> Connect-XenServer -Server srv -UserName usr -Password pwd -SetDefaultSession ``` ```powershell PS> $XenServer_Default_Session = Get-XenSession -Server srv ``` -------------------------------- ### Add Tag to XenAPI Host Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Adds a tag to a XenAPI Host object. The host is specified by name, and the tag is provided as a parameter. ```powershell PS> Add-XenHost -Name "Demo Host" -Tags "Tag1" ``` -------------------------------- ### Convert to XenRef Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Converts an object to its XenRef representation, which is often required by XenServer cmdlets. This cmdlet aids in managing object references. ```powershell PS> Get-XenVM -Name "Demo VM" | ConvertTo-XenRef ``` -------------------------------- ### Disconnect from XenServer Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Logs out of all open XenServer sessions. It is good practice to disconnect when finished. ```powershell PS> Get-XenSession | Disconnect-XenServer ``` -------------------------------- ### Invoke XenServer Object Operation Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Invokes a specific operation on a XenServer object. Use -T, -Ref, -UUID, or -Name to specify the object and -XenAction to specify the operation. ```powershell PS> Get-XenPBD -Uuid 1871ac51-ce6b-efc3-7fd0-28bc65aa39ff | Invoke-XenPBD -XenAction Unplug ``` -------------------------------- ### Remove XenAPI SR by Name Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Destroys a XenAPI Storage Repository (SR) object specified by its name. The object is piped to the Remove-XenSR cmdlet. ```powershell PS> Get-XenSR -Name "Demo SR" | Remove-XenSR ``` -------------------------------- ### Remove Host Property Source: https://github.com/xapi-project/xen-api-sdk/blob/master/powershell/autogen/about_XenServer.help.txt Removes elements from fields of a XenAPI Host object, such as tags or other configuration keys. Multiple fields can be removed in one call. ```powershell PS> Remove-XenHostProperty -Name "myHost" -Tags "tag1" -OtherConfig "myKey" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.