Ejemplo n.º 1
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(out collection, manifest);
            return(collection);
        }
Ejemplo n.º 2
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(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);
                }
            }
        }
Ejemplo n.º 3
0
 private void ConfigureNewService(ServiceComponents components, ServicePathInfo paths, string serviceName)
 {
     Components.Definition.name         = serviceName;
     Components.CloudConfig.serviceName = serviceName;
     Components.LocalConfig.serviceName = serviceName;
     Components.Save(paths);
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
 public ServiceComponents(ServicePathInfo paths)
 {
     LoadComponents(paths);
 }
Ejemplo n.º 12
0
 private void ConfigureNewService(ServiceComponents components, ServicePathInfo paths, string serviceName)
 {
     Components.Definition.name = serviceName;
     Components.CloudConfig.serviceName = serviceName;
     Components.LocalConfig.serviceName = serviceName;
     Components.Save(paths);
 }
Ejemplo n.º 13
0
 public CloudServiceProject(string rootPath, string scaffoldingPath)
 {
     SetScaffolding(scaffoldingPath);
     Paths = new ServicePathInfo(rootPath);
     Components = new ServiceComponents(Paths);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Reloads the cloud service project configuration from the disk.
 /// </summary>
 public void Reload()
 {
     Paths = new ServicePathInfo(Paths.RootPath);
     Components = new ServiceComponents(Paths);
 }
Ejemplo n.º 15
0
 /// <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);
 }
Ejemplo n.º 16
0
 /// <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);
 }
Ejemplo n.º 17
0
 /// <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);
 }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 19
0
 /// <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);
 }
Ejemplo n.º 20
0
 public CloudServiceProject(string rootPath, string scaffoldingPath)
 {
     SetScaffolding(scaffoldingPath);
     Paths      = new ServicePathInfo(rootPath);
     Components = new ServiceComponents(Paths);
 }
Ejemplo n.º 21
0
 public ServiceComponents(ServicePathInfo paths)
 {
     LoadComponents(paths);
 }
Ejemplo n.º 22
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(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);
                }
            }
        }
Ejemplo n.º 23
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(out collection, manifest);
     return collection;
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Reloads the cloud service project configuration from the disk.
 /// </summary>
 public void Reload()
 {
     Paths      = new ServicePathInfo(Paths.RootPath);
     Components = new ServiceComponents(Paths);
 }