Esempio n. 1
0
        internal override void ExecuteCommand()
        {
            ServiceManagementProfile.Initialize();

            base.ExecuteCommand();
            if (CurrentDeploymentNewSM == null)
            {
                return;
            }

            DeploymentGetResponse deploymentResponse = this.ComputeClient.Deployments.GetBySlot(this.ServiceName, DeploymentSlot.Production);

            if (deploymentResponse.Roles.FirstOrDefault(r => r.RoleName.Equals(Name, StringComparison.InvariantCultureIgnoreCase)) == null)
            {
                throw new ArgumentOutOfRangeException(String.Format(Resources.RoleInstanceCanNotBeFoundWithName, Name));
            }

            if (deploymentResponse.RoleInstances.Count > 1)
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.ComputeClient.VirtualMachines.Delete(this.ServiceName, CurrentDeploymentNewSM.Name, Name));
            }
            else
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.ComputeClient.Deployments.DeleteBySlot(this.ServiceName, DeploymentSlot.Production));
            }
        }
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            if (this.Name != null)
            {
                ExecuteClientActionNewSM(null,
                                         CommandRuntime.ToString(),
                                         () => this.ManagementClient.AffinityGroups.Get(this.Name),
                                         (s, affinityGroup) => (new int[1]).Select(i => ContextFactory(affinityGroup, s,
                                                                                                       ServiceManagementProfile.Mapper.Map <AffinityGroupGetResponse, AffinityGroupContext>,
                                                                                                       ServiceManagementProfile.Mapper.Map))
                                         );
            }
            else
            {
                ExecuteClientActionNewSM(null,
                                         CommandRuntime.ToString(),
                                         () => this.ManagementClient.AffinityGroups.List(),
                                         (s, affinityGroups) => affinityGroups.AffinityGroups
                                         .Select(ag => ContextFactory(ag, s,
                                                                      ServiceManagementProfile.Mapper.Map <AffinityGroupListResponse.AffinityGroup, AffinityGroupContext>,
                                                                      ServiceManagementProfile.Mapper.Map))
                                         );
            }
        }
Esempio n. 3
0
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            if (!string.IsNullOrEmpty(this.DiskName))
            {
                this.ExecuteClientActionNewSM(
                    null,
                    this.CommandRuntime.ToString(),
                    () => this.ComputeClient.VirtualMachineDisks.GetDisk(this.DiskName),
                    (s, response) => this.ContextFactory(response, s,
                                                         ServiceManagementProfile.Mapper.Map <VirtualMachineDiskGetResponse, DiskContext>,
                                                         ServiceManagementProfile.Mapper.Map));
            }
            else
            {
                this.ExecuteClientActionNewSM(
                    null,
                    this.CommandRuntime.ToString(),
                    () => this.ComputeClient.VirtualMachineDisks.ListDisks(),
                    (s, response) => response.Disks
                    .Select(disk => this.ContextFactory(disk, s,
                                                        ServiceManagementProfile.Mapper.Map <VirtualMachineDiskListResponse.VirtualMachineDisk, DiskContext>,
                                                        ServiceManagementProfile.Mapper.Map)));
            }
        }
