PortGroup change after a virtual machine cloning

Hello there,

hope someone can help me, find a solution to my problem: I want to change the PortGroup to a virtual computer after cloning a model.

Thanks http://mighty-virtualization.blogspot.com I am able to get all the information I need. But I have no solution to try to change the PortGroup.

My actions for the information:

getPortGroupByNetworkName

var dvGroups = VcPlugin.getAllDistributedVirtualPortgroups ();

i in dvGroups
{
If (dvGroups [i] .name is NetworkName)
{
return dvGroups [i];
}
}

getDistributedVirtualSwitchByPortGroup

VGA var = VcPlugin.getAllDistributedVirtualPortgroups ();
var DVS = new Array();

i in VGA
{
DVS.push (dvPG [i].config.distributedVirtualSwitch);
DVS.sort ();

for (i = 0; i < DVS.length; i ++)
{
If (I! = 0)
{
While (DVS [i] is DVS [i-1])
DVS.splice (i, 1);
}
}
}

(j in DVS)
{
(h in DVS [j] .portgroup)
{
If (.portgroup [j] [h] DVS is PortGroup)
{
return DVS [j];
}
}
}

My task scriptable workflow after completing the dvSwitch and the portGroup by networkname:

var MinLastStatusChange = 2;
var DateNow = new Date();
var TempYear = DateNow.getFullYear ();
var TempMonth = DateNow.getMonth ();
var TempDay is DateNow.getDate () - MinLastStatusChange.;

If (TempDay < = 0)
{
TempDay = TempDay + MinLastStatusChange;
TempMonth = TempMonth - 1;
}
If (TempMonth < = 0)
{
TempMonth = TempMonth + 12;
TempYear = TempYear - 1;
}

var DateTwoDaysAgo = new Date (DateNow.getFullYear (), TempMonth, TempDay, DateNow.getHours (), DateNow.getMinutes (), DateNow.getSeconds ());
var PortSpecs = new VcDistributedVirtualSwitchPortCriteria();
PortSpecs.connected = false;
PortSpecs.portgroupKey = new Array (detectedPortGroup.key);

System.log("------------------------------------------------------------------------------------------------");
System.log ("-today:" + DateNow);
System.log ("-two days ago:" + DateTwoDaysAgo);
System.log("------------------------------------------------------------------------------------------------");
System.log ("detected PortGroup Key:" + detectedPortGroup.key);
System.log ("detected PortGroup Name:" + detectedPortGroup.name);

System.log ("detected dvSwitch Name:" + detectedDvSwitch.name);
System.log ("detected dvSwitch ID:" + detectedDvSwitch.id);
System.log ("detected dvSwitch UUID:" + detectedDvSwitch.uuid);
System.log("------------------------------------------------------------------------------------------------");

Ports of the var = detectedDvSwitch.fetchDVPorts (PortSpecs);
i in Ports
{
If (.lastStatusChange [i] Ports < = DateTwoDaysAgo)
{
var detectedPort = [i] Ports;
break;
}
}
System.log (' key Port detected: "+ detectedPort.key +" IS FREE"');
System.log ("the State of the Port detected:" + detectedPort.state);
System.log ("last Port State change detected:" + detectedPort.lastStatusChange);
System.log("------------------------------------------------------------------------------------------------");

var myVirtualDeviceConfigSpec = new VcVirtualDeviceConfigSpec();
var myVirtualMachineConfigSpec = new VcVirtualMachineConfigSpec();
var myVirtualDeviceArray = new Array();

