Skip to content

Multiple time segment import in import_flex_segments #48

Description

@laurentmas

Describe the bug

When importing nsx configuration into sddc, import_flex_segments function imports multiple times the segment as the code flex_segment_import_exclude_list has indentation code issue

Reproduction steps

  1. import the nsx configuration
  2. check the output logs when importing the flex segments
  3. "error_message" : "Cannot create an object with path=[/infra/segments/seg-aaa-db] as it already exists."
    ...

Expected behavior

import only one time the segment and do not tries to import multiple times

Additional context

Error is in the VMCImportExport.py file code line 1246. Indentation is not correct as the segment put code is inside the flex_segment_import_exclude_list loop.
if skip_network is True code must be at the same level as for e in self.flex_segment_import_exclude_list:

Curent code is the following

        for f in flex_segments:
            skip_network = False
            for e in self.flex_segment_import_exclude_list:
                m = re.match(e,f['display_name'])
                if m:
                    print(f"{f['display_name']}, skipped - matches excluseion regex")
                    skip_network = True
                    break
                if skip_network is True:
                    continue
                result = ""
                result_note = ""
                json_data = {}

it must be the following

        for f in flex_segments:
            skip_network = False
            for e in self.flex_segment_import_exclude_list:
                m = re.match(e,f['display_name'])
                if m:
                    print(f"{f['display_name']}, skipped - matches excluseion regex")
                    skip_network = True
                    break
            if skip_network is True:
                continue
            result = ""
            result_note = ""
            json_data = {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions