Set the priority of restarting a virtual machine

Hello

I'm trying to set the priority of restarting a virtual machine in a cluster. I worked along THIS DISCUSSION to create this script:

var myVcClusterDasConfigInfo = new VcClusterDasConfigInfo() ; 
var myVcClusterDasVmConfigSpec = new VcClusterDasVmConfigSpec() ; 
myVcClusterDasVmConfigSpec.operation = VcArrayUpdateOperation.add; 
var myVcClusterDasVmConfigInfo = new VcClusterDasVmConfigInfo() ;
myVcClusterDasVmConfigInfo.key = VM;
myVcClusterDasVmConfigInfo.restartPriority =  VcDasVmPriority.high;
myVcClusterDasVmConfigSpec.info = myVcClusterDasVmConfigInfo;
var myVcClusterDasVmConfigSpecArray = new Array() ; 
myVcClusterDasVmConfigSpecArray.push( myVcClusterDasVmConfigSpec ); 
var myVcClusterConfigSpecEx = new VcClusterConfigSpecEx() ; 
myVcClusterConfigSpecEx.dasConfig = myVcClusterDasConfigInfo; 
myVcClusterConfigSpecEx.dasVmConfigSpec = myVcClusterDasVmConfigSpecArray; 
Cluster.reconfigureComputeResource_Task( myVcClusterConfigSpecEx, true );

Where Cluster and VM are objects of the WF input.

Executions of thoughts scripts, however, in the CR, I get the error «the parameter of {entry.@enum.» InvalidDasConfigArgument.EntryForInvalidArgument} is not valid for the cluster.

It's simple... but I just can't cope.

Thank you guys

Also I just realized... that the method I used is deprecated... grrr

Here's the correct one:

var myVcClusterDasVmSettings = new VcClusterDasVmSettings();
myVcClusterDasVmSettings.restartPriority=VcClusterDasVmSettingsRestartPriority.fromString(priority);

var myVcClusterDasVmConfigInfo = new VcClusterDasVmConfigInfo();
myVcClusterDasVmConfigInfo.key=VM;
myVcClusterDasVmConfigInfo.dasSettings=myVcClusterDasVmSettings;

var myVcClusterDasVmConfigSpec = new VcClusterDasVmConfigSpec() ;
myVcClusterDasVmConfigSpec.operation = VcArrayUpdateOperation.add;
myVcClusterDasVmConfigSpec.info = myVcClusterDasVmConfigInfo;

var myVcClusterDasVmConfigSpecArray = new Array() ;
myVcClusterDasVmConfigSpecArray.push( myVcClusterDasVmConfigSpec );
var myVcClusterConfigSpecEx = new VcClusterConfigSpecEx() ;
var myVcClusterDasConfigInfo = new VcClusterDasConfigInfo() ;
myVcClusterConfigSpecEx.dasConfig = myVcClusterDasConfigInfo;
myVcClusterConfigSpecEx.dasVmConfigSpec = myVcClusterDasVmConfigSpecArray;
task=ClusterName.reconfigureComputeResource_Task( myVcClusterConfigSpecEx, true );

Tags: VMware

