Remove a NIC vCloud several virtual machines

Hello

I am a vCO and extremely raw newbie with JavaScript (a great combination).  My production environment consist of vCenter 5.0, 5.1 and 5.1 vCO vCD. I have the plugin installed vCD and running with Orchestrator.  I am trying to build a workflow that removes NIC1 (NIC 1) of a series of vCloud VMs.  I took a copy of the vCloud Director Library Workflow (remove a NETWORK adapter) and edited the virtual machines of an input parameter to be an array / vCloud:VM.  I modified the taks script so that it loops through the virtual machines in the array and returns their network adapters.  It seems that the network cards are returned as a UID (I have this return to the screen via a System.Log).  This UID is obviously not with that I entered to the workflow runtime - I said "NIC 1" and my workflow will fail with an error "no primary network connection exists; majorErrorCode = 400; minorErrorCode = BAD_REQUEST; vendorSpecificErrorCode = null; (Workflow: remove a NIC 1 / remove the NIC (item0) #22) " Here is the code I use: .

If (vm. Status! = VclVMStatus.POWERED_OFF.value) {}
throw "VM is not off."
}
var found = false;
var len = vms.length;
for (var i = 0; i < len; i ++)
{
var VM = vms [i];
network var cards = VM.getNetworkCards ();
System.log (NICS);
var newNics = new Array();
for (i = 0; i < nics.length; i ++) {}
If (. itemResource.elementName.value NIC [i]! = nicName) {}
newNics.push (nics [i]);
} else {}
found = true;
}
}
If (! found) {}
throw 'Invalid NIC name';
}
task = VM.updateNetworkCards (newNics);
}

As I mentioned earlier, I am a complete newb to vCO\JavaScript and would be really grateful for some input\advice.  If there is a better method to remove the NIC 1 to a litany of vCloud VMs, or if someone has already developed a workflow for this, I would be very grateful for your help.

Thank you


Try this:

var section = vm.getNetworkConnectionSection();
System.log("Primary card was NIC : " + section.primaryNetworkConnectionIndex);
section.primaryNetworkConnectionIndex = 1;
task = vm.updateSection(section);

He's worked here.

Tags: VMware

