예제 #1
0
 /// <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);
             }
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Retrieve currently available cloud runtimes
        /// </summary>
        /// <param name="paths">service path info</param>
        /// <param name="manifest">The manifest to use to get current runtime info - default is the cloud manifest</param>
        /// <returns></returns>
        public CloudRuntimeCollection GetCloudRuntimes(ServicePathInfo paths, string manifest)
        {
            CloudRuntimeCollection collection;

            CloudRuntimeCollection.CreateCloudRuntimeCollection(Location.NorthCentralUS, out collection, manifest);
            return(collection);
        }
        public static bool CreateCloudRuntimeCollection(Location location, out CloudRuntimeCollection runtimes, string manifestFile = null)
        {
            runtimes = new CloudRuntimeCollection();
            XmlDocument manifest = runtimes.GetManifest(manifestFile);
            string      baseUri;
            Collection <CloudRuntimePackage> runtimePackages;
            bool success = TryGetBlobUriFromManifest(manifest, location, out baseUri);

            success &= TryGetRuntimePackages(manifest, baseUri, out runtimePackages);
            foreach (CloudRuntimePackage package in runtimePackages)
            {
                runtimes.Add(package);
            }

            return(success);
        }