Non-blocking with Perl VI API monitor task

I am writing a perl script that needs...

  1. Suspend a virtual machine
  2. Do 'some other supervision' while the virtual machine in the suspension process
  3. Make sure that the task is complete suspension

I was looking at the documentation for the API, but also the code example and there are many examples which have helped me understand how to do #1 and to some extent #3 by calling SuspendVM() on the managed virtual computer object (see my sample code "Option 1").  But it is not perfect for #3 and does not allow me to do #2 at all.  API documentation leads me to believe that I should be able to use SuspendVM_Task() on the virtual computer object for a task monitor-a measure of object (see 'Option 2') in my sample code.)

However, I can't understand how to use this object task to track progress.  I think it must be something like "Block monitor" in my code, but that doesn't seem to work.  Watching a dump of the task object, "info" property seems to not even be there.  I can bless the object to its class real slot (instead of the generic ManagedObjectReference, it starts as), but then the property of the info is just empty.

I know I probably stopped next to a simple shade of perlOO/perl/perlReference, but can not find where I'm going wrong... any help out there?

Output of dump of the object of the task

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

$VAR1 = bless ({}
'value' = > ' haTask-1808 - vim.VirtualMachine.suspend - 1852795401',
'type' = > 'task '.
(}, "ManagedObjectReference");

Code example

==========

#! / usr/bin/perl - w

use strict;

use warnings;

Use Data::Dumper;

use VMware::VIRuntime;

past #./vmSuspend.pl--mot, username - XXXX XXXX - Server XXX.XXX.XXX. XXX - vmname XXXX

My % opts =)

'vmname' = > {}

Type = > "s =",

help = > "the name of the virtual machine.

required = > 1,

},

'filter' = > {}

Type = > "s =",

help = > 'filter to select corresponding virtual machines. "

required = > 0,

},

);

OPTS::add_options (%OPTS);

OPTS::parse();

OPTS::Validate();

Util::Connect();

My $retval = 0;

my $name = Opts::get_option ('vmname');

My $vm_view = Vim::find_entity_view (view_type = > 'VirtualMachine',)

filter = > {'name' = > $name});

my $state = $vm_view-> run - > powerState-> val;

Print "$name is $state\n";

# Option 1 - blocking

# $vm_view-> SuspendVM();

# Option 2 - non-blocking

My $suspendTask = $vm_view-> SuspendVM_Task();

print Dumper ($suspendTask);

# Block monitor

# everything in ($suspendTask-> info-> status-> val eq 'running' | $suspendTask-> info-> status-> val eq 'pending') {}

# < < some other surveillance > >

#}

$vm_view-> update_view_data();

$state = $vm_view-> run - > powerState-> val;

Print "$name is $state\n";

Take a look at this script for example: http://communities.vmware.com/docs/DOC-10269 there is a method in there called getStatus() that shows you a task queue is complete before continuing. You are on the right track, but must do a few more things to get the display of the task and make sure that you update the view after sleep/wait and then check again.

Tags: VMware