Similar Questions

  • Remove the NIC of the virtual machine running?

    Im trying to remove one NIC from a script and the machine has to be on. I am trying:

    Get-NetworkAdapter $vmname | where {$_.NetworkName - eq "Network 10"} | Remove-NIC

    Remove-NetworkAdapter: 2011-09-28 15:59:24 the VM Remove-network card must be in the following State: PoweredOff.
    At line: 1 char: 101
    + Get NetworkAdapter W7-AutoPrv003 | where {$_.NetworkName - eq "Network 10"} | Remove-NIC < < < <
    + CategoryInfo: InvalidOperation: (PoweredOn:PowerState) [Remove-NetworkAdapter], ViError
    + FullyQualifiedErrorId: Common_SharedParameterHelper_VerifyVmIsInState_VmNotInState, VMware.VimAutomation.ViCore.Cmdlets.Commands.RemoveNetworkAdapter

    Would I really thing that there is a way to remove the NETWORK card when the virtual machine is turned on?

    There with the ReconfigVM_Task method.

    $vm = Get-VM MyVM $nic = $vm.ExtensionData.Config.Hardware.Device | where {$_.DeviceInfo.Label -eq "Network adapter 2"}
    
    $spec = New-Object VMware.Vim.VirtualMachineConfigSpec $dev = New-Object VMware.Vim.VirtualDeviceConfigSpec $dev.operation = "remove" $dev.Device = $nic
    $spec.DeviceChange += $dev
    
     $vm.ExtensionData.ReconfigVM($spec)
    

    Don't know what the risk is, however.

  • rename several virtual machines based on the State of food &amp; VM name

    I'm looking for a powershell script to rename the virtual machine based on the state name and vm power.  For example, I have several virtual machines with a - temp at the end of the name of the server.  Some are turned on and some are turned off.  I am wanting to rename only those who is off

    Thank you

    tjw82

    Assuming that - temp is part of the name

    Get - vm | where {$_.powerstate - eq "poweredoff"} | foreach {Set-machine virtual - VM $_ - name (($_.name).)} Replace ("temp", "delete"))}

  • Several virtual machines attached to port VM group

    Hi all

    So I did research on the internet and on this forum and I have not found a good answer to my question. So I would check that I can create a unique Virtual Machine port group and attach multiple virtual machines and run them simultaneously. I basically want to have each VM attached to this switch, but instead to a separate port group, it seems that I can just attach to the same port group that puts on the vSwitch.

    Is there problems of L2 with MAC address or ARPing or something like that? I realize that I have to ensure that each VM has correctly configured the IP settings. I know there are problems, but I am wanting clarification of the people who have done this before. Are there problems of interface as with a real switch speed or who is not serious in a vSwitch?

    Thank you!

    -GNS

    You can attach multiple virtual machines to the same group of port without problems, this is how normally environment are created. Have a look here for more details: vSphere Standard switches

    The image below shows several virtual machines connected to the same port group:

  • Workstation - Bat file to run several Virtual Machines

    I am currently using the following .bat file to launch several virtual machines:

    Start "" /b "C:\Users\Abe\Desktop\Virtual machine 1.lnk".

    Start "" /b "C:\Users\Abe\Desktop\Virtual machine 2.lnk".

    My problem is that start each machine's own instance of VMware.  Is it possible to build a script (.bat or other) who will start the virtual machines in a single instance of VMware Workstation.

    Regards and thanks in advance

    k

    You can create a file of commands like this:

    vmrun start "C:\VM\VM1.vmx".

    vmrun start "C:\VM\VM21.vmx".

    This would open up two virtual machines in the same GUI - at least that's the way it works on my Windows 7 host with 9 Workstation.

  • removal of large size of virtual machine snapshot, esxi 4.0.0 (208167)

    Dear Experts,

    I am looking for assistance before you do this step, remove the snapshot of a virtual machine (NNMi-Test), 100 GB thick disk has been assigned to this virtual machine when it is created. After the installation of the operating system, we took a snapshot. Explained user had to test something on this one and we wanted as if during the tests of some problem occur due to the facilities at least that we can return to the fresh install of OS snapshot.

    After that we missed by mistake that we had seen on this machine. Now I want to delete this single snapshot, but its size is now KB 26,182,660. The current state of the machine, we want to keep, it's OK with us.

    I can proceed without fear of deleting, I should say 'remove all' OR 'delete '. Image is attached here with. This machine is the "EVAstorage2" data store and 193 GB is free on this subject.

    There is another virtual host below computers run on it, I also need help with clichés:

    -machine virtual (NNMi) , assigned to 150 GB thick disk, also have same instant problem has been created and it is now 7.7 GB,.

    This machine is on "EVAstorage1" and is 221GB free space

    -virtual machine (Bukhari), assigned thick 150 GB, also named snapshot after operating system installation and size soft

    this wink, shot is now showing only 128GB

    I have attached the images of the three machines I need assistance for: NNMi-Test, NNMi Bukhari

    Please note that the Esxi is 4.0.0 (208167)

    Please help me and require further details before giving an answer to me, please ask me. Also, keep in mind there are also other virtual machines on the same 'EVAstorage1' and 'EVAstorage2' data with disk available warehouses thin and little with thick disk.

    Kind regards

    Jocelyn

    The GUI seems to check the hard of the last snapshot file in the chain to see if it contains an entry "ddb.thinProvisioned". Because this entry is present in the hard disk basic GUI file guess a thick disc put into service.

    I suggest that you remove the snasphot of a single virtual machine at the same time and that after opening hours. Please make sure that there are no application backup or other task that would try to create a snapshot of this machine that performs the erase process.

    I wouldn't worry too much about the size of the snapshot or any performance impact, just be patient and wait as the deletion process at the end (which could take a while).

    The maximum required temporarily on the disk with a single snapshot is about the size of the snapshot itself more space for a snapshot of assistance, which contains changes to the virtual machine, while the removal is underway.

    André

  • Create several virtual machines from a

    Is it possible to create multiple virtual machines a build? I have a 2008 R2 vm. instead of having to rebuild the whole system from scratch is there a way to make a template or something to create several virtual machines a build? I am using vcenter 5 and I have 2 servers esxi 5.

    You can create a template by right-clicking the virtual machine and choose Clone to the model and give the datstore where you want to save after that you will have a model using this model to deploy the virtual machine using Customization Wizard.

  • 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

  • Create several virtual machines from the same base image

    Hi all

    Is there any vi api sdk by which I can create several virtual machines form same base vmdk file?

    All create the VM from the base VMDK file will have their own delta vmdk file that will refer to the same base VMDK file. Only changes that are performed on each virtual machine are saved on their respective delta vmdk files.

    Thanks in advance...

    Hello

    What you are referring is called Clones related, in the current VI API, there is no method that supports this feature. You can take a look at CloneVM_Task() http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.VirtualMachine.html#clone if you want to implement a full clone and this will require you to have access to vCenter.

    In the next version of vSphere, vSphere SDK THAT will provide a way to implement the related Clones and it will be a parameter you can specify CloneVM_Task() , more precisely in the VirtualMachineRelocateSpec where you will specify diskMoveType to createNewChildDiskBacking

    You can find more information once vSphere of GA and the new QAnywhere VI documents are released, but if you are looking to implement related Clones today, you can take a look at the product of VMware View 3, which provides support for linked Clones or you can take a look at two scripts that I wrote which creates linked Clones similar to that of the view :

    Clones related to ESX

    CLones related to ESXi

    =========================================================================

    William Lam

    VMware vExpert 2009

    Scripts for VMware ESX/ESXi and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

    repository scripts vGhetto

    http://Twitter.com/lamw

    If you find this information useful, please give points to "correct" or "useful".

  • Question about the volume on several virtual machines sharing

    Hey!

    Try to use vmkfstools on Vi remote CLI, but he says that he is not recognized as an internal or external command... Is there an easy way to share data between several virtual machines? If so, how? Also if we are implementing raid 5 are we building our vitrual (windows 2008 Server) with the typical c: or d: drives? That is to say. You put the Windows Server 2008 on a separate virtual C: drive and data on a disk separate from virtual D:? Or is it no more? What about the Windows swap files? Must create us virtual drives, JUST for page files? Sorry I know this is a lot, but any help would be greatly appreciated!

    Thank you!

    1. is there an easy way to share data between several

    virtual machines? If so, how? A CIFSor NFS share would be preferable. Since I got you guess the VMS are mainly Windows you want to go with a CIFS share. You can run a virtual NAS appliance  (http://www.openfiler.com/community/download/)

    Also if we are implementing raid 5 are we building

    our vitrual Server (windows server 2008) with the typical c: or d: drives?

    That is to say. You put the Windows Server 2008 on a separate virtual C: drive

    and the data on a virtual disk from D:? Or does not everything

    more? Yes design you virtual as your physical systems i.e. separate Boot/system information application. just build you VMs how you would with physical systems (especially true of SQL or Exchange).

    What about the Windows swap files? We create virtual drives

    Yet, ONLY for page files? Never did it for physical so no systems

  • Removal of the network of virtual machines powered cards

    I wanted to remove the network adapters on multiple virtual machines, so I thought that he would do a simple script:

    Get-NetworkAdapter -vm test* | ?{$_.NetworkName -like "dummy"} |Remove-NetworkAdapter
    

    But this results only by mistake because the virtual machine is running:

    Remove-NetworkAdapter: 2013-08-13 15:58:48 NetworkAdapter Remove the

    Virtual MACHINE must be in the following State: PoweredOff.

    Is it possible to get around this problem?

    Given that this is possible through the vSphere Client he gave me the chance to try Onyx. Here is the result of the Onyx:

    $spec = New-Object VMware.Vim.VirtualMachineConfigSpec
    $spec.changeVersion = "2013-08-14T07:04:15.86208Z"
    $spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[] (1)
    $spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec
    $spec.deviceChange[0].operation = "remove"
    $spec.deviceChange[0].device = New-Object VMware.Vim.VirtualVmxnet3
    $spec.deviceChange[0].device.key = 4000
    $spec.deviceChange[0].device.deviceInfo = New-Object VMware.Vim.Description
    $spec.deviceChange[0].device.deviceInfo.label = "Network adapter 1"
    $spec.deviceChange[0].device.deviceInfo.summary = "dummy"
    $spec.deviceChange[0].device.backing = New-Object VMware.Vim.VirtualEthernetCardNetworkBackingInfo
    $spec.deviceChange[0].device.backing.deviceName = "dummy"
    $spec.deviceChange[0].device.backing.useAutoDetect = $false
    $spec.deviceChange[0].device.backing.inPassthroughMode = $false
    $spec.deviceChange[0].device.connectable = New-Object VMware.Vim.VirtualDeviceConnectInfo
    $spec.deviceChange[0].device.connectable.startConnected = $true
    $spec.deviceChange[0].device.connectable.allowGuestControl = $false
    $spec.deviceChange[0].device.connectable.connected = $true
    $spec.deviceChange[0].device.connectable.status = "ok"
    $spec.deviceChange[0].device.controllerKey = 100
    $spec.deviceChange[0].device.unitNumber = 7
    $spec.deviceChange[0].device.addressType = "assigned"
    $spec.deviceChange[0].device.macAddress = "00:50:56:8f:74:52"
    $spec.deviceChange[0].device.wakeOnLanEnabled = $false
    
    $_this = Get-View -Id 'VirtualMachine-vm-646'
    $_this.ReconfigVM_Task($spec)
    

    After the stripping it down a bit I ended up with:

    $spec = New-Object VMware.Vim.VirtualMachineConfigSpec
    $spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[] (1)
    $spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec
    $spec.deviceChange[0].operation = "remove"
    $spec.deviceChange[0].device = New-Object VMware.Vim.VirtualVmxnet3
    $spec.deviceChange[0].device.key = 4000
    $spec.deviceChange[0].device.deviceInfo = New-Object VMware.Vim.Description
    $spec.deviceChange[0].device.deviceInfo.label = "Network adapter 1"
    $spec.deviceChange[0].device.deviceInfo.summary = "dummy"
    
    $_this = Get-View -Id 'VirtualMachine-vm-646'
    $_this.ReconfigVM_Task($spec)
    

    Run this doesn't give any errors, but are still all NICs.

    Is there a way to easy or better for this script?

    You must create an entry in the DeviceChange property by the device you wish to reconfigure.

    Try something like this

    $VMs = Get-VM test*
    
    $NICs = 1..6 | %{"Network Adapter $_"}$i = 0
    
    foreach($VM in $VMs){  $spec = New-Object VMware.Vim.VirtualMachineConfigSpec  $Adapters = Get-NetworkAdapter -VM $VM|?{$_.NetworkName -like "dummy"}  foreach($Adapter in $Adapters){    if($NICs -contains $Adapter){      $devSpec = New-Object VMware.Vim.VirtualDeviceConfigSpec      $devSpec.operation = "remove"      $devSpec.device += $Adapter.ExtensionData      $spec.deviceChange += $devSpec    }  }  $VM.ExtensionData.ReconfigVM_Task($spec)}
    
  • Is it possible under the EULA to have several virtual machines on a single physical hard disk while using the same OS license or do I need a separate license for each virtual computer?

    I have several programs that are not compatible with my 64 bit Windows 7 operating system.  I would like to run each different software under another virtual machine of VMWare (5 packs of different software programs and 5 different virtual machines of Windows XP).  These would all be installed on your laptop.  I can use the same license of Windows XP for each virtual machine, or do I need a separate XP license for each (different XP in case 5 licenses)?

    It is lifted directly from my EULA:

    1. GRANT OF LICENSE.
    The manufacturer that you grant the following rights, provided that
    comply you with all terms and conditions of this EULA:
    1.1 installation and use.  You may install, use, access,
    display and run one copy of the SOFTWARE on
    THE COMPUTER.  The SOFTWARE may not be used
    by more than two 2-processor both on the
    COMPUTER, unless a greater number is
    indicated on the certificate of authenticity.
    Then...
    This means that as long as you are running two or more instances of XP at the same TIME, you agree? Or does this mean that, after you install once, you have reached your limit?
    I imagine that most people (including those who are running Microsoft!) will say that the second interpretation is correct.
    However...
    If this is the case, anyone their hard drive as a backup to clone strategy would violate the EULA!
  • Sharing the drive between several virtual machines

    Hi all

    We have a configuration with a SAN (Dell Compellent) and use vSphere 6 to host a number of Windows servers. We now have a giant machine of Windows with a large number of small files for a particular application.

    Now, we would like to create a cluster with a LoadBalancer in front of him, so that we can handle more load. To do this, we want to create a disk that is shared between 2 (or more) of windows machines.

    One of the problems is that NTFS is not a supported clustered file system. So, I did a lot of research on Google to see what my options are. In my opinion, they are the following:

    1. set up a Cluster Shared Volume (CSV) Microsoft (use SMB if I read the documentation)

    2. the user Windows shares on a separate file server

    3. the user NFS (depreacted under Windows)

    4. switch to Linux and use NFS

    The problem I have, is that they use all the network traffic. For example, option 2 is ridiculous slow. NFS under Linux is also a way slower than the local drive (managed by VMWare iSCSI) disk access and NFS on windows does not appear to be

    support very well.

    I know that there are aware filesystems, clustered as VMFS etc. Is there a way to access it directly from my Windows VM or are there devices SAN which is directly accessible from the virtual Windows machine?

    Or maybe there are other solutions to set up a shared drive?

    I know that there are aware filesystems, clustered as VMFS etc. Is there a way to access it directly from my Windows VM or are there devices SAN which is directly accessible from the virtual Windows machine?

    VMFS is a really clustered file system and allow access of multiple virtual machine the same amount of storage (data store) which is different from that to create a virtual disk (hard) and present to multiple virtual machines. You can do this, BUT the guest virtual machine should take care of several accesses to the hard, for Windows, you must turn on the feature... without this clustering with failover data may be corrupted.

    I think the best and supported solution for you is to create another cluster with Failover Cluster functionality and create a resource sharing files with files that will access your NLB nodes.

  • Remove the advanced option of virtual machine error

    Dear community of Vmware,

    I'm new to Powercli and I should delete an advanced setting to a virtual machine, that's what I tried:

    PowerCLI C:\Program Files (x 86) \VMware\Infrastructure\vSphere PowerCLI > Get-AdvancedSetting-entity (Get-VM-jar of name) - Name ' ethernet1.featur' | Delete-AdvancedSetting

    And that's what I get:

    Delete-AdvancedSetting: 29.10.2014 13:45:59 remove AdvancedSetting Vmachine irtual advanced settings can be removed.

    + Get-AdvancedSetting - entity (Get-VM-jar of name) - name ' ether net1.features' | Delete-AdvancedSetting < < < < + CategoryInfo: InvalidArgument: (ethernet1.features:5:AdvancedSettingImpl) [Remove-AdvancedSetting], ViError

    + FullyQualifiedErrorId: Client20_SystemManagementServiceImpl_RemoveAdvancedSetting_VMSettingsNotSupported, VMware.VimAutomation.ViCore.Cmdlets.CommANDS. RemoveAdvancedSetting

    I'm doing something wrong here? Is it a question of privilege?

    All the best

    Patrik

    And the last 5.8 PowerCLI R1 I guess?

  • Configure 2 NICs for a virtual machine

    Hello

    How can I connect two physical network interface cards in a virtual machine?

    Each NIC is configured on a separate network - but on the same machine.

    is it possible...

    Thank you

    Hello

    Just create 2 vSwitches on the host, allocate the host's physical network cards to the separate vSwitches, then create the Group of ports by vSwitch, in the comments adds another nic and assign it to the Group of ports that you need.

Maybe you are looking for

  • KB2656351 and KB2487367

    I get one to not update KB2656351 and KB2487367 with 0Ko again and again every time I'm staying on.

  • How to send a video?

    Need help to send videos to YouTube I videos I would like to send, but I am unable to do so what program I need to do. I can only email videos from the Flip program I have. Not thoseI downloaded from another digital camera.

  • problem running the usb modem

    IM under win 7 ultimate on my laptop. with each resetting of my knees, once shows error SiS 7001 PCI to USB Open Host Controllerdeactivation of my usb modem and once without error... I tried the troubleshooter but with no. use... and I tried to updat

  • Screen disappears and returns to desktop screen

    Can someone tell me why, in Windows 7, when typing or not typing, the screen automatically disappears from the task at hand and it is up on screen 'House '? What happens to me constantly on top of my laptop and office and it becomes really aggravatin

  • The Z10 blackBerry restart

    My z10 blackberry keeps restarting without getting a reboot. What can I do to remedy this