Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor(cv_deploy): Add support for new studio_topology API #4859

Draft
wants to merge 1 commit into
base: devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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
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
Loading