Skip to content

Commit

Permalink
Refactor(cv_workflow): Add support for new studio_topology API
Browse files Browse the repository at this point in the history
  • Loading branch information
ClausHolbechArista committed Jan 7, 2025
1 parent 79000ab commit 459b41d
Show file tree
Hide file tree
Showing 54 changed files with 10,082 additions and 567 deletions.
4 changes: 2 additions & 2 deletions ansible_collections/arista/avd/plugins/action/cv_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ async def build_object_for_device(
else:
in_interesting_context = False

structured_config = load("".join(structured_config_lines), Loader=YamlLoader) # noqa: S506 TODO: Consider safeload
structured_config = load("".join(structured_config_lines), Loader=YamlLoader) or {} # noqa: S506 TODO: Consider safeload
else:
# Load as JSON
structured_config = json.load(structured_config_stream)
structured_config = json.load(structured_config_stream) or {}
else:
# No structured config file.
structured_config = {}
Expand Down
8 changes: 4 additions & 4 deletions python-avd/pyavd/_cv/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Example to add experimental protos:
# EXTRA_EXTRA_DIRS="-I ~/go/src/arista/resources" EXTRA_EXTRA_PROTOS="~/go/src/arista/resources/arista/configlet.v1/configlet.proto ~/go/src/arista/resources/arista/configlet.v1/services.gen.proto" make
VENDORPATH=cloudvision-apis
EXTRA_PROTOS=${PWD}/extra_cv_protos/arista/swg.v1/swg.proto ${PWD}/extra_cv_protos/arista/swg.v1/services.gen.proto
EXTRA_DIRS=-I ${PWD}/extra_cv_protos
EXTRAPATH=${PWD}/extra_cv_protos
EXTRA_EXTRA_DIRS?=
EXTRA_EXTRA_PROTOS?=
DUMMY := $(shell \
Expand All @@ -14,7 +13,8 @@ APIPATH=api

PYTHON ?= python3

ALL_PROTOS=$(shell find $(VENDORPATH) -name "*.proto")
VENDOR_PROTOS=$(shell find $(VENDORPATH) -name "*.proto")
EXTRA_PROTOS=$(shell find $(EXTRAPATH) -name "*.proto")

default: api

Expand All @@ -28,7 +28,7 @@ api-dir:
touch ./api/__init__.py

api-models: api-dir
$(PYTHON) -m grpc_tools.protoc -I $(VENDORPATH) $(EXTRA_DIRS) $(EXTRA_EXTRA_DIRS) --python_aristaproto_out=$(APIPATH) $(ALL_PROTOS) $(EXTRA_PROTOS) $(EXTRA_EXTRA_PROTOS)
$(PYTHON) -m grpc_tools.protoc -I $(VENDORPATH) -I $(EXTRAPATH) $(EXTRA_EXTRA_DIRS) --python_aristaproto_out=$(APIPATH) $(VENDOR_PROTOS) $(EXTRA_PROTOS) $(EXTRA_EXTRA_PROTOS)

api: api-dir api-models ## Build/refresh gRPC bindings in ./api
@rm -rf $(VENDORPATH)
Expand Down
2 changes: 1 addition & 1 deletion python-avd/pyavd/_cv/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) 2024-2025 Arista Networks, Inc.
# Copyright (c) 2025 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
2 changes: 1 addition & 1 deletion python-avd/pyavd/_cv/api/arista/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) 2024-2025 Arista Networks, Inc.
# Copyright (c) 2025 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
2 changes: 1 addition & 1 deletion python-avd/pyavd/_cv/api/arista/alert/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) 2024-2025 Arista Networks, Inc.
# Copyright (c) 2025 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
2 changes: 1 addition & 1 deletion python-avd/pyavd/_cv/api/arista/alert/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2024-2025 Arista Networks, Inc.
# Copyright (c) 2025 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
# Generated by the protocol buffer compiler. DO NOT EDIT!
Expand Down
2 changes: 1 addition & 1 deletion python-avd/pyavd/_cv/api/arista/bugexposure/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) 2024-2025 Arista Networks, Inc.
# Copyright (c) 2025 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
2 changes: 1 addition & 1 deletion python-avd/pyavd/_cv/api/arista/bugexposure/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2024-2025 Arista Networks, Inc.
# Copyright (c) 2025 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
# Generated by the protocol buffer compiler. DO NOT EDIT!
Expand Down
2 changes: 1 addition & 1 deletion python-avd/pyavd/_cv/api/arista/changecontrol/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) 2024-2025 Arista Networks, Inc.
# Copyright (c) 2025 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
31 changes: 30 additions & 1 deletion python-avd/pyavd/_cv/api/arista/changecontrol/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2024-2025 Arista Networks, Inc.
# Copyright (c) 2025 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
# Generated by the protocol buffer compiler. DO NOT EDIT!
Expand Down Expand Up @@ -37,6 +37,8 @@ class StageStatus(aristaproto.Enum):
"""StageStatus defines the possible execution statuses of a stage."""

UNSPECIFIED = 0
"""STAGE_STATUS_UNSPECIFIED means unknown stage status."""

RUNNING = 1
"""STAGE_STATUS_RUNNING means the stage has begun execution."""

Expand All @@ -59,6 +61,10 @@ class ChangeControlStatus(aristaproto.Enum):
"""

UNSPECIFIED = 0
"""
CHANGE_CONTROL_STATUS_UNSPECIFIED means the change control status is unknown.
"""

RUNNING = 1
"""
CHANGE_CONTROL_STATUS_RUNNING means the change control has begun
Expand Down Expand Up @@ -416,6 +422,21 @@ class Filter(aristaproto.Message):
"""


@dataclass(eq=False, repr=False)
class DeviceToStageMap(aristaproto.Message):
"""
DeviceToStageMap is a map of a device ID and its list of corresponding stages.
"""

values: Dict[str, "___fmp__.RepeatedString"] = aristaproto.map_field(
1, aristaproto.TYPE_STRING, aristaproto.TYPE_MESSAGE
)
"""
values maps the device ID with the stages which are associated with a device
in a changecontrol state model.
"""


@dataclass(eq=False, repr=False)
class ChangeControl(aristaproto.Message):
"""
Expand Down Expand Up @@ -466,6 +487,14 @@ class ChangeControl(aristaproto.Message):
device_ids is a list of device IDs on which the change control will operate.
"""

device_id_to_stage_ids: "DeviceToStageMap" = aristaproto.message_field(9)
"""
device_id_to_stage_ids is a map of device IDs to the stages present in the
specified Change state.
This is not affected by the device ID based custom filtering and will contain
info about all the devices associated with a CC ID.
"""


@dataclass(eq=False, repr=False)
class ApproveConfig(aristaproto.Message):
Expand Down
2 changes: 1 addition & 1 deletion python-avd/pyavd/_cv/api/arista/configlet/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) 2024-2025 Arista Networks, Inc.
# Copyright (c) 2025 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
2 changes: 1 addition & 1 deletion python-avd/pyavd/_cv/api/arista/configlet/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2024-2025 Arista Networks, Inc.
# Copyright (c) 2025 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
# Generated by the protocol buffer compiler. DO NOT EDIT!
Expand Down
2 changes: 1 addition & 1 deletion python-avd/pyavd/_cv/api/arista/configstatus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) 2024-2025 Arista Networks, Inc.
# Copyright (c) 2025 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
Loading

0 comments on commit 459b41d

Please sign in to comment.