コード例 #1
0
        /// <summary>
        /// Restarts the virtual machine instance
        /// </summary>
        public void Restart()
        {
            // start the role up -- this could take a while the previous two operations are fairly lightweight
            // and the provisioning doesn't occur until the role starts not when it is created
            var restartCommand = new StartVirtualMachineCommand(Properties)
            {
                SubscriptionId = Properties.SubscriptionId,
                Certificate    = Properties.Certificate
            };

            restartCommand.Execute();
        }
コード例 #2
0
 /// <summary>
 /// Restarts the virtual machine instance
 /// </summary>
 public void Restart()
 {
     // start the role up -- this could take a while the previous two operations are fairly lightweight
     // and the provisioning doesn't occur until the role starts not when it is created
     Trace.WriteLine(String.Format("Restarting {0} virtual machines in deployment {1} in cloud service {2}",
                                   Properties.Count, Properties.First().DeploymentName, Properties.First().CloudServiceName));
     foreach (var linuxVirtualMachineProperty in Properties)
     {
         var restartCommand = new StartVirtualMachineCommand(linuxVirtualMachineProperty)
         {
             SubscriptionId = SubscriptionId,
             Certificate    = ManagementCertificate
         };
         restartCommand.Execute();
         Trace.WriteLine(String.Format("VM restarted with hostname {0}", linuxVirtualMachineProperty.HostName));
     }
 }
コード例 #3
0
        /// <summary>
        /// Creates a new virtual machine from a gallery template
        /// </summary>
        /// <param name="properties">Can be any gallery template</param>
        public IVirtualMachineClient CreateNewVirtualMachineFromTemplateGallery(WindowsVirtualMachineProperties properties)
        {
            // for the time being we're going to adopt the default powershell cmdlet behaviour and always create a new cloud services
            EnsureVirtualMachineProperties(properties);
            if (!properties.UseExistingCloudService)
            {
                var cloudServiceCommand = new CreateCloudServiceCommand(properties.CloudServiceName, "Created by Fluent Management", properties.Location)
                {
                    SubscriptionId = properties.SubscriptionId,
                    Certificate    = properties.Certificate
                };
                cloudServiceCommand.Execute();
            }
            // continue to the create the virtual machine in the cloud service
            var command = new CreateWindowsVirtualMachineDeploymentCommand(properties)
            {
                SubscriptionId = properties.SubscriptionId,
                Certificate    = properties.Certificate
            };

            command.Execute();
            // start the role up -- this could take a while the previous two operations are fairly lightweight
            // and the provisioning doesn't occur until the role starts not when it is created
            var startCommand = new StartVirtualMachineCommand(properties)
            {
                SubscriptionId = properties.SubscriptionId,
                Certificate    = properties.Certificate
            };

            startCommand.Execute();
            // important here to force a refresh - just in case someone to conduct an operation on the VM in a single step
            Properties = properties;
            var vm = VirtualMachine;

            // create a new client and return this so that properties can be populated automatically
            return(new WindowsVirtualMachineClient(properties));
        }