Exemplo n.º 1
0
 void DisplayUpdates(Object sender, PropertyFilterUpdateEventArgs eArgs)
 {
     foreach (PropertyChange change in eArgs.FilterUpdate.objectSet[0].changeSet)
     {
         if (change.op == PropertyChangeOp.add || change.op == PropertyChangeOp.assign)
         {
             if ("guest" == change.name)
             {
                 GuestInfo gi = (GuestInfo)change.val;
                 System.Console.WriteLine("GuestInfo.state->{0}\tGuestInfo.toolsStatus->{1}",
                                          gi.guestState, gi.toolsStatusSpecified?gi.toolsStatus.ToString():"not-present");
             }
             else if ("summary.quickStats" == change.name)
             {
                 VirtualMachineQuickStats qs = (VirtualMachineQuickStats)change.val;
                 System.Console.WriteLine("QuickStats.guestHeartbeatStatus->{0}\tQuickStats.overallCpuUsage->{1}",
                                          qs.guestHeartbeatStatus, qs.overallCpuUsage);
             }
             else if ("summary.runtime.powerState" == change.name)
             {
                 System.Console.WriteLine("PowerState->{0}", change.val);
             }
         }
     }
 }
 public VirtualMachine(ManagedObjectReference _this,
         String name,
         ManagedObjectReference host,
         VirtualMachinePowerState powerState,
         ManagedEntityStatus overallStatus,
         VirtualMachineQuickStats quickStats)
 {
     this.setMoRef(_this);
     this.setName(name);
     this.setHost(host);
     this.setPowerState(powerState);
     this.setOverallStatus(overallStatus);
     this.setQuickStats(quickStats);
 }
Exemplo n.º 3
0
 void handleChanges(PropertyChange[] changes)
 {
     for (int pci = 0; pci < changes.Length; ++pci)
     {
         String           name  = changes[pci].name;
         Object           value = changes[pci].val;
         PropertyChangeOp op    = changes[pci].op;
         if (op != PropertyChangeOp.remove)
         {
             Console.WriteLine("  Property Name: " + name);
             if ("summary.quickStats".Equals(name))
             {
                 if (value.GetType().Name.Equals("VirtualMachineQuickStats"))
                 {
                     VirtualMachineQuickStats vmqs = (VirtualMachineQuickStats)value;
                     String cpu    = vmqs.overallCpuUsage.ToString() == null ? "unavailable" :vmqs.overallCpuUsage.ToString();
                     String memory = vmqs.hostMemoryUsage.ToString() == null ? "unavailable" : vmqs.hostMemoryUsage.ToString();
                     Console.WriteLine("   Guest Status: " +
                                       vmqs.guestHeartbeatStatus.ToString());
                     Console.WriteLine("   CPU Load %: " + cpu);
                     Console.WriteLine("   Memory Load %: " + memory);
                 }
                 else if (value.GetType().Name.Equals("HostListSummaryQuickStats"))
                 {
                     HostListSummaryQuickStats hsqs = (HostListSummaryQuickStats)value;
                     String cpu    = hsqs.overallCpuUsage.ToString() == null ? "unavailable" : hsqs.overallCpuUsage.ToString();
                     String memory = hsqs.overallMemoryUsage.ToString() == null ? "unavailable" : hsqs.overallMemoryUsage.ToString();
                     Console.WriteLine("   CPU Load %: " + cpu);
                     Console.WriteLine("   Memory Load %: " + memory);
                 }
             }
             else if ("runtime".Equals(name))
             {
                 if (value.GetType().Name.Equals("VirtualMachineRuntimeInfo"))
                 {
                     VirtualMachineRuntimeInfo vmri = (VirtualMachineRuntimeInfo)value;
                     Console.WriteLine("   Power State: "
                                       + vmri.powerState.ToString());
                     Console.WriteLine("   Connection State: "
                                       + vmri.connectionState.ToString());
                     DateTime bTime = vmri.bootTime;
                     if (bTime != null)
                     {
                         Console.WriteLine("   Boot Time: " + bTime.TimeOfDay);
                     }
                     long mOverhead = vmri.memoryOverhead;
                     if (mOverhead.ToString() != null)
                     {
                         Console.WriteLine("   Memory Overhead: " + mOverhead);
                     }
                 }
                 else if (value.GetType().Name.Equals("HostRuntimeInfo"))
                 {
                     HostRuntimeInfo hri = (HostRuntimeInfo)value;
                     Console.WriteLine("   Connection State: "
                                       + hri.connectionState.ToString());
                     DateTime bTime = hri.bootTime;
                     if (bTime != null)
                     {
                         Console.WriteLine("   Boot Time: " + bTime.TimeOfDay);
                     }
                 }
             }
             else if ("name".Equals(name))
             {
                 Console.WriteLine("   " + value);
             }
             else
             {
                 Console.WriteLine("   " + value.ToString());
             }
         }
         else
         {
             Console.WriteLine("Property Name: " + name + " value removed.");
         }
     }
 }
 public void setQuickStats(
         VirtualMachineQuickStats quickStats)
 {
     this.quickStats = quickStats;
 }