for (i = 0; i < vm.config.hardware.device.length; i ++)
{
If (System.GetModule("de.) (("WW - Informatik.Functions") .wwiIsNetworkCard (VM.config.hardware.Device [i]) == true)
{
Map var = vm.config.hardware.device [i];

System.log ("NIC(Device"+ i +") found:"+ card ");

System.log ("PRE port:" + networkCard.backing.port);
System.log ("PRE portgroupKey:" + networkCard.backing.port.portgroupKey);
System.log ("PRE Key:"+ networkCard.backing.port.portKey ");
System.log ("PRE dvSwitch UUID:"+ networkCard.backing.port.switchUuid ");
System.log("------------------------------------------------------------------------------------------------");

TempBacking = System.getModule("com.vmware.library.vc.vm.spec.config.device").createVirtualEthernetCardDvNetworkConfigSpec (detectedPortGroup);

myVirtualDeviceConfigSpec = TempBacking;
myVirtualDeviceConfigSpec.device = map;
myVirtualDeviceConfigSpec.device.connectable.connected = true;
myVirtualDeviceConfigSpec.device.connectable.startConnected = true;
myVirtualDeviceConfigSpec.device.backing.port.portKey = detectedPort.key;
myVirtualDeviceConfigSpec.device.backing.port.portgroupKey = detectedPortGroup.key;
myVirtualDeviceConfigSpec.device.backing.port.switchUuid = detectedDvSwitch.uuid;
myVirtualDeviceConfigSpec.operation = VcVirtualDeviceConfigSpecOperation.edit;
myVirtualDeviceArray [0] = myVirtualDeviceConfigSpec;

myVirtualMachineConfigSpec.deviceChange = myVirtualDeviceArray;

task = vm.reconfigVM_Task (myVirtualMachineConfigSpec);

System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd (task, false, 0);
}
}

Maybe I did the steps wrong to change the portgroup but I tried a few things and this is my best solution, but it does not work.

Hope you can help me.

Best regards

Chris

Please try my package here http://communities.vmware.com/message/1731492#1731492 since you are targeting a GROUP of virtual ports distributed

Tags: VMware

Similar Questions

  • Duplicate name after a virtual machine cloning

    We run ESX 3.5. After I cloned a cup of virtual XP Machines, all have the same host name and I get duplicate name message. How to avoid that?

    Bob Lee, MS - MVP, MCSE & CNE

    Networking, Internet, routing, VPN Troubleshooting

    http://www.ChicagoTech.NET

    Sysprep and models should take care of this.

    http://www.VMware.com/PDF/vc_2_templates_usage_best_practices_wp.PDF

  • When a snapshot is complete, so I can start to make changes to the virtual machine?

    When I take a snapshot in merge, a progress bar appears in the window of virtual computer, then disappears in a few seconds.

    But a picture of a clock also appears on the Fusion icon in the dock. Only the clock takes a minute or two to disappear.

    What process is the clock?  What is the take a complete snapshot?  When the progress bar disappears, or when the clock disappears?

    Can I safely begin to make changes to the virtual machine, I want to be able to restore, immediately after the progress bar disappears?

    Or, it is more prudent to wait to make changes until the clock disappears?

    Thank you

    (The progress bar and the clock appear in my Fusion 3 that I use always happy... I don't know what appears in more recent versions).

    While the stopwatch turns, Fusion is busy writing the snapshot to disk, so the performance of your comments and your host could be reduced.

    As long as the performance isn't an obstacle, you can continue to use the virtual machine while the snapshot is taken.  Merger will ensure that the snapshot includes the exact state of the virtual machine at the moment, you started the snapshot: nothing of what you are doing inside the guest, while the snapshot is in progress does not affect the State of the socket.

    See you soon,.

    --

    Darius

  • What is the difference between a virtual machine cloning and v2v conversion to a virtual machine

    What is the difference between a virtual machine cloning and v2v conversion to a virtual machine

    Cloning process is to duplicate a VM. V2V is deploy vm on vsphere environment to another virtual machine format (example: the workstation, hyper-v).

  • Replicate changes to a virtual machine

    Someone saw procedures for creating a base Image Windows Server VM, then have this statue of gold changes replicated to the virtual machines in the cluster. I know that Update Manager can do for security patches. No mechanism to update the configuration, the dll and other files? Thanks,-Jeff

    I don't know of a method. This ability would be more specific to a product like VMware View and related cloning technology. Currently, I think your options are VUM, WSUS, or another technology that updates your guests individually.

    Mike

  • Windows XP does not correctly load after installing Virtual Machine

    Original title: System Restore

    I recently tried to install a Machine Microsoft VM on myWindows XPcomputer. By getting a message "Please reboot", I clicked on "restart now." The computer turned off and running back. When he steps back, the loading screen appears, and then the blueHP Inventscreen appeared (which is normal). But then something odd happened. A small window appears in the left corner of the screen. It read: "loading your personal settings: System Restore, Control Panel, etc...", or something of the sort. The default software supplied with the computer window appeared. The blue HP Invent screen continued to remain in the shadows.

    When I eventually clicked the 'x' in the antivirus window, the taskbar, start button, etc. appeared, but most of my desktop icons were missing. Then I noticed that the blue screen of theHP Ivent became my wallpaper. Puzzled, I navigated to the 'System Restore' window. Then, several windows titled 'Welcome in Windows XP' and "Turn Windows XP" appeared. I have navigated to System Restore window and chose a system restore point (which was the day before) and continued the process of system restore. The system was supposed to be restored. At startup, the same window in the left corner appeared; the antivirus window is appeared. The system restore window is appeared then, confirming that the system restore was successful (which it wasn't). Everything was the same way before I had done the system restore.

    In a panic, I went to Internet Explorer. The browser then showed up and greeted me with messages as if I had never used, and [if not all] most of my favorites had been withdrawn. Then, I assumed that my computer has been restored to factory settings. But of course, in opposition to my thesis, my Antivirus AVG software  that I had installed before all these problems occurred, was still on my computer. My iTunes was also still on my computer, but my entire library has been destroyed, and when I double click the icon, it asked me to install the iTunes software (as if I had just downloaded on my computer).

    I procceeded to try to restore my computer to different restore points, but all attempts were in vain, because no settings have been changed... And that's my story. Also, I would appreciate some answers detailed as soon as possible, because this computer is not me anyway... Thanks for reading guys!

    I recently tried to install a Machine Microsoft VM on myWindows XPcomputer. By getting a message "Please reboot", I clicked on "restart now." .....

    the small window that you mentioned is probably the virtual machine window.  and if you it configured during installation, as attributed too much ram memory and disk space, and then the windows in normal mode went out of these valuable resources.

    In addition, if the system disks and files was not optimal performance via tune ups, then they could have been less than optimal before installing the vpc and the systems simply becoming worse by installing more data.

    regarding the failed system restore points, we don't know why they did not work.  but the system restore function is stable, except somethings interferes with her bad anti anti-virus programs or system files have been corrupted with infections beyond you're a.v design..  the bottom line is that "who knows?"

    You can probably try is to start in safe mode and try to uninstall virtual pc via Add/Remove programs in the control panel.

    then see if the normal mode is normal once again.

    Another method, you can try again in safe mode is the restoration of the system again.

    then see if the normal mode is normal once again.

    Another method, you can try in safe mode, you can try to perform a clean boot to normal mode.

    DB·´¯'·.. ¸ >-))) º > ·´¯'·.. ¸ >-))) º > share nirvana mann

  • After Reboot virtual machine - VM not no projection in host, orphaned in vCenter

    Hi all

    I had a server 2 k 8 running as an IIS server.  While using it last night, he hung up on me and I couldn't restart it.  I went in vCenter and restarted from there and the VM looks ok to stop, but he would not return to the top.  I tried to start but got an error.  Then in the host ESX and virtual machine was no longer available at the level of the host and on the vCenter, it showed also orphaned.

    I did a reading online and follow a guide who was told to remove the orphaned VM and add the VMDK as a new virtual machine.  After these steps, my VM boots now beyond the BIOS screen, and starts to load windows then get a quick second BSOD split, then the VM restarts and gives me the possibility of:

    -Start windows normally

    -Windows startup recovery

    If I boot normally, it makes a loop in the same cycle, if I do a start of the recovery, it gives me the normal windows recovery tools.  In the diskpart tool, I see the end as well as the disk partitions.

    Can someone the tsar me in the right direction? My guess is that something in the files of the virtual computer is corrupted, causing windows back his process of starting because of a hardware problem... ?

    I have attached a few newspapers too.  Thanks for the tips!

    If this is the only virtual machine affected, then this is probably the OS corruption. You can deploy a new virtual machine and migrate data on existing records to the new (just to mount the VMDK on the new virtual machine) or go to the effort of the diagnosis and repair of the system.

    If you are going to do the later, then start by identifying the BSOD error - is is a mistake of 7B? (please post a screenshot). You can start in safe mode? If you can, it would be from a local value of core dumps are configured so that you can run the. DMP file via WinDbg to debug the stop error... This will give you information about this driver etc. is causing the crash dump.

    See you soon,.

    Jon

  • excluding the hard drives in a virtual machine cloning

    Hello

    I want to clone a virtual machine that has multiple drives. The c: drive has OS (W2008R2) and is small enough, D:, E:, and F: are large (terabytes), and contain data. I need only the C: drive in the clone. Is it possible to exclude other readers during the cloning process? I clicked through the wizard, but it does not give me an option.

    Thank you

    Matthias

    I would use the VMware Converter Standalone where you have a choice of which drives to clone.  http://VMware.com/go/converter

  • Windows 2 k 3 lack of SCSI controller after running virtual machine converter

    Hello

    After you convert a Windows 2 k 3 server making the VM P2V is now lack a SCSI controller for the virtual machine cannot start.

    What is the best way to solve this problem? I need to copy the drivers from the physical server?

    Thanks in advance,

    PM

    If the disk controller type see you in the settings of the virtual machine is IDE, check out http://kb.vmware.com/kb/1016192.

    Another option is to choose the type of controller in the converter, when it comes to hardware.

    André

  • portgroup match VLANS to virtual machines

    Hello

    I was wondering if there is a tool that can automate this function?

    I mean right now, I'm using EcoShell but with that you can only list all the exchanges and then you can query each portgroup for VMs on the inside, but either you must do it one by one and name each report separately, or you can select several a few exchanges / VLAN and ask all the virtual machines. But second way does not show you where VLAN does VM sit.

    Do you already have something that might help with this kind of report?

    Thank you in advance.

    The following script gives a correspondence between virtual machines and exchanges:

    Get-VM | ForEach-Object {
      $VM= $_
      $VM | Get-VirtualPortGroup | `
        Select-Object @{N="VM";E={$VM.Name}},@{N="PortGroup";E={$_.Name}}
    }
    

    Best regards, Robert

  • After the Virtual Machine is hot migrated lose the reference to the virtual computer object (VMware.Vim.VirtualMachine)

    Hello

    In my VB.Net application, I retrieve the virtual computer object (VMware.Vim.VirtualMachine) through scripting Powershell VI.

    If the Virtual Machine is migrated to another host (hotmigrate) I receive an event (VMware.Vim.VmMigratedEvent), which also holds the moref of the Virtual Machine. I tried to use the updateview method to refresh the virtual computer object but failed with an error message stating that the object could not be found, or never existed.

    I also tried to recover the virtual computer object again, throug the method Client.GetView and the moref returned by the event, but the same error message.

    How can I get my hands on the virtual computer object or update after migration to another host takes place. I have to get it back again? It would be great if I could do it somhow with information from moref I hold the event!

    Any help is appreciated!

    Concerning

    Manfred

    Sorry, but I can only show you how to do this in PowerShell.

    I use the purpose of the task to get to the prompt MoRef.

    Here's how:

    $vmName = 
    $tgtHost = 
    $tgtPool = 
    
    $vm = Get-VM $vmName | Get-View
    $poolMoRef = (Get-ResourcePool $tgtPool | Get-View).MoRef
    $esxMoRef = (Get-VMHost $tgtHost | Get-View).MoRef
    
    $task= Get-View ($vm.MigrateVM_Task($poolMoRef, $esxMoRef, "lowPriority", "poweredOn"))
    
    while($task.Info.State -eq "running" -or $task.Info.State -eq "queuing"){
      $task.UpdateViewData()
    }
    
    $vmImpl = Get-VIObjectByVIView -MORef $task.Info.Entity
    

    I don't know how you get at the VmMigratedEvent event, but the MoRef in there is pointing to the correct prompt.

    In the following script, I extracted all the events related to the task of vMigrate immediately after the vMigrate task finished

    function Print-VmName{
         param($event)
    
         $MoRef = New-Object VMware.Vim.ManagedObjectReference
         $MoRef.Type = $event.vm.vm.type
         $MoRef.Value = $event.vm.vm.Value
         $vm = Get-View $MoRef
         Write-Host $vm.Name
    }
    
    $events = Get-VIEvent -Start (Get-Date).addminutes(-15)
    $events | % {
         $event = $_
         $eventType = $_.GetType().Name
         switch ($eventType){
              "VmMigratedEvent" {
                   $eventType
                   Print-VmName $event
              }
              "VmEmigratingEvent"{
                   $eventType
                   Print-VmName $event
              }
              "VmBeingHotMigratedEvent" {
                   $eventType
                   Print-VmName $event
              }
              "TaskEvent" {
                   $eventType
                   Print-VmName $event
              }
         }
    }
    
  • Have problems connecting to the Internet after the virtual machine has crashed.

    Original title: problems sudden ethernet

    Hello

    I'm having a problem with connecting my computer custom-made. I was with my virtual machine to run an android phone. It connected via a second wireless connection (I don't know much I just let it work). It crashed my computer and when I rebooted I had no internet.

    It would also be useful to mention that I recently had a BSOD because of the virtual Manager and a driver, but I solved it.

    He said that no connection is available, and there is a red cross.

    So far I have tried:

    A second ethernet cable - nothing. (The two wires green on the end of the PC and the end of the router).

    Updated windows, but he can't because of the lack of connection.

    System Restore, but it says "Windows has detected corruption of system files on Local disk (C .)» You should check the drive for errors before you can restore it.

    sfc/scannow, but which translates "could not Windows Resource Protection start the repair service".

    I have also reinstalled the drivers for my cable ethernet twice and nothing.

    If more information is needed please ask. Thanks in advance.

    Hello

    In Device Manager, expand network adapters, right click on the Ethernet device and update the driver.  Otherwise, identify the manufacturer, go to their website and download the latest driver.

  • Persistent routes no longer work after the virtual machine restarts

    Hello community.

    I was hoping that someone can shine a light on a problem I have experienced. I have a virtual machine that multiple network cards. Some are exposed to the Internet, some are just private and some are B2B connections. Now, I put the roads for a particular to Adapater it limits by using this command: route add 13.x.x.x mask 255.255.255.255 if0x10005-p 10.x.x.x. I could pinch the IP address once I put it but once I restart the virtual machine of the road is still there, but I can no longer to pinch the INVESTIGATION period. This happens in several environments I.

    I am running windows 2003 which has been recently patched with the latest

    I'm running the latest ESX3 and VC 2.5

    Any help would be great.

    FYI - Pinch is another form of Ping.

    Set the gateway on the roads. Both that the getway is only not shared by any other way on the same system your traffic should go out any interface is associated with the network which is located in the gateway. in this way, you don't have to worry about the interface.

  • PowerShell Script SCVMM to controller of VM virtual machine cloning

    Dear experts,

    I'm looking to automate creating a VM (VM cloning), but also looking to explicitly select the VLAN ID and push specific IP,.

    Thanks in advance for your help/input

    Thnaks

    Mohammad Al-Masri

    This issue is beyond the scope of this site (for consumers) and to be sure, you get the best (and fastest) reply, we have to ask either on Technet (for IT Pro) or MSDN (for developers)
    *
  • cloning of an existing virtual machine

    Hello

    I would like to clone an existing virtual machine. Is this possible with VMware Server 2.0. I want to avoid the hollow will creat a whole new machine virtual process since what I need is already here with the exception of a patch to the version of the JVM.

    Hi, yes you can do it.

    Close the vm to be cloned (cleanly).

    Copy all the files that make up the virtual machine to a new directory in the same or a new data store.

    the web UI, click the host, then select 'Add the virtual machine to inventory' Browse warehouses of data in your vm copied, then select it.

    Start the new virtual machine, when prompted answer that the virtual machine has been copied.

    make changes to the virtual machine (sysprep if you can) change the name of the computer, static ip, license etc. According to os

    Start the original virtual machine

    This should be it.

    Good luck

Maybe you are looking for