Esempio n. 4
0
        protected override void ProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            if (DiskConfig.DataDiskConfigurations != null)
            {
                IEnumerable <DataDiskConfiguration> dataDisks = null;

                if (string.Equals(this.ParameterSetName, RemoveByDiskNameParamSet))
                {
                    dataDisks = DiskConfig.DataDiskConfigurations.Where(
                        d => !string.Equals(d.Name, this.DataDiskName, StringComparison.OrdinalIgnoreCase));
                }
                else
                {
                    dataDisks = DiskConfig.DataDiskConfigurations.Where(
                        d => d.Lun != this.Lun
                        );
                }

                if (dataDisks != null)
                {
                    DiskConfig.DataDiskConfigurations = new DataDiskConfigurationList();
                    foreach (var dataDisk in dataDisks)
                    {
                        DiskConfig.DataDiskConfigurations.Add(dataDisk);
                    }
                }
            }

            WriteObject(DiskConfig);
        }
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            if (!string.IsNullOrEmpty(this.StorageAccountName))
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.StorageClient.StorageAccounts.Get(this.StorageAccountName),
                    (s, response) =>
                {
                    var context = ContextFactory <StorageAccountGetResponse, StorageServicePropertiesOperationContext>(response, s);
                    Mapper.Map(response.StorageAccount.Properties, context);
                    return(PSStorageService.Create(this.StorageClient, context));
                });
            }
            else
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.StorageClient.StorageAccounts.List(),
                    (s, storageServices) =>
                    storageServices.StorageAccounts.Select(r =>
                {
                    var context = ContextFactory <StorageAccount, StorageServicePropertiesOperationContext>(r, s);
                    Mapper.Map(r.Properties, context);
                    return(PSStorageService.Create(this.StorageClient, context));
                }));
            }

            WriteWarning(Resources.DeprecationOfTheGeoReplicationEnabledParamInTheGetCmdlet);
        }
Esempio n. 6
0
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            if (this.ServiceName != null)
            {
                //TODO: https://github.com/WindowsAzure/azure-sdk-for-net-pr/issues/111
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.ComputeClient.HostedServices.Get(this.ServiceName),
                    (operation, service) => new int[1].Select(i =>
                {
                    var context = ContextFactory <HostedServiceGetResponse, HostedServiceDetailedContext>(service, operation);
                    Mapper.Map(service.Properties, context);
                    return(context);
                }));
            }
            else
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.ComputeClient.HostedServices.List(),
                    (operation, services) => services.HostedServices.Select(service =>
                {
                    var context = ContextFactory <HostedServiceListResponse.HostedService, HostedServiceDetailedContext>(service, operation);
                    Mapper.Map(service.Properties, context);
                    return(context);
                }));
            }
        }
        protected override void ProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            if (DiskConfig.DataDiskConfigurations == null)
            {
                DiskConfig.DataDiskConfigurations = new DataDiskConfigurationList();
            }

            var diskConfig = DiskConfig.DataDiskConfigurations.FirstOrDefault(
                d => this.ParameterSetName == UpdateAzureVMImageParamSet
                    ? string.Equals(d.Name, this.DataDiskName, StringComparison.OrdinalIgnoreCase)
                    : d.MediaLink == this.MediaLink);

            if (diskConfig == null)
            {
                diskConfig = new DataDiskConfiguration();
                DiskConfig.DataDiskConfigurations.Add(diskConfig);
            }

            diskConfig.Name        = this.DataDiskName;
            diskConfig.HostCaching = this.HostCaching;
            diskConfig.Lun         = this.Lun;
            diskConfig.MediaLink   = this.MediaLink;

            WriteObject(DiskConfig);
        }
