<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:clearspace="http://www.jivesoftware.com/xmlns/clearspace/rss" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>VMware Communities: Message List - create a schedule task of poweroff the specified Virtual Machine using the SDK getting failed</title>
    <link>http://communities.vmware.com/community/developer/forums/guestapi?view=discussions</link>
    <description>Most recent forum messages</description>
    <language>en</language>
    <pubDate>Mon, 01 Jun 2009 04:51:29 GMT</pubDate>
    <generator>Clearspace 1.10.12 (http://jivesoftware.com/products/clearspace/)</generator>
    <dc:date>2009-06-01T04:51:29Z</dc:date>
    <dc:language>en</dc:language>
    <item>
      <title>Re: create a schedule task of poweroff the specified Virtual Machine using the SDK getting failed</title>
      <link>http://communities.vmware.com/message/1267654?tstart=0#1267654</link>
      <description>Please check the method action you created and also if the Virtual Machine MORef is correct or not. Refer following code snippet for MethodAction&lt;br /&gt;
&lt;br /&gt;
      MethodAction action = new MethodAction();&lt;br /&gt;
      action.name = "PowerOffVM_Task";&lt;br /&gt;
      action.argument= new MethodActionArgument[] { };&lt;br /&gt;
&lt;br /&gt;
      DateTime currentTime = new DateTime();&lt;br /&gt;
      currentTime = DateTime.Now;&lt;br /&gt;
      DateTime runTime = currentTime.AddMinutes(30);&lt;br /&gt;
&lt;p /&gt;
      OnceTaskScheduler scheduler = new OnceTaskScheduler();&lt;br /&gt;
      scheduler.runAt= runTime;&lt;br /&gt;
&lt;br /&gt;
      String taskName = "PowerOff a Virtual machine"; &lt;br /&gt;
         ScheduledTaskSpec scheduleSpec = new ScheduledTaskSpec();&lt;br /&gt;
         scheduleSpec.name=taskName;&lt;br /&gt;
         scheduleSpec.description="PowerOff VM in 30 minutes";&lt;br /&gt;
         scheduleSpec.enabled=true;&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
         scheduleSpec.action=taskAction;&lt;br /&gt;
         scheduleSpec.scheduler=scheduler;&lt;br /&gt;
&lt;p /&gt;
&lt;p /&gt;
         if(_virtualMachine != null) {         &lt;br /&gt;
            ManagedObjectReference task = &lt;br /&gt;
               _service.CreateScheduledTask(&lt;br /&gt;
                        _scheduleManager, _virtualMachine, scheduleSpec);&lt;br /&gt;
	}</description>
      <pubDate>Mon, 01 Jun 2009 04:51:29 GMT</pubDate>
      <author>Seemankij</author>
      <guid>http://communities.vmware.com/message/1267654?tstart=0#1267654</guid>
      <dc:date>2009-06-01T04:51:29Z</dc:date>
      <clearspace:dateToText>5 months, 3 weeks ago</clearspace:dateToText>
    </item>
    <item>
      <title>create a schedule task of poweroff the specified Virtual Machine using the SDK getting failed</title>
      <link>http://communities.vmware.com/message/1265489?tstart=0#1265489</link>
      <description>&lt;br /&gt;
Hi everyone,&lt;br /&gt;
&lt;br /&gt;
I made a code to create a schedule task using the SDK, but I have errors:&lt;br /&gt;
&lt;p /&gt;
Here is my code:&lt;br /&gt;
&lt;p /&gt;
// Find the virtual machine list from the virtual machine folder found above.&lt;br /&gt;
&lt;p /&gt;
ManagedObjectReference&lt;a class="jive-link-adddocument" href="http://communities.vmware.com/community-document-picker.jspa?communityID=&amp;subject=%5D+vmList+%3D+%28ManagedObjectReference%5B"&gt;] vmList = (ManagedObjectReference[&lt;/a&gt;)getObjectProperty(vmFolderRef, "childEntity");&lt;br /&gt;
&lt;p /&gt;
//Searching for the template/virtual machine&lt;br /&gt;
&lt;p /&gt;
ManagedObjectReference templateRef = null;&lt;br /&gt;
&lt;p /&gt;
for (int i = 0; i &amp;lt; vmList.Length; i++)&lt;br /&gt;
&lt;p /&gt;
{&lt;br /&gt;
&lt;p /&gt;
if (vmList&lt;i&gt;.type == "VirtualMachine")&lt;br /&gt;
&lt;p /&gt;
{&lt;br /&gt;
&lt;p /&gt;
Object[] vmProps = getProperties(vmList&lt;a class="jive-link-adddocument" href="http://communities.vmware.com/community-document-picker.jspa?communityID=&amp;subject=i%5D%2C+new+String%5B"&gt;i], new String[&lt;/a&gt; { "config.name", "config.template" });&lt;br /&gt;
&lt;p /&gt;
if (((String)vmProps[0]).Equals(srcName))&lt;br /&gt;
&lt;p /&gt;
{&lt;br /&gt;
&lt;p /&gt;
templateRef = vmList&lt;i&gt;;&lt;br /&gt;
&lt;p /&gt;
}&lt;br /&gt;
&lt;p /&gt;
}&lt;br /&gt;
&lt;p /&gt;
}&lt;br /&gt;
&lt;p /&gt;
// Define the operation to be performed.&lt;br /&gt;
&lt;p /&gt;
MethodAction ma = new MethodAction();&lt;br /&gt;
&lt;p /&gt;
ma.argument = new MethodActionArgument[1];&lt;br /&gt;
&lt;p /&gt;
ma.name = "PowerOffVM_Task";&lt;br /&gt;
&lt;p /&gt;
DateTime theDate = DateTime.Now;&lt;br /&gt;
&lt;p /&gt;
theDate.AddMinutes(1);&lt;br /&gt;
&lt;p /&gt;
// Define the scheduled task specification.&lt;br /&gt;
&lt;p /&gt;
OnceTaskScheduler dTScheduler = new OnceTaskScheduler();&lt;br /&gt;
&lt;p /&gt;
dTScheduler.runAt = theDate; &lt;br /&gt;
&lt;p /&gt;
dTScheduler.runAtSpecified = true;&lt;br /&gt;
&lt;p /&gt;
dTScheduler.activeTimeSpecified = true;&lt;br /&gt;
&lt;p /&gt;
dTScheduler.activeTime = DateTime.Now;&lt;br /&gt;
&lt;p /&gt;
dTScheduler.expireTime = theDate.AddHours(1);&lt;br /&gt;
&lt;p /&gt;
dTScheduler.expireTimeSpecified = true;&lt;br /&gt;
&lt;p /&gt;
ScheduledTaskSpec tSpec = new ScheduledTaskSpec();&lt;br /&gt;
&lt;p /&gt;
tSpec.description = "Revert to the specified snapshot according to the schedule.";&lt;br /&gt;
&lt;p /&gt;
tSpec.enabled = true;&lt;br /&gt;
&lt;p /&gt;
tSpec.name = "Power Off Virtual Machine";&lt;br /&gt;
&lt;p /&gt;
tSpec.action = ma;&lt;br /&gt;
&lt;p /&gt;
tSpec.scheduler = dTScheduler;&lt;br /&gt;
&lt;p /&gt;
tSpec.notification = &lt;a class="jive-link-email" href="mailto:Foo@Bar.com"&gt;Foo@Bar.com&lt;/a&gt;;&lt;br /&gt;
&lt;p /&gt;
VS.CreateScheduledTask(_ServiceContent.scheduledTaskManager, templateRef, tSpec);&lt;br /&gt;
&lt;p /&gt;
Error: SOAPEXCEPTION was unhandled. Aspecified parameter was not correct.&lt;br /&gt;
&lt;p /&gt;
Do i am doing wrong with this parameter:--------------------------------------------&lt;br /&gt;
&lt;p /&gt;
ma.argument = new MethodActionArgument[1];&lt;br /&gt;
&lt;p /&gt;
Regards&lt;br /&gt;
&lt;p /&gt;
Sudhir Kumar&lt;/i&gt;&lt;/i&gt;</description>
      <pubDate>Thu, 28 May 2009 18:57:06 GMT</pubDate>
      <author>kumar_sudhir1</author>
      <guid>http://communities.vmware.com/message/1265489?tstart=0#1265489</guid>
      <dc:date>2009-05-28T18:57:06Z</dc:date>
      <clearspace:dateToText>5 months, 4 weeks ago</clearspace:dateToText>
      <clearspace:replyCount>1</clearspace:replyCount>
    </item>
  </channel>
</rss>

