コード例 #1
0
        public void GetAzureRuntimesProcess(string runtimeType, string manifest = null)
        {
            CloudRuntimeCollection runtimes;

            CloudRuntimeCollection.CreateCloudRuntimeCollection(out runtimes, manifest);
            WriteObject(runtimes.Where <CloudRuntimePackage>(p => string.IsNullOrEmpty(runtimeType) ||
                                                             p.Runtime == CloudRuntime.GetRuntimeByType(runtimeType)).ToList <CloudRuntimePackage>(), true);
        }
コード例 #2
0
        /// <summary>
        /// Retrieve the runtimes from the given manifest, or from the default cloud location, if none given.
        /// The manifest parameter is mainly a testing hook.
        /// </summary>
        /// <param name="runtimeType">The runtime type to filter by</param>
        /// <param name="rootPath">The path to the service in question</param>
        /// <param name="manifest">The path to the manifest file, if null, the default cloud manifest is used (test hook)</param>
        public void GetAzureRuntimesProcess(string runtimeType, string rootPath, string manifest = null)
        {
            AzureService           service  = new AzureService(rootPath, null);
            CloudRuntimeCollection runtimes = service.GetCloudRuntimes(service.Paths, manifest);

            WriteObject(runtimes.Where <CloudRuntimePackage>(p => string.IsNullOrEmpty(runtimeType) ||
                                                             p.Runtime == CloudRuntime.GetRuntimeByType(runtimeType)), true);
        }
コード例 #3
0
        /// <summary>
        /// Checks if memcache is already enabled or not for the given role startup.
        /// It does this by checking the role startup task.
        /// </summary>
        /// <param name="startup">The role startup</param>
        /// <returns>Either enabled or not</returns>
        private bool IsCacheEnabled(Startup startup)
        {
            if (startup.Task != null)
            {
                return(Array.Exists <Variable>(CloudRuntime.GetRuntimeStartupTask(startup).Environment,
                                               v => v.name.Equals(Resources.RuntimeTypeKey) && v.value.Contains(Resources.CacheRuntimeValue)));
            }

            return(false);
        }
コード例 #4
0
        /// <summary>
        /// Main entry for enabling memcache.
        /// </summary>
        /// <param name="roleName">The web role name</param>
        /// <param name="cacheWorkerRoleName">The cache worker role name</param>
        /// <param name="rootPath">The service root path</param>
        /// <param name="message">The resulted message</param>
        /// <param name="azureService">The azure service instance</param>
        /// <param name="webRole">The web role to enable caching one</param>
        private void EnableMemcache(string roleName, string cacheWorkerRoleName, ref string message, ref AzureService azureService)
        {
            // Add MemcacheShim runtime installation.
            azureService.AddRoleRuntime(azureService.Paths, roleName, Resources.CacheRuntimeValue, CacheRuntimeVersion);

            // Fetch web role information.
            Startup startup = azureService.Components.GetRoleStartup(roleName);

            // Assert that cache runtime is added to the runtime startup.
            Debug.Assert(Array.Exists <Variable>(CloudRuntime.GetRuntimeStartupTask(startup).Environment,
                                                 v => v.name.Equals(Resources.RuntimeTypeKey) && v.value.Contains(Resources.CacheRuntimeValue)));

            if (azureService.Components.IsWebRole(roleName))
            {
                WebRole webRole = azureService.Components.GetWebRole(roleName);
                webRole.LocalResources = General.InitializeIfNull <LocalResources>(webRole.LocalResources);
                DefinitionConfigurationSetting[] configurationSettings = webRole.ConfigurationSettings;

                CachingConfigurationFactoryMethod(
                    azureService,
                    roleName,
                    true,
                    cacheWorkerRoleName,
                    webRole.Startup,
                    webRole.Endpoints,
                    webRole.LocalResources,
                    ref configurationSettings,
                    CacheRuntimeVersion);
                webRole.ConfigurationSettings = configurationSettings;
            }
            else
            {
                WorkerRole workerRole = azureService.Components.GetWorkerRole(roleName);
                workerRole.LocalResources = General.InitializeIfNull <LocalResources>(workerRole.LocalResources);
                DefinitionConfigurationSetting[] configurationSettings = workerRole.ConfigurationSettings;

                CachingConfigurationFactoryMethod(
                    azureService,
                    roleName,
                    false,
                    cacheWorkerRoleName,
                    workerRole.Startup,
                    workerRole.Endpoints,
                    workerRole.LocalResources,
                    ref configurationSettings,
                    CacheRuntimeVersion);
                workerRole.ConfigurationSettings = configurationSettings;
            }

            // Save changes
            azureService.Components.Save(azureService.Paths);

            message = string.Format(Resources.EnableMemcacheMessage, roleName, cacheWorkerRoleName, Resources.MemcacheEndpointPort);
        }
コード例 #5
0
        /// <summary>
        /// Get the startup task environment settings for the given role
        /// </summary>
        /// <param name="definition">The definition containign the role</param>
        /// <param name="roleName">The name of the role</param>
        /// <returns>The environment settings for the role, or null if the role is not found</returns>
        private static Variable[] GetRoleRuntimeEnvironment(ServiceDefinition definition, string roleName)
        {
            WebRole webRole;

            if (TryGetWebRole(definition, roleName, out webRole))
            {
                return(CloudRuntime.GetRuntimeStartupTask(webRole.Startup).Environment);
            }

            WorkerRole workerRole;

            if (TryGetWorkerRole(definition, roleName, out workerRole))
            {
                return(CloudRuntime.GetRuntimeStartupTask(workerRole.Startup).Environment);
            }

            return(null);
        }
コード例 #6
0
        /// <summary>
        /// Apply the specified Variable values to the specified role's startup task environment
        /// </summary>
        /// <param name="definition">The service definition containing the role</param>
        /// <param name="roleName">The name of the role to change</param>
        /// <param name="environment">The Variables containing the changes</param>
        /// <returns>true if the variables environment is successfully changed</returns>
        private static bool ApplyRuntimeChanges(ServiceDefinition definition, string roleName, Variable[] environment)
        {
            WebRole webRole;

            if (TryGetWebRole(definition, roleName, out webRole))
            {
                CloudRuntime.GetRuntimeStartupTask(webRole.Startup).Environment = environment;
                return(true);
            }

            WorkerRole workerRole;

            if (TryGetWorkerRole(definition, roleName, out workerRole))
            {
                CloudRuntime.GetRuntimeStartupTask(workerRole.Startup).Environment = environment;
                return(true);
            }

            return(false);
        }