Esempio n. 8
0
        public void RemoveDeploymentProcess()
        {
            ServiceManagementProfile.Initialize();

            var slotType = (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true);

            DeploymentGetResponse deploymentGetResponse = this.ComputeClient.Deployments.GetBySlot(this.ServiceName, slotType);

            if (deploymentGetResponse != null && !string.IsNullOrEmpty(deploymentGetResponse.ReservedIPName))
            {
                WriteVerboseWithTimestamp(string.Format(Resources.ReservedIPNameNoLongerInUseByDeploymentButStillBeingReserved, deploymentGetResponse.ReservedIPName));
            }
            if (DeleteVHD.IsPresent)
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.ComputeClient.Deployments.DeleteByName(this.ServiceName, deploymentGetResponse.Name, DeleteVHD.IsPresent));
            }
            else
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.ComputeClient.Deployments.DeleteBySlot(this.ServiceName, slotType));
            }
        }
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            var slotType = string.IsNullOrEmpty(this.Slot) ?
                           DeploymentSlot.Production :
                           (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true);


            string deploymentName = this.ComputeClient.Deployments.GetBySlot(
                this.ServiceName,
                slotType).Name;

            ExecuteClientActionNewSM(
                null,
                CommandRuntime.ToString(),
                () =>
            {
                var parameters = new NetworkReservedIPMobilityParameters
                {
                    ServiceName    = this.ServiceName,
                    DeploymentName = deploymentName
                };

                return(this.NetworkClient.ReservedIPs.Associate(this.ReservedIPName, parameters));
            });
        }
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();
            string deploymentName = string.Empty;

            if (!string.IsNullOrEmpty(this.ServiceName))
            {
                var slotType = string.IsNullOrEmpty(this.Slot) ?
                               DeploymentSlot.Production :
                               (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true);


                deploymentName = this.ComputeClient.Deployments.GetBySlot(
                    this.ServiceName,
                    slotType).Name;
            }

            ExecuteClientActionNewSM(
                null,
                CommandRuntime.ToString(),
                () =>
            {
                var parameters = new NetworkReservedIPCreateParameters
                {
                    Name           = this.ReservedIPName,
                    Label          = this.Label,
                    Location       = this.Location,
                    ServiceName    = this.ServiceName,
                    DeploymentName = deploymentName,
                    VirtualIPName  = this.VirtualIPName
                };

                return(this.NetworkClient.ReservedIPs.Create(parameters));
            });
        }
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            if (this.Abort.IsPresent)
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.NetworkClient.Networks.AbortMigration(this.VirtualNetworkName));
            }
            else if (this.Commit.IsPresent)
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.NetworkClient.Networks.CommitMigration(this.VirtualNetworkName));
            }
            else
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.NetworkClient.Networks.PrepareMigration(this.VirtualNetworkName));
            }
        }
Esempio n. 12
0
        protected override void ExecuteCommand()
        {
            ServiceManagementProfile.Initialize();
            base.ExecuteCommand();
            if (CurrentDeploymentNewSM == null)
            {
                return;
            }

            string roleName = (this.ParameterSetName.Contains("ByName")) ? this.Name : this.VM.RoleName;

            if (this.Redeploy.IsPresent)
            { // Redeploy VM
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.ComputeClient.VirtualMachines.Redeploy(this.ServiceName, CurrentDeploymentNewSM.Name, roleName),
                    (s, response) => ContextFactory <OperationStatusResponse, ManagementOperationContext>(response, s));
            }
            else
            { // Restart VM
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.ComputeClient.VirtualMachines.Restart(this.ServiceName, CurrentDeploymentNewSM.Name, roleName),
                    (s, response) => ContextFactory <OperationStatusResponse, ManagementOperationContext>(response, s));
            }
        }
