GetNameFromInitString() public method

Gets a name given an init string - name can be anything
public GetNameFromInitString ( string initString ) : string
initString string Init string is a prefix for the name
return string
Ejemplo n.º 1
0
 public static OSVirtualHardDisk GetCustomServerOSImage(string storageAccountName, string imageName, string diskName = null, string diskLabel = null)
 {
     var namer = new RandomAccountName();
     return new OSVirtualHardDisk
                {
                    DiskLabel = diskLabel,
                    DiskName = diskName,
                    MediaLink =
                        String.Format("http://{0}.blob.core.windows.net/vhds/{1}{2}.vhd", storageAccountName,
                                      namer.GetNameFromInitString("os"), DateTime.Now.ToString("ddmmyy")),
                    SourceImageName = imageName,
                    HostCaching = HostCaching.ReadWrite,
                };
 }
 /// <summary>
 /// Gets a virtual disk located in blob storage and sets a default size to the disk of 30 GB and a logical unit no. of 0 (drive e:)
 /// </summary>
 /// <param name="storageAccountName">The path to blob storage for the disk</param>
 /// <param name="size">the size of the disk in GB - can be up to 1TB</param>
 /// <param name="logicalUnitNumber">number between 0 and 15 which is the logical unit of the drive</param>
 /// <param name="diskName">the name of the disk</param>
 /// <param name="diskLabel">the label of the disk</param>
 /// <returns></returns>
 public static DataVirtualHardDisk GetDefaultDataDisk(string storageAccountName, int size = 30, int logicalUnitNumber = 0, string diskName = null, string diskLabel = null)
 {
     var namer = new RandomAccountName();
     return new DataVirtualHardDisk
                {
                    LogicalDiskSizeInGB = size,
                    LogicalUnitNumber = logicalUnitNumber,
                    HostCaching = HostCaching.ReadWrite,
                    DiskLabel = diskLabel,
                    DiskName = diskName,
                    MediaLink =
                        String.Format("http://{0}.blob.core.windows.net/vhds/{1}-{2}.vhd", storageAccountName,
                                      namer.GetNameFromInitString("data"), DateTime.Now.ToString("ddmmyy")),
                };
 }
 /// <summary>
 /// This gets the host OS image of Windows Server Data Centre and SQL Server 2012
 /// </summary>
 /// <param name="storageAccountName">The path to the media space in blob storage where the host vhd will be placed</param>
 /// <param name="diskName">The name of the C: drive </param>
 /// <param name="diskLabel">The drive volume label for C:</param>
 /// <returns>An OSVirtualHardDisk instance</returns>
 public static OSVirtualHardDisk GetSqlServerOSImage(string storageAccountName, string diskName = null, string diskLabel = null)
 {
     /*<OSVirtualHardDisk>
                 <MediaLink>http://elastacacheweb.blob.core.windows.net/vhds/elastasql.vhd</MediaLink>
                 <SourceImageName>MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd</SourceImageName>
             </OSVirtualHardDisk>*/
     var namer = new RandomAccountName();
     return new OSVirtualHardDisk
                {
                    DiskLabel = diskLabel,
                    DiskName = diskName,
                    MediaLink = String.Format("http://{0}.blob.core.windows.net/vhds/{1}{2}.vhd", storageAccountName, namer.GetNameFromInitString("os"), DateTime.Now.ToString("ddmmyy")),
                    SourceImageName = "MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd",
                    HostCaching = HostCaching.ReadWrite,
                };
 }
        /// <summary>
        /// This gets the host OS image of Windows Server Data Centre and SQL Server 2012
        /// </summary>
        /// <param name="properties">The path to the media space in blob storage where the host vhd will be placed</param>
        /// <returns>An OSVirtualHardDisk instance</returns>
        public static OSVirtualHardDisk GetWindowsOSImageFromTemplate(WindowsVirtualMachineProperties properties)
        {
            /*<OSVirtualHardDisk>
                        <MediaLink>http://elastacacheweb.blob.core.windows.net/vhds/elastasql.vhd</MediaLink>
                        <SourceImageName>MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd</SourceImageName>
              </OSVirtualHardDisk>*/
            string templateDetails = null;
            switch (properties.VirtualMachineType)
            {
                case VirtualMachineTemplates.BiztalkServer2012:
                    templateDetails = VmConstants.VmTemplateBiztalk;
                    break;
                case VirtualMachineTemplates.SqlServer2012:
                    templateDetails = VmConstants.VmTemplateSqlServer2012Eval;
                    break;
                case VirtualMachineTemplates.WindowsServer2008R2SP1:
                    templateDetails = VmConstants.VmTemplateWin2K8SP1DataCentreServerDecember2012;
                    break;
                case VirtualMachineTemplates.WindowsServer2012:
                    templateDetails = VmConstants.VmTemplateWin2012DataCentreServerDecember2012;
                    break;
            }
            if(templateDetails == null && properties.CustomTemplateName == null)
                throw new FluentManagementException("no template specified cannot proceed", "CreateWindowsVirtualMachineDeploymentCommand");

            var namer = new RandomAccountName();
            return new OSVirtualHardDisk
            {
                DiskLabel = "OsDisk",
                DiskName = "OsDisk",
                MediaLink = String.Format("http://{0}.blob.core.windows.net/vhds/{1}{2}.vhd", properties.StorageAccountName, namer.GetNameFromInitString("os"), DateTime.Now.ToString("ddmmyy")),

                SourceImageName = templateDetails,
                HostCaching = HostCaching.ReadWrite,
            };
        }