Base class for describing roles that we will create.
Example #1
0
        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]));
                }
            }
        }
Example #2
0
 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);
 }
Example #3
0
        /// <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);
        }
Example #4
0
 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;
 }
Example #5
0
        /// <summary>
        /// Adds the given role to both config files and the service def.
        /// </summary>
        private void AddRoleCore(String Scaffolding, RoleInfo role, RoleType type)
        {
            Dictionary<string, object> parameters = CreateDefaultParameters(role);
            parameters[ScaffoldParams.NodeModules] = General.GetNodeModulesPath();
            parameters[ScaffoldParams.NodeJsProgramFilesX86] = General.GetWithProgramFilesPath(Resources.NodeProgramFilesFolderName, false);

            string scaffoldPath = Path.Combine(Path.Combine(scaffoldingFolderPath, Scaffolding), type.ToString());
            Scaffold.GenerateScaffolding(scaffoldPath, Path.Combine(Paths.RootPath, role.Name), 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] = CloudServiceUtilities.GetNodeModulesPath();
            parameters[ScaffoldParams.NodeJsProgramFilesX86] = CloudServiceUtilities.GetWithProgramFilesPath(Resources.NodeProgramFilesFolderName, false);

            GenerateScaffolding(scaffolding, role.Name, parameters);
        }
Example #7
0
        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 Microsoft.WindowsAzure.Management.CloudService.Model.ServiceComponents(new Microsoft.WindowsAzure.Management.CloudService.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);
        }
        /// <summary>
        /// Adds the given role to both config files and the service def.
        /// </summary>
        /// <param name="role"></param>
        private void AddRoleCore(String Scaffolding, 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();
            parameters[ScaffoldParams.NodeJsProgramFilesX86] = General.GetWithProgramFilesPath(Resources.NodeProgramFilesFolderName, false);

            string scaffoldPath = Path.Combine(Path.Combine(scaffoldingFolderPath, Scaffolding), type.ToString());
            Scaffold.GenerateScaffolding(scaffoldPath, Path.Combine(Paths.RootPath, role.Name), parameters);
        }
Example #9
0
 protected virtual void OnProcessing(RoleInfo roleInfo)
 {
     // Placeholder for work to do after adding the role scaffolding.
 }