Skip to content

Commit

Permalink
cloudvision/cvlib: do mainline tag pulls at workspace mainline time
Browse files Browse the repository at this point in the history
Closes: BUG928344
Change-Id: I9d601661ca4b5ca0904f19bf8257bd1aa1aa9935
  • Loading branch information
gitsuran committed Apr 12, 2024
1 parent 9b82c4e commit 0f58b1d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cloudvision/cvlib/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@
ELEMENT_TYPE_INTERFACE,
CREATOR_TYPE_USER
)

from arista.time.time_pb2 import TimeBounds
from .exceptions import (
TagOperationException
)
from .workspace import (
getWorkspaceLastSynced
)

MAINLINE_ID = ""

Expand Down Expand Up @@ -272,9 +275,12 @@ def _getAllDeviceTagsFromMainline(self):
in the mainline. Also sets the local cache to this map.
The returned map is of the form: map[deviceId]map[label]=[value1,value2,..]
'''
wsTs = getWorkspaceLastSynced(self.ctx.getApiClient,
self.ctx.getWorkspaceId())
timeBound = TimeBounds(end=wsTs)
self.relevantTagAssigns = {}
tagClient = self.ctx.getApiClient(TagAssignmentServiceStub)
tagRequest = TagAssignmentStreamRequest()
tagRequest = TagAssignmentStreamRequest(time=timeBound)
tagFilter = TagAssignment()
tagFilter.tag_creator_type = CREATOR_TYPE_USER
tagFilter.key.element_type = ELEMENT_TYPE_DEVICE
Expand Down Expand Up @@ -516,9 +522,12 @@ def _getAllInterfaceTagsFromMainline(self):
The returned map is of the form:
map[deviceId]map[interfaceId]map[label]=[value1,value2,..]
'''
wsTs = getWorkspaceLastSynced(self.ctx.getApiClient,
self.ctx.getWorkspaceId())
timeBound = TimeBounds(end=wsTs)
self.relevantIntfTagAssigns = {}
tagClient = self.ctx.getApiClient(TagAssignmentServiceStub)
tagRequest = TagAssignmentStreamRequest()
tagRequest = TagAssignmentStreamRequest(time=timeBound)
tagFilter = TagAssignment()
tagFilter.tag_creator_type = CREATOR_TYPE_USER
tagFilter.key.element_type = ELEMENT_TYPE_INTERFACE
Expand Down
6 changes: 6 additions & 0 deletions test/cvlib/tags/test_deviceTags.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
TagAssignmentStreamResponse,
TagAssignmentConfigStreamResponse
)
from arista.workspace.v1.services import (
WorkspaceResponse
)


def convertListToStream(assignmentList):
Expand Down Expand Up @@ -81,6 +84,9 @@ def GetAll(self, request):
response.remove(item)
return response

def GetOne(self, _):
return WorkspaceResponse()

def SetGetAllResponse(self, response):
self.tagResponse = response

Expand Down
6 changes: 6 additions & 0 deletions test/cvlib/tags/test_interfaceTags.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
TagAssignmentStreamResponse,
TagAssignmentConfigStreamResponse
)
from arista.workspace.v1.services import (
WorkspaceResponse
)


def convertListToStream(assignmentList):
Expand Down Expand Up @@ -83,6 +86,9 @@ def GetAll(self, request):
response.remove(item)
return response

def GetOne(self, _):
return WorkspaceResponse()

def SetGetAllResponse(self, response):
self.tagResponse = response

Expand Down
6 changes: 6 additions & 0 deletions test/cvlib/tags/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
TagConfigServiceStub,
TagConfigSetSomeResponse
)
from arista.workspace.v1.services import (
WorkspaceResponse
)


def convertListToStream(assignmentList):
Expand Down Expand Up @@ -100,6 +103,9 @@ def GetAll(self, request):
response.remove(item)
return response

def GetOne(self, _):
return WorkspaceResponse()

def SetGetAllResponse(self, response):
self.tagResponse = response

Expand Down

0 comments on commit 0f58b1d

Please sign in to comment.