Esempio n. 13
0
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            if (this.Label == null && this.Description == null && this.ReverseDnsFqdn == null)
            {
                ThrowTerminatingError(new ErrorRecord(
                                          new Exception(
                                              Resources.LabelOrDescriptionOrReverseDnsFqdnMustBeSpecified),
                                          string.Empty,
                                          ErrorCategory.InvalidData,
                                          null));
            }

            var parameters = new HostedServiceUpdateParameters
            {
                Label          = this.Label ?? null,
                Description    = this.Description,
                ReverseDnsFqdn = this.ReverseDnsFqdn
            };

            ExecuteClientActionNewSM(parameters,
                                     CommandRuntime.ToString(),
                                     () => this.ComputeClient.HostedServices.Update(this.ServiceName, parameters));
        }
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            var parameters = new LoadBalancerUpdateParameters()
            {
                Name = this.InternalLoadBalancerName,
                FrontendIPConfiguration = new FrontendIPConfiguration
                {
                    Type       = FrontendIPConfigurationType.Private,
                    SubnetName = this.SubnetName,
                    StaticVirtualNetworkIPAddress = this.StaticVNetIPAddress == null ? null
                                                  : this.StaticVNetIPAddress.ToString()
                }
            };

            ExecuteClientActionNewSM(null,
                                     CommandRuntime.ToString(),
                                     () =>
            {
                var deploymentName = this.ComputeClient.Deployments.GetBySlot(
                    this.ServiceName,
                    DeploymentSlot.Production).Name;

                return(this.ComputeClient.LoadBalancers.Update(
                           this.ServiceName,
                           deploymentName,
                           this.InternalLoadBalancerName,
                           parameters));
            });
        }
        public void ExecuteCommand()
        {
            ServiceManagementProfile.Initialize(this);

            var truePred = (Func <HostedServiceListAvailableExtensionsResponse.ExtensionImage, bool>)(s => true);

            Func <string, Func <HostedServiceListAvailableExtensionsResponse.ExtensionImage, string>,
                  Func <HostedServiceListAvailableExtensionsResponse.ExtensionImage, bool> > predFunc =
                (x, f) => string.IsNullOrEmpty(x) ? truePred : s => string.Equals(x, f(s), StringComparison.OrdinalIgnoreCase);

            var typePred      = predFunc(this.ExtensionName, s => s.Type);
            var nameSpacePred = predFunc(this.ProviderNamespace, s => s.ProviderNamespace);
            var versionPred   = predFunc(this.Version, s => s.Version);

            ExecuteClientActionNewSM(null,
                                     CommandRuntime.ToString(),
                                     () =>
            {
                if (AllVersions.IsPresent || !string.IsNullOrEmpty(this.Version))
                {
                    return(this.ComputeClient.HostedServices.ListExtensionVersions(this.ProviderNamespace, this.ExtensionName));
                }
                else
                {
                    return(this.ComputeClient.HostedServices.ListAvailableExtensions());
                }
            },
                                     (op, response) => response.Where(typePred).Where(nameSpacePred).Where(versionPred).Select(
                                         extension => ContextFactory <HostedServiceListAvailableExtensionsResponse.ExtensionImage, ExtensionImageContext>(extension, op)));
        }
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            if (!string.IsNullOrEmpty(this.StorageAccountName))
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.StorageClient.StorageAccounts.Get(this.StorageAccountName),
                    (s, response) =>
                {
                    var context = ContextFactory <StorageServiceGetResponse, StorageServicePropertiesOperationContext>(response, s);
                    Mapper.Map(response.Properties, context);
                    return(context);
                });
            }
            else
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.StorageClient.StorageAccounts.List(),
                    (s, storageServices) =>
                    storageServices.StorageServices.Select(r =>
                {
                    var context = ContextFactory <StorageServiceListResponse.StorageService, StorageServicePropertiesOperationContext>(r, s);
                    Mapper.Map(r.Properties, context);
                    return(context);
                }));
            }
        }
Esempio n. 17
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            if (!string.IsNullOrEmpty(this.ImageName))
            {
                var imageType = new VirtualMachineImageHelper(this.ComputeClient).GetImageType(this.ImageName);
                _isOSImage = imageType.HasFlag(VirtualMachineImageType.OSImage);
                _isVMImage = imageType.HasFlag(VirtualMachineImageType.VMImage);

                if (_isOSImage && _isVMImage)
                {
                    var errorMsg = string.Format(Resources.DuplicateNamesFoundInBothVMAndOSImages, this.ImageName);
                    WriteError(new ErrorRecord(new Exception(errorMsg), string.Empty, ErrorCategory.CloseError, null));
                }
            }

            try
            {
                ServiceManagementProfile.Initialize();
                this.ValidateParameters();
                this.NewAzureVMProcess();
            }
            catch (Exception ex)
            {
                WriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.CloseError, null));
            }
        }
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            this.ExecuteClientActionNewSM(
                null,
                this.CommandRuntime.ToString(),
                () =>
            {
                AzureOperationResponse op = null;

                var imageType  = new VirtualMachineImageHelper(this.ComputeClient).GetImageType(this.ImageName);
                bool isOSImage = imageType.HasFlag(VirtualMachineImageType.OSImage);
                bool isVMImage = imageType.HasFlag(VirtualMachineImageType.VMImage);

                if (isOSImage && isVMImage)
                {
                    WriteErrorWithTimestamp(
                        string.Format(Resources.DuplicateNamesFoundInBothVMAndOSImages, this.ImageName));
                }
                else if (isVMImage)
                {
                    op = this.ComputeClient.VirtualMachineVMImages.Delete(this.ImageName, this.DeleteVHD.IsPresent);
                }
                else
                {
                    // Remove the image from the image repository
                    op = this.ComputeClient.VirtualMachineOSImages.Delete(this.ImageName, this.DeleteVHD.IsPresent);
                }

                return(op);
            });
        }
