Skip to content

Commit f9875ae

Browse files
authored
Merge pull request #405 from fabric-testbed/rel1.8
Rel1.8 - changes
2 parents 2afc424 + 32594a7 commit f9875ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1589
-369
lines changed

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,7 @@ logs
138138
*_creds
139139
*.lock
140140
*.log
141-
neo4j1/
142-
neo4j2/
143-
neo4j3/
144-
neo4j4/
141+
neo4j*/
145142
pdp/
146143
pg_data/
147144
schema/

Dockerfile-auth

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM python:3.11.0
22
MAINTAINER Komal Thareja<[email protected]>
33

4-
ARG HANDLERS_VER=1.7.1
4+
ARG HANDLERS_VER=1.8.0
55

66
RUN mkdir -p /usr/src/app
77
WORKDIR /usr/src/app

fabric_cf/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "1.7.0"
1+
__version__ = "1.8.0"
22
__VERSION__ = __version__

fabric_cf/actor/boot/configuration.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ def __init__(self, *, config: dict):
4545
if Constants.CONFIG_SECTION_O_AUTH in config:
4646
self.oauth = config.get(Constants.CONFIG_SECTION_O_AUTH)
4747

48+
self.smtp = {}
49+
if Constants.CONFIG_SECTION_SMTP in config:
50+
self.smtp = config.get(Constants.CONFIG_SECTION_SMTP)
51+
4852
self.database = {}
4953
if Constants.CONFIG_SECTION_DATABASE in config:
5054
self.database = config.get(Constants.CONFIG_SECTION_DATABASE)
@@ -87,6 +91,12 @@ def get_oauth(self) -> dict:
8791
"""
8892
return self.oauth
8993

94+
def get_smtp(self) -> dict:
95+
"""
96+
Return smtp config
97+
"""
98+
return self.smtp
99+
90100
def get_database(self) -> dict:
91101
"""
92102
Return database config
@@ -425,6 +435,10 @@ def get_oauth_config(self) -> dict:
425435
return self.global_config.get_oauth()
426436
return None
427437

