Help! Why my script crash my server from vSphere?

I must be doins something wrong. I don't know what. I'm very new to the API and I'm piecing a script to create virtual machines together. I can't use the standard one because I have different requirements (SAN clusters and distributed vswitches). In addition, scripting is fun

So, this is the first attempt to create a new customer. Every time that I run vSphere server crashes completely. My vSphere Server is version 5.0.0.29542.

Any thoughts on why it crashed? The script is attached.

Thank you

Scott

#! / usr/bin/perl
use strict;
use VMware::VIRuntime;
use VMware::VILib;
Use Data::Dumper;
# Se connect to vSphere and collect information
OPTS::parse();
OPTS::Validate();
Util::Connect();
My $dscluster = Vim::find_entity_view (view_type = > 'StoragePod', filter = > {"name" = > "MySAN"}, properties = > ['name']);
If (! defined ($dscluster)) {}
Print "unable to locate the data cluster store: $dscluster! \n » ;
Util::Disconnect();
Exit 1;
}
My $folder = Vim::find_entity_view (view_type = > 'Folder', filter = > {"name" = > "RandomFolder"}, properties = > ['name']);
If (! defined ($folder)) {}
Print "cannot find the folder to use.
!\n";
Util::Disconnect();
Exit 1;
}
# Define the new virtual machine
My @vm_devices;
My $configSpec = VirtualMachineConfigSpec-> new)
name = > 'test-vm. "
memoryMB = > 2048,
numCPUs = > 2,
deviceChange = > \@vm_devices);
# We only a pool of resources. Use this one for the storageplacementspec
My $resourcePools = Vim::find_entity_views (view_type = > "ResourcePool");
# Create a placement of storage to the host switch to recommenddatastores
My $storageMgr = Vim::get_view (mo_ref = > Vim::get_service_content()-> storageResourceManager);
My $podSpec = StorageDrsPodSelectionSpec-> new (storagePod = > $dscluster);
My $storageSpec = StoragePlacementSpec-> new (type = > 'create',)
podSelectionSpec = > $podSpec,
file = > $folder,
Context = > $configSpec,
resourcePool = > $resourcePools-> [0]
);
# Understand what data store to put the comments. Choose the virtual machine that will have the
# more free space at the end
my $result = $storageMgr-> RecommendDatastores (storageSpec = > $storageSpec);
My $curRec;
My $curRecFree = 100;
my $rec foreach (@{$result-> recommendations}) {}
If ($rec-> action-> [0]-> spaceUtilAfter < $curRecFree) {}
$curRecFree = $rec-> action-> [0]-> spaceUtilAfter;
$curRec = $rec-> key;
}
}
# Create the virtual computer
$storageMgr-> ApplyStorageDrsRecommendation_Task (key = > [$curRec]);

OK, so I have a script that works now...

First comment...

The case with regular support went nowhere. Because it had to do with the SDK, he falls into a grey area where all they can do is get the engineers to examine why it crashes. There is another group, support SDK which specializes in project SDK. It is not included with the normal support and must be purchased separately. However, it is IMPOSSIBLE to get your hands on the SDK support team. My sales representative was completely less than helpful. And support could not find a way to find or the other. Their web form is left unanswered, so I won't even worry about posting the link here. The support people went above and beyond to try to find them (Richard and his Director Jean-Paul... Thanks for trying, guys!) but couldn't find them either... My guess is that the SDK support is a group of toolboxes, hidden in the cellar under the stairs or something.

Now the fix...

It is clear that the ApplyStorageDRSRecommendation is broken by trying to create a guest... So, I rewound that I made and decided to use createVM_Task instead. But, how do you know what the cluster data store to register to? Well, I wrote a routine that got all the warehouses of data in the cluster and found the one with the most space... Which is all I wanted the DRS service anyway. When checking the prompt resulting summary view and DTS settings it seems to be configured correctly (same level of automation as other guests) even if I'm not using the DTS API directly, so I'm happy... For the time being.

Here's the function to determine what data store to use. Comments are welcome...