Esempio n. 19
0
        protected override void ProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            var dnsUpdateParameters = new DNSUpdateParameters()
            {
                Address = this.IPAddress,
                Name    = this.Name
            };

            ExecuteClientActionNewSM(null,
                                     CommandRuntime.ToString(),
                                     () =>
            {
                var deploymentName = this.ComputeClient.Deployments.GetBySlot(
                    this.ServiceName,
                    DeploymentSlot.Production).Name;

                return(this.ComputeClient.DnsServer.UpdateDNSServer(
                           this.ServiceName,
                           deploymentName,
                           dnsUpdateParameters.Name,
                           dnsUpdateParameters));
            });
        }
Esempio n. 20
0
        internal override void ExecuteCommand()
        {
            ServiceManagementProfile.Initialize();

            base.ExecuteCommand();
            if (CurrentDeploymentNewSM == null)
            {
                return;
            }

            var role = CurrentDeploymentNewSM.Roles.FirstOrDefault(r => r.RoleName.Equals(Name, StringComparison.InvariantCultureIgnoreCase));

            if (role == null)
            {
                throw new ApplicationException(string.Format(Resources.NoCorrespondingRoleCanBeFoundInDeployment, Name));
            }
            try
            {
                var vm           = role;
                var roleInstance = CurrentDeploymentNewSM.RoleInstances.First(r => r.RoleName == vm.RoleName);
                var vmContext    = new PersistentVMRoleContext
                {
                    ServiceName           = ServiceName,
                    Name                  = vm.RoleName,
                    DeploymentName        = CurrentDeploymentNewSM.Name,
                    AvailabilitySetName   = vm.AvailabilitySetName,
                    Label                 = vm.Label,
                    InstanceSize          = vm.RoleSize.ToString(),
                    InstanceStatus        = roleInstance.InstanceStatus,
                    IpAddress             = roleInstance.IPAddress,
                    InstanceStateDetails  = roleInstance.InstanceStateDetails,
                    PowerState            = roleInstance.PowerState.ToString(),
                    InstanceErrorCode     = roleInstance.InstanceErrorCode,
                    InstanceName          = roleInstance.InstanceName,
                    InstanceFaultDomain   = roleInstance.InstanceFaultDomain.HasValue ? roleInstance.InstanceFaultDomain.Value.ToString(CultureInfo.InvariantCulture) : null,
                    InstanceUpgradeDomain = roleInstance.InstanceUpgradeDomain.HasValue ? roleInstance.InstanceUpgradeDomain.Value.ToString(CultureInfo.InvariantCulture) : null,
                    OperationDescription  = CommandRuntime.ToString(),
                    OperationId           = GetDeploymentOperationNewSM.Id,
                    OperationStatus       = GetDeploymentOperationNewSM.Status.ToString(),
                    VM = new PersistentVM
                    {
                        AvailabilitySetName  = vm.AvailabilitySetName,
                        ConfigurationSets    = PersistentVMHelper.MapConfigurationSets(vm.ConfigurationSets),
                        DataVirtualHardDisks = Mapper.Map(vm.DataVirtualHardDisks, new Collection <DataVirtualHardDisk>()),
                        Label             = vm.Label,
                        OSVirtualHardDisk = Mapper.Map(vm.OSVirtualHardDisk, new OSVirtualHardDisk()),
                        RoleName          = vm.RoleName,
                        RoleSize          = vm.RoleSize.ToString(),
                        RoleType          = vm.RoleType,
                        DefaultWinRmCertificateThumbprint = vm.DefaultWinRmCertificateThumbprint
                    }
                };
                PersistentVMHelper.SaveStateToFile(vmContext.VM, Path);
                WriteObject(vmContext, true);
            }
            catch (Exception e)
            {
                throw new ApplicationException(string.Format(Resources.VMPropertiesCanNotBeRead, role.RoleName), e);
            }
        }
