/// <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(out collection, manifest);
            return(collection);
        }
        /// <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(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)));
                    desiredRuntime.CloudServiceProject = this;
                    if (worker != null)
                    {
                        desiredRuntime.ApplyRuntime(foundPackage, worker);
                    }
                    else if (web != null)
                    {
                        desiredRuntime.ApplyRuntime(foundPackage, web);
                    }

                    this.Components.Save(this.Paths);
                }
            }
        }
 private void ConfigureNewService(ServiceComponents components, ServicePathInfo paths, string serviceName)
 {
     Components.Definition.name         = serviceName;
     Components.CloudConfig.serviceName = serviceName;
     Components.LocalConfig.serviceName = serviceName;
     Components.Save(paths);
 }
        public void ChangeServiceName(string newName, ServicePathInfo paths)
        {
            Validate.ValidateDnsName(newName, "service name");

            Components.Definition.name         = newName;
            Components.CloudConfig.serviceName = newName;
            Components.LocalConfig.serviceName = newName;
            Components.Save(paths);
        }
        public void Save(ServicePathInfo paths)
        {
            // Validate directory exists and it's valid
            if (paths == null) throw new ArgumentNullException("paths");

            General.SerializeXmlFile<ServiceDefinition>(Definition, paths.Definition);
            General.SerializeXmlFile<ServiceConfiguration>(CloudConfig, paths.CloudConfiguration);
            General.SerializeXmlFile<ServiceConfiguration>(LocalConfig, paths.LocalConfiguration);
            Settings.Save(paths.Settings);
        }
示例#6
0
        public void Save(ServicePathInfo paths)
        {
            // Validate directory exists and it's valid
            if (paths == null)
            {
                throw new ArgumentNullException("paths");
            }

            General.SerializeXmlFile <ServiceDefinition>(Definition, paths.Definition);
            General.SerializeXmlFile <ServiceConfiguration>(CloudConfig, paths.CloudConfiguration);
            General.SerializeXmlFile <ServiceConfiguration>(LocalConfig, paths.LocalConfiguration);
            Settings.Save(paths.Settings);
        }
        public CloudServiceProject(string serviceParentDirectory, string name, string scaffoldingPath)
            : this()
        {
            Validate.ValidateDirectoryFull(serviceParentDirectory, Resources.ServiceParentDirectory);
            Validate.ValidateStringIsNullOrEmpty(name, "Name");
            Validate.ValidateFileName(name, string.Format(Resources.InvalidFileName, "Name"));
            Validate.ValidateDnsName(name, "Name");

            string newServicePath = Path.Combine(serviceParentDirectory, name);
            if (Directory.Exists(newServicePath))
            {
                throw new ArgumentException(string.Format(Resources.ServiceAlreadyExistsOnDisk, name, newServicePath));
            }

            SetScaffolding(scaffoldingPath);
            Paths = new ServicePathInfo(newServicePath);
            CreateNewService(Paths.RootPath, name);
            Components = new ServiceComponents(Paths);
            ConfigureNewService(Components, Paths, name);
        }
        public CloudServiceProject(string serviceParentDirectory, string name, string scaffoldingPath)
            : this()
        {
            Validate.ValidateDirectoryFull(serviceParentDirectory, Resources.ServiceParentDirectory);
            Validate.ValidateStringIsNullOrEmpty(name, "Name");
            Validate.ValidateFileName(name, string.Format(Resources.InvalidFileName, "Name"));
            Validate.ValidateDnsName(name, "Name");

            string newServicePath = Path.Combine(serviceParentDirectory, name);

            if (Directory.Exists(newServicePath))
            {
                throw new ArgumentException(string.Format(Resources.ServiceAlreadyExistsOnDisk, name, newServicePath));
            }

            SetScaffolding(scaffoldingPath);
            Paths = new ServicePathInfo(newServicePath);
            CreateNewService(Paths.RootPath, name);
            Components = new ServiceComponents(Paths);
            ConfigureNewService(Components, Paths, name);
        }