438+
def get_smtp_config(self) -> dict:
439+
if self.global_config:
440+
return self.global_config.get_smtp()
441+
428442
def get_actor_config(self) -> ActorConfig:
429443
"""
430444
Return Actor Config

fabric_cf/actor/core/apis/abc_actor_management_object.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ def get_sites(self, *, caller: AuthToken, site: str) -> ResultSitesAvro:
238238
def get_reservations(self, *, caller: AuthToken, states: List[int] = None,
239239
slice_id: ID = None, rid: ID = None, oidc_claim_sub: str = None,
240240
email: str = None, rid_list: List[str] = None, type: str = None,
241-
site: str = None, node_id: str = None,
242-
host: str = None, ip_subnet: str = None, full: bool = False) -> ResultReservationAvro:
241+
site: str = None, node_id: str = None, host: str = None, ip_subnet: str = None,
242+
full: bool = False, start: datetime = None, end: datetime = None) -> ResultReservationAvro:
243243
"""
244244
Get Reservations
245245
@param states states
@@ -256,10 +256,30 @@ def get_reservations(self, *, caller: AuthToken, states: List[int] = None,
256256
@param host host
257257
@param ip_subnet ip subnet
258258
@param full
259+
@param start: start time
260+
@param end: end time
259261
260262
@return returns list of the reservations
261263
"""
262264

265+
def get_components(self, *, node_id: str, rsv_type: list[str], states: list[int],
266+
component: str = None, bdf: str = None, start: datetime = None,
267+
end: datetime = None, excludes: List[str] = None) -> Dict[str, List[str]]:
268+
"""
269+
Returns components matching the search criteria
270+
@param node_id: Worker Node ID to which components belong
271+
@param states: list of states used to find reservations
272+
@param rsv_type: type of reservations
273+
@param component: component name
274+
@param bdf: Component's PCI address
275+
@param start: start time
276+
@param end: end time
277+
@param excludes: Excludes the list of reservations
278+
NOTE# For P4 switches; node_id=node+renc-p4-sw component=ip+192.168.11.8 bdf=p1
279+
280+
@return Dictionary with component name as the key and value as list of associated PCI addresses in use.
281+
"""
282+
263283
def get_slices(self, *, slice_id: ID, caller: AuthToken, slice_name: str = None, email: str = None,
264284
states: List[int] = None, project: str = None, limit: int = None,
265285
offset: int = None, user_id: str = None, search: str = None,

fabric_cf/actor/core/apis/abc_mgmt_actor.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from __future__ import annotations
2727

2828
from abc import abstractmethod
29+
from datetime import datetime
2930
from typing import TYPE_CHECKING, List, Tuple, Dict
3031

3132
from fabric_mb.message_bus.messages.delegation_avro import DelegationAvro
@@ -151,7 +152,8 @@ def accept_update_slice(self, *, slice_id: ID) -> bool:
151152
def get_reservations(self, *, states: List[int] = None, slice_id: ID = None,
152153
rid: ID = None, oidc_claim_sub: str = None, email: str = None, rid_list: List[str] = None,
153154
type: str = None, site: str = None, node_id: str = None,
154-
host: str = None, ip_subnet: str = None, full: bool = False) -> List[ReservationMng]:
155+
host: str = None, ip_subnet: str = None, full: bool = False,
156+
start: datetime = None, end: datetime = None) -> List[ReservationMng]:
155157
"""
156158
Get Reservations
157159
@param states states
@@ -166,10 +168,31 @@ def get_reservations(self, *, states: List[int] = None, slice_id: ID = None,
166168
@param ip_subnet ip subnet
167169
@param host host
168170
@param full
171+
@param start: start time
172+
@param end: end time
169173
Obtains all reservations
170174
@return returns list of the reservations
171175
"""
172176

177+
def get_components(self, *, node_id: str, rsv_type: list[str], states: list[int],
178+
component: str = None, bdf: str = None, start: datetime = None,
179+
end: datetime = None, excludes: List[str] = None) -> Dict[str, List[str]]:
180+
"""
181+
Returns components matching the search criteria
182+
@param node_id: Worker Node ID to which components belong
183+
@param states: list of states used to find reservations
184+
@param rsv_type: type of reservations
185+
@param component: component name
186+
@param bdf: Component's PCI address
187+
@param start: start time
188+
@param end: end time
189+
@param excludes: Excludes the list of reservations
190+
NOTE# For P4 switches; node_id=node+renc-p4-sw component=ip+192.168.11.8 bdf=p1
191+
192+
@return Dictionary with component name as the key and value as list of associated PCI addresses in use.
193+
"""
194+
raise NotImplementedError
195+
173196
@abstractmethod
174197
def get_sites(self, *, site: str) -> List[SiteAvro] or None:
175198
"""

fabric_cf/actor/core/common/constants.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ class Constants:
173173
PROPERTY_CONF_O_AUTH_TRL_REFRESH = "trl-refresh"
174174
PROPERTY_CONF_O_AUTH_VERIFY_EXP = "verify-exp"
175175

176+
CONFIG_SECTION_SMTP = "smtp"
177+
176178
CONFIG_SECTION_DATABASE = "database"
177179
PROPERTY_CONF_DB_USER = "db-user"
178180
PROPERTY_CONF_DB_PASSWORD = "db-password"
@@ -302,10 +304,11 @@ class Constants:
302304

303305
USER_SSH_KEY = "user.ssh.key"
304306
ALGORITHM = 'algorithm'
307+
CORE_CAPACITY_THRESHOLD = "core_capacity_threshold"
305308

306309
# Orchestrator Lease params
307310
TWO_WEEKS = timedelta(days=15)
308-
DEFAULT_MAX_DURATION = TWO_WEEKS
311+
DEFAULT_MAX_DURATION_IN_WEEKS = TWO_WEEKS
309312
LEASE_TIME_FORMAT = "%Y-%m-%d %H:%M:%S %z"
310313
DEFAULT_LEASE_IN_HOURS = 24
311314
LONG_LIVED_SLICE_TIME_WEEKS = timedelta(weeks=26)

fabric_cf/actor/core/core/policy.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#
2424
#
2525
# Author: Komal Thareja ([email protected])
26+
import enum
27+
from enum import Enum
28+
2629
from fabric_cf.actor.boot.configuration import ActorConfig
2730
from fabric_cf.actor.core.apis.abc_actor_mixin import ABCActorMixin
2831
from fabric_cf.actor.core.apis.abc_delegation import ABCDelegation
@@ -36,6 +39,19 @@
3639
from fabric_cf.actor.core.kernel.resource_set import ResourceSet
3740

3841

42+
class AllocationAlgorithm(Enum):
43+
FirstFit = enum.auto()
44+
BestFit = enum.auto()
45+
WorstFit = enum.auto()
46+
Random = enum.auto()
47+
48+
def __repr__(self):
49+
return self.name
50+
51+
def __str__(self):
52+
return self.name
53+
54+
3955
class Policy(ABCPolicy):
4056
"""
4157
Base class for all policy implementations.

fabric_cf/actor/core/kernel/reservation_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,8 @@ def probe_join_state(self):
10041004

10051005
# This is a regular request for modifying network resources to an upstream broker.
10061006
self.sequence_ticket_out += 1
1007-
print(f"Issuing an extend ticket {sliver_to_str(sliver=self.get_requested_resources().get_sliver())}")
1007+
self.logger.debug(f"Issuing an extend ticket "
1008+
f"{sliver_to_str(sliver=self.get_requested_resources().get_sliver())}")
10081009
RPCManagerSingleton.get().extend_ticket(reservation=self)
10091010

10101011
# Update ASM with Reservation Info

fabric_cf/actor/core/manage/actor_management_object.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,11 +428,17 @@ def get_sites(self, *, caller: AuthToken, site: str) -> ResultSitesAvro:
428428

429429
return result
430430

431+
def get_components(self, *, node_id: str, rsv_type: list[str], states: list[int],
432+
component: str = None, bdf: str = None, start: datetime = None,
433+
end: datetime = None, excludes: List[str] = None) -> Dict[str, List[str]]:
434+
return self.db.get_components(node_id=node_id, rsv_type=rsv_type, states=states,
435+
component=component, bdf=bdf, start=start, end=end, excludes=excludes)
436+
431437
def get_reservations(self, *, caller: AuthToken, states: List[int] = None,
432438
slice_id: ID = None, rid: ID = None, oidc_claim_sub: str = None,
433439
email: str = None, rid_list: List[str] = None, type: str = None,
434-
site: str = None, node_id: str = None, host: str = None,
435-
ip_subnet: str = None, full: bool = False) -> ResultReservationAvro:
440+
site: str = None, node_id: str = None, host: str = None, ip_subnet: str = None,
441+
full: bool = False, start: datetime = None, end: datetime = None) -> ResultReservationAvro:
436442
result = ResultReservationAvro()
437443
result.status = ResultAvro()
438444

@@ -452,7 +458,8 @@ def get_reservations(self, *, caller: AuthToken, states: List[int] = None,
452458
else:
453459
res_list = self.db.get_reservations(slice_id=slice_id, rid=rid, email=email,
454460
states=states, rsv_type=rsv_type, site=site,
455-
graph_node_id=node_id, host=host, ip_subnet=ip_subnet)
461+
graph_node_id=node_id, host=host, ip_subnet=ip_subnet,
462+
start=start, end=end)
456463
except Exception as e:
457464
self.logger.error("getReservations:db access {}".format(e))
458465
result.status.set_code(ErrorCodes.ErrorDatabaseError.value)

fabric_cf/actor/core/manage/kafka/kafka_actor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
# Author: Komal Thareja ([email protected])
2626
from __future__ import annotations
2727

28+
from datetime import datetime
2829
from typing import List
2930

3031
from fabric_mb.message_bus.messages.close_delegations_avro import CloseDelegationsAvro
@@ -132,7 +133,8 @@ def delete_slice(self, *, slice_id: ID) -> bool:
132133
def get_reservations(self, *, states: List[int] = None, slice_id: ID = None,
133134
rid: ID = None, oidc_claim_sub: str = None, email: str = None, rid_list: List[str] = None,
134135
type: str = None, site: str = None, node_id: str = None,
135-
host: str = None, ip_subnet: str = None, full: bool = False) -> List[ReservationMng]:
136+
host: str = None, ip_subnet: str = None, full: bool = False,
137+
start: datetime = None, end: datetime = None) -> List[ReservationMng]:
136138
request = GetReservationsRequestAvro()
137139
request = self.fill_request_by_id_message(request=request, slice_id=slice_id,
138140
states=states, email=email, rid=rid,

fabric_cf/actor/core/manage/local/local_actor.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from __future__ import annotations
2727

2828
import traceback
29+
from datetime import datetime
2930
from typing import TYPE_CHECKING, List, Tuple, Dict
3031

3132
from fabric_mb.message_bus.messages.delegation_avro import DelegationAvro
@@ -44,12 +45,11 @@
4445
from fabric_mb.message_bus.messages.reservation_mng import ReservationMng
4546
from fabric_mb.message_bus.messages.reservation_state_avro import ReservationStateAvro
4647
from fabric_mb.message_bus.messages.slice_avro import SliceAvro
47-
from fabric_cf.actor.core.manage.management_object import ManagementObject
4848
from fabric_cf.actor.security.auth_token import AuthToken
4949

5050

5151
class LocalActor(LocalProxy, ABCMgmtActor):
52-
def __init__(self, *, manager: ManagementObject, auth: AuthToken):
52+
def __init__(self, *, manager: ActorManagementObject, auth: AuthToken):
5353
super().__init__(manager=manager, auth=auth)
5454

5555
if not isinstance(manager, ActorManagementObject):
@@ -111,13 +111,14 @@ def remove_slice(self, *, slice_id: ID) -> bool:
111111
def get_reservations(self, *, states: List[int] = None, slice_id: ID = None,
112112
rid: ID = None, oidc_claim_sub: str = None, email: str = None, rid_list: List[str] = None,
113113
type: str = None, site: str = None, node_id: str = None,
114-
host: str = None, ip_subnet: str = None, full: bool = False) -> List[ReservationMng]:
114+
host: str = None, ip_subnet: str = None, full: bool = False,
115+
start: datetime = None, end: datetime = None) -> List[ReservationMng]:
115116
self.clear_last()
116117
try:
117118
result = self.manager.get_reservations(caller=self.auth, states=states, slice_id=slice_id, rid=rid,
118119
oidc_claim_sub=oidc_claim_sub, email=email, rid_list=rid_list,
119120
type=type, site=site, node_id=node_id, host=host,
120-
ip_subnet=ip_subnet, full=full)
121+
ip_subnet=ip_subnet, full=full, start=start, end=end)
121122
self.last_status = result.status
122123

123124
if result.status.get_code() == 0:
@@ -126,6 +127,16 @@ def get_reservations(self, *, states: List[int] = None, slice_id: ID = None,
126127
except Exception as e:
127128
self.on_exception(e=e, traceback_str=traceback.format_exc())
128129

130+
def get_components(self, *, node_id: str, rsv_type: list[str], states: list[int],
131+
component: str = None, bdf: str = None, start: datetime = None,
132+
end: datetime = None, excludes: List[str] = None) -> Dict[str, List[str]]:
133+
try:
134+
return self.manager.get_components(node_id=node_id, rsv_type=rsv_type, states=states,
135+
component=component, bdf=bdf, start=start,
136+
end=end, excludes=excludes)
137+
except Exception as e:
138+
self.on_exception(e=e, traceback_str=traceback.format_exc())
139+
129140
def get_sites(self, *, site: str) -> List[SiteAvro] or None:
130141
self.clear_last()
131142
try:

fabric_cf/actor/core/manage/management_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class ManagementUtils:
6767
@staticmethod
6868
def update_slice(*, slice_obj: ABCSlice, slice_mng: SliceAvro) -> ABCSlice:
6969
slice_obj.set_graph_id(graph_id=slice_mng.get_graph_id())
70+
slice_obj.set_lease_start(lease_start=slice_mng.get_lease_start())
7071
slice_obj.set_lease_end(lease_end=slice_mng.get_lease_end())
7172
slice_obj.set_config_properties(value=slice_mng.get_config_properties())
7273
return slice_obj

0 commit comments

Comments
 (0)