Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/1416 - Enable setting container create options on system modules in edge models #1418

Merged
merged 2 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,13 @@
<MudTable Items="Model.SystemModules" Dense=true Hover=true Bordered=true Striped=true Elevation=0>
<ColGroup>
<col style="width: 15%;" />
<col style="width: 40%;" />
<col style="width: 15%;" />
<col style="width: 50%;" />
<col style="width: 10%;" />
</ColGroup>

<HeaderContent>
<MudTh Style="text-align: center">Module name</MudTh>
<MudTh Style="text-align: center">Image URI</MudTh>
<MudTh Style="text-align: center">Version</MudTh>
<MudTh Style="text-align: center">Detail</MudTh>
</HeaderContent>

Expand All @@ -91,9 +89,6 @@
<MudTd DataLabel="System module Image URI" Style="word-break: break-all;">
<MudTextField id=@nameof(EdgeModelSystemModule.ImageUri) @bind-Value="@sysModule.ImageUri" Margin="Margin.Dense" Label="Image URI" For="@(() => sysModule.ImageUri )" Variant="Variant.Outlined" />
</MudTd>
<MudTd DataLabel="System module version" Style="word-break: break-all;">
<MudTextField id=@nameof(EdgeModelSystemModule.SchemaVersion) @bind-Value="@sysModule.SchemaVersion" Margin="Margin.Dense" Label="Version" For="@(() => sysModule.SchemaVersion )" Variant="Variant.Outlined" />
</MudTd>
<MudTd DataLabel="See detail" Style="text-align: center;">
<MudButton Variant="Variant.Filled" id="@("editSystModuleButton_"+sysModule.Name)" OnClick="@(async () => await ShowSystemModuleDetail(sysModule))">Detail</MudButton>
</MudTd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Label="Module name"
Variant="Variant.Outlined"
For="@(()=> Module.Name)"
Required="true" />
Required="true" Disabled/>
</MudItem>
<MudItem xs="12" md="6">
<MudTextField @bind-Value="@currentImageUri"
Expand All @@ -19,6 +19,16 @@
For="@(()=> Module.ImageUri)"
Required="true" />
</MudItem>
<MudItem xs="12">
<MudTextField @bind-Value="@currentContainerCreateOptions"
id=@nameof(EdgeModelSystemModule.ContainerCreateOptions)
Label="Container Create Options"
Variant="Variant.Outlined"
For="@(()=> Module.ContainerCreateOptions)" Lines="8" />
</MudItem>
<MudItem xs="12">
<MudAlert Severity="Severity.Info"><MudLink Href="https://learn.microsoft.com/en-us/azure/iot-edge/how-to-use-create-options" Target="_blank ">How to configure container create options for IoT Edge modules</MudLink></MudAlert>
</MudItem>
</MudGrid>

<MudTabs Elevation="1" Class="mt-10" Rounded="true" PanelClass="mt-6 scrollable-tab-content">
Expand Down Expand Up @@ -55,6 +65,7 @@

