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);
            }
        }
Exemplo n.º 2
0
 protected virtual void OnProcessing(RoleInfo roleInfo)
 {
     // Placeholder for work to do after adding the role scaffolding.
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        /// <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);
        }
        /// <summary>
        /// Configure the worker role for caching by:
        /// * Add caching module to the role imports.
        /// * Enable caching Diagnostic store.
        /// * Remove input endpoints.
        /// * Add caching configuration settings.
        /// </summary>
        /// <param name="rootPath"></param>
        /// <param name="cacheRoleInfo"></param>
        /// <returns></returns>
        private AzureService Version180Configuration(string rootPath, RoleInfo cacheRoleInfo)
        {
            // Fetch cache role information from service definition and service configuration files.
            AzureService azureService = new AzureService(rootPath, null);
            WorkerRole cacheWorkerRole = azureService.Components.GetWorkerRole(cacheRoleInfo.Name);
            RoleSettings cacheRoleSettings = azureService.Components.GetCloudConfigRole(cacheRoleInfo.Name);

            // Add caching module to the role imports
            cacheWorkerRole.Imports = General.ExtendArray<Import>(cacheWorkerRole.Imports, new Import { moduleName = Resources.CachingModuleName });

            // Enable caching Diagnostic store.
            LocalStore diagnosticStore = new LocalStore { name = Resources.CacheDiagnosticStoreName, cleanOnRoleRecycle = false };
            cacheWorkerRole.LocalResources = General.InitializeIfNull<LocalResources>(cacheWorkerRole.LocalResources);
            cacheWorkerRole.LocalResources.LocalStorage = General.ExtendArray<LocalStore>(cacheWorkerRole.LocalResources.LocalStorage, diagnosticStore);

            // Remove input endpoints.
            cacheWorkerRole.Endpoints.InputEndpoint = null;

            // Add caching configuration settings
            AddCacheConfiguration(azureService.Components.GetCloudConfigRole(cacheRoleInfo.Name));
            AddCacheConfiguration(azureService.Components.GetLocalConfigRole(cacheRoleInfo.Name), Resources.EmulatorConnectionString);
            return azureService;
        }
Exemplo n.º 7
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);
 }
        private AzureService CachingConfigurationFactoryMethod(string rootPath, RoleInfo cacheWorkerRole, string sdkVersion)
        {
            switch (sdkVersion)
            {
                case SDKVersion.Version180:
                    return Version180Configuration(rootPath, cacheWorkerRole);

                default:
                    throw new Exception(string.Format(Resources.AzureSdkVersionNotSupported,
                        Resources.MinSupportAzureSdkVersion, Resources.MaxSupportAzureSdkVersion));
            }
        }
Exemplo n.º 9
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]));
                }
            }
        }
Exemplo n.º 10
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.Utilities.CloudService.ServiceComponents(new Microsoft.WindowsAzure.Management.Utilities.CloudService.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>
        /// 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);
            }
        }
Exemplo n.º 12
0
 protected virtual void OnProcessing(RoleInfo roleInfo)
 {
     // Placeholder for work to do after adding the role scaffolding.
 }