public static CloudRuntime CreateCloudRuntime(string runtimeType, string runtimeVersion, string roleName, string rolePath) { CloudRuntime runtime = CreateRuntimeInternal(GetRuntimeByType(runtimeType), roleName, rolePath); runtime.Version = runtimeVersion; return(runtime); }
/// <summary> /// Add the specified runtime to a role, checking that the runtime and version are currently available int he cloud /// </summary> /// <param name="paths">service path info</param> /// <param name="roleName">Name of the role to change</param> /// <param name="runtimeType">The runtime identifier</param> /// <param name="runtimeVersion">The runtime version</param> /// <param name="manifest">Location fo the manifest file, default is the cloud manifest</param> public void AddRoleRuntime(ServicePathInfo paths, string roleName, string runtimeType, string runtimeVersion, string manifest = null) { if (this.Components.RoleExists(roleName)) { CloudRuntimeCollection collection; CloudRuntimeCollection.CreateCloudRuntimeCollection(Location.NorthCentralUS, out collection, manifest); CloudRuntime desiredRuntime = CloudRuntime.CreateCloudRuntime(runtimeType, runtimeVersion, roleName, Path.Combine(paths.RootPath, roleName)); CloudRuntimePackage foundPackage; if (collection.TryFindMatch(desiredRuntime, out foundPackage)) { WorkerRole worker = (this.Components.Definition.WorkerRole == null ? null : this.Components.Definition.WorkerRole.FirstOrDefault <WorkerRole>(r => string.Equals(r.name, roleName, StringComparison.OrdinalIgnoreCase))); WebRole web = (this.Components.Definition.WebRole == null ? null : this.Components.Definition.WebRole.FirstOrDefault <WebRole>(r => string.Equals(r.name, roleName, StringComparison.OrdinalIgnoreCase))); if (worker != null) { desiredRuntime.ApplyRuntime(foundPackage, worker); } else if (web != null) { desiredRuntime.ApplyRuntime(foundPackage, web); } } } }
/// <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; }
/// <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); }
private static Collection <CloudRuntime> GetRuntimes(Dictionary <string, string> settings, string roleName, string rolePath) { Collection <CloudRuntime> runtimes = new Collection <CloudRuntime>(new List <CloudRuntime>()); foreach (Runtime runtimeType in GetRuntimeTypes(settings)) { CloudRuntime runtime = CreateRuntimeInternal(runtimeType, roleName, rolePath); runtime.Configure(settings); runtimes.Add(runtime); } return(runtimes); }
public bool TryFindMatch(CloudRuntime runtime, out CloudRuntimePackage matchingPackage) { matchingPackage = packages[runtime.Runtime].OrderByDescending <CloudRuntimePackage, string>(p => p.Version, new VersionComparer()).FirstOrDefault <CloudRuntimePackage>(crp => runtime.Match(crp)); if (matchingPackage != null) { return(true); } if (defaults.ContainsKey(runtime.Runtime)) { matchingPackage = defaults[runtime.Runtime]; } return(false); }