예제 #1
0
        public Collection <VSphereVirtualMachine> GetVirtualMachines()
        {
            LogDebug("Retrieving list of virtual machines from vSphere.");

            VSphereSelectionSpec selectAllVMs =
                new VSphereSelectionSpec("recurseFolders", VSphereManagedObjectType.Folder, "childEntity",
                                         new VSphereSelectionSpec("recurseFolders"),
                                         new VSphereSelectionSpec(VSphereManagedObjectType.Datacenter, "vmFolder",
                                                                  new VSphereSelectionSpec("recurseFolders"))
                                         );

            Collection <VSphereVirtualMachine> vms = new Collection <VSphereVirtualMachine>();

            foreach (VSphereManagedObject vm in CallVSphere(n => n.RetrieveObjects(selectAllVMs, VSphereVirtualMachine.StandardProperties)))
            {
                vms.Add(new VSphereVirtualMachine(vm));
            }
            return(vms);
        }
예제 #2
0
        /// <summary>
        /// Retrieves a set of vSphere managed objects using the specified <see cref="VSphereSelectionSpec" /> and <see cref="VSpherePropertySpec" /> set.
        /// </summary>
        /// <param name="startingObject">The <see cref="VSphereManagedObject" /> from which the query should start.</param>
        /// <param name="selectionSpec">The <see cref="VSphereSelectionSpec" /> that specifies which objects will be queried.</param>
        /// <param name="propertySpecs">The collection of <see cref="VSpherePropertySpec" /> that specifies which object properties will be retrieved.</param>
        /// <returns>A collection of <see cref="VSphereManagedObject" />.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="startingObject" /> is null.
        /// <para>or</para>
        /// <paramref name="selectionSpec" /> is null.
        /// <para>or</para>
        /// <paramref name="propertySpecs" /> is null.
        /// </exception>
        public IEnumerable <VSphereManagedObject> RetrieveObjects(VSphereManagedObject startingObject, VSphereSelectionSpec selectionSpec, IEnumerable <VSpherePropertySpec> propertySpecs)
        {
            if (selectionSpec == null)
            {
                throw new ArgumentNullException(nameof(selectionSpec));
            }

            return(RetrieveObjects(startingObject, new[] { selectionSpec }, propertySpecs));
        }
예제 #3
0
 /// <summary>
 /// Retrieves a set of vSphere managed objects using the specified <see cref="VSphereSelectionSpec" /> and <see cref="VSpherePropertySpec" /> set.
 /// </summary>
 /// <param name="selectionSpec">The <see cref="VSphereSelectionSpec" /> that specifies which objects will be queried.</param>
 /// <param name="propertySpecs">The collection of <see cref="VSpherePropertySpec" /> that specifies which object properties will be retrieved.</param>
 /// <returns>A collection of <see cref="VSphereManagedObject" />.</returns>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="selectionSpec" /> is null.
 /// <para>or</para>
 /// <paramref name="propertySpecs" /> is null.
 /// </exception>
 public IEnumerable <VSphereManagedObject> RetrieveObjects(VSphereSelectionSpec selectionSpec, IEnumerable <VSpherePropertySpec> propertySpecs)
 {
     return(RetrieveObjects(new VSphereManagedObject(_serviceContent.rootFolder), selectionSpec, propertySpecs));
 }