ADM bug fixes (#205)
This commit is contained in:
Родитель
0ec77517aa
Коммит
8732dafa9d
|
@ -183,6 +183,7 @@ namespace Services.Test
|
|||
DeviceGroupId = deviceGroupId,
|
||||
DeviceGroupQuery = deviceGroupQuery,
|
||||
PackageContent = packageContent,
|
||||
PackageType = PackageType.EdgeManifest,
|
||||
Priority = priority
|
||||
};
|
||||
|
||||
|
|
|
@ -211,16 +211,24 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.Services
|
|||
|
||||
private IDictionary<string, DeploymentStatus> GetDeviceStatuses(Configuration deployment)
|
||||
{
|
||||
deployment.Labels.TryGetValue(ConfigurationsHelper.PACKAGE_TYPE_LABEL, out string deploymentType);
|
||||
string deploymentType = null;
|
||||
if (ConfigurationsHelper.IsEdgeDeployment(deployment))
|
||||
{
|
||||
deploymentType = PackageType.EdgeManifest.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
deploymentType = PackageType.DeviceConfiguration.ToString();
|
||||
}
|
||||
|
||||
deployment.Labels.TryGetValue(ConfigurationsHelper.CONFIG_TYPE_LABEL, out string configType);
|
||||
|
||||
IDictionary<QueryType, String> Queries = GetQueries(deploymentType, configType);
|
||||
|
||||
var deviceWithStatus = new Dictionary<string, DeploymentStatus>();
|
||||
|
||||
string deploymentId = deployment.Id;
|
||||
var appliedDevices = this.GetDevicesInQuery(Queries[QueryType.APPLIED], deploymentId);
|
||||
|
||||
var deviceWithStatus = new Dictionary<string, DeploymentStatus>();
|
||||
|
||||
if (!(ConfigurationsHelper.IsEdgeDeployment(deployment)) &&
|
||||
!(configType.Equals(ConfigType.Firmware.ToString())))
|
||||
{
|
||||
|
|
|
@ -83,14 +83,46 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.Services.Helpers
|
|||
|
||||
public static Boolean IsEdgeDeployment(Configuration deployment)
|
||||
{
|
||||
deployment.Labels.TryGetValue(PACKAGE_TYPE_LABEL, out var type);
|
||||
string deploymentLabel = null;
|
||||
|
||||
if (type.Equals(PackageType.EdgeManifest.ToString()))
|
||||
{
|
||||
return true;
|
||||
if (deployment.Labels != null &&
|
||||
deployment.Labels.ContainsKey(ConfigurationsHelper.PACKAGE_TYPE_LABEL)) {
|
||||
deploymentLabel = deployment.Labels[ConfigurationsHelper.PACKAGE_TYPE_LABEL];
|
||||
}
|
||||
|
||||
return false;
|
||||
if (!(string.IsNullOrEmpty(deploymentLabel)))
|
||||
{
|
||||
if (deployment.Labels.Values.Contains(PackageType.EdgeManifest.ToString()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (deployment.Labels.Values.Contains(PackageType.DeviceConfiguration.ToString()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidConfigurationException("Deployment package type should not be empty.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is for the backward compatibility, as some of the old
|
||||
* deployments may not have the required label.
|
||||
*/
|
||||
if (deployment.Content?.ModulesContent != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (deployment.Content?.DeviceContent != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidConfigurationException("Deployment package type should not be empty.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Replaces DeploymentId, if present, in the custom metrics query
|
||||
|
|
|
@ -52,39 +52,13 @@ namespace Microsoft.Azure.IoTSolutions.IotHubManager.Services.Models
|
|||
|
||||
this.Priority = deployment.Priority;
|
||||
|
||||
if (deployment.Labels.ContainsKey(ConfigurationsHelper.PACKAGE_TYPE_LABEL) &&
|
||||
!(string.IsNullOrEmpty(deployment.Labels[ConfigurationsHelper.PACKAGE_TYPE_LABEL])))
|
||||
if (ConfigurationsHelper.IsEdgeDeployment(deployment))
|
||||
{
|
||||
if (deployment.Labels.Values.Contains(PackageType.EdgeManifest.ToString()))
|
||||
{
|
||||
this.PackageType = PackageType.EdgeManifest;
|
||||
}
|
||||
else if (deployment.Labels.Values.Contains(PackageType.DeviceConfiguration.ToString()))
|
||||
{
|
||||
this.PackageType = PackageType.DeviceConfiguration;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidConfigurationException("Deployment package type should not be empty.");
|
||||
}
|
||||
this.PackageType = PackageType.EdgeManifest;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is for the backward compatibility, as some of the old
|
||||
* deployments may not have the required label.
|
||||
*/
|
||||
if (deployment.Content?.ModulesContent != null)
|
||||
{
|
||||
this.PackageType = PackageType.EdgeManifest;
|
||||
}
|
||||
else if (deployment.Content?.DeviceContent != null)
|
||||
{
|
||||
this.PackageType = PackageType.DeviceConfiguration;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidConfigurationException("Deployment package type should not be empty.");
|
||||
}
|
||||
this.PackageType = PackageType.DeviceConfiguration;
|
||||
}
|
||||
|
||||
if (deployment.Labels.ContainsKey(ConfigurationsHelper.CONFIG_TYPE_LABEL))
|
||||
|
|
Загрузка…
Ссылка в новой задаче