Scripting: Automate VM operations on XenServer with PowerShell

8:15 PM
Scripting: Automate VM operations on XenServer with PowerShell -

XenServer+PowerShell With the release of XenServer 6.2 SDK, there is a better alignment between the PowerShell snap-in and the PowerShell standards cmdlets design and use. Here are some good reference documents:

  • XenServer 6.2.0 SDK Release Notes
  • XenServer 6.2.0 PowerShell SDK Overview

in the solutions from Citrix Lab we have for all our XenServer environment Einsatzaufgaben this SDK was with and we want to share with you.

all this installation on the XenServer pool master under perform

downloading and XenServer PowerShell snap-in scripts include connection and a set of cmdlets perform the various tasks. Of course this requires that you have the latest XenServer PowerShell snap-in that is available for download installed at http://www.xenserver.org/partners/developing-products-for-xenserver.html under Download SDK components and click the software Development Kit link.

to extract After downloading the XenServer-6.2.0-SDK.zip file, and run the [1945010XenServerPSSnapIn-620-1msi] located at XenServer SDK XenServerPSSnapIn .

[1945001auch], keep in mind that the XenServerPSSnapIn_old folder contains the old version of PowerShell snap-in, which is not used in this discussion. If this was a mistake installed, you can uninstall it and the right of the XenServerPSSnapIn install folder.

The sample tasks

, to perform a task, such as with other complex operation, the script go through a series of steps to achieve the desired result. Below I will go over the steps that are used the example of tasks to accomplish. Each of these steps can be referenced in the sample scripts as comments with the prefix "blog step" to help follow you

Creating VMs from other VMs or templates

  • Download the. XenServer snap-in
  • to connect to the XenServer Pool Master
  • Get the source VM or template
  • Decide whether we a clone or copy (ie thin vs. do thick provision)
  • Plan complete the creation of VMs
  • wait for the creation
  • When we started with templates, then we need VMs for the provision of terminate copies / clones and wait for the provision of
  • If we want the VMs, then get each VM and schedule a performance on
  • separating XenServer pool Master
  • Remove the XenServer snap -in start

change the VM resources such as CPU, memory and networks

  • load the snap-in XenServer
  • the pool XenServer Connect Master
  • each VM Get and a graceful closed schedule
  • ensure each VM Get and that the VM is off
  • If we modify networking:
    • If we are to hold the non-existing networks on the VM, then remove all the existing networks on the VM
    • networks VMs simultaneously adding it to skip duplicates and a number of devices hold
  • If we modify CPU (we must always meet a CPU control from 0
  • When CPUs in VM are greater than our desired number, then we can reduce start-up CPUs, followed by max CPUs
  • When CPUs in VM are less than our desired count, then we increase max CPUs followed by start-up CPUs
  • If we this action
skip
  • If we modify memory (we must always meet a memory control memory_static_min ≤ memory_dynamic_min ≤ memory_dynamic_max ≤ memory_static_max):
    • If desired memory amount is less than the static minimum, then our desired amount to the change storage static minimum
    • If static maximum memory is greater than our desired amount of VM, then we put dynamic minimum, followed by dynamic maximum and finally static maximum
    • If static maximum storage on VM less than our desired amount, then we set the static maximum, followed by the dynamic maximum and finally dynamic minimum
    • Otherwise, we skip this measure
  • Get any VM and schedule performance on
  • When networks were added, then we wait until the VM is rebootable a graceful reboot plan to apply changes
  • separating XenServer pool Master
  • remove the XenServer snap-in
  • Creating and resetting of VM snapshots

    • Download the XenServer snap-in
    • to connect to the XenServer pool Master
    • If we take a snapshot:
      • each VM get and a graceful shut plan to obtain each VM down of VMs
      • , ensure that the VM is turned off, and plan the creation of snapshot
    • If we take a snapshot reset:
    • obtain
        each VM, you get the snapshot, you plan the reversion of snapshot
    • Get each VM and plan performance on
    • separating XenServer pool Master
    • remove the XenServer snap-in

    Get the sample scripts

    We would like to share with you some sample scripts that go described above in the various tasks of the steps. These scripts are very useful when the sample tasks is carried out as bulk operations across multiple VMs.

    Creating VMs from other VMs or templates

    Copy XenServerVMTemplate.ps1

    Change the VM resources such as CPU, memory and networks

    Set- XenServerVMResources.ps1

    Creating and resetting of VM snapshots

    Set-XenServerVMSnapshot.ps1

    Happy Scripting!

    Santiago Cardenas

    Citrix Solutions Lab

    Disclaimer:

    This software / sample code provided "AS IS "without representations, warranties or conditions of any kind. you can use, modify and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES OF ANY KIND, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the software / code sample could be inaccurate, design flaws or other problems that may cause data loss or damage to property; (B) it may not be possible to make the software / sample code fully functional; and (c) Citrix may, without notice or liability to you, no longer available to make the current version and / or future versions of the software / sample code. In no case the software / code to support ultra-hazardous activities should be used, including but not limited life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS IN BREACH OF CONTRACT OR ANY OTHER LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THE SOFTWARE / SAMPLE CODE, INCLUDING DIRECT, SPECIAL, CONSEQUENTIAL DAMAGES OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You agree to indemnify and defend Citrix against any claims arising from the use, modification or distribution of the code created.

    Previous
    Next Post »
    0 Komentar