Similar Questions

  • How to set the vlan native on a virtual machine in vSphere when you use the 1000V?

    Using the General switch original vSphere, we put VLAN native by VM by setting the VLAN 0 d.

    How do we set VLAN native for a virtual machine, if the virtual computer is connected to a 1000V? I heard that is over, we can use VLAN ID 0?

    Same way as you would on any Cisco switch.

    Add this command to your profile of uplink port:

    switchport trunk vlan native X

    Keep in mind there is no VLAN 0.  VLAN '0' is just how vmware means the VLAN untagged.  There are valid in accordance with the standard 1-4095.

    Kind regards

    Robert

  • Set the priority to restart HA of a csv file

    Hello

    I have a problem HA restart the priority of a CSV on the VMs.

    My share of script is like this:

    If ($Export)

    {

    # Export to CSV

    $mycluster = get-Cluster-name $Cluster

    $mycluster. ExtensionData.Configuration.DasVmConfig |

    Select @{N = "VM"; E = {Get-view $_.} Key - the name of the property. {{Select - ExpandProperty name}}.

    @{N = "RestartPriority"; E={$_. RestartPriority}} |

    {Csv Export $Path\HARestartPrio.csv - NoTypeInformation - UseCulture}

    If ($Set)

    {

    # Put csv

    $Import = import-Csv $Path\HARestartPrio.csv

    foreach ($line in $Import)

    {set-VM - vm $line. "" VM "-HARestartPriority $line. {{"" RestartPriority "-confirm: $false}}

    When I put the priority, the CLI will give an error:

    The parameter HARestartPriority can not check. The Argument is Null or is empty

    What is the problem in my script? You have any ideas?

    It is not the Export-Csv is the problem in my humble opinion, you must also specify the Import-Csv cmdlet UseCulture switch.

  • Set the host name for a virtual machine

    While the vApps instantiation using a model about the same way as the sample of HellovCloud.java, I need to be able to change the host name (called the name of the computer in vCD) of the only virtual machine contained in the VAPP. I can't find examples on how to do it. Any ideas?

    Hope that this helps, I took it out some code that we use (SDK). NET - this is not an exact copy of the labour code, but must be what it takes to get there.

    String modifierText = "1234";

    With complete API v1.5 may need to change this kind of object to Vm

    VAPP vm = GETTHECHILDFROMTHEAPP (VAPP. GetChildrenVms());

    If (vm. GetGuestCustomizationSection()! = null)
    {
    GuestCustomizationSectionType guestSection is vm. GetGuestCustomizationSection();
    int len = guestSection.ComputerName.Length;
    If (len > 10) len = 10;
    guestSection.ComputerName = guestSection.ComputerName.Substring (0, len) + modifierText;
    Try
    {
    VM. UpdateSection (guestSection);
    }
    catch (VCloudException ex)
    {
    Exception thrown by 1.5 hosts: VCloudException
    (The parameter is not supported in the current context: AdminPassword)
    bug workaround
    If (Message.Contains ("AdminPassword") e.g.)
    {
    AdminPassword value NULL and try again
    guestSection.AdminPassword = null;
    VM. UpdateSection (guestSection);
    } else {}
    throw;
    }
    }
    }
  • Virtual machine set up their: consolidation of necessary virtual machine disk.

    a virtual machine guest: set up number: consolidation of necessary virtual machine disk.

    I click on this virtual machine > > snapshot > > Consolidation.then about a minute.

    He failed: cannot access < unspecified file name > file because it is locked

    02.jpg

    This question well in the base backup tool VADP Storage API. This file is locked by worker VPXA get. Then restart (host managegemnt connection) services vpxa and spend on your host and redo the consolidation 1) disable alarm processing host connection failure and failure of network connection (to avoid unnecessary alarm0 2) connection to the host through ssh) 3 run # /etc/init.d/hostd restart and restart # etc/init.d/vpxa, 4) re-do the consolidation of the vm.

  • Can I change the RAM available on a virtual machine without having to reboot?

    I would like to know if there is an option to change the RAM available on a virtual machine without restarting the virtual machine. I saw this old news item that says that it is

    possible (http://news.cnet.com/8301-1001_3-10044031-92.html), but I don't know how to do it. Any suggestions?

    Thanks in advance.

    Arne post, called PowerCLI: toggle the function add Hot VMs, shows how.

  • command to restart for virtual machines in a cluster

    Hi all.

    I have a vCenter Server 4.1 (HA, VMotion, DRS active) and a group of 8 ESX 4.1 works perfectly, with some virtual machines on it.

    I was asked if it was possible with vCenter, to restart three virtual machines in a specific order, not matter what ESX, there is on. At first, I thought a rule on the cluster to group them, but then I realized that it was not possible to specify the boot order, but only that they could be (or not) on the same host.

    Does anyone have an idea on how to fix this?

    Thank you very much.

    Hello.

    This sounds like a possible use case of vApps.  You can put VMS in the vApp and then specify the order of start and stop them.

    Good luck!

  • Can I use the same windows on my virtual machine?

    I had windows pre-installed in my dell laptop (Latitude E6420). I did not have the cd key but I extracted using a program called Magical jelly bean key finder. Now, I have the following information on my windows installation

    Windows 7 Professional Service Pack 1
    Product no.: XXXXXXXX
    Installed from media "OEM."
    Product ID: XXXXX-OEM-XXXXXXXX
    CD Key: XXXXXXXXXXXXXXXXXXXXXXXX
    Computer name: XXXXX
    Registered owner: XXXXX
    Registered organization: Microsoft
    Now, I want to install linux on my machine and use the current windows in a virtual machine inside the linux host. Is is possible if I completely uninstall this windows of my computer and reinstall the virtual machine with the same key?
    I'm not very familiar with this also can someone guide me what are the steps I have to take if this is possible.

    Hi Andre,

    Thank you for your answer, but this does not completely answer my question. I also read that OEM installation does not install the same windows on another machine (virtual machine is like different machine even if I do this on the same machine) and installation of the mine is OEM type.

    More important still, how install windows in the virtual environment? If I format the computer and install linux, in addition to this install virualbox and install inside windows that use the cd - key and it will work. ? I doubt it because the windows is already activated in this machine.

    The extract of the contract (EULA) for Windows 7 and applies to the retail and OEM of Windows 7 versions. So, Yes, you can reinstall it in a Virtual Machine.

    Yes, you will need to format the machine under Linux, then reinstall Windows 7 in a computer program virtual suitable as Oracle Virtual Box 4.2, VMWare Player 5.0 or VMWare Workstation. You can then use the product key located on the COA sticker to reactivate the license.

  • Not possible to export a list of virtual machines that are created in the past 7, 30, 120 and 180 days since an imported csv file containing the date of creation of virtual machine

    Not possible to export a list of virtual machines that are created in the past 7, 30, 120 and 180 days since an imported csv file containing the date of creation of virtual machine. My questions is the correct statement to the variable: $VmCreated7DaysAgo: $_CreatedOn "-lt" $CDate7.

    # #SCRIPT_START

    $file = "C:\Users\Admin\Documents\WindowsPowerShell\08-18-2014\VM-Repo.csv".

    $Import = import-csv $file

    $VMCreatedLast7RDayRepoFile = "C:\Users\Admin\Documents\WindowsPowerShell\08-18-2014\Last7Days.csv".

    $start7 = (get-Date). AddMonths(-1)

    $CDate7 = $start7. ToString('MM/dd/yyyy')

    $VmCreated7DaysAgo = $Import | Select-object - property name, Powerstate, vCenter, VMHost, Cluster, file, Application, CreatedBy, CreatedOn, NumCpu, MemoryGB | Where-Object {$_.} CreatedOn - lt $CDate7} | Sort-Object CreatedOn

    $TotalVmCreated7DaysAgo = $VmCreated7DaysAgo.count

    $VmCreated7DaysAgo | Export-Csv-path $VMCreatedLast7RDayRepoFile - NoTypeInformation - UseCulture

    Write-Host "$TotalVmCreated7DaysAgo VMs created in 7 days" - BackgroundColor Magenta

    Invoke-Item $VMCreatedLast7RDayRepoFile

    # #SCRIPT_END

    You can use the New-Timespan cmdlet in the Where clause, it returns the time difference between 2 DateTime objects.

    An example of this cmdley

    New-TimeSpan-start (Get-Date). AddDays(-7)-end (Get-Date). Select days - ExpandProperty

    In your case, you could do

    Where {(New Timespan-démarrer ([DateTime] $_.))} CreatedOn) - end $start7). {7 days - gt}

    But beware of negative numbers.

  • What is the advantage to affect multiple virtual machines in a data store?

    Hello

    Quite a question stupid and basic, but I can't answer . What is the advantage of having multiple virtual machines in a store of VMFS data instead of having each VM in another VMFS data store? (eg. 3 VMs in 1 data store or 3 data warehouses and each virtual machine in one of them). I can only think about the ease of management for storage administrator because it creates only a single large LUN.

    Thank you

    By allowing multiple virtual machines in a data store, you can run more than 256 virtual machines in a DRS cluster.

    As a host has a limit of 256 scsi identification numbers, which means that it accesses no more than 255 LUNS shared. 1 scsi ID is used for local storage.

    In a DRS cluster as each host must be mapped to the same data warehouses to ensure that virtual machines can be moved on the cluster and run on any of the hosts.

    Now in my life as an architect VMware PSO I saw that a lot of virtual machines that require a single data store. The main reason to isolate a virtual machine on a data store must provide sufficient i/o performance. This can be achieved with other solutions than to isolate a virtual machine on a data store. Having a properly architected storage subsystem is crucial, vSphere can get out of a very large number of the IOPS / s. With technologies such as SIOC and DRS for storage, you can check that the virtual machines receive IO performance according to the needs.

  • Is it possible to hide the news of Vmware's Virtual Machine?

    Hello just a small matter of team.

    We have 5 ESX

    Is it possible to hide the news of Vmware's Virtual Machine during the creation of the Virtual Machine (not in registry) that we have a lot of VM?

    Start > run > msinfo32 >

    Thank you

    GoldTipu

    Hello

    It is possible that you could change some things in the registry, but there are many other "clues" as something being a virtual machine, such as the presence of tools VM, MAC address, drivers, etc.

  • Need help updated the VMX file on several Virtual Machine

    All,

    Can anyone help with a problem I'm having?  Here is a brief explanation of what is happening and what we need to solve.

    Recently we found out that we need to add a line in the file VMX of several virtual machines.  In the past, I was able to do this, but would have cold start the virtual machine for the changes to take effect.  Starts cold won't be a problem, because we can program it.

    However, no one knows a way to add this line in the file VMX virtual machines in a cluster.

    Here's the line I need added:

    Devices.hotplug = "false".

    Here is a script that was used earlier (esx 3.0 days) to keep the VM tools updated on reboot.  At this point, if the virtual machine has been turned on, this change could not do through the UI.  However, this script worked to update the .vmx file and then we have cold reboots for the changes to take effect.

    Get-viserver - < Server > - < user > - < password >

    $viview = get-Cluster-name NOMCLUSTER | Get - VM | foreach-object {get-view ($_.ID)}
    $viview | {foreach-object
    $vmConfigSpec = new-Object VMware.Vim.VirtualMachineConfigSpec
    $vmConfigSpec.Tools = new-Object VMware.Vim.ToolsConfigInfo
    $vmConfigSpec.Tools.afterPowerOn = 'True '.
    $vmConfigSpec.Tools.afterResume = 'True '.
    $vmConfigSpec.Tools.beforeGuestStandby = 'True '.
    $vmConfigSpec.Tools.beforeGuestShutdown = 'True '.
    $vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle".
    $_. ReconfigVM ($vmConfigSpec)
    }

    The exact script can be found in Disable HotPlug

  • Deleting the same files of many virtual machines remotely

    Hi all

    I tried to delete the same file several virtual machines remotely using the following script PowerCLI:

    $a = Get - VM | %{

    foreach ($nic as $_.) Guest.Nics) {}
    Write-output $nic. IPAddress
    }
    }
    foreach ($i in $a)
    {$b = get-WmiOBJECT-query "SELECT * from CIM_DataFile where Name='C:\\test\\deleteme.exe'"-computername $i}
    $b.delete)

    }

    It works perfectly when I run the script on the host virtual machines while I am running the script PowerCLI. When I Connect-viserver to another host however and try to run the script, I get the dreaded "RPC server is unavailable error (HRESULT: 0x800706BA)" for Get-WmiObject.  Virtual machines don't have Windows Firewall and have all TCP/IP, RPC and WMI services started, so who could eliminate any possibility.

    I am also able to run other scripts that use the Get-wmiobject across all virtual machines such as scripts to change the DNS or Netbios name across many machines on different hosts.

    Any comments would be greatly appreciated and please feel free to comment if you know maybe other ways which can delete files on multiple virtual machines in any other way.  Installation PowerCLI to run the script locally on each host would be a laborious process to do.

    Thank you very much!

    Best regards

    To solve the problem with the quotes, you can use double quotes inside the string. Like this:

    «del "«c:\documents and settings\text.exe»»»

    Or you can use for the string single quotes and double quotes inside:

    "del"c:\documents and settings\text.exe"

  • After restart ESXI Virtual Machine back to start

    I have an a bit Esxi 4 Virtual Machine but he is the one who each time to restart VmWare machine system begins to start, if I put a file or install software after restart all software and data are cleaned of VmWare and I have to reinstall all, why?

    This Virtual Machine is a migration of a real machine.

    Welcome to the forums

    There is an explanation why this can happen.

    1 VM start after reboot of the host:

    Look under the tab of host - start/stop the Virtual Machine configuration

    See if this virtual machine is enabled to start when the start host

    Disable this if you do not want that it

    2. all changes on VM ignored after reboot

    Right-click the virtual machine and choose change setting

    Take a look at the hard drive options, it can be set to independent - not persistent

    Uncheck independent or select persistent

    Please attribute points by clicking on correct/good

  • Change the operating system selected a virtual machine under tension in vCenter

    Is this possible? I looked in the box change the Settings - Options - but I can't see the usual fall down?

    You should turn off the machine.

    If you have made a mistake by setting for 32-bit or 64 - bit or vice versa, it does not really affect the virtual machine.

    If you have entirely changed the operating system, then you will need to power off and do it right that there is again a critical impact. the operating system you choose decides the type of SCSI controllers and things.

    I suggest you set a stop and do time.

Maybe you are looking for