Esempio n. 21
0
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            if (this.ServiceName != null)
            {
                ExecuteClientActionNewSM(null,
                                         CommandRuntime.ToString(),
                                         () => this.ComputeClient.HostedServices.Get(this.ServiceName),
                                         (operation, service) =>
                {
                    var context = ContextFactory <HostedServiceGetResponse, HostedServiceDetailedContext>(service, operation);
                    Mapper.Map(service.Properties, context);
                    return(context);
                });
            }
            else
            {
                ExecuteClientActionNewSM(null,
                                         CommandRuntime.ToString(),
                                         () => this.ComputeClient.HostedServices.List(),
                                         (operation, services) => services.HostedServices.Select(
                                             service =>
                {
                    var context = ContextFactory <HostedServiceListResponse.HostedService, HostedServiceDetailedContext>(service, operation);
                    Mapper.Map(service.Properties, context);
                    return(context);
                }));
            }
        }
Esempio n. 22
0
        public virtual void ExecuteCommand()
        {
            ServiceManagementProfile.Initialize();

            Func <VirtualMachineExtensionListResponse.ResourceExtension, bool> truePred = s => true;

            Func <string, Func <VirtualMachineExtensionListResponse.ResourceExtension, string>,
                  Func <VirtualMachineExtensionListResponse.ResourceExtension, bool> > predFunc =
                (x, f) => string.IsNullOrEmpty(x) ? truePred : s => string.Equals(x, f(s), StringComparison.OrdinalIgnoreCase);

            var typePred      = predFunc(this.ExtensionName, s => s.Name);
            var publisherPred = predFunc(this.Publisher, s => s.Publisher);
            var versionPred   = predFunc(this.Version, s => s.Version);

            ExecuteClientActionNewSM(null,
                                     CommandRuntime.ToString(),
                                     () =>
            {
                if (this.AllVersions.IsPresent || !string.IsNullOrEmpty(this.Version))
                {
                    return(this.ComputeClient.VirtualMachineExtensions.ListVersions(this.Publisher, this.ExtensionName));
                }
                else
                {
                    return(this.ComputeClient.VirtualMachineExtensions.List());
                }
            },
                                     (op, response) => response.Where(typePred).Where(publisherPred).Where(versionPred).Select(
                                         extension => ContextFactory <VirtualMachineExtensionListResponse.ResourceExtension, VirtualMachineExtensionImageContext>(extension, op)));
        }