示例#9
0
        private void LoadComponents(ServicePathInfo paths)
        {
            Validate.ValidateNullArgument(paths, string.Format(Resources.NullObjectMessage, "paths"));
            Validate.ValidateFileFull(paths.CloudConfiguration, Resources.ServiceConfiguration);
            Validate.ValidateFileFull(paths.LocalConfiguration, Resources.ServiceConfiguration);
            Validate.ValidateFileFull(paths.Definition, Resources.ServiceDefinition);

            try
            {
                Validate.ValidateFileFull(paths.Settings, Resources.ServiceSettings);
            }
            catch (FileNotFoundException)
            {
                // Try recreating the settings file
                File.WriteAllText(paths.Settings, Resources.SettingsFileEmptyContent);
            }

            Definition  = General.DeserializeXmlFile <ServiceDefinition>(paths.Definition);
            CloudConfig = General.DeserializeXmlFile <ServiceConfiguration>(paths.CloudConfiguration);
            LocalConfig = General.DeserializeXmlFile <ServiceConfiguration>(paths.LocalConfiguration);
            Settings    = ServiceSettings.Load(paths.Settings);
        }
        private void LoadComponents(ServicePathInfo paths)
        {
            Validate.ValidateNullArgument(paths, string.Format(Resources.NullObjectMessage, "paths"));
            Validate.ValidateFileFull(paths.CloudConfiguration, Resources.ServiceConfiguration);
            Validate.ValidateFileFull(paths.LocalConfiguration, Resources.ServiceConfiguration);
            Validate.ValidateFileFull(paths.Definition, Resources.ServiceDefinition);

            try
            {
                Validate.ValidateFileFull(paths.Settings, Resources.ServiceSettings);
            }
            catch (FileNotFoundException)
            {
                // Try recreating the settings file
                File.WriteAllText(paths.Settings, Resources.SettingsFileEmptyContent);
            }

            Definition = General.DeserializeXmlFile<ServiceDefinition>(paths.Definition);
            CloudConfig = General.DeserializeXmlFile<ServiceConfiguration>(paths.CloudConfiguration);
            LocalConfig = General.DeserializeXmlFile<ServiceConfiguration>(paths.LocalConfiguration);
            Settings = ServiceSettings.Load(paths.Settings);
        }
示例#11
0
 public ServiceComponents(ServicePathInfo paths)
 {
     LoadComponents(paths);
 }
 private void ConfigureNewService(ServiceComponents components, ServicePathInfo paths, string serviceName)
 {
     Components.Definition.name = serviceName;
     Components.CloudConfig.serviceName = serviceName;
     Components.LocalConfig.serviceName = serviceName;
     Components.Save(paths);
 }
 public CloudServiceProject(string rootPath, string scaffoldingPath)
 {
     SetScaffolding(scaffoldingPath);
     Paths = new ServicePathInfo(rootPath);
     Components = new ServiceComponents(Paths);
 }
 /// <summary>
 /// Reloads the cloud service project configuration from the disk.
 /// </summary>
 public void Reload()
 {
     Paths = new ServicePathInfo(Paths.RootPath);
     Components = new ServiceComponents(Paths);
 }
 /// <summary>
 /// Sets the role instance count
 /// </summary>
 /// <param name="paths">The service paths</param>
 /// <param name="roleName">The name of the role to change its instance count</param>
 /// <param name="VMSize">The new role instance count</param>
 public void SetRoleInstances(ServicePathInfo paths, string roleName, int instances)
 {
     Components.SetRoleInstances(roleName, instances);
     Components.Save(paths);
 }
 /// <summary>
 /// Sets the role VMSize
 /// </summary>
 /// <param name="paths">The service paths</param>
 /// <param name="roleName">The name of the role to change its vm size</param>
 /// <param name="VMSize">The new role vm size</param>
 public void SetRoleVMSize(ServicePathInfo paths, string roleName, string VMSize)
 {
     Components.SetRoleVMSize(roleName, VMSize);
     Components.Save(paths);
 }
 /// <summary>
 /// Sets the role instance count
 /// </summary>
 /// <param name="paths">The service paths</param>
 /// <param name="roleName">The name of the role to change its instance count</param>
 /// <param name="VMSize">The new role instance count</param>
 public void SetRoleInstances(ServicePathInfo paths, string roleName, int instances)
 {
     Components.SetRoleInstances(roleName, instances);
     Components.Save(paths);
 }
        public void ChangeServiceName(string newName, ServicePathInfo paths)
        {
            Validate.ValidateDnsName(newName, "service name");

            Components.Definition.name = newName;
            Components.CloudConfig.serviceName = newName;
            Components.LocalConfig.serviceName = newName;
            Components.Save(paths);
        }
 /// <summary>
 /// Sets the role VMSize
 /// </summary>
 /// <param name="paths">The service paths</param>
 /// <param name="roleName">The name of the role to change its vm size</param>
 /// <param name="VMSize">The new role vm size</param>
 public void SetRoleVMSize(ServicePathInfo paths, string roleName, string VMSize)
 {
     Components.SetRoleVMSize(roleName, VMSize);
     Components.Save(paths);
 }
 public CloudServiceProject(string rootPath, string scaffoldingPath)
 {
     SetScaffolding(scaffoldingPath);
     Paths      = new ServicePathInfo(rootPath);
     Components = new ServiceComponents(Paths);
 }
 public ServiceComponents(ServicePathInfo paths)
 {
     LoadComponents(paths);
 }
        /// <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(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)));
                    desiredRuntime.CloudServiceProject = this;
                    if (worker != null)
                    {
                        desiredRuntime.ApplyRuntime(foundPackage, worker);
                    }
                    else if (web != null)
                    {
                        desiredRuntime.ApplyRuntime(foundPackage, web);
                    }

                    this.Components.Save(this.Paths);
                }
            }
        }
 /// <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(out collection, manifest);
     return collection;
 }
 /// <summary>
 /// Reloads the cloud service project configuration from the disk.
 /// </summary>
 public void Reload()
 {
     Paths      = new ServicePathInfo(Paths.RootPath);
     Components = new ServiceComponents(Paths);
 }