By thiesens, 30 September, 2024 Forums Gurux.DLMS.AMI Hi Gurux. Will you be adding a version of the agent, to run in docker? /Henrik was thinking: Add params to… was thinking: Add params to class: static string serverName = Environment.GetEnvironmentVariable("GURUX_SERVER") ?? "https://localhost:8001"; static string hostName = Environment.GetEnvironmentVariable("GURUX_HOST") ?? System.Net.Dns.GetHostName(); static string token = Environment.GetEnvironmentVariable("GURUX_TOKEN"); Change the RegisterAgent: public static async Task RegisterAgent( IServiceCollection services, AutoResetEvent newVersion, IGXAgentWorker worker, AgentOptions options) { string name = hostName ?? System.Net.Dns.GetHostName(); if (string.IsNullOrEmpty(token)) { Console.WriteLine("Running on host. Collecting params"); // string name = System.Net.Dns.GetHostName(); Console.WriteLine("Welcome to use Gurux.DLMS.AMI."); Console.WriteLine(string.Format("Gurux.DLMS.AMI address: [{0}]", options.Address)); string? tmp = Console.ReadLine(); if (!string.IsNullOrEmpty(tmp)) { options.Address = tmp; } Console.WriteLine(string.Format("Enter agent name: [{0}]", name)); tmp = Console.ReadLine(); if (!string.IsNullOrEmpty(tmp)) { name = tmp; } Console.WriteLine("Enter Personal Access Token:"); options.Token = Console.ReadLine(); if (options.Token == null || options.Token.Length != 64) { throw new ArgumentException("Invalid token."); } } else { Console.WriteLine("Running in a container."); options.Address = serverName; name = hostName; options.Token = token; } worker.Init(services, options, newVersion); options.Id = await worker.AddAgentAsync(name); if (options.Id == Guid.Empty) { throw new ArgumentException("Invalid agent Id."); } File.WriteAllText(settingsFile, JsonSerializer.Serialize(options)); Console.WriteLine("Connection succeeded."); } Add a dockerfile, and run it with the 3 env variables. Hi Henrik, Yes, this is… Hi Henrik, Yes, this is possible. The new Gurux.DLMS.AMI tests start next week. I'll check if it is possible to add this before the next version is released, but it's coming latest with the new version. BR, Mikko Perfect Mikke. Looking… Perfect Mikke. Looking forward to this. Log in or register to post comments
was thinking: Add params to… was thinking: Add params to class: static string serverName = Environment.GetEnvironmentVariable("GURUX_SERVER") ?? "https://localhost:8001"; static string hostName = Environment.GetEnvironmentVariable("GURUX_HOST") ?? System.Net.Dns.GetHostName(); static string token = Environment.GetEnvironmentVariable("GURUX_TOKEN"); Change the RegisterAgent: public static async Task RegisterAgent( IServiceCollection services, AutoResetEvent newVersion, IGXAgentWorker worker, AgentOptions options) { string name = hostName ?? System.Net.Dns.GetHostName(); if (string.IsNullOrEmpty(token)) { Console.WriteLine("Running on host. Collecting params"); // string name = System.Net.Dns.GetHostName(); Console.WriteLine("Welcome to use Gurux.DLMS.AMI."); Console.WriteLine(string.Format("Gurux.DLMS.AMI address: [{0}]", options.Address)); string? tmp = Console.ReadLine(); if (!string.IsNullOrEmpty(tmp)) { options.Address = tmp; } Console.WriteLine(string.Format("Enter agent name: [{0}]", name)); tmp = Console.ReadLine(); if (!string.IsNullOrEmpty(tmp)) { name = tmp; } Console.WriteLine("Enter Personal Access Token:"); options.Token = Console.ReadLine(); if (options.Token == null || options.Token.Length != 64) { throw new ArgumentException("Invalid token."); } } else { Console.WriteLine("Running in a container."); options.Address = serverName; name = hostName; options.Token = token; } worker.Init(services, options, newVersion); options.Id = await worker.AddAgentAsync(name); if (options.Id == Guid.Empty) { throw new ArgumentException("Invalid agent Id."); } File.WriteAllText(settingsFile, JsonSerializer.Serialize(options)); Console.WriteLine("Connection succeeded."); } Add a dockerfile, and run it with the 3 env variables.
Hi Henrik, Yes, this is… Hi Henrik, Yes, this is possible. The new Gurux.DLMS.AMI tests start next week. I'll check if it is possible to add this before the next version is released, but it's coming latest with the new version. BR, Mikko
was thinking: Add params to…
was thinking:
Add params to class:
static string serverName = Environment.GetEnvironmentVariable("GURUX_SERVER") ?? "https://localhost:8001";
static string hostName = Environment.GetEnvironmentVariable("GURUX_HOST") ?? System.Net.Dns.GetHostName();
static string token = Environment.GetEnvironmentVariable("GURUX_TOKEN");
Change the RegisterAgent:
public static async Task RegisterAgent(
IServiceCollection services,
AutoResetEvent newVersion,
IGXAgentWorker worker,
AgentOptions options)
{
string name = hostName ?? System.Net.Dns.GetHostName();
if (string.IsNullOrEmpty(token))
{
Console.WriteLine("Running on host. Collecting params");
// string name = System.Net.Dns.GetHostName();
Console.WriteLine("Welcome to use Gurux.DLMS.AMI.");
Console.WriteLine(string.Format("Gurux.DLMS.AMI address: [{0}]", options.Address));
string? tmp = Console.ReadLine();
if (!string.IsNullOrEmpty(tmp))
{
options.Address = tmp;
}
Console.WriteLine(string.Format("Enter agent name: [{0}]", name));
tmp = Console.ReadLine();
if (!string.IsNullOrEmpty(tmp))
{
name = tmp;
}
Console.WriteLine("Enter Personal Access Token:");
options.Token = Console.ReadLine();
if (options.Token == null || options.Token.Length != 64)
{
throw new ArgumentException("Invalid token.");
}
}
else
{
Console.WriteLine("Running in a container.");
options.Address = serverName;
name = hostName;
options.Token = token;
}
worker.Init(services, options, newVersion);
options.Id = await worker.AddAgentAsync(name);
if (options.Id == Guid.Empty)
{
throw new ArgumentException("Invalid agent Id.");
}
File.WriteAllText(settingsFile, JsonSerializer.Serialize(options));
Console.WriteLine("Connection succeeded.");
}
Add a dockerfile, and run it with the 3 env variables.
Hi Henrik, Yes, this is…
Hi Henrik,
Yes, this is possible. The new Gurux.DLMS.AMI tests start next week. I'll check if it is possible to add this before the next version is released, but it's coming latest with the new version.
BR,
Mikko
Perfect Mikke. Looking…
Perfect Mikke.
Looking forward to this.