Skip to content

Commit c2c6069

Browse files
authored
Merge pull request #180 from fabric-testbed/get_slices
Changes identified during tests
2 parents 3c7dd04 + 35f6998 commit c2c6069

24 files changed

+55
-69
lines changed

Dockerfile-auth

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

4-
ARG HANDLERS_VER=1.2rc6
4+
ARG HANDLERS_VER=1.2.1
55

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

authority.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
#!/usr/bin/env bash
2-
3-
python3 -m fabric_cf.authority
2+
docker exec -i $1-am-db psql am fabric < psql.upgrade

broker.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
#!/usr/bin/env bash
2-
3-
python3 -m fabric_cf.broker
2+
docker exec -i broker-db psql broker fabric < psql.upgrade

fabric_cf/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__VERSION__ = "1.2rc4"
1+
__VERSION__ = "1.2.1"

fabric_cf/actor/core/core/ticket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def get_ticket(self) -> ResourceTicket:
115115
"""
116116
return self.resource_ticket
117117

118-
def add(self, *, concrete_set, configure: bool):
118+
def add(self, *, concrete_set: ABCConcreteSet, configure: bool):
119119
raise TicketException("add() is not supported by Ticket")
120120

121121
def change(self, *, concrete_set: ABCConcreteSet, configure: bool):

fabric_cf/actor/core/core/unit_set.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ def restore(self, *, plugin: ABCBasePlugin, reservation: ABCReservationMixin):
9696
self.logger = plugin.get_logger()
9797
self.reservation = reservation
9898

99-
def ensure_type(self, *, cset: ABCConcreteSet):
99+
@staticmethod
100+
def ensure_type(*, cset: ABCConcreteSet):
100101
"""
101102
Validate the type of incoming concrete set
102103
@param cset cset

fabric_cf/actor/core/kernel/reservation_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,9 @@ def prepare_ticket(self):
457457
continue
458458

459459
pred_state = self.redeem_predecessors.get(ID(uid=rid))
460+
if not pred_state:
461+
self.logger.error(f"Redeem predecessors not found {rid} for {self.get_reservation_id()}")
462+
continue
460463
parent_res = pred_state.get_reservation()
461464
if parent_res is not None and \
462465
ReservationStates(parent_res.get_state()) == ReservationStates.Ticketed:
@@ -580,7 +583,7 @@ def do_relinquish(self):
580583

581584
def close(self):
582585
if self.state == ReservationStates.Nascent or self.state == ReservationStates.Failed:
583-
self.logger.debug("Reservation in Nascent or failed state, transition to close")
586+
self.logger.debug(f"Reservation in state: {self.state}, transition to {ReservationStates.Closed}")
584587
self.transition(prefix="close", state=ReservationStates.Closed, pending=self.pending_state)
585588
if self.broker is not None:
586589
self.logger.debug("Triggering relinquish")

