示例#1
0
        /// <summary>
        /// Used to create a deployment and add any persistent vm role to the deployment
        /// </summary>
        /// <param name="properties"></param>
        /// <param name="roles">The PersistentVMRole</param>
        /// <returns>The Deployment that is being used</returns>
        private static Deployment AddPersistentVMRole(VirtualMachineProperties properties, IEnumerable <PersistentVMRole> roles)
        {
            var namer      = new RandomAccountName();
            var deployment = new Deployment
            {
                // use the first deployment property if it's not the same then fluent doesn't supporting deployment splitting at this level!
                Name = properties.DeploymentName,
//                                     Label = Convert.ToBase64String(Encoding.UTF8.GetBytes(cloudServiceName))
                Label = properties.DeploymentName
            };

            if (properties.VirtualNetwork != null)
            {
                deployment.VirtualNetworkName = properties.VirtualNetwork.VirtualNetworkName;
            }
            var roleList = new RoleList();

            foreach (var role in roles)
            {
                role.RoleName = role.RoleName ?? namer.GetPureRandomValue();
                roleList.Roles.Add(role);
            }

            deployment.RoleList = roleList;
            return(deployment);
        }
        /// <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.None,
                DiskLabel = diskLabel,
                DiskName = diskName,
                MediaLink =
                    String.Format("http://{0}.blob.core.windows.net/vhds/{1}-{2}.vhd", storageAccountName,
                                  namer.GetNameFromInitString(diskName), DateTime.Now.ToString("ddmmyy")),
            });
        }
示例#3
0
        /// <summary>
        /// Gets the Xml tree for the custom serialiser
        /// </summary>
        /// <returns>An XElement </returns>
        public XElement GetXmlTree()
        {
            var      namer   = new RandomAccountName();
            XElement element = null;

            if (RoleName != null)
            {
                element = new XElement(Namespaces.NsWindowsAzure + "Role",
                                       new XElement(Namespaces.NsWindowsAzure + "RoleName", RoleName),
                                       new XElement(Namespaces.NsWindowsAzure + "RoleType", RoleType));
            }
            else
            {
                element = new XElement(Namespaces.NsWindowsAzure + "PersistentVMRole");
            }
            XElement configurationSets = new XElement(Namespaces.NsWindowsAzure + "ConfigurationSets",
                                                      NetworkConfigurationSet.GetXmlTree());

            if (OperatingSystemConfigurationSet != null)
            {
                configurationSets.Add(OperatingSystemConfigurationSet.GetXmlTree());
            }
            element.Add(configurationSets);
            if (HardDisks != null)
            {
                element.Add(HardDisks.GetXmlTree());
            }
            if (RoleName != null)
            {
                element.Add(new XElement(Namespaces.NsWindowsAzure + "Label", Convert.ToBase64String(Encoding.UTF8.GetBytes(RoleName))));
            }
            if (OSHardDisk != null)
            {
                element.Add(OSHardDisk.GetXmlTree());
            }
            // TODO: Another hack the enum value is always present here so assume if we have no OS hard disk then we don't need a role size
            if (OSHardDisk != null)
            {
                element.Add(new XElement(Namespaces.NsWindowsAzure + "RoleSize", RoleSize.ToString()));
            }
            if (AvailabilityNameSet != null)
            {
                element.Add(new XElement(Namespaces.NsWindowsAzure + "AvailabilitySetName", AvailabilityNameSet));
            }
            return(element);
        }
示例#4
0
        /// <summary>
        /// Used to create a deployment and add any persistent vm role to the deployment
        /// </summary>
        /// <param name="role">The PersistentVMRole</param>
        /// <param name="cloudServiceName">The Name of the cloud service which the role is present in</param>
        /// <returns>The Deployment that is being used</returns>
        private static Deployment AddPersistentVMRole(string cloudServiceName, PersistentVMRole role)
        {
            var namer      = new RandomAccountName();
            var deployment = new Deployment
            {
                Name = cloudServiceName,
//                                     Label = Convert.ToBase64String(Encoding.UTF8.GetBytes(cloudServiceName))
                Label = cloudServiceName
            };

            role.RoleName = namer.GetPureRandomValue();
            var roleList = new RoleList();

            roleList.Roles.Add(role);
            deployment.RoleList = roleList;
            return(deployment);
        }
示例#5
0
        /// <summary>
        /// Gets the Xml tree for the custom serialiser
        /// </summary>
        /// <returns>An XElement </returns>
        public XElement GetXmlTree()
        {
            var namer = new RandomAccountName();

            // if the timezone is set to null then set it GMT
            TimeZone = TimeZone ?? "GMT Standard Time";
            var element = new XElement(Namespaces.NsWindowsAzure + "ConfigurationSet",
                                       new XElement(Namespaces.NsWindowsAzure + "ConfigurationSetType", ConfigurationSetType.ToString()),
                                       new XElement(Namespaces.NsWindowsAzure + "ComputerName", namer.GetPureRandomValue().ToUpper()),
                                       new XElement(Namespaces.NsWindowsAzure + "AdminPassword", AdminPassword),
                                       new XElement(Namespaces.NsWindowsAzure + "ResetPasswordOnFirstLogon", ResetPasswordOnFirstLogon.ToString(CultureInfo.InvariantCulture).ToLower()),
                                       new XElement(Namespaces.NsWindowsAzure + "EnableAutomaticUpdates", EnableAutomaticUpdate.ToString(CultureInfo.InvariantCulture).ToLower()),
                                       new XElement(Namespaces.NsWindowsAzure + "TimeZone", TimeZone));

            //if (ComputerName != null)
            //    element.Add(new XElement(Namespaces.NsWindowsAzure + "ComputerName",
            //                             ComputerName.ToString(CultureInfo.InvariantCulture)));
            return(element);
        }
示例#6
0
        /// <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,
            });
        }
示例#7
0
        /// <summary>
        /// Gets the Xml tree for the custom serialiser
        /// </summary>
        /// <returns>An XElement </returns>
        public XElement GetXmlTree()
        {
            var namer   = new RandomAccountName();
            var element = new XElement(Namespaces.NsWindowsAzure + "Role",
                                       new XElement(Namespaces.NsWindowsAzure + "RoleName", RoleName),
                                       new XElement(Namespaces.NsWindowsAzure + "RoleType", RoleType));
            var configurationSets = new XElement(Namespaces.NsWindowsAzure + "ConfigurationSets", OperatingSystemConfigurationSet.GetXmlTree(),
                                                 NetworkConfigurationSet.GetXmlTree());

            element.Add(configurationSets);
            element.Add(HardDisks.GetXmlTree());
            element.Add(new XElement(Namespaces.NsWindowsAzure + "Label", Convert.ToBase64String(Encoding.UTF8.GetBytes(RoleName))));
            element.Add(OSHardDisk.GetXmlTree());
            element.Add(new XElement(Namespaces.NsWindowsAzure + "RoleSize", RoleSize.ToString()));
            if (AvailabilityNameSet != null)
            {
                element.Add(AvailabilityNameSet);
            }
            return(element);
        }