private static void CacheWorkerRole180(string rootPath, RoleInfo cacheRoleInfo) { // Fetch cache role information from service definition and service configuration files. CloudServiceProject cloudServiceProject = new CloudServiceProject(rootPath, null); WorkerRole cacheWorkerRole = cloudServiceProject.Components.GetWorkerRole(cacheRoleInfo.Name); RoleSettings cacheRoleSettings = cloudServiceProject.Components.GetCloudConfigRole(cacheRoleInfo.Name); // Add caching module to the role imports cacheWorkerRole.Imports = GeneralUtilities.ExtendArray<Import>( cacheWorkerRole.Imports, new Import { moduleName = Resources.CachingModuleName }); // Enable caching Diagnostic store. LocalStore diagnosticStore = new LocalStore { name = Resources.CacheDiagnosticStoreName, cleanOnRoleRecycle = false }; cacheWorkerRole.LocalResources = GeneralUtilities.InitializeIfNull<LocalResources>(cacheWorkerRole.LocalResources); cacheWorkerRole.LocalResources.LocalStorage = GeneralUtilities.ExtendArray<LocalStore>( cacheWorkerRole.LocalResources.LocalStorage, diagnosticStore); // Remove input endpoints. cacheWorkerRole.Endpoints.InputEndpoint = null; // Add caching configuration settings AddCacheConfiguration(cloudServiceProject.Components.GetCloudConfigRole(cacheRoleInfo.Name)); AddCacheConfiguration( cloudServiceProject.Components.GetLocalConfigRole(cacheRoleInfo.Name), Resources.EmulatorConnectionString); cloudServiceProject.Components.Save(cloudServiceProject.Paths); }
/// <summary> /// Configuration required to enable dedicated caching on a given role. /// </summary> /// <param name="rootPath">The service project root path</param> /// <param name="cacheRoleInfo">The cache role info</param> private static void CacheRole180(string rootPath, RoleInfo cacheRoleInfo) { CloudServiceProject cloudServiceProject = new CloudServiceProject(rootPath, null); if (!cloudServiceProject.Components.IsWebRole(cacheRoleInfo.Name)) { CacheWorkerRole180(rootPath, cacheRoleInfo); } }
public static void AreEqualServiceConfiguration(ServiceConfiguration actual, string serviceName, RoleInfo[] roles = null) { Assert.AreEqual<string>(actual.serviceName, serviceName); if (roles != null) { Assert.AreEqual<int>(actual.Role.Length, roles.Length); int length = roles.Length; for (int i = 0; i < length; i++) { Assert.IsTrue(roles[i].Equals(actual.Role[i])); } } }
protected override void OnProcessing(RoleInfo roleInfo) { var interpPath = FindPythonInterpreterPath(); if (interpPath != null) { string stdOut, stdErr; string originalDir = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(Path.Combine(RootPath, roleInfo.Name)); try { ProcessHelper.StartAndWaitForProcess( new ProcessStartInfo( Path.Combine(interpPath, PythonInterpreterExe), string.Format(DjangoStartProjectCommand, roleInfo.Name) ), out stdOut, out stdErr); } finally { Directory.SetCurrentDirectory(originalDir); } if (!string.IsNullOrEmpty(stdErr)) { WriteWarning(string.Format(Resources.UnableToCreateDjangoApp, stdErr)); WriteWarning(Resources.UnableToCreateDjangoAppFix); } } else { WriteWarning(Resources.MissingPythonPreReq); } }
protected virtual void OnProcessing(RoleInfo roleInfo) { // Placeholder for work to do after adding the role scaffolding. }
public void ChangeRolePermissions(RoleInfo role) { string rolePath = Path.Combine(Paths.RootPath, role.Name); DirectoryInfo directoryInfo = new DirectoryInfo(rolePath); DirectorySecurity directoryAccess = directoryInfo.GetAccessControl(AccessControlSections.All); directoryAccess.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null), FileSystemRights.ReadAndExecute | FileSystemRights.Write, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow)); directoryInfo.SetAccessControl(directoryAccess); }
/// <summary> /// Adds the given role to both config files and the service def. /// </summary> /// <param name="role"></param> private void AddPythonRoleCore(RoleInfo role, RoleType type) { Dictionary<string, object> parameters = CreateDefaultParameters(role); string scaffoldPath = Path.Combine(Path.Combine(scaffoldingFolderPath, Resources.PythonScaffolding), type.ToString()); Scaffold.GenerateScaffolding(scaffoldPath, Path.Combine(Paths.RootPath, role.Name), parameters); }
private Dictionary<string, object> CreateDefaultParameters(RoleInfo role) { Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters[ScaffoldParams.Role] = role; parameters[ScaffoldParams.Components] = Components; parameters[ScaffoldParams.RoleName] = role.Name; parameters[ScaffoldParams.InstancesCount] = role.InstanceCount; parameters[ScaffoldParams.Port] = Components.GetNextPort(); parameters[ScaffoldParams.Paths] = Paths; return parameters; }
/// <summary> /// Adds the given role to both config files and the service def. /// </summary> private void AddRoleCore(string scaffolding, RoleInfo role) { Dictionary<string, object> parameters = CreateDefaultParameters(role); parameters[ScaffoldParams.NodeModules] = General.GetNodeModulesPath(); parameters[ScaffoldParams.NodeJsProgramFilesX86] = General.GetWithProgramFilesPath(Resources.NodeProgramFilesFolderName, false); GenerateScaffolding(scaffolding, role.Name, parameters); }
public static void AzureServiceExists(string serviceRootPath, string scaffoldFilePath, string serviceName, ServiceSettings settings = null, WebRoleInfo[] webRoles = null, WorkerRoleInfo[] workerRoles = null, string webScaff = null, string workerScaff = null, RoleInfo[] roles = null) { ServiceComponents components = new ServiceComponents(new PowerShellProjectPathInfo(serviceRootPath)); ScaffoldingExists(serviceRootPath, scaffoldFilePath); if (webRoles != null) { for (int i = 0; i < webRoles.Length; i++) { ScaffoldingExists(Path.Combine(serviceRootPath, webRoles[i].Name), webScaff); } } if (workerRoles != null) { for (int i = 0; i < workerRoles.Length; i++) { ScaffoldingExists(Path.Combine(serviceRootPath, workerRoles[i].Name), workerScaff); } } AreEqualServiceConfiguration(components.LocalConfig, serviceName, roles); AreEqualServiceConfiguration(components.CloudConfig, serviceName, roles); IsValidServiceDefinition(components.Definition, serviceName, webRoles, workerRoles); AreEqualServiceSettings(settings ?? new ServiceSettings(), components.Settings); }
protected virtual void OnProcessing(RoleInfo roleInfo) { // Placeholder for work to do after adding the role scaffolding. }
/// <summary> /// Adds the given role to both config files and the service def. /// </summary> private void AddRoleCore(string scaffolding, RoleInfo role) { Dictionary<string, object> parameters = CreateDefaultParameters(role); parameters[ScaffoldParams.NodeModules] = Path.Combine( FileUtilities.GetAssemblyDirectory(), Resources.NodeModulesPath); parameters[ScaffoldParams.NodeJsProgramFilesX86] = FileUtilities.GetWithProgramFilesPath(Resources.NodeProgramFilesFolderName, false); GenerateScaffolding(scaffolding, role.Name, parameters); }