Exemplo n.º 1
0
        private Management.Compute.Models.Role CreatePersistentVMRole(Tuple <Model.PersistentVM, bool, bool> tuple, CloudStorageAccount currentStorage)
        {
            Model.PersistentVM persistentVM = tuple.Item1;
            bool isVMImage = tuple.Item3;

            var mediaLinkFactory = new MediaLinkFactory(currentStorage, this.ServiceName, persistentVM.RoleName);

            if (!isVMImage)
            {
                if (persistentVM.OSVirtualHardDisk.MediaLink == null && string.IsNullOrEmpty(persistentVM.OSVirtualHardDisk.DiskName))
                {
                    persistentVM.OSVirtualHardDisk.MediaLink = mediaLinkFactory.Create();
                }
            }

            foreach (var datadisk in persistentVM.DataVirtualHardDisks.Where(d => d.MediaLink == null && string.IsNullOrEmpty(d.DiskName)))
            {
                datadisk.MediaLink = mediaLinkFactory.Create();
            }

            var result = new Management.Compute.Models.Role
            {
                AvailabilitySetName = persistentVM.AvailabilitySetName,
                OSVirtualHardDisk   = isVMImage ? null : Mapper.Map(persistentVM.OSVirtualHardDisk, new Management.Compute.Models.OSVirtualHardDisk()),
                RoleName            = persistentVM.RoleName,
                RoleSize            = persistentVM.RoleSize,
                RoleType            = persistentVM.RoleType,
                Label = persistentVM.Label,
                ProvisionGuestAgent         = persistentVM.ProvisionGuestAgent,
                ResourceExtensionReferences = persistentVM.ProvisionGuestAgent != null && persistentVM.ProvisionGuestAgent.Value ? Mapper.Map <List <ResourceExtensionReference> >(persistentVM.ResourceExtensionReferences) : null,
                VMImageName = isVMImage ? persistentVM.OSVirtualHardDisk.SourceImageName : null
            };

            if (result.OSVirtualHardDisk != null)
            {
                result.OSVirtualHardDisk.IOType = null;
            }

            if (persistentVM.DataVirtualHardDisks != null && persistentVM.DataVirtualHardDisks.Any())
            {
                persistentVM.DataVirtualHardDisks.ForEach(c =>
                {
                    var dataDisk = Mapper.Map(c, new Microsoft.WindowsAzure.Management.Compute.Models.DataVirtualHardDisk());
                    dataDisk.LogicalUnitNumber = dataDisk.LogicalUnitNumber;
                    result.DataVirtualHardDisks.Add(dataDisk);
                });
                result.DataVirtualHardDisks.ForEach(d => d.IOType = null);
            }
            else
            {
                result.DataVirtualHardDisks = null;
            }

            if (persistentVM.ConfigurationSets != null)
            {
                PersistentVMHelper.MapConfigurationSets(persistentVM.ConfigurationSets).ForEach(c => result.ConfigurationSets.Add(c));
            }

            return(result);
        }
Exemplo n.º 2
0
 public GetAzureDataDiskCmdletInfo(Model.PersistentVM vM)
 {
     this.cmdletName = Utilities.GetAzureDataDiskCmdletName;
     this.cmdletParams.Add(new CmdletParam("VM", vM));
 }
 public RemoveAzureDataDiskConfig(int lun, Model.PersistentVM vm)
 {
     this.Vm = vm;
     this.lun = lun;
 }
Exemplo n.º 4
0
 public RemoveAzureDataDiskConfig(int lun, Model.PersistentVM vm)
 {
     this.Vm  = vm;
     this.lun = lun;
 }