sub get_recommended_datastore_from_cluster {
    my ( $cluster ) = @_;

    # Get datastore information from system
    my $sp = Vim::find_entity_view( view_type => 'StoragePod',
                                        properties => [ 'name', 'childEntity' ],
                                        filter => { name => $cluster  } );
    return undef if ( ! defined( $sp ) );

    # Go through the datastores that are in the cluster and get their space
    my %datastores;
    foreach my $mo ( @{$sp->childEntity} ) {
        my $ds = Vim::get_view( mo_ref => $mo,
                                properties => [ "name", "summary.freeSpace" ] );
        $datastores{$ds->{"summary.freeSpace"}} = $ds->name;
    }

    # Find the one with the most free space and return it
    my $max = ( sort { $b <=> $a } keys( %datastores ) )[0];
    return $datastores{$max};
}

Thank you

Scott

Tags: VMware

Similar Questions

  • Cannot access the server from vsphere client

    Hi, people.

    After having been very well for a few weeks, now I'm unable to access my server from vSphere client, I get an error of:

    Call 'ServiceInstance.RetrieveContent' to object 'ServiceInstance' on the server '192.168.6.2' failed.

    I've attached screenshots of the error message.

    The pc and the server are on the same subnet, and the error comes from several PCs that try to connect.

    Help, please!

    NM

    So I think you must restart these services as vivari said.

    If you are unable to log in via ssh, you must have access to the consoles. Then, you can restart the services or enable ssh to do via ssh.

  • How to remove the server from vSphere VI3 licenses 4?

    Hi all

    In the application of the license of our environment vSphere 4, I always cited the old server license VI3. Since we do not use it more (whatever it is has been upgraded to vSphere 4 a long time ago), we have disabled and therefore vCenter complains somewhere in the newspapers not being able to communicate with her.

    However, I couldn't find an easy way to remove it from vSphere licenses... Does anyone have an idea?

    Andreas

    - Blog of experience front of VMware

    in vCenter go Administration - vCenter Server Settings - authorization - license server.  Delete the entry and uncheck the box «reconfigure...» »

  • I have a question why U removed the session of keyboard spelling checker is a very useful sit Apple give it in products. It helps a lot in communicting with others from different countries, even in our studies and the communication

    I have a question why U removed the session of keyboard spelling checker is a very useful sit Apple give it in products. It helps a lot in communicting with others from different countries, even in our studies and communication with our teachers.plz it back... .hope you will do

    Nothing has been deleted. Perhaps if you explain better what it is you are looking for, a person might be able to help. You mean maybe predictive text? All these settings are in settings > general > keyboard.

  • When I open Corel Draw 7 (Yes it's old, but he's all I have to do) as soon as I try to do anything on a graph, the window titled ' help' "Why can't I get help from this program?

    Original title: the HELP window interferes with Corel 7

    When I open Corel Draw 7 (Yes it's old, but he's all I have to do) as soon as I try to do anything on a graph, the window titled ' help' "Why can't I get help from this program?  opens and won't allow me to contimue.  As soon as I close the window, the first action I take it opens again.  Nothing EVER happens on my chart.  I can't take ANY action.  How can I close that window and keep it closed.

    Any ideas?

    I just did a clean install of Windows 7 Home Premium from a disk I bought at Staples.  I then re-load my old version of Corel.  Corel Photo-Paint works well, it is fair to Corel Draw.

    Corel Draw 7 is not compatible with win7, even when you use the compatibility options

  • Why my games crash immediately after clicking on the icon?

    original title: After double clicking on the icon of the game, the problem windows window appears and says it checks for a solution.  I can't understand how to solve this problem.  It does not occur on all games.

    Why my games crash immediately after clicking on the icon?

    Hello
     
     
     
    1. what game you play when this happens?
    2. have you ever run properly on your computer?
    3 did you changes to the computer recently?
     

    Method 1.
    Play this game in the clean boot and then check if it works very well.
    See the article below for instructions on how to start your computer in a clean boot state.
    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
    http://support.Microsoft.com/kb/929135
    Note: When the diagnosis is complete, don't forget to reset your computer to normal startup. Follow step 7 in the above article.

     
    Method 2.
    I would like to look at the logs of the same observer. Here's how you can pull up the newspapers:
    Type eventvwr.msc/s in the address bar.
     
    The list of all the events that are listed as 'Error' in the main window when you go to 'Newspapers Windows' and 'Application '. There is often a large number of them. Send us any ones you see listed for the last few days. (Please also do it for the log files in 'System'). When you do, provide us the name of the 'Source' and all that is listed in the description below the list of newspapers box when you click on one.
     
    For more information on event viewer, see the articles below:
    Open event viewer
    http://Windows.Microsoft.com/en-us/Windows7/open-Event-Viewer
    What are the information contained in the logs of the event (Event Viewer)?
    http://Windows.Microsoft.com/en-us/Windows7/what-information-appears-in-event-logs-Event-Viewer
     
     
    I hope hear from you soon!

    Thank you, and in what concerns:
    Shekhar S - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.
    If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • Why the volume speaker icon disappear from the Office

    WHY THE VOLUME SPEAKER ICON DISAPPEAR FROM THE OFFICE

    Hi FREDERICKLOU,

    Follow the steps below to make sure that the volume icon is set to display in the notification bar:

    1. Click the arrow in the notification bar, click Customize and click Start > Control Panel > Notification area icons
    2. Use the drop-down list next to the Volume and select Show icon and notifications
    3. Click OK

    Let us know if that helps.

  • Viewing JPG and GIF files crashes the server (Windows Server 2008)

    I work in an office with windows server 2008 and we are having a problem where the right click images and choosing preview or open with IE will crash our server, then everyone must wait 3 minutes to go.  I tried like 2 hours and cannot find any info on this problem online.  Everyone knows about this problem with Server 2008?  It seems to be very consistent and arrived on different images (JPG, GIF) until we had to install a third Viewer left - but the problem is still there and now and then someone accidentally blocking us.

    I have tested what it about three times what about everyone when it crashes - but so far I'm 3 for 3, so I don't think it's randomly occurring even though I don't know if led EACH image.

    Help, please!

    It's a consumer Forum, your question would be better fit in a Technet forum, please repost it und include more details (for example the detailed error message). Thank you. http://social.technet.Microsoft.com/forums/en-us/categories/

  • After an attack of virus on the server, I am unable to connect to the server from any client computer.

    After an attack of virus on the server, I am unable to connect to the server from any client computer.

    I have a small net work in my house, and until yesterday, the network works well. MSSE clean virus win32 on my server attack yesterday and here after that I am unable to connect to the server of customers while I was able to connect to server cleints. I used MS Fixit widjows firewall and then problem determination after the Client computer request user name & against which I entered the login data, password but it displays the same error message.

    PL help someone who will be widely recognized.

    Thank you best regards &.

    Gandhi Prasad

    Hello

    Because the problem is with the server, I recommend you post this question in the TechNet forum.

    http://social.technet.Microsoft.com/forums/en-us/category/windowsxpitpro

  • Why can't I paste it from the Clipboard?

    Why can't I paste it from the Clipboard on my desk?

    Hello

    I suggest you post the question in the forums and check them off below if it helps:

    http://answers.Microsoft.com/en-us/Office/Forum/word?page=1

    It will be useful.

  • Why my computer crash when I play Minecraft?

    Why my computer crash when I play minecraft?

    Original title: the computer crashes

    To allow someone to help you, you must provide additional information.

    For example:

    -How and when it crash (i.e. it just do not start, or the game starts and then crashes to the desktop, etc.).

    -Are there exact error messages or error codes?

    -What are the specifications/brand/model of your PC (RAM/CPU/GPU, etc.)

    If the game is designed for an earlier version of Windows (e.g. Windows XP) have you tried compatibility mode to see if it works OK. Or try to install the game via this mode as well.

    In the meantime, does that help? (found through a search fast V forum)

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_other-gaming/Minecraft-does-not-work-with-Windows-7-or-my/6f7b5f4a-ed2b-4583-93aa-b3a161d69f77

    But you can be better to ask here (if you have not already done so).

  • Help, please! Illustrator crashing when opening...

    Hello, please help me! I have a Mac from 2007 which is an OS X El Capitan. my Illustrator crashed on me a few months ago, and a very nice person here helped me through step by step how to uninstall and reinstall. I suspect that his blocks for the same reason as last time because the way he hangs is exactly the same: the program will begin a new document and then crashes before it can fully open.

    any help would be greatly appreciated, thank you!

    What version of Illustrator is running?

  • Need a Script to pull data from use of resources based on the resource pool by.

    LucD I have created the script, but I wanted to add additional information such as total memory, CPU, Avg Total memory usage, below, the Avg CPU usage total storage.etc

    $report = @)

    {foreach ($cluster Get-cluster)

    foreach ($rp in Get-ResourcePool-location $cluster) {}

    foreach ($vm in (Get-VM-location the $rp)) {}

    $report += get-disk hard - VM $vm |

    Select @{N = "Cluster"; E = {$cluster. Name}},

    @{N = "ResourcePool"; E = {$rp. Name}},

    @{N = "VM"; E = {$vm. Name}},

    @{N = 'HD'; E={$_. Name}},

    @{N = "Datastore"; E={($_. Filename.Split(']') [0]). TrimStart('[')}},

    @{N = 'Filename'; E={($_. Filename.Split('_') [1]). "Split('/') [0]}},"

    @{N = 'Path VMDK'; E={$_. File name}}.

    @{N = "Format"; E={$_. StorageFormat}},

    @{N = ' Type'; E={$_. DiskType}},

    @{N = 'VM tools status'; E = {$vm. ExtensionData.Guest.ToolsStatus}},

    @{N = "CapacityGB"; E={$_. CapacityGB}}

    }

    $report | Export Csv C:\temp\report.csv - NoTypeInformation - UseCulture

    }

    }

    Something like below the lines wanted to add in my script above but could not understand how do. Need to add information resources as much as possible. Please help me on this.

    @{N='GHz CPU capacity';} E={[math]::Round($_. CpuTotalMhz / 1000 , 2 )}},

    @{N="GHz CPU used";} E={[math]::Round($_. CpuUsageMhz / 1000, 2 )}},

    @{N="CPU GHz free";} E={[math]::Round(($_. CpuTotalMhz - $_. CpuUsageMhz) / 1000 , 2 )}},

    @{N='Go memory capacity';} E={[math]::Round($_. MemoryTotalGB , 2 )}},

    @{N="Used memory GB";} E={[math]::Round($_. MemoryUsageGB , 2 )}},

    @{N="GB free memory";} E={[math]::Round(($_. MemoryTotalGB - $_. MemoryUsageGB) ,2 )}}



    The lines to add are displaying the results of a calculation on performance data, which are obtained through Get-Stat.

    In this script you better start from the script where you have taken these lines and then add the properties of the 1st script.

    In the objects returned by Get-Stat, you have access to the virtual machine through the property of the entity.

  • Media Encoder crashes when exporting from Premiere Pro

    Media Encoder crashes when exporting from Premiere Pro. I am the queue several files to export and Media Encoder will crash. The computer system has 32 GB of RAM and videos of export fine in first, but which requires export each individually. Each video file turned down and some can be quite long (more than 3-5 hours). Nothing else is running on the computer that take over memory.

    No idea why Media Encoder will crash?

    Try turning off the GPU acceleration.

  • I can crash any server ESXi 4.1 of the guest operating system

    Two months we went from ESXi 3.5 to 4.1. All servers are 320173 construction, all the virtual machines have the latest VMware tools installed. Among several hundred other reviews dare, we have 4 very old virtual machines, using SuSE Linux 8.x or 9.x with kernel 2.4. They are the remains of our stone age, but they work well and do their job.

    When I have one of these virtual machines, stop everything ist fine.

    When I boot these VMs upward once again, everything is fine.

    But when I restart one of these virtual machines, the ESXi host crashes with all other virtual machines on it!

    The usual image on the console remains the same, but it will not answer strikes more. Also, it does not ping, you can not connect you SSH or vSphere Client - nothing. She is completely blocked. The only options are the key reset or power button.

    He will not make a difference, if you issue restarts the VM inside the os, as/sbin/reboot, or will it deliver you from vSphere Client with "Restart Guest". The result is always the same: a total crash of the whole army - and of course all other virtual machines on it.

    We do not really know, if accidents are due to the fact, that these virtual machines use the old 2.4 kernel or some other problem. But those 4 virtual machines are the only ones that could damage the VMware host and they also are the only ones we have with the 2.4 kernel. + 100 other guests Linux with kernel 2.6 work as well as before with ESXi 3.5.

    During this time we could improve (restore) 2 of these virtual machines with a modern with kernel 2.6 Linux. No problem with their reboot more. But the other 2 use old software that is not available for moden more Linux distributions. We have yet no work around. One of the remaining VMS cravings to restart last night and crashed the server [it's 07:00 right now in Vienna] and SMS alerts woke me out of bed about two hours ago.

    Anyone else have these problems?

    Everyone maybe there one alternative that "install a modern operating system"?

    Thank you!

    A shot in the dark, but have you tried to update your tools from VMware and the upgrade to vHardware 7 on those virtual machines?

Maybe you are looking for