Example #1
0
 public static void ClearRuntime(WorkerRole role)
 {
     Task startupTask = GetRuntimeStartupTask(role.Startup);
      if (startupTask != null)
      {
          ClearEnvironmentValue(startupTask.Environment, Resources.RuntimeUrlKey);
      }
 }
Example #2
0
        /// <summary>
        /// Create a cloud runtime application, essentialy this is a tuple of runtime X package X role
        /// </summary>
        /// <param name="cloudRuntime">The runtime in the tuple</param>
        /// <param name="cloudRuntimePackage">The package in the tuple</param>
        /// <param name="role">The role to apply the package to</param>
        /// <returns>The tuple, use the apply method to apply the runtime as specified</returns>
        public static CloudRuntimeApplicator CreateCloudRuntimeApplicator(CloudRuntime cloudRuntime, CloudRuntimePackage cloudRuntimePackage, WorkerRole role)
        {
            CloudRuntimeApplicator applicator = new CloudRuntimeApplicator
            {
                Runtime = cloudRuntime,
                Package = cloudRuntimePackage,
                WorkerRole = role
            };

            return applicator;
        }
Example #3
0
        internal override void AddRoleToDefinition(ServiceDefinition def, object template)
        {
            base.AddRoleToDefinition(def, template);
            WorkerRole workerRole = template as WorkerRole;
            var toAdd = new WorkerRole[] { workerRole };

            if (def.WorkerRole != null)
            {
                def.WorkerRole = def.WorkerRole.Concat(toAdd).ToArray();
            }
            else
            {
                def.WorkerRole = toAdd;
            }
        }
 /// <summary>
 /// Try to get the specified worker role from the given definiiton
 /// </summary>
 /// <param name="definition">The service definiiton</param>
 /// <param name="roleName">The name of the role</param>
 /// <param name="role">output variable where the worker role is returned</param>
 /// <returns>true if the web role is found in the given definition</returns>
 private static bool TryGetWorkerRole(ServiceDefinition definition, string roleName, out WorkerRole role)
 {
     role = definition.WorkerRole.FirstOrDefault<WorkerRole>(r => string.Equals(r.name, roleName,
         StringComparison.OrdinalIgnoreCase));
     return role != null;
 }
Example #5
0
        private static Dictionary<string, string> GetStartupEnvironment(WorkerRole workerRole)
        {
            Dictionary<string, string> settings = new Dictionary<string, string>();
            foreach (Variable variable in GetRuntimeStartupTask(workerRole.Startup).Environment)
            {
                settings[variable.name] = variable.value;
            }

            return settings;
        }
Example #6
0
 private static void ApplyRoleXmlChanges(Dictionary<string, string> changes, WorkerRole workerRole)
 {
     GetRuntimeStartupTask(workerRole.Startup).Environment = ApplySettingChanges(changes, GetRuntimeStartupTask(workerRole.Startup).Environment);
 }
Example #7
0
        public virtual void ApplyRuntime(CloudRuntimePackage package, WorkerRole workerRole)
        {
            Dictionary<string, string> changes;
            if (this.GetChanges(package, out changes))
            {
                ApplyRoleXmlChanges(changes, workerRole);
            }

            ApplyScaffoldingChanges(package);
        }
Example #8
0
 public static Collection<CloudRuntime> CreateRuntime(WorkerRole workerRole, string rolePath)
 {
     return GetRuntimes(GetStartupEnvironment(workerRole), workerRole.name, rolePath);
 }
Example #9
0
 public static void ClearRuntime(WorkerRole role)
 {
     ClearEnvironmentValue(role.Startup.Task[0].Environment, Resources.RuntimeUrlKey);
 }
Example #10
0
 private static void ApplyRoleXmlChanges(Dictionary<string, string> changes, WorkerRole workerRole)
 {
     workerRole.Startup.Task[0].Environment = ApplySettingChanges(changes, workerRole.Startup.Task[0].Environment);
 }