private void ConfigureNewService(ServiceComponents components, CloudProjectPathInfo paths, string serviceName) { Components.Definition.name = serviceName; Components.CloudConfig.serviceName = serviceName; Components.LocalConfig.serviceName = serviceName; Components.Save(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( CloudProjectPathInfo 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(CloudProjectPathInfo paths, string manifest) { CloudRuntimeCollection collection; CloudRuntimeCollection.CreateCloudRuntimeCollection(out collection, manifest); return(collection); }
public void ChangeServiceName(string newName, CloudProjectPathInfo paths) { Validate.ValidateDnsName(newName, "service name"); Components.Definition.name = newName; Components.CloudConfig.serviceName = newName; Components.LocalConfig.serviceName = newName; Components.Save(paths); }
public static void AreEqualServicePathInfo(string rootPath, CloudProjectPathInfo actual) { Assert.AreEqual<string>(rootPath, actual.RootPath); Assert.AreEqual<string>(Path.Combine(rootPath, Resources.ServiceDefinitionFileName), actual.Definition); Assert.AreEqual<string>(Path.Combine(rootPath, Resources.CloudServiceConfigurationFileName), actual.CloudConfiguration); Assert.AreEqual<string>(Path.Combine(rootPath, Resources.LocalServiceConfigurationFileName), actual.LocalConfiguration); Assert.AreEqual<string>(Path.Combine(rootPath, Resources.SettingsFileName), actual.Settings); Assert.AreEqual<string>(Path.Combine(rootPath, Resources.CloudPackageFileName), actual.CloudPackage); Assert.AreEqual<string>(Path.Combine(rootPath, Resources.LocalPackageFileName), actual.LocalPackage); }
public void Save(CloudProjectPathInfo 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 void Save(CloudProjectPathInfo 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); }
/// <summary> /// Set the runtime properties for a role /// </summary> /// <param name="definition">The service containing the role</param> /// <param name="roleName">The name of the role to change</param> /// <param name="path">The path to the service</param> /// <param name="version">The version of the runtime to be installed</param> /// <param name="overrideUrl">The value of the override url, if the user wants to opt out of the system</param> /// <returns>true if the settings were successfully changed</returns> public static bool SetRoleRuntime(ServiceDefinition definition, string roleName, CloudProjectPathInfo path, string version = null, string overrideUrl = null) { bool changed = false; Variable[] environment = GetRoleRuntimeEnvironment(definition, roleName); if (version != null) { string filePath = Path.Combine(path.RootPath, roleName, "package.json"); File.WriteAllText(filePath, string.Format(TestResources.ValidPackageJson, "testapp", version)); changed = true; } if (overrideUrl != null) { environment = SetRuntimeEnvironment(environment, Resources.RuntimeOverrideKey, overrideUrl); changed = true; } return changed && ApplyRuntimeChanges(definition, roleName, environment); }
private void LoadComponents(CloudProjectPathInfo 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(CloudProjectPathInfo 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); }
/// <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( CloudProjectPathInfo 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(CloudProjectPathInfo paths, string manifest) { CloudRuntimeCollection collection; CloudRuntimeCollection.CreateCloudRuntimeCollection(out collection, manifest); return collection; }
/// <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(CloudProjectPathInfo 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(CloudProjectPathInfo paths, string roleName, int instances) { Components.SetRoleInstances(roleName, instances); Components.Save(paths); }
public void ChangeServiceName(string newName, CloudProjectPathInfo paths) { Validate.ValidateDnsName(newName, "service name"); Components.Definition.name = newName; Components.CloudConfig.serviceName = newName; Components.LocalConfig.serviceName = newName; Components.Save(paths); }
private void ConfigureNewService(ServiceComponents components, CloudProjectPathInfo paths, string serviceName) { Components.Definition.name = serviceName; Components.CloudConfig.serviceName = serviceName; Components.LocalConfig.serviceName = serviceName; 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(CloudProjectPathInfo 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(CloudProjectPathInfo paths, string roleName, int instances) { Components.SetRoleInstances(roleName, instances); Components.Save(paths); }
public ServiceComponents(CloudProjectPathInfo paths) { LoadComponents(paths); }
public static void AreEqualServicePathInfo(CloudProjectPathInfo expected, CloudProjectPathInfo actual) { AreEqualServicePathInfo(expected.CloudConfiguration, expected.CloudPackage, expected.Definition, expected.LocalConfiguration, expected.LocalPackage, expected.RootPath, expected.Settings, actual); }
public ServiceComponents(CloudProjectPathInfo paths) { LoadComponents(paths); }
public static void AreEqualServicePathInfo(string cloudConfig, string cloudPackage, string def, string localConfig, string localPackage, string rootPath, string settings, CloudProjectPathInfo actual) { throw new NotImplementedException(); }