예제 #1
0
            /// <summary>
            /// Lists the XenServer virtual machine templates.
            /// </summary>
            /// <returns>The list of templates.</returns>
            /// <exception cref="XenException">Thrown if the operation failed.</exception>
            public List <XenTemplate> List()
            {
                var response  = client.SafeInvokeItems("template-list", "params=all");
                var templates = new List <XenTemplate>();

                foreach (var result in response.Items)
                {
                    templates.Add(new XenTemplate(result));
                }

                return(templates);
            }
예제 #2
0
            /// <summary>
            /// Lists the XenServer virtual machines.
            /// </summary>
            /// <returns>The list of virtual machines.</returns>
            /// <exception cref="XenException">Thrown if the operation failed.</exception>
            /// <remarks>
            /// <note>
            /// Only virtual machines with names will be returned with the
            /// assumption that unnamed VMs are XenServer infrastructure
            /// related.
            /// </note>
            /// </remarks>
            public List <XenVirtualMachine> List()
            {
                var response = client.SafeInvokeItems("vm-list", "params=all");
                var vms      = new List <XenVirtualMachine>();

                foreach (var vmProperties in response.Items)
                {
                    if (!vmProperties.TryGetValue("name-label", out var nameLabel))
                    {
                        continue;
                    }

                    vms.Add(new XenVirtualMachine(vmProperties));
                }

                return(vms);
            }