fabric_cf/actor/core/kernel/resource_set.py

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -50,47 +50,7 @@ class ResourceSet:
5050
ResourceSet with an attached ConcreteSet is "concrete." The ConcreteSet binds
5151
real resources (or a promise) for some or all of the abstract units in the
5252
set: for example, a concrete ResourceSet can represent a ticket or
53-
lease. Adding or removing concrete resources does not affect the number of
54-
abstract units. If there are fewer concrete units than abstract units, the
55-
set has a "deficit".
56-
57-
An "elastic" ResourceSet may be filled at less than its full request, and it
58-
may change size on extends. An actor may modify an elastic ResourceSet on an
59-
active ReservationClient by calling "flex", if there is no pending operation
60-
in progress, e.g., in preparation for an elastic extend. This class updates
61-
the unit count to match the concrete resources on each reserve or extend (on
62-
a server), or update (on a client).
63-
64-
Operations on the ConcreteSet through this class may drive probes and state
65-
transitions on the underlying resources transferred in and out of the
66-
ResourceSet (e.g., node configuration and node reboot for a COD authority, or
67-
resource membership changes on a orchestrator). ConcreteSets are
68-
responsible for their own synchronization: calls to ConcreteSet go through
69-
pre-op "prepare" or post-op "service" methods in this class, which may block
70-
and should not hold any higher-level locks. Most other operations are called
71-
through Mapper or the Reservation class with the Manager lock held.
72-
73-
Implementation notes
74-
The unit count is updated immediately to reflect additions or deletions
75-
from the set. Updates to the unit count must occur only in the locked
76-
methods. Configuration actions on the ConcreteSet (e.g., as resources join
77-
and leave the set) must occur only in unlocked methods (e.g., "service"). A
78-
tricky part is flex(), which updates abstract count to reflect a new request:
79-
it is unlocked, which could race with an incoming unsolicited lease (which
80-
are currently allowed), or with overlapping requests on the same set (which
81-
are currently not allowed).
82-
ResourceSet was conceived as supporting methods that are independent of
83-
context and type of ConcreteSet. That ideal has eroded somewhat, and some key
84-
fields and methods are specific to a particular context or role. Someday it
85-
may be useful to break this into subclasses.
86-
Currently leases are validated only with validateIncoming(). There may be
87-
some additional checks to enforce.
88-
No changes to ResourceData on merges. Needs thought and documentation. We
89-
should remove the properties argument on ConcreteSet.change.
90-
The 'null ticket corner case' (see above) is a source of complexity, and
91-
should be cleaned up.
92-
Calls that "reach around" ResourceSet to the concrete set are
93-
discouraged/deprecated.
53+
lease.
9454
"""
9555
def __init__(self, *, concrete: ABCConcreteSet = None, gained: ABCConcreteSet = None,
9656
lost: ABCConcreteSet = None, modified: ABCConcreteSet = None,

fabric_cf/actor/core/policy/network_node_inventory.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,12 @@ def __check_capacities(self, *, rid: ID, requested_capacities: Capacities, deleg
8989
def __set_ips(self, *, req_ifs: InterfaceSliver, lab: Labels):
9090
if req_ifs.labels is not None and req_ifs.labels.ipv4 is not None:
9191
lab.ipv4 = req_ifs.labels.ipv4
92+
if req_ifs.labels.ipv4_subnet is not None:
93+
lab.ipv4_subnet = req_ifs.labels.ipv4_subnet
9294
if req_ifs.labels is not None and req_ifs.labels.ipv6 is not None:
9395
lab.ipv6 = req_ifs.labels.ipv6
96+
if req_ifs.labels.ipv6_subnet is not None:
97+
lab.ipv6_subnet = req_ifs.labels.ipv6_subnet
9498
return lab
9599

96100
def __update_shared_nic_labels_and_capacities(self, *, available_component: ComponentSliver,

fabric_cf/actor/core/policy/network_service_inventory.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ def allocate(self, *, rid: ID, requested_ns: NetworkServiceSliver, owner_switch:
208208
- exclude the 1st subnet (reserved for control plane)
209209
- exclude the subnets already assigned to other V4/V6 NetworkService on the same owner switch
210210
- allocate the first available subnet to the NetworkService
211+
:param rid: Reservation ID
211212
:param requested_ns: Requested NetworkService
212213
:param owner_switch: BQM Owner site switch identified to serve the NetworkService
213214
:param existing_reservations: Existing Reservations which also are served by the owner switch

fabric_cf/actor/core/proxies/kafka/translate.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def translate_slice_to_avro(*, slice_obj: ABCSlice) -> SliceAvro:
104104
avro_slice.config_properties = slice_obj.get_config_properties()
105105
avro_slice.set_lease_end(lease_end=slice_obj.get_lease_end())
106106
avro_slice.set_lease_start(lease_start=slice_obj.get_lease_start())
107-
avro_slice.set_project_id(project_id=slice_obj.get_project_id())
107+
if hasattr(slice_obj, 'project_id') is not None:
108+
avro_slice.set_project_id(project_id=slice_obj.get_project_id())
108109

109110
if slice_obj.get_resource_type() is not None:
110111
avro_slice.set_resource_type(str(slice_obj.get_resource_type()))
@@ -123,7 +124,8 @@ def translate_auth_to_avro(*, auth: AuthToken) -> AuthAvro:
123124
result.guid = str(auth.get_guid())
124125
result.oidc_sub_claim = auth.get_oidc_sub_claim()
125126
result.email = auth.get_email()
126-
result.token = auth.get_token()
127+
if hasattr(auth, 'token') is not None:
128+
result.token = auth.get_token()
127129
return result
128130

129131
@staticmethod

fabric_cf/actor/core/time/actor_clock.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,8 @@ def from_milliseconds(*, milli_seconds) -> datetime:
185185

186186
@staticmethod
187187
def to_milliseconds(*, when: datetime) -> int:
188-
epoch = datetime.fromtimestamp(0, timezone.utc)
188+
if when.tzinfo is not None:
189+
epoch = datetime.fromtimestamp(0, timezone.utc)
190+
else:
191+
epoch = datetime.fromtimestamp(0)
189192
return int((when - epoch).total_seconds() * 1000)

fabric_cf/actor/fim/fim_helper.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from fim.graph.resources.neo4j_arm import Neo4jARMGraph
3434
from fim.graph.resources.neo4j_cbm import Neo4jCBMGraph, Neo4jCBMFactory
3535
from fim.graph.slices.abc_asm import ABCASMPropertyGraph
36-
from fim.graph.slices.neo4j_asm import Neo4jASMFactory, Neo4jASM
36+
from fim.graph.slices.neo4j_asm import Neo4jASMFactory
3737
from fim.graph.slices.networkx_asm import NetworkxASM, NetworkXASMFactory
3838
from fim.slivers.attached_components import ComponentSliver
3939
from fim.slivers.base_sliver import BaseSliver
@@ -42,7 +42,7 @@
4242
from fim.slivers.interface_info import InterfaceSliver, InterfaceType
4343
from fim.slivers.network_node import NodeSliver
4444
from fim.slivers.network_service import NetworkServiceSliver
45-
from fim.user import ExperimentTopology, Labels, ServiceType, NodeType
45+
from fim.user import ExperimentTopology, Labels, NodeType
4646

4747

4848
class InterfaceSliverMapping:
@@ -288,6 +288,16 @@ def update_node(*, graph_id: str, sliver: BaseSliver):
288288
node.components[cname].set_properties(label_allocations=component.label_allocations,
289289
capacity_allocations=component.capacity_allocations,
290290
node_map=component.node_map)
291+
# Update Mac address
292+
for ns in component.network_service_info.network_services.values():
293+
if ns.interface_info is None or ns.interface_info.interfaces is None:
294+
continue
295+
296+
for ifs in ns.interface_info.interfaces.values():
297+
topo_component = node.components[cname]
298+
topo_ifs = topo_component.interfaces[ifs.get_name()]
299+
topo_ifs.set_properties(label_allocations=ifs.label_allocations)
300+
291301
elif isinstance(sliver, NetworkServiceSliver):
292302
node = neo4j_topo.network_services[node_name]
293303
node.set_properties(label_allocations=sliver.label_allocations,

fabric_cf/actor/security/auth_token.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def clone(self):
9090
return AuthToken(name=self.name, guid=self.guid)
9191

9292
def __str__(self):
93-
return f"name: {self.name} guid: {self.guid} email: {self.email} token: {self.token}"
93+
return f"name: {self.name} guid: {self.guid} email: {self.email}"
9494

9595
def get_token(self):
9696
"""

