Creates a deployment for a virtual machine and allows some preconfigured defaults from the image gallery
Inheritance: Elastacloud.AzureManagement.Fluent.Commands.Services.ServiceCommand
        private void CheckVmDeploymentIsRunning(List<LinuxVirtualMachineProperties> properties)
        {
            // 1. Get the number of vms in the role and create a binary list
            var linuxProperties = new Dictionary<string, RoleInstanceStatus>();
            properties.ForEach(property => linuxProperties.Add(property.HostName, RoleInstanceStatus.RoleStateUnknown));
            var vmProperties = new LinuxVirtualMachineProperties() {CloudServiceName = properties[0].CloudServiceName};
            // 2. Set the value to if the vm is running or not
            int index = 0;
            // time this out just in case after an hour?
            while (linuxProperties.Any(role => role.Value != RoleInstanceStatus.ReadyRole) || index == 360)
            {
                var command = new GetVirtualMachineContextCommand(vmProperties)
                {
                    SubscriptionId = SubscriptionId,
                    Certificate = ManagementCertificate
                };
                command.Execute();
                command.PersistentVm.ForEach(vm =>
                {
                    if (linuxProperties[vm.RoleName] == vm.Status) return;
                    // raise the event with the old and new status
                    LinuxVirtualMachineStatusEvent(this, new VirtualMachineStatus()
                    {
                        NewStatus = vm.Status,
                        OldStatus = linuxProperties[vm.RoleName],
                        VirtualMachineInstanceName = vm.RoleName,
                        CloudService = vmProperties.CloudServiceName
                    });
                    // update the status in the dictionary
                    linuxProperties[vm.RoleName] = vm.Status;
                });
                index++;
                // TODO: advice from Zak on the best way to use task.delay instead
                Thread.Sleep(TimeSpan.FromSeconds(10));
            }

            if (index == 360)
            {
                throw new FluentManagementException("timed out listening for status changes - check vms are running correctly", "LinuxVirtualMachineClient");
            }
        }
        /// <summary>
        /// Gets a list of hosts, internal ip addresses and other things
        /// </summary>
        public List<VmHost> GetHostDetails(string cloudServiceName)
        {
            var hosts = new List<VmHost>();

            var command = new GetVirtualMachineContextCommand(cloudServiceName)
            {
                SubscriptionId = SubscriptionId,
                Certificate = ManagementCertificate
            };
            command.Execute();
            if (command.PersistentVm == null && command.ResponseStackTrace != null)
            {
                throw new FluentManagementException(command.ResponseStackTrace, "LinuxVirtualMachineClient");
            }
            var persistentHosts = command.PersistentVm.ToList();

            persistentHosts.ForEach(vm => hosts.Add(new VmHost()
            {
                HostName = vm.RoleName,
                IpAddress = vm.IPAddress,
                RoleName = vm.RoleName,
                Endpoints = vm.NetworkConfigurationSet.InputEndpoints.Endpoints.AsReadOnly()
            }));
            return hosts;
        }