Skip to content

Commit

Permalink
Merge pull request #395 from fabric-testbed/rel1.7
Browse files Browse the repository at this point in the history
Rel1.7 - changes
  • Loading branch information
kthare10 authored Jul 18, 2024
2 parents be2e7b5 + 908add7 commit 195d6e7
Show file tree
Hide file tree
Showing 93 changed files with 3,898 additions and 956 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,8 @@ fabric_cf/actor/test/*.graphml
secrets/kafkacat2-ca1-signed.pem
secrets/kafkacat1-ca1-signed.pem
secrets/...
neo4j/RENC.graphml
neo4j/Network-dev.graphml
.DS_Store
*.log*
*.avsc
3 changes: 2 additions & 1 deletion Dockerfile-auth
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:3.11.0
MAINTAINER Komal Thareja<komal.thareja@gmail.com>

ARG HANDLERS_VER=1.6.3
ARG HANDLERS_VER=1.7.1

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
Expand All @@ -11,6 +11,7 @@ EXPOSE 11000

RUN apt-get update
RUN apt-get install cron -y
RUN apt-get install sshpass -y

COPY docker-entrypoint.sh /usr/src/app/
COPY fabric_cf /usr/src/app/fabric_cf
Expand Down
2 changes: 1 addition & 1 deletion fabric_cf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "1.6.2"
__version__ = "1.7.0"
__VERSION__ = __version__
9 changes: 9 additions & 0 deletions fabric_cf/actor/core/apis/abc_actor_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,12 @@ def remove_actor_database(self, *, actor_name: str):
Remove Actor Database
@params actor_name: actor name
"""

@abstractmethod
def get_actor(self) -> ABCActorMixin:
"""
Return Actor
@return Actor
"""
pass
72 changes: 69 additions & 3 deletions fabric_cf/actor/core/apis/abc_actor_management_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
from __future__ import annotations

from abc import abstractmethod
from datetime import datetime
from typing import TYPE_CHECKING, Tuple, Dict, List

from fabric_mb.message_bus.messages.poa_avro import PoaAvro
from fabric_mb.message_bus.messages.result_avro import ResultAvro
from fabric_mb.message_bus.messages.result_delegation_avro import ResultDelegationAvro
from fabric_mb.message_bus.messages.result_poa_avro import ResultPoaAvro
Expand All @@ -38,6 +38,7 @@
from fabric_mb.message_bus.messages.result_slice_avro import ResultSliceAvro
from fabric_mb.message_bus.messages.result_string_avro import ResultStringAvro
from fabric_mb.message_bus.messages.slice_avro import SliceAvro
from fim.user import GraphFormat

from fabric_cf.actor.core.apis.abc_management_object import ABCManagementObject
from fabric_cf.actor.core.container.maintenance import Site
Expand Down Expand Up @@ -237,7 +238,8 @@ def get_sites(self, *, caller: AuthToken, site: str) -> ResultSitesAvro:
def get_reservations(self, *, caller: AuthToken, states: List[int] = None,
slice_id: ID = None, rid: ID = None, oidc_claim_sub: str = None,
email: str = None, rid_list: List[str] = None, type: str = None,
site: str = None, node_id: str = None) -> ResultReservationAvro:
site: str = None, node_id: str = None,
host: str = None, ip_subnet: str = None) -> ResultReservationAvro:
"""
Get Reservations
@param states states
Expand All @@ -251,12 +253,16 @@ def get_reservations(self, *, caller: AuthToken, states: List[int] = None,
@param node_id node id
Obtains all reservations with error information in case of failure
@param caller caller
@param host host
@param ip_subnet ip subnet
@return returns list of the reservations
"""

def get_slices(self, *, slice_id: ID, caller: AuthToken, slice_name: str = None, email: str = None,
states: List[int] = None, project: str = None, limit: int = None,
offset: int = None, user_id: str = None) -> ResultSliceAvro:
offset: int = None, user_id: str = None, search: str = None,
exact_match: bool = False) -> ResultSliceAvro:
"""
Obtains all slices.
@param slice_id slice id
Expand All @@ -268,13 +274,73 @@ def get_slices(self, *, slice_id: ID, caller: AuthToken, slice_name: str = None,
@param offset offset
@param caller caller
@param user_id user_id
@param search: search term applied
@param exact_match: Exact Match for Search term
@return returns list of slices
"""

@abstractmethod
def increment_metrics(self, *, project_id: str, oidc_sub: str, slice_count: int = 1) -> bool:
"""
Add or update metrics
@param project_id project id
@param oidc_sub oidc sub
@param slice_count slice_count
@return true or false
@throws Exception in case of error
"""

@abstractmethod
def get_metrics(self, *, project_id: str, oidc_sub: str, excluded_projects: List[str] = None) -> list:
"""
Get metrics
@param project_id project id
@param oidc_sub oidc sub
@param excluded_projects excluded_projects
@return list of metric information
@throws Exception in case of error
"""

def get_slice_count(self, *, caller: AuthToken, email: str = None, states: List[int] = None,
project: str = None, user_id: str = None, excluded_projects: List[str] = None) -> int:
"""
Obtains Slice count matching the filter criteria.
@param email email
@param project project id
@param states slice states
@param caller caller
@param user_id user_id
@param excluded_projects excluded_projects
@return returns number of slices
"""

def remove_slice(self, *, slice_id: ID, caller: AuthToken) -> ResultAvro:
"""
Removes the specified slice
@param slice_id slice id
@param caller caller
@return true for success; false otherwise
"""

def build_broker_query_model(self, level_0_broker_query_model: str, level: int,
graph_format: GraphFormat = GraphFormat.GRAPHML,
start: datetime = None, end: datetime = None, includes: str = None,
excludes: str = None) -> str:
"""
Build the BQM Model using current usage
@param level_0_broker_query_model Capacity Model
@param level: level of details
@param graph_format: Graph Format
@param start: start time
@param end: end time
@param includes: comma separated lists of sites to include
@param excludes: comma separated lists of sites to exclude
@return BQM
"""
4 changes: 3 additions & 1 deletion fabric_cf/actor/core/apis/abc_actor_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from fabric_cf.actor.core.apis.abc_tick import ABCTick

if TYPE_CHECKING:
from fabric_cf.actor.core.kernel.slice_state_machine import SliceState
from fabric_cf.actor.core.apis.abc_actor_event import ABCActorEvent
from fabric_cf.actor.core.apis.abc_actor_proxy import ABCActorProxy
from fabric_cf.actor.core.apis.abc_base_plugin import ABCBasePlugin
Expand Down Expand Up @@ -431,12 +432,13 @@ def register_slice(self, *, slice_object: ABCSlice):
"""

@abstractmethod
def modify_slice(self, *, slice_object: ABCSlice):
def modify_slice(self, *, slice_object: ABCSlice, new_state: SliceState):
"""
Modify the slice registered with the actor. Moves the slice into Modifying State
Args:
slice_object: slice_object
new_state: new_state
Raises:
Exception in case of error
"""
Expand Down
11 changes: 9 additions & 2 deletions fabric_cf/actor/core/apis/abc_client_actor_management_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,22 @@ def update_broker(self, *, broker: ProxyAvro, caller: AuthToken) -> ResultAvro:

@abstractmethod
def get_broker_query_model(self, *, broker: ID, caller: AuthToken, id_token: str,
level: int, graph_format: GraphFormat) -> ResultBrokerQueryModelAvro:
level: int, graph_format: GraphFormat, start: datetime = None,
end: datetime = None, includes: str = None,
excludes: str = None) -> ResultBrokerQueryModelAvro:
"""
Get Pool Info
@param broker : broker ID
@param caller: caller
@param id_token: str
@param level: level of details
@param graph_format: Graph Format
@return pool information
@param start: start time
@param end: end time
@param includes: comma separated lists of sites to include
@param excludes: comma separated lists of sites to exclude
@return resource information
"""

@abstractmethod
Expand Down
72 changes: 64 additions & 8 deletions fabric_cf/actor/core/apis/abc_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ def update_slice(self, *, slice_object: ABCSlice):

@abstractmethod
def get_reservations(self, *, slice_id: ID = None, graph_node_id: str = None, project_id: str = None,
email: str = None, oidc_sub: str = None, rid: ID = None,
states: list[int] = None, site: str = None,
rsv_type: list[str] = None) -> List[ABCReservationMixin]:
email: str = None, oidc_sub: str = None, rid: ID = None, states: list[int] = None,
site: str = None, rsv_type: list[str] = None, start: datetime = None,
end: datetime = None, ip_subnet: str = None, host: str = None) -> List[ABCReservationMixin]:
"""
Retrieves the reservations.
Expand All @@ -172,13 +172,22 @@ def get_reservations(self, *, slice_id: ID = None, graph_node_id: str = None, pr

@abstractmethod
def get_components(self, *, node_id: str, states: list[int], rsv_type: list[str], component: str = None,
bdf: str = None) -> Dict[str, List[str]]:
bdf: str = None, start: datetime = None, end: datetime = None,
excludes: List[str] = None) -> Dict[str, List[str]]:
"""
Retrieves the components.
Returns components matching the search criteria
@param node_id: Worker Node ID to which components belong
@param states: list of states used to find reservations
@param rsv_type: type of reservations
@param component: component name
@param bdf: Component's PCI address
@param start: start time
@param end: end time
@param excludes: Excludes the list of reservations
@return list of components
NOTE# For P4 switches; node_id=node+renc-p4-sw component=ip+192.168.11.8 bdf=p1
@throws Exception in case of error
@return Dictionary with component name as the key and value as list of associated PCI addresses in use.
"""

@abstractmethod
Expand All @@ -194,7 +203,8 @@ def get_client_reservations(self, *, slice_id: ID = None) -> List[ABCReservation
@abstractmethod
def get_slices(self, *, slice_id: ID = None, slice_name: str = None, project_id: str = None, email: str = None,
states: list[int] = None, oidc_sub: str = None, slc_type: List[SliceTypes] = None,
limit: int = None, offset: int = None, lease_end: datetime = None) -> List[ABCSlice] or None:
limit: int = None, offset: int = None, lease_end: datetime = None,
search: str = None, exact_match: bool = False) -> List[ABCSlice] or None:
"""
Retrieves the specified slices.
Expand All @@ -208,12 +218,58 @@ def get_slices(self, *, slice_id: ID = None, slice_name: str = None, project_id:
@param limit limit
@param offset offset
@param lease_end lease_end
@param search: search term applied
@param exact_match: Exact Match for Search term
@return list of slices
@throws Exception in case of error
"""

@abstractmethod
def get_slice_count(self, *, project_id: str = None, email: str = None, states: list[int] = None,
oidc_sub: str = None, slc_type: List[SliceTypes] = None,
excluded_projects: List[str] = None) -> int:
"""
Retrieves the slices count.
@param project_id project id
@param email email
@param states states
@param oidc_sub oidc sub
@param slc_type slice type
@param excluded_projects excluded_projects
@return number of slices matching the filter criteria
@throws Exception in case of error
"""

@abstractmethod
def increment_metrics(self, *, project_id: str, oidc_sub: str, slice_count: int = 1) -> bool:
"""
Add or Update Metrics
@param project_id project id
@param oidc_sub oidc sub
@param slice_count slice_count
@return true or false
@throws Exception in case of error
"""

@abstractmethod
def get_metrics(self, *, project_id: str, oidc_sub: str, excluded_projects: List[str] = None) -> list:
"""
Get Metrics
@param project_id: project id
@param oidc_sub: user id
@param excluded_projects: list of project ids to exclude
@return list of metrics
"""

@abstractmethod
def initialize(self):
"""
Expand Down
Loading

0 comments on commit 195d6e7

Please sign in to comment.