Hi Dojo,
I'm trying to create DomInstance with optional and multiple sections of particular section definition and got error about InvalidSections and DomInstanceDoesNotContainRequiredModuleSections.
It is allowed in DomDefinition
my code:
var myInstance = new DomInstance() {DomDefinitionId = serviceDomDef.ID, StatusId = "draft"};
var serviceSecDef = domHelper.SectionDefinitions.Read(SectionDefinitionExposers.Name.Equal("section_service")).FirstOrDefault();
var inputSecDef = domHelper.SectionDefinitions.Read(SectionDefinitionExposers.Name.Equal("section_input")).FirstOrDefault();
var outputSecDef = domHelper.SectionDefinitions.Read(SectionDefinitionExposers.Name.Equal("section_output")).FirstOrDefault();var mySection = new Section(serviceSecDef);
mySection.AddOrUpdateValue(serviceSecDef.GetAllFieldDescriptors().FirstOrDefault(fd => fd.Name == "ServiceName"), "TestName");
myInstance.Sections.Add(mySection);/////////////////// INPUT SECTION ////////////////////////
mySection = new Section(inputSecDef);
mySection.AddOrUpdateValue(inputSecDef.GetAllFieldDescriptors().FirstOrDefault(fd => fd.Name == "InDstIP"), "1.2.3.4");
myInstance.Sections.Add(mySection);/////////////////// SECOND INPUT SECTION ////////////////////////
mySection = new Section(inputSecDef);
mySection.AddOrUpdateValue(inputSecDef.GetAllFieldDescriptors().FirstOrDefault(fd => fd.Name == "InDstIP"), "5.6.7.8");
myInstance.Sections.Add(mySection);/////////////////// OUTPUT SECTION ////////////////////////
mySection = new Section(outputSecDef);
mySection.AddOrUpdateValue(outputSecDef.GetAllFieldDescriptors().FirstOrDefault(fd => fd.Name == "OutDstIP"), "4.3.2.1");
myInstance.Sections.Add(mySection);domHelper.DomInstances.Create(myInstance);
I got error:
Error Creating Instance: Exception of type 'Skyline.DataMiner.Net.ManagerStore.CrudFailedException' was thrown.
Error reason: DomInstanceDoesNotContainRequiredModuleSections
TraceData: (amount = 1)
- ErrorData: (amount = 1)
- ErrorReason: DomInstanceDoesNotContainRequiredModuleSections, DomInstance: DomInstance[3ced7b30-9083-472d-944d-d8d6b271ea69], DomInstanceName: , InvalidSections: SectionDefinitionID[48bdaef5-d26f-4a09-92a2-49f0f72ae910],
My DomDefinition looks like:
{
"Id": {
"Id": "af30687a-a6c6-4c51-b83a-9055074b1071",
"ModuleId": "headend_test"
},
"SectionDefinitionLinks": [
{
"SectionDefinitionID": {
"Id": "8fa03266-483d-4b9c-a3dc-f0ac5112c159",
"ModuleId": "headend_test"
},
"IsSoftDeleted": false,
"IsOptional": false,
"AllowMultipleSections": false
},
{
"SectionDefinitionID": {
"Id": "48bdaef5-d26f-4a09-92a2-49f0f72ae910",
"ModuleId": "headend_test"
},
"IsSoftDeleted": false,
"IsOptional": true,
"AllowMultipleSections": true
},
{
"SectionDefinitionID": {
"Id": "83f7c76a-c9ae-4474-8b92-3d271a4f5ada",
"ModuleId": "headend_test"
},
"IsSoftDeleted": false,
"IsOptional": true,
"AllowMultipleSections": true
}
],
"Name": "Service",
"VisualStructure": {
"SectionDefinitionInfos": [
],
"IsHidden": false
},
"BehaviorDefinitionId": null,
"ModuleSettingsOverrides": {
"NameDefinition": null
},
"SyncLastModified": "2024-10-24T11:26:45.2650291Z",
"LastModifiedBy": "Administrator",
"CreatedAt": "2024-09-27T12:34:41.5468175Z",
"CreatedBy": "Jan Palansky"
}
It works for singular sections. I also tried create instance without input and output section (which are optional) and also got simillar error.
Can you please help me?
Hi Jan,
Thanks for sharing your issue with this detailed post. The error you are seeing (DomInstanceDoesNotContainRequiredModuleSections) is one related to the 'Module Sections' concept. If a SectionDefinition is marked as a 'Module Section', that means that exactly one section needs to be present for it on all DOM instances in the module.
You can find the error and description in this table of the docs: https://docs.dataminer.services/user-guide/Advanced_Modules/DOM/DOM_objects/DomInstance.html#errors
Note that only one section can be present, meaning that defining multiple sections (or none) for a 'Module Section' is not supported.
These 'Module Sections' are configured as a list of IDs on the ModuleSettings. Was this SectionDefinition's ID added to this list with the intention to use this concept, or was this rather accidental? If that was not really intended, removing the IDs from that list should fix the errors for you. So far, we haven't seen this 'Module Sections' concept be used, so there are currently no plant to add support for configuring multiple section for those.
If you are using the DOM editor IAS UI, you can find this list under 'Manager Settings' > 'Module Sections'. Deselect the SectionDefinitions that should support optional/multiple sections, click back & apply. If you manage your configuration via code, that list of IDs can be found here: ModuleSettings.DomManagerSettings.ModuleSections.
Let me know if anything would be unclear or if you have additional questions.
Hi Thomas, thank you very much for help and explanation. You are right, that all sections was accidently set as Module sections. I unmark them and now it works fine.