public async Task <ICommand> UpdateEdgeAgentAsync(IModuleWithIdentity module, IRuntimeInfo runtimeInfo) { using (this.factoryMetrics.MeasureTime("update")) { return(await this.underlying.UpdateEdgeAgentAsync(module, runtimeInfo)); } }
public Task <ICommand> CreateAsync(IModuleWithIdentity module, IRuntimeInfo runtimeInfo) => Task.FromResult(CreateOrUpdateCommand.BuildCreate( this.moduleManager, module.Module, module.ModuleIdentity, this.configSource, this.combinedConfigProvider.GetCombinedConfig(module.Module, runtimeInfo)) as ICommand);
public Task <ICommand> CreateAsync(IModuleWithIdentity module, IRuntimeInfo runtimeInfo) { if (this.checkImagePullBeforeModuleCreate) { T config = this.combinedConfigProvider.GetCombinedConfig(module.Module, runtimeInfo); return(Task.FromResult( new GroupCommand( new PrepareUpdateCommand(this.moduleManager, module.Module, config), CreateOrUpdateCommand.BuildCreate( this.moduleManager, module.Module, module.ModuleIdentity, this.configSource, config, this.edgeDeviceHostname, this.parentEdgeHostname) as ICommand) as ICommand)); } else { return(Task.FromResult( CreateOrUpdateCommand.BuildCreate( this.moduleManager, module.Module, module.ModuleIdentity, this.configSource, this.combinedConfigProvider.GetCombinedConfig(module.Module, runtimeInfo), this.edgeDeviceHostname, this.parentEdgeHostname) as ICommand)); } }
public async Task <ICommand> CreateAsync(IModuleWithIdentity module, IRuntimeInfo runtimeInfo) { this.factoryMetrics.AddMessage(module.Module, FactoryMetrics.ModuleCommandMetric.Start); using (this.factoryMetrics.MeasureTime("create")) { return(await this.underlying.CreateAsync(module, runtimeInfo)); } }
public async Task <ICommand> UpdateAsync(IModule current, IModuleWithIdentity next, IRuntimeInfo runtimeInfo) { this.factoryMetrics.AddMessage(current, FactoryMetrics.ModuleCommandMetric.Start); this.factoryMetrics.AddMessage(next.Module, FactoryMetrics.ModuleCommandMetric.Stop); using (this.factoryMetrics.MeasureTime("update")) { return(await this.underlying.UpdateAsync(current, next, runtimeInfo)); } }
public async Task <ICommand> UpdateAsync(IModule current, IModuleWithIdentity next, IRuntimeInfo runtimeInfo) { if (current is DockerModule currentDockerModule && next.Module is DockerModule) { return(new GroupCommand( new RemoveCommand(this.client, currentDockerModule), await this.CreateAsync(next, runtimeInfo))); } return(NullCommand.Instance); }
public async Task <ICommand> CreateAsync(IModuleWithIdentity module, IRuntimeInfo runtimeInfo) { if (module.Module is DockerModule dockerModule) { CombinedDockerConfig combinedDockerConfig = this.combinedConfigProvider.GetCombinedConfig(dockerModule, runtimeInfo); return(new GroupCommand( new PullCommand(this.client, combinedDockerConfig), await CreateCommand.BuildAsync(this.client, dockerModule, module.ModuleIdentity, this.dockerLoggerConfig, this.configSource, module.Module is EdgeHubDockerModule))); } return(NullCommand.Instance); }
public virtual bool Equals(IModuleWithIdentity other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(this.module.Equals(other.Module) && this.moduleIdentity.Equals(other.ModuleIdentity)); }
public async Task <ICommand> UpdateAsync(IModule current, IModuleWithIdentity next, IRuntimeInfo runtimeInfo) { if (current is DockerModule currentDockerModule && next.Module is DockerModule nextDockerModule) { CombinedDockerConfig combinedDockerConfig = this.combinedConfigProvider.GetCombinedConfig(nextDockerModule, runtimeInfo); return(new GroupCommand( new PullCommand(this.client, combinedDockerConfig), new StopCommand(this.client, currentDockerModule), new RemoveCommand(this.client, currentDockerModule), await CreateCommand.BuildAsync(this.client, nextDockerModule, next.ModuleIdentity, this.dockerLoggerConfig, this.configSource, next.Module is EdgeHubDockerModule))); } return(NullCommand.Instance); }
async Task <ICommand> UpdateAsync(Option <IModule> current, IModuleWithIdentity next, IRuntimeInfo runtimeInfo, bool start) { T config = this.combinedConfigProvider.GetCombinedConfig(next.Module, runtimeInfo); return(new GroupCommand( new PrepareUpdateCommand(this.moduleManager, next.Module, config), await current.Match(c => this.StopAsync(c), () => Task.FromResult <ICommand>(NullCommand.Instance)), CreateOrUpdateCommand.BuildUpdate( this.moduleManager, next.Module, next.ModuleIdentity, this.configSource, config, start) as ICommand)); }
public async Task <ICommand> CreateAsync(IModuleWithIdentity module, IRuntimeInfo runtimeInfo) { if (module.Module is DockerModule dockerModule) { CombinedDockerConfig combinedDockerConfig = this.combinedConfigProvider.GetCombinedConfig(dockerModule, runtimeInfo); var commands = new List <ICommand>(); if (module.Module.ImagePullPolicy != ImagePullPolicy.Never) { commands.Add(new PullCommand(this.client, combinedDockerConfig)); } commands.Add(await CreateCommand.BuildAsync(this.client, dockerModule, module.ModuleIdentity, this.dockerLoggerConfig, this.configSource, module.Module is EdgeHubDockerModule)); return(new GroupCommand(commands.ToArray())); } return(NullCommand.Instance); }
public async Task <ICommand> UpdateAsync(IModule current, IModuleWithIdentity next, IRuntimeInfo runtimeInfo) { if (current is DockerModule currentDockerModule && next.Module is DockerModule nextDockerModule) { CombinedDockerConfig combinedDockerConfig = this.combinedConfigProvider.GetCombinedConfig(nextDockerModule, runtimeInfo); var commands = new List <ICommand>(); if (next.Module.ImagePullPolicy != ImagePullPolicy.Never) { commands.Add(new PullCommand(this.client, combinedDockerConfig)); } commands.AddRange( new ICommand[] { new StopCommand(this.client, currentDockerModule), new RemoveCommand(this.client, currentDockerModule), await CreateCommand.BuildAsync(this.client, nextDockerModule, next.ModuleIdentity, this.dockerLoggerConfig, this.configSource, next.Module is EdgeHubDockerModule) }); return(new GroupCommand(commands.ToArray())); } return(NullCommand.Instance); }
internal override InitializationResult _Init(IConfigurationRoot configuration, IContainer container) { _dockerClient = new DockerClientConfiguration(new Uri(configuration.GetValue <string>("DockerUri"))) .CreateClient(); var configSource = new EmulatorConfigSource(configuration); var dockerLoggingOptions = new Dictionary <string, string> { { "max-size", "1m" }, { "max-file", "1" } }; var loggingConfig = new DockerLoggingConfig("json-file", dockerLoggingOptions); var dockerAuthConfig = configuration.GetSection("DockerRegistryAuth").Get <List <AuthConfig> >() ?? new List <AuthConfig>(); var combinedDockerConfigProvider = new CombinedDockerConfigProvider(dockerAuthConfig); //var runtimeInfoProvider = RuntimeInfoProvider.CreateAsync(_dockerClient); var dockerModule = new Devices.Edge.Agent.Docker.DockerModule( Name, DockerHostingSettings.Version, DockerHostingSettings.DesiredStatus.Value, DockerHostingSettings.RestartPolicy.Value, DockerHostingSettings.Config, null, null ); var connectionString = configuration.GetValue <string>(Devices.Edge.Agent.Core.Constants.EdgeHubConnectionStringKey); var connectionStringBuilder = IotHubConnectionStringBuilder.Create(connectionString); var moduleIdentity = new ModuleIdentity(connectionStringBuilder.IotHubName, Environment.MachineName, connectionStringBuilder.DeviceId, connectionStringBuilder.ModuleId, new ConnectionStringCredentials(connectionString)); _moduleWithIdentity = new ModuleWithIdentity(dockerModule, moduleIdentity); //var combinedDockerConfig = combinedDockerConfigProvider.GetCombinedConfig(dockerModule, runtimeInfo); _dockerFactory = new LoggingCommandFactory(new DockerCommandFactory(_dockerClient, loggingConfig, configSource, combinedDockerConfigProvider), Devices.Edge.Util.Logger.Factory); //var updateCommand = new GroupCommand( // new RemoveCommand(_dockerClient, dockerModule), // new GroupCommand( // new PullCommand(_dockerClient, combinedDockerConfig), // CreateCommand.BuildAsync(_dockerClient, // dockerModule, // dockerModuleWithIdentity.ModuleIdentity, // loggingConfig, // configSource, // false).Result)); //_createCommand = new GroupCommand( // new PullCommand(_dockerClient, combinedDockerConfig), // CreateCommand.BuildAsync(_dockerClient, // dockerModule, // dockerModuleWithIdentity.ModuleIdentity, // loggingConfig, // configSource, // false).Result); //_startCommand = dockerFactory.StartAsync(dockerModule).Result; return(base._Init(configuration, container)); }
public Task <ICommand> UpdateEdgeAgentAsync(IModuleWithIdentity module, IRuntimeInfo runtimeInfo) => this.UpdateAsync(Option.None <IModule>(), module, runtimeInfo, true);
public Task <ICommand> UpdateAsync(IModule current, IModuleWithIdentity next, IRuntimeInfo runtimeInfo) => this.UpdateAsync(Option.Some(current), next, runtimeInfo, false);
public async Task <ICommand> CreateAsync(IModuleWithIdentity module, IRuntimeInfo runtimeInfo) => new LoggingCommand(await this.underlying.CreateAsync(module, runtimeInfo), "create", this.logger);
public async Task <ICommand> UpdateAsync(IModule current, IModuleWithIdentity next, IRuntimeInfo runtimeInfo) => new LoggingCommand(await this.underlying.UpdateAsync(current, next, runtimeInfo), "update", this.logger);
public Task <ICommand> UpdateEdgeAgentAsync(IModuleWithIdentity module, IRuntimeInfo runtimeInfo) => Task.FromResult(NullCommand.Instance as ICommand);
public Task <ICommand> UpdateEdgeAgentAsync(IModuleWithIdentity module, IRuntimeInfo runtimeInfo) { Assert.True(module.Module is TestModule); return(Task.FromResult <ICommand>(new TestCommand(TestCommandType.TestUpdateEdgeAgent, module.Module, this.Recorder))); }
public Task <ICommand> UpdateAsync(IModule current, IModuleWithIdentity next, IRuntimeInfo runtimeInfo) { Assert.True(current is TestModule); Assert.True(next.Module is TestModule); return(Task.FromResult <ICommand>(new TestCommand(TestCommandType.TestUpdate, next.Module, this.Recorder))); }
public Task <ICommand> CreateAsync(IModuleWithIdentity module, IRuntimeInfo runtimeInfo) { Assert.True(module.Module is TestModule); return(Task.FromResult <ICommand>(new TestCommand(TestCommandType.TestCreate, module.Module, this.Recorder, true))); }
public async Task <ICommand> UpdateEdgeAgentAsync(IModuleWithIdentity module, IRuntimeInfo runtimeInfo) => new LoggingCommand(await this.underlying.UpdateEdgeAgentAsync(module, runtimeInfo), "update Edge Agent", this.logger);
public Task <ICommand> CreateAsync(IModuleWithIdentity module, IRuntimeInfo runtimeInfo) => Task.FromResult((ICommand)NullCommand.Instance);
public Task <ICommand> UpdateAsync(IModule current, IModuleWithIdentity next, IRuntimeInfo runtimeInfo) => Task.FromResult((ICommand)NullCommand.Instance);