Jump to content

Konstantina Chremmou

Internal Members
  • Posts

    22
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Konstantina Chremmou

  1. The command works using the  -Name too, as long as the variable is passed in correctly:

    PS> $vmName="myVM"
    PS> get-xenvm -name $vmName | select HVM_boot_params
    
    HVM_boot_params
    ---------------
    {[order, cd], [firmware, uefi]}
    
    PS> $HVMBootParams = @{ "firmware" = "bios";"order" = "n"}
    PS> set-xenvm -name $vmName -HVMBootParams $HVMBootParams
    PS> get-xenvm -name $vmName | select HVM_boot_params
    
    HVM_boot_params
    ---------------
    {[order, n], [firmware, bios]}

     

  2. The command looks correct, but the syntax does not look PS compliant. The hash table should be declared as follows:

    $HVMBootParams = @{ "firmware" = "uefi";"order" = "n"}

    i.e. with semicolon separating the pairs and no commas within the keys.

    Also, use $VMNAME for the name variable.

  3. A simpler way to write the above is

    Get-XenHost -Name "hostname" | select -Expandproperty resident_VMs | Get-XenVM

     

    However, you mentioned affinity to a home server. This is not the same as the server where the VM runs. Affinity is the server where we prefer the VM to run, but if there are no available resources, it may run on a different server. The above snippet returns the VMs currently running on a given server, but it doesn't mean that all these VMs have this server affinity or any affinity at all.

     

    To query VMs with a certain server affinity:

    Get-XenVM | where {$_.affinity -eq $h.opaque_ref}

     

  4. PCI info is exposed via the SDK/API (http://xapi-project.github.io/xen-api/classes/pci.html), but I think it's not exposed via the xe CLI (https://docs.citrix.com/en-us/citrix-hypervisor/command-line-interface.html). Using the PowerShell module, for example, you can obtain it via the cmdlet Get-XenPCI.

    • Like 1
  5. $platform = Get-XenVM -uuid xxxx | select -ExpandProperty platform
    $platform["cores-per-socket"]=yyy
    Set-XenVM -uuid xxxx -Platform $platform

    All the Citrix Hypervisor SDK flavours as well as the CLI are API wrappers, which means there is practically nothing the one can achieve that the other cannot. For a generic overview of the powershell cmdlets, please install the module and type (as mentioned in the accompanying readme):

    PS> Get-Help about_XenServer

     

  6. To re-attach you need to work along the following lines:

    $hostRef = (Get-XenHost).opaque_ref
    $deviceConfig = @{ "target"="192.168.x.x"; "port"="xxxx"; "targetIQN"="xxxxxx"; "SCSIid"="xxxxx" }
    $result = Invoke-XenSR -XenAction Probe -XenHost $hostRef -Type "lvmoiscsi" -DeviceConfig $deviceConfig -Ref OpaqueRef:NULL -PassThru
    $doc=[xml]$result
    $sr = Invoke-XenSR -XenAction Introduce -UuidParam $doc.SRlist.SR.UUID -NameLabel mySR -Type "lvmoiscsi" -Shared $true -Ref OpaqueRef:NULL -PassThru
    $pbd = New-XenPBD -XenHost $hostRef -SR $sr -DeviceConfig $deviceConfig -PassThru
    Invoke-xenPBD -XenAction Plug -PBD $pbd

    Now, I'm not 100% sure how your test goes about it, but if your SR supports replication and the reattach is part of a DR task, you can do:

    New-XenDRTask -Type "lvmoiscsi" -DeviceConfig $deviceConfig -PassThru

    On a general note, the powershell cmdlets wrap the C# SDK used by XenCenter, which means most stuff XenCenter does can be achieved with powershell, but sometimes it's tricky to find the right cmdlets to use. It may be helpful to look at how XenCenter (https://github.com/xenserver/xenadmin) does things and try to replicate it with powershell.

    • Like 1
  7. The target/IQN should be in the DeviceConfig. Try this:

    New-XenSR -NameLabel "mySR" -XenHost "hostname" -Type "lvmoiscsi" -Shared $true `
      -DeviceConfig @{ "target"="192.168.x.x"; "port"="xxxx"; "targetIQN"="xxxxxx"; "SCSIid"="xxxxx" }  

     

  8. This is not going to work because at the moment the -VDI parameter does not accept pipeline input, and additionally it is a reference, not a VDI object.

     

    The most PS-like way I can think of writing your command is:

    PS> Invoke-XenVBD -VBD (Get-XenVBD)[2] -XenAction Insert -VDI (Get-XenVDI -Name "$BootISOName" | select -ExpandProperty opaque_ref)

    or

    PS> (Get-XenVBD)[2] | Invoke-XenVBD -XenAction Insert -VDI (Get-XenVDI -Name "$BootISOName" | select -ExpandProperty opaque_ref)

×
×
  • Create New...