Repository navigation
Segments: fix segment types and segment assignment requirements - #18
Merged
Merged
Conversation
… parse the wire answer
…nd CDE segments load
… the profile patch that assigns it
…he refusal is pinned with a resolver loaded
…ds the segment resolver, and is refused only for a segment the ID names
… and what an ID with no resolver meets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Segments read from a real VCO now work end to end. Assigning one no longer crashes, a ref row that names a PRIVATE or CDE segment loads, and an edge can no longer add a segment its profile lacks.
What changed
NetworkSegmentstores enum fields as their wire strings (use_enum_values), so a segment parsed fromgetEnterpriseNetworkSegmentsheldtype_as astr.SegmentResolver.loadpassed it on unchanged, andassign_segmentthen crashed on.value. The resolver now converts it toNetworkSegmentType, anddescriptor_oftakes either form. The test fakes (make_segment_resolver,MockVcoClient.get_enterprise_network_segments) now parse a real wire answer, built by the newpyvelo.testing.network_segment_wire, so tests meet the form the VCO actually sends.DeviceSettingsSegmentRef.type_was a"REGULAR"literal and is nowNetworkSegmentType. Every type still dumps as its wire string.PatchError(segment_rule). The message gives the profile patch that assigns the segment, in a form a JSON caller can follow ({"segments": {"Lab": {"_op": "add"}}}, orassign_segment)."+". It holds whether the add's body names the segment bysegment.nameor only by an ID (segmentIdorsegmentLogicalId). The older rule against an add of an inherited segment now covers ID-only adds too. The ID is read the waymerge_patchreads it ("7"and7.0are segment 7), through one shared helper,read_given_idincore/merge.py.merge_patch. With a segment resolver loaded,merge_patchreports it as an unknown ID. With no resolver, it reports the missingsegment.name(invalid_value). A lookup that needs a resolver not yet loaded raisesResolverNotLoadedError, soapplyloads the resolver and tries again._prepare_segmentis split into its three cases, with its context in one_SegmentScope. Thenoqait carried is removed.CONFIGURATION.mdand the README'spyvelo.testingrow describe the new behaviour.Behaviour changes
addof a segment the profile lacks now raisesPatchError(segment_rule). Before, it was saved silently if a segment resolver knew the segment, and otherwise raised aLookupError. One existing test that pinned theLookupErrornow expects the refusal.Known limits
applyloads only a resolver that has to be loaded first. The stockSegmentResolverdoesn't, and while unloaded it knows no segment. A state fromloadalways has it loaded, so only a state built by hand can see "Unknown SegmentIdentity" for a real ID.Testing
scripts/check.shpasses: ruff (all rules), ruff format, basedpyright (all, failing on warnings) and strict pytest, with 7886 passed and 2 skipped.