diff --git a/apis/nodecore/v1alpha1/flavour_types.go b/apis/nodecore/v1alpha1/flavour_types.go index 570350f..6212af1 100644 --- a/apis/nodecore/v1alpha1/flavour_types.go +++ b/apis/nodecore/v1alpha1/flavour_types.go @@ -105,9 +105,6 @@ type OptionalFields struct { type FlavourSpec struct { // This specs are based on the REAR Protocol specifications. - // FlavourID is the name of the Flavour. - FlavourID string `json:"flavourID"` - // ProviderID is the ID of the FLUIDOS Node ID that provides this Flavour. // It can correspond to ID of the owner FLUIDOS Node or to the ID of a FLUIDOS SuperNode that represents the entry point to a FLUIDOS Domain ProviderID string `json:"providerID"` diff --git a/apis/reservation/v1alpha1/reservation_types.go b/apis/reservation/v1alpha1/reservation_types.go index 4705be0..9d11237 100644 --- a/apis/reservation/v1alpha1/reservation_types.go +++ b/apis/reservation/v1alpha1/reservation_types.go @@ -39,9 +39,6 @@ type ReservationSpec struct { // This is the Node identity of the buyer FLUIDOS Node. Buyer nodecorev1alpha1.NodeIdentity `json:"buyer"` - // BuyerClusterID is the Liqo ClusterID used by the seller to search a contract and the related resources during the peering phase. - BuyerClusterID string `json:"buyerClusterID"` - // This is the Node identity of the seller FLUIDOS Node. Seller nodecorev1alpha1.NodeIdentity `json:"seller"` diff --git a/deployments/node/crds/advertisement.fluidos.eu_peeringcandidates.yaml b/deployments/node/crds/advertisement.fluidos.eu_peeringcandidates.yaml index 8175c5d..e28e641 100644 --- a/deployments/node/crds/advertisement.fluidos.eu_peeringcandidates.yaml +++ b/deployments/node/crds/advertisement.fluidos.eu_peeringcandidates.yaml @@ -122,9 +122,6 @@ spec: - cpu - memory type: object - flavourID: - description: FlavourID is the name of the Flavour. - type: string optionalFields: description: This field is used to specify the optional fields that can be retrieved from the Flavour. In the future it @@ -250,7 +247,6 @@ spec: type: string required: - characteristics - - flavourID - optionalFields - owner - policy diff --git a/deployments/node/crds/nodecore.fluidos.eu_allocations.yaml b/deployments/node/crds/nodecore.fluidos.eu_allocations.yaml index 4f4a82d..b94fda2 100644 --- a/deployments/node/crds/nodecore.fluidos.eu_allocations.yaml +++ b/deployments/node/crds/nodecore.fluidos.eu_allocations.yaml @@ -123,9 +123,6 @@ spec: - cpu - memory type: object - flavourID: - description: FlavourID is the name of the Flavour. - type: string optionalFields: description: This field is used to specify the optional fields that can be retrieved from the Flavour. In the future it @@ -251,7 +248,6 @@ spec: type: string required: - characteristics - - flavourID - optionalFields - owner - policy diff --git a/deployments/node/crds/nodecore.fluidos.eu_flavours.yaml b/deployments/node/crds/nodecore.fluidos.eu_flavours.yaml index 1754b77..43d2954 100644 --- a/deployments/node/crds/nodecore.fluidos.eu_flavours.yaml +++ b/deployments/node/crds/nodecore.fluidos.eu_flavours.yaml @@ -85,9 +85,6 @@ spec: - cpu - memory type: object - flavourID: - description: FlavourID is the name of the Flavour. - type: string optionalFields: description: This field is used to specify the optional fields that can be retrieved from the Flavour. In the future it will be expanded @@ -211,7 +208,6 @@ spec: type: string required: - characteristics - - flavourID - optionalFields - owner - policy diff --git a/deployments/node/crds/reservation.fluidos.eu_contracts.yaml b/deployments/node/crds/reservation.fluidos.eu_contracts.yaml index 2087007..593493f 100644 --- a/deployments/node/crds/reservation.fluidos.eu_contracts.yaml +++ b/deployments/node/crds/reservation.fluidos.eu_contracts.yaml @@ -153,9 +153,6 @@ spec: - cpu - memory type: object - flavourID: - description: FlavourID is the name of the Flavour. - type: string optionalFields: description: This field is used to specify the optional fields that can be retrieved from the Flavour. In the future it @@ -281,7 +278,6 @@ spec: type: string required: - characteristics - - flavourID - optionalFields - owner - policy diff --git a/deployments/node/crds/reservation.fluidos.eu_reservations.yaml b/deployments/node/crds/reservation.fluidos.eu_reservations.yaml index 42644c5..0e84480 100644 --- a/deployments/node/crds/reservation.fluidos.eu_reservations.yaml +++ b/deployments/node/crds/reservation.fluidos.eu_reservations.yaml @@ -86,11 +86,6 @@ spec: - ip - nodeID type: object - buyerClusterID: - description: BuyerClusterID is the Liqo ClusterID used by the seller - to search a contract and the related resources during the peering - phase. - type: string partition: description: Parition is the partition of the flavour that is being reserved @@ -171,7 +166,6 @@ spec: type: string required: - buyer - - buyerClusterID - seller - solverID type: object diff --git a/pkg/rear-controller/gateway/client.go b/pkg/rear-controller/gateway/client.go index 88adda5..5cd36f9 100644 --- a/pkg/rear-controller/gateway/client.go +++ b/pkg/rear-controller/gateway/client.go @@ -38,6 +38,12 @@ func (g *Gateway) ReserveFlavour(ctx context.Context, reservation *reservationv1 return nil, err } + liqoCredentials, err := GetLiqoCredentials(ctx, g.client) + if err != nil { + klog.Errorf("Error when getting Liqo credentials: %s", err) + return nil, err + } + var transaction models.Transaction body := models.ReserveRequest{ @@ -47,6 +53,13 @@ func (g *Gateway) ReserveFlavour(ctx context.Context, reservation *reservationv1 IP: g.ID.IP, Domain: g.ID.Domain, }, + ClusterID: liqoCredentials.ClusterID, + Partition: func() *models.Partition { + if reservation.Spec.Partition != nil { + return parseutil.ParsePartition(reservation.Spec.Partition) + } + return nil + }(), } klog.Infof("Reservation %s for flavour %s", reservation.Name, flavourID) diff --git a/pkg/utils/parseutil/parseutil.go b/pkg/utils/parseutil/parseutil.go index 1aecb63..c5a707a 100644 --- a/pkg/utils/parseutil/parseutil.go +++ b/pkg/utils/parseutil/parseutil.go @@ -154,6 +154,8 @@ func ParseContract(contract *reservationv1alpha1.Contract) models.Contract { Token: contract.Spec.SellerCredentials.Token, Endpoint: contract.Spec.SellerCredentials.Endpoint, }, + ExpirationTime: contract.Spec.ExpirationTime, + ExtraInformation: contract.Spec.ExtraInformation, } } diff --git a/pkg/utils/resourceforge/forge.go b/pkg/utils/resourceforge/forge.go index 5defe30..f76bbef 100644 --- a/pkg/utils/resourceforge/forge.go +++ b/pkg/utils/resourceforge/forge.go @@ -97,6 +97,12 @@ func ForgeReservation(peeringCandidate advertisementv1alpha1.PeeringCandidate, p }, Reserve: true, Purchase: true, + Partition: func() *reservationv1alpha1.Partition { + if partition != nil { + return partition + } + return nil + }(), }, } if partition != nil { @@ -193,8 +199,13 @@ func ForgeTransactionObj(ID string, req models.ReserveRequest) models.Transactio Buyer: req.Buyer, ClusterID: req.ClusterID, FlavourID: req.FlavourID, - Partition: req.Partition, - StartTime: tools.GetTimeNow(), + Partition: func() *models.Partition { + if req.Partition != nil { + return req.Partition + } + return nil + }(), + StartTime: tools.GetTimeNow(), } } @@ -363,6 +374,10 @@ func ForgeFlavourFromObj(flavour models.Flavour) *nodecorev1alpha1.Flavour { Currency: flavour.Price.Currency, Period: flavour.Price.Period, }, + OptionalFields: nodecorev1alpha1.OptionalFields{ + Availability: flavour.OptionalFields.Availability, + WorkerID: flavour.OptionalFields.WorkerID, + }, }, } return f