Esempio n. 23
0
        protected override void ExecuteCommand()
        {
            ServiceManagementProfile.Initialize();

            base.ExecuteCommand();

            if (this.CurrentDeploymentNewSM == null)
            {
                return;
            }

            string[] inputRoleNames = (this.ParameterSetName == "ByName") ? this.Name : this.VM.Select(vm => vm.GetInstance().RoleName).ToArray();

            // Generate a list of role names matching wildcard patterns or
            // the exact name specified in the -Name parameter.
            var roleNames = PersistentVMHelper.GetRoleNames(this.CurrentDeploymentNewSM.RoleInstances, inputRoleNames);

            // Insure at least one of the role name instances can be found.
            if ((roleNames == null) || (!roleNames.Any()))
            {
                throw new ArgumentOutOfRangeException(String.Format(Resources.RoleInstanceCanNotBeFoundWithName, Name));
            }

            var parameters = new VirtualMachineStartRolesParameters();

            foreach (var r in roleNames)
            {
                parameters.Roles.Add(r);
            }

            this.ExecuteClientActionNewSM(
                null,
                this.CommandRuntime.ToString(),
                () => this.ComputeClient.VirtualMachines.StartRoles(this.ServiceName, this.CurrentDeploymentNewSM.Name, parameters));
        }
 protected override void OnProcessRecord()
 {
     ServiceManagementProfile.Initialize();
     ExecuteClientActionNewSM(
         null,
         this.CommandRuntime.ToString(),
         () => this.NetworkClient.Gateways.Create(this.VNetName, new GatewayCreateParameters()));
 }
        internal void ExecuteCommand()
        {
            ServiceManagementProfile.Initialize();
            var role             = VM.GetInstance();
            var configSetbuilder = new ConfigurationSetsBuilder(role.ConfigurationSets);

            if (Linux.IsPresent)
            {
                role.NoSSHEndpoint = NoSSHEndpoint.IsPresent;
                SetProvisioningConfiguration(configSetbuilder.LinuxConfigurationBuilder.Provisioning);
                configSetbuilder.LinuxConfigurationBuilder.Provisioning.HostName = role.RoleName;

                if (!(DisableSSH.IsPresent || NoSSHEndpoint.IsPresent))
                {
                    configSetbuilder.NetworkConfigurationBuilder.AddSshEndpoint();
                }
            }
            else
            {
                role.NoRDPEndpoint = NoRDPEndpoint.IsPresent;
                SetProvisioningConfiguration(configSetbuilder.WindowsConfigurationBuilder.Provisioning);
                configSetbuilder.WindowsConfigurationBuilder.Provisioning.ComputerName = role.RoleName;

                if (!NoRDPEndpoint.IsPresent)
                {
                    configSetbuilder.NetworkConfigurationBuilder.AddRdpEndpoint();
                }

                if (!this.DisableWinRMHttps.IsPresent)
                {
                    var builder = new WinRmConfigurationBuilder();
                    if (this.EnableWinRMHttp.IsPresent)
                    {
                        builder.AddHttpListener();
                    }
                    builder.AddHttpsListener(this.WinRMCertificate);

                    configSetbuilder.WindowsConfigurationBuilder.Provisioning.WinRM = builder.Configuration;

                    if (!this.NoWinRMEndpoint.IsPresent)
                    {
                        configSetbuilder.NetworkConfigurationBuilder.AddWinRmEndpoint();
                    }
                    role.WinRMCertificate = WinRMCertificate;
                }

                role.X509Certificates = new List <X509Certificate2>();
                if (this.X509Certificates != null)
                {
                    role.X509Certificates.AddRange(this.X509Certificates);
                }
                role.NoExportPrivateKey  = this.NoExportPrivateKey.IsPresent;
                role.ProvisionGuestAgent = !DisableGuestAgent.IsPresent;
            }

            WriteObject(VM, true);
        }
Esempio n. 26
0
 protected override void OnProcessRecord()
 {
     ServiceManagementProfile.Initialize();
     ExecuteClientActionNewSM(
         null,
         this.CommandRuntime.ToString(),
         () => this.NetworkClient.StaticIPs.Check(VNetName, IPAddress),
         (operation, response) => ContextFactory <NetworkStaticIPAvailabilityResponse, VirtualNetworkStaticIPAvailabilityContext>(response, operation));
 }
        internal void ExecuteCommand()
        {
            ServiceManagementProfile.Initialize();

            ExecuteClientActionNewSM(
                null,
                CommandRuntime.ToString(),
                () => this.ManagementClient.AffinityGroups.Delete(this.Name));
        }
Esempio n. 28
0
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();
            var virtualNetworkSites = this.GetVirtualNetworkSiteProcess();

            if (virtualNetworkSites != null)
            {
                WriteObject(virtualNetworkSites, true);
            }
        }
 protected override void OnProcessRecord()
 {
     ServiceManagementProfile.Initialize();
     WriteObject(new InternalLoadBalancerConfig
     {
         InternalLoadBalancerName = this.InternalLoadBalancerName,
         SubnetName = this.SubnetName,
         IPAddress  = this.StaticVNetIPAddress == null ? null : this.StaticVNetIPAddress.ToString()
     });
 }
Esempio n. 30
0
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            ExecuteClientActionNewSM(
                null,
                CommandRuntime.ToString(),
                () => this.ComputeClient.OperatingSystems.List(),
                (op, oSes) => oSes.OperatingSystems.Select(os => ContextFactory <OperatingSystemListResponse.OperatingSystem, OSVersionsContext>(os, op)));
        }