/// <summary> /// Adds the given role to both config files and the service def. /// </summary> /// <param name="role"></param> private void AddRoleCore(RoleInfo role, RoleType type) { 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; parameters[ScaffoldParams.NodeModules] = General.GetNodeModulesPath(); string scaffoldPath = Path.Combine(Path.Combine(scaffoldingFolderPath, Resources.NodeScaffolding), type.ToString()); Scaffold.GenerateScaffolding(scaffoldPath, Path.Combine(Paths.RootPath, 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 AzureDeploymentCmdlets.Model.ServiceComponents(new AzureDeploymentCmdlets.Model.ServicePathInfo(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); }
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); }
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])); } } }