fabric_cf/actor/security/fabric_token.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def get_project_and_tags(self) -> Tuple[str or None, List[str] or None]:
118118
project = key
119119
for tag in value:
120120
tag_list.append(tag)
121-
break
121+
break
122122
return project, tag_list
123123

124124
def __str__(self):

fabric_cf/actor/security/pdp_auth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ def _headers() -> dict:
9999
}
100100
return headers
101101

102-
@staticmethod
103-
def build_pdp_request(*, fabric_token: FabricToken, action_id: ActionId,
102+
def build_pdp_request(self, *, fabric_token: FabricToken, action_id: ActionId,
104103
resource: BaseSliver or ExperimentTopology, lease_end_time: datetime) -> dict:
105104
"""
106105
Build PDP Request
@@ -122,6 +121,8 @@ def build_pdp_request(*, fabric_token: FabricToken, action_id: ActionId,
122121
# next we need to set the owner of the resource and their projects
123122
# generally only the id is needed. If action is create, it's not needed at all
124123
project, tag_list = fabric_token.get_project_and_tags()
124+
self.logger.debug("project: %s", project)
125+
self.logger.debug("tag_list: %s", tag_list)
125126
if project is None:
126127
raise PdpAuthException("No project found in fabric token")
127128

fabric_cf/authority/config.site.am.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ runtime:
4545
kafka-sasl-consumer-password:
4646
prometheus.port: 11000
4747
kafka.request.timeout.ms: 120000
48-
rpc.request.timeout.seconds: 900
48+
rpc.request.timeout.seconds: 1200
4949

5050
logging:
5151
## The directory in which actor should create log files.

fabric_cf/broker/config.broker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ runtime:
4545
kafka-sasl-consumer-password:
4646
prometheus.port: 11000
4747
kafka.request.timeout.ms: 120000
48-
rpc.request.timeout.seconds: 900
48+
rpc.request.timeout.seconds: 1200
4949

5050
logging:
5151
## The directory in which actor should create log files.

fabric_cf/orchestrator/config.orchestrator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ runtime:
4646
orchestrator.rest.port: 8700
4747
prometheus.port: 11000
4848
kafka.request.timeout.ms: 120000
49-
rpc.request.timeout.seconds: 900
49+
rpc.request.timeout.seconds: 1200
5050

5151
logging:
5252
## The directory in which actor should create log files.

fabric_cf/orchestrator/core/orchestrator_handler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,9 @@ def get_slices(self, *, token: str, slice_id: str = None, states: List[str] = No
374374

375375
fabric_token = self.__authorize_request(id_token=token, action_id=ActionId.query)
376376

377-
project, tags = fabric_token.get_project_and_tags()
377+
# TODO - uncomment once project based view is implemented on portal
378+
#project, tags = fabric_token.get_project_and_tags()
379+
project = None
378380
slice_list = controller.get_slices(slice_id=slice_guid, state=slice_states,
379381
email=fabric_token.get_email(), project=project)
380382
return ResponseBuilder.get_slice_summary(slice_list=slice_list)

fabric_cf/orchestrator/swagger_server/response/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
#
2424
#
2525
# Author: Komal Thareja ([email protected])
26-
import connexion
26+
from flask import request
2727

2828

2929
def get_token() -> str:
30-
token = connexion.request.headers.get('Authorization', None)
30+
token = request.headers.get('Authorization', None)
3131
if token is not None:
3232
token = token.replace('Bearer ', '')
33-
return token
33+
return token

orchestrator.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
#!/usr/bin/env bash
2-
3-
python3 -m fabric_cf.orchestrator
2+
docker exec -i orchestrator-db psql orchestrator fabric < psql.upgrade

psql.upgrade

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE "Slices" ADD COLUMN IF NOT EXISTS project_id VARCHAR;
2+
ALTER TABLE "Reservations" ADD COLUMN IF NOT EXISTS project_id VARCHAR;

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ typing-extensions==3.7.4.3
1313
six==1.15.0
1414
wrapt==1.12.1
1515
fabric-message-bus==1.2.3
16-
fabric-fim==1.2.2
16+
fabric-fim==1.2.4

0 commit comments

Comments
 (0)