currentModuleName = Module.Name;
currentImageUri = Module.ImageUri;
currentContainerCreateOptions = Module.ContainerCreateOptions;
currentEnvironmentVariables = new List<IoTEdgeModuleEnvironmentVariable>(Module.EnvironmentVariables.ToArray());
await Task.Delay(0);
IsLoading = false;
Expand All @@ -64,6 +75,7 @@
{
Module.Name = currentModuleName;
Module.ImageUri = currentImageUri;
Module.ContainerCreateOptions = currentContainerCreateOptions;
Module.EnvironmentVariables = new List<IoTEdgeModuleEnvironmentVariable>(currentEnvironmentVariables.ToArray());
MudDialog.Close(DialogResult.Ok(true));
}
Expand Down
13 changes: 7 additions & 6 deletions src/AzureIoTHub.Portal.Server/Helpers/ConfigHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,25 +227,26 @@ public static Dictionary<string, IDictionary<string, object>> GenerateModulesCon
{
var edgeAgentPropertiesDesired = new EdgeAgentPropertiesDesired();

if (string.IsNullOrEmpty(edgeModel.SystemModules.Single(x => x.Name == "edgeAgent").ImageUri))
if (!string.IsNullOrEmpty(edgeModel.SystemModules.Single(x => x.Name == "edgeAgent").ImageUri))
{
edgeAgentPropertiesDesired.SystemModules.EdgeAgent.Settings.Image = edgeModel.SystemModules.Single(x => x.Name == "edgeAgent").ImageUri;
}

if (string.IsNullOrEmpty(edgeModel.SystemModules.Single(x => x.Name == "edgeAgent").SchemaVersion))
if (!string.IsNullOrEmpty(edgeModel.SystemModules.Single(x => x.Name == "edgeAgent").ContainerCreateOptions))
{
edgeAgentPropertiesDesired.SchemaVersion = edgeModel.SystemModules.Single(x => x.Name == "edgeAgent").SchemaVersion;
edgeAgentPropertiesDesired.SystemModules.EdgeAgent.Settings.CreateOptions = edgeModel.SystemModules.Single(x => x.Name == "edgeAgent").ContainerCreateOptions;
}

if (string.IsNullOrEmpty(edgeModel.SystemModules.Single(x => x.Name == "edgeHub").ImageUri))
if (!string.IsNullOrEmpty(edgeModel.SystemModules.Single(x => x.Name == "edgeHub").ImageUri))
{
edgeAgentPropertiesDesired.SystemModules.EdgeHub.Settings.Image = edgeModel.SystemModules.Single(x => x.Name == "edgeHub").ImageUri;
}

var edgeHubPropertiesDesired = GenerateRoutesContent(edgeModel.EdgeRoutes);
if (!string.IsNullOrEmpty(edgeModel.SystemModules.Single(x => x.Name == "edgeHub").SchemaVersion))

if (!string.IsNullOrEmpty(edgeModel.SystemModules.Single(x => x.Name == "edgeHub").ContainerCreateOptions))
{
edgeHubPropertiesDesired.SchemaVersion = edgeModel.SystemModules.Single(x => x.Name == "edgeHub").SchemaVersion;
edgeAgentPropertiesDesired.SystemModules.EdgeHub.Settings.CreateOptions = edgeModel.SystemModules.Single(x => x.Name == "edgeHub").ContainerCreateOptions;
}

foreach (var item in edgeModel.SystemModules.Single(x => x.Name == "edgeAgent").EnvironmentVariables)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class EdgeModelSystemModule

public string ImageUri { get; set; }

public string SchemaVersion { get; set; }
public string ContainerCreateOptions { get; set; }

public List<IoTEdgeModuleEnvironmentVariable> EnvironmentVariables { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task SystemModuleDialogMustCloseOnCLickOnCloseButton()
Value = Fixture.Create<string>()
}
},
SchemaVersion = "1.0"
ContainerCreateOptions = Fixture.Create<string>(),
};

var cut = RenderComponent<MudDialogProvider>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void GenerateModulesContentShouldReturnValue()
new EdgeModelSystemModule("edgeAgent")
{
ImageUri = "image",
SchemaVersion = "1.0",
ContainerCreateOptions = Guid.NewGuid().ToString(),
EnvironmentVariables = new List<IoTEdgeModuleEnvironmentVariable>()
{
new IoTEdgeModuleEnvironmentVariable(){ Name ="test", Value = "test" }
Expand All @@ -193,7 +193,7 @@ public void GenerateModulesContentShouldReturnValue()
new EdgeModelSystemModule("edgeHub")
{
ImageUri = "image",
SchemaVersion = "1.0",
ContainerCreateOptions = Guid.NewGuid().ToString(),
EnvironmentVariables = new List<IoTEdgeModuleEnvironmentVariable>()
{
new IoTEdgeModuleEnvironmentVariable(){ Name ="test", Value = "test" }
Expand Down