Similar Questions

  • Accessible resources within a platform with the HQ API

    Hello

    I use the HQ API to build a custom Java monitoring tool.
    So far, I can easily access agents and its related settings.

    My problem is that I don't know how to access resources related to agent: Mount of the file server, servers, services... Is it impossible with the HQ API?

    How can I do?

    If you use this, it will be very easy!

    Get all your HQ server agents: this will return a list of the agents!

    listAgent = hq.getAgentApi () .getAgents () .getAgent ();

    Get all your HQ server platform: this will return a list of Resources (platform)!

    listPlatform = hq.getResourceApi () .getResources (listAgent.get (i), true, true) .getResource ();

    Get all your HQ Server server: this will return a list of Resources (server)!

    list server = listPlatform.get (j) .getResource ();

    get all your HQ Server services: this will return a list of Resources (services)!

    listServices = listServer.get (k) .getResources ();

    with this, you can have the agent (machines) and all the resources under it!

    Hope this will help u

  • List of NetConnection with Perl bindings

    I started experimenting with SIGAR to generate surveillance/security scripts to manage all machines in my company. Because I like the Perl, I was happy to see that there is already a Perl bindings for SIGAR and so far I've been having fun doing my scripts in this way. I'm working on a script to monitor the various connections to the server to help find an unauthorized activity on unauthorized ports. Although I can't seem to find a list of NetConnection work as there is in the Java bindings. I could be overlooking it, or not understanding the proper use of the NetConnection, but if anyone can offer some advice? From what I gathered it just is not coded, and before attempting to code something I thought I should ask here.

    Regards, Matt

    Hi Matt,

    Good to hear you having fun with Perl and SIGAR. The Perl interface has fallen behind the Java one, so feel free to scream or patch when you find something missing.  I just added the net_connection_list method:
    http://svn.Hyperic.org/?view=Rev&root=Hyperic+Sigar&revision=3175

    And just tested with this one-liner:
    Perl - Mblib - e MSigar.
    "print map {$_-> remote_address, $/} @{Sigar-> new-> net_connection_list(0x01|0x10)}". "

    It would be really cool if you want to share something to put in the perl/examples/who is also low compared to those on the side of java.

  • How to use a KeyManager custom in SSLSocketChannel non-blocking

    In our existing project I had to replace the SocketChannel non-blocking by SSLSocketChannel no blocking. My implementation of the SSLSocketChannel non-blocking mask all the SSL stuff and can be used as a SocketChannel overall of the project that just use the SSLSocketChannelProvider instead of SocketChannelProvider in one place.

    Now I have a new requirement. Different server-certificate should be used for various IPS on the same SSLServerSocket. The relationship between the IPs and certificates is well known. The first idea was to use a custom KeyManagerDelegate that extends from X509ExtendedKeyManager to select the certificate from the server. The KeyManagerDelegate should delegate calls to a KeyManager obtained by
    KeyManagerFactory.getInstance("NewSunX509").getKeyManagers();
    It works if I use a blocking SSLServerSocket obtained by SSLContext.getServerSocketFactory () .createServerSocket ();

    But the KeyManagerDelegate is never called by the SSLContext if I use my own non blocking SSLServerSocketChannel. Instead of calling my KeyManagerDelegate the SSLEngineImpl throws an Exception
    javax.net.ssl.SSLHandshakeException: no cipher suites in common
         at com.sun.net.ssl.internal.ssl.Handshaker.checkThrown(Handshaker.java:951)
         at com.sun.net.ssl.internal.ssl.SSLEngineImpl.checkTaskThrown(SSLEngineImpl.java:466)
         at com.sun.net.ssl.internal.ssl.SSLEngineImpl.writeAppRecord(SSLEngineImpl.java:1092)
         at com.sun.net.ssl.internal.ssl.SSLEngineImpl.wrap(SSLEngineImpl.java:1064)
         at javax.net.ssl.SSLEngine.wrap(SSLEngine.java:452) 
    The next thing I'm going to try would be to get the SSLContext to use my own SSLSocketChannelProvider as ServerSocketFactory.

    Or I use different SSLContext for each incoming connection, which would break my own design because the server had to waste his time with the construction of new SSLContext. Another possibility is to implement a callback in the ServerSocketChannel to get a new SSLContext for each accepted connection. It would be sure my design but looks like a ugly workaround solution for me and I do not know if it works.

    All the best ideas?

    Thanks Domi

    I just tested this with my SSLSocketChannel and it works like correctly, the KeyManager methods called as expected. You hurt something else ;-) Do not extend X509ExtendedKeyManager to work properly with the engine.

  • Web HTTP proxy using IO Non blocking

    Solved thank you...

    customer. Register (selector, SelectionKey.OP_READ
    | SelectionKey.OP_WRITE);

    OP_READ only at this stage. OP_WRITE is always 'ready' unless the socket buffer is full, so your selector will turn only. Do not save OP_WRITE until you have something to write.

    ByteBuffer bferClient = ByteBuffer.allocate (4096);

    You do this each time around the loop, and you don't even know if the key is still readable. Do it when you accept a connection, and then save it as the essential accessory for this channel.

    client.configureBlocking (false);

    It is already in non-blocking mode. Why you do it again?

    try {}
    If ((bytesRead = client.read (bferClient))! = - 1) {}

    bferClient.flip ();
    String msgFromClient = new String (bferClient.array ());

    new String (bferClient.array (), 0, bferClient.limit () - 1), but you're assuming that you've got a complete command here. You do not have. This is another reason why you need a ByteBuffer by channel.

    Channel.Connect (SocketAddress);

    You should do it in non-blocking mode, save the channel for OP_CONNECT and leave the select loop to take care to complete the connection.

    Channel.Write (bferClient);

    The incoming command is CONNECT. You do not write than upstream.

    If (!) » ». {Equals (msgFromClient.Trim ()))}
    int bytesReadServer;
    response from Byte [] = new ubyte [4096];
    try {}
    ByteBuffer bufferNIO = ByteBuffer.allocateDirect (1024);
    While ((channel.read (bufferNIO))! = - 1) {}
    bufferNIO.flip ();
    customer. Write (bufferNIO);
    bufferNIO.clear ();
    }

    And you don't do that here. Register the new channel for OP_CONNECT, then when you get finishConnect() and then save it to OP_READ, and moving forward in your select loop. You also need to associate the channel with the channel that read you the CONNECTION since. If you really need an object of attachment key for the original channel that contains the buffer of bytes and the channel upstream; Similarly, the channel upstream must a key attachment that contains sound buffer and its channel downstream. The effect of making all this stuff here rather than around the loop of selection is that you're never going back to the loop of the selection: you manage what a customer here in blocking mode, until the connection is dropped. Completely wrong.

    } catch (IOException e) {}

    Hang up. If bytesRead a-1, you must close the channel.

    e.printStackTrace ();

    And if you get an IOException here you must also close the channel.

    If (channel! = null) {}
    try {}
    Channel.Close ();

    This is a really strange place to close this channel.

    When you get this fixed upward, your zip code and I will tell you how to handle the OP_WRITE.

  • Modal dialog box non-blocking

    Hello world

    I want to display a modal dialog box, capture user input and use it for further processing, as below:

    showWindow(); PopupManager.createPopUp () calls
    code to deal with user input

    My problem is that the showWindow() call is non-blocking, i.e. the code to deal with user input is executed immediately after the posting of the modal window. How can I do to run when the modal window is closed?

    Any help will be greatly appreciated.

    Thank you

    Rajesh Jayaprakash

    You can register a listener for the event of closure of the pop-up window and then on this listener, call the method that you want to run when the window is closed.

  • Anyone know how I can disable the block with the wikipedia etc. that appears in the place of the cursor if you hover over the texts? This is a most annoying invention! Help, please! Thank you!

    Anyone know how I can disable the block with the wikipedia, google, etc., which opens at the location of the cursor if you hover over the texts? This is a feature of most annoying that one should be able to disable if not needed. I use windows xp family and have the latest desktop version of FF, but I don't think that they are the problem. Thank you very much.

    This isn't a core feature of Firefox (AFAIK) - looks like an extension you have installed is that fact.

    Please send the contents of the extensions section of about: support

  • Buy an iphone 6 with the third person, I don't have the original receipt, now by mistake I block with icloud, I can ' t unlock.

    I have an iPhone 6 who bought in a pawn to Tijuana Mx shop, but the guys give me just one goal to sell - buy reception.

    my daughter block with icloud I have account or password saved, how can unlocked, I am not the original purchaser

    Since it is a second hand iPhone, it's your ONLY option:

    Turn off find my iPhone Activation Lock - Apple Support

  • HP Pavilion 17-e020dx: can I replace a Keyboard(Non-Backlit) with a backlit keyboard in my laptop HP Pavilion 17-e020dx?

    Can I replace a Keyboard(Non-Backlit) with a backlit keyboard in my laptop HP Pavilion 17-e020dx?

    Hello

    This series of computers portable your (and many others) have only 1 option for keyboard:

    Full-size, island-keyboard with numeric pad in black or white finish. Gesture of support: MultiTouch gestures
    activated, two fingers to scroll and pinchzoom as default
    Faucets, active by default
    Support for Windows 8 modern trackpad

    Therefore, you can not replace the keyboard only, you must also replace the motherboard that supports a backlit keyboard. If necessary, it would be a very expensive upgrade.

    Kind regards.

  • HP Pavilion x 360 Convertible: can I replace a Keyboard(Non-Backlit) with backlit keyboard in my HP Pavilion x 360 convertible

    Can I replace a Keyboard(Non-Backlit) with my HP Pavilion x 360 Convertible X0T24PA #ABG backlit keyboard

    Hello

    I checked the spare parts available for your laptop and which does not list a backlit keyboard. So I don't know if you'll be able to get that changed from 3rd party.

  • Just updated to ios 9 and my ipod touch is stuck at 'update of the iCloud parameters.  I can not restore from iTunes as I have to disable 'find my iPod toch' and cannot do the iPod is blocked with the message to update.  Will not work force a stop down.

    Just updated to ios 9.2 (from 8 something) and my ipod touch is stuck at 'update of the iCloud parameters.  I can not restore from iTunes because I have to disable "Find my iPod touch" first of all, and I can't do as the iPod is blocked with the message to update.  Forcing a stop down does not work that for some reason, I am unable to turn off my iPod touch manually.  I tried to turn off my wifi to see if that stops the iPod touch, but he always keeps on the message to iCloud.  Do I just wait until the battery sinks so that it forces a reboot?

    Place your iOS device into Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.

    iOS: I forgot the password or disabled device

    If the recovery mode does not work, try the DFU mode.

    How to put iPod touch / iPhone in DFU "Karthik doodles."

    To learn how to restore:

    iTunes: restore iOS software

    To restore backup see:

    Restore your device from an iCloud or iTunes backup - Apple Support

    If you restore from a backup of iCloud apps will be automatically downloaded. If you restore from backup iTunes, applications and music must be in iTunes since synchronized as music media library and apps are not included in the backup of the iOS device what iTunes does.

    You can re-download most of iTunes purchases by:

    Download after purchase from the App Store and iTunes Store iBookstore

    If no problem what happens or doesn't happen, and when in the instructions? When you get the iPod into recovery successfully mode and connect to iTunes on the computer should say that it found an iPod in recovery mode.

  • reading non-blocking

    Hello

    I'm trying to implement a lock read along the lines of peekdata() in matlab http://www.mathworks.de/access/helpdesk/help/toolbox/daq/index.html?/access/helpdesk/help/toolbox/da...

    I found I can do readings not blocked from using the reading + http://forums.ni.com/ni/board/message?board.id=230&thread.id=2862 reminders

    Is there another way to get non-blocking reads?   The reason is that if the above, I've implemented the matlab Matlab mex interface calls the file (mex) C and I do read (must wait the trigger occurs) before returning from the C file (aka it becomes again blocking). So that callbacks are not really useful if the thought in a single thread passing that matlab works.

    Thanks for reading.

    The way in which the driver is written is to block on a reading DAQmx.  In a single threaded method will always call blocking as I know.

  • Is it possible to set up workstations with 2 or 3 monitors each in MultiPoint Server 2011?

    Hello everyone!

    I have studied MultiPoint Server documents, but have not found the answer: is it possible to set up workstations with 2 or 3 monitors each in MultiPoint Server 2011? For example I have computer with graphics HD6970 and HD4790 (more HD4290 on board) and to 'split' in several positions - a high performance graphic with 3 monitors and 2 connected to HD6970 or 3 other workstations for internet/treatment of text with each, a lcd panel connected to HD4790 and HD4290 cards. So I could build small desk with a powerful station :).

    In other words, using windows terminology guide, one might wonder it is able to have the teachers with more than one monitor computer, while students have jobs with a monitor?

    (Subsidiary question is: what Eyefinity, is working for MultiPoint - assuming that the station with more than a graphics card?) Can't find any information in the deployment also guide).

    Kind regards

    Maciej

    Please transfer your inquiry in the most appropriate in Forum Windows Multipoint Server.  Thank you!

  • Faced with a failure of OSD task sequence. The failure messages in the end are: failure to file WIM mount (0 x 80070002) & Failed to create media (0 x 80070002)

    Hello

    Faced with a failure of OSD task sequence.

    The failure messages in the end are:

    --------------------------------------------------

    Has no file WIM mount 0 x 80070002

    Cannot create media 0 x 80070002

    CreatTSMedia failed with error 0 x 80070002 details MediaGenerator

    --------------------------------------------------------------------------------------------

    It comes via SCCM 2007 R3 and a version of Windows XP.

    I think 0 x 80070002 means "the system cannot find the file specified."

    But what file?

    How do you determine what the media Wizard is missing to generate this error?

    Is this a driver problem?

    Thank you

    John

    Hello

    The question you posted would be better suited in the TechNet Forums. I would recommend posting your query in the TechNet Forums. You can follow the link to your question:

    http://social.technet.Microsoft.com/forums/en/configmgrosd/threads

    Hope this information helps.

  • Hi, im working with 2 1920 * 1080 monitors and you want to display a background thar image is on a resolution of 3840 * 1080 and I wanted to be half on each monitor. can u help me?

    Hi, im working with 2 1920 * 1080 monitors and you want to display a background thar image is on a resolution of 3840 * 1080 and I wanted to be half on each monitor. can u help me?

    Friday, July 20, 2012 14:35:27 + 0000, GastonBriatore wrote:

    Hi, im working with 2 1920 * 1080 monitors and you want to display a background thar image is on a resolution of 3840 * 1080 and I wanted to be half on each monitor. can u help me?

    Windows does not allow you this. However, you might be able to find a
    third party program that could do this.

    Ken Blake, Microsoft MVP

Maybe you are looking for