Skip to content

Commit

Permalink
Some fixes on the generation on the contracts e some other minor ones
Browse files Browse the repository at this point in the history
  • Loading branch information
cannarelladev committed Oct 21, 2023
1 parent 47bf2eb commit f8583ed
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 30 deletions.
3 changes: 0 additions & 3 deletions apis/nodecore/v1alpha1/flavour_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
3 changes: 0 additions & 3 deletions apis/reservation/v1alpha1/reservation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -250,7 +247,6 @@ spec:
type: string
required:
- characteristics
- flavourID
- optionalFields
- owner
- policy
Expand Down
4 changes: 0 additions & 4 deletions deployments/node/crds/nodecore.fluidos.eu_allocations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -251,7 +248,6 @@ spec:
type: string
required:
- characteristics
- flavourID
- optionalFields
- owner
- policy
Expand Down
4 changes: 0 additions & 4 deletions deployments/node/crds/nodecore.fluidos.eu_flavours.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -211,7 +208,6 @@ spec:
type: string
required:
- characteristics
- flavourID
- optionalFields
- owner
- policy
Expand Down
4 changes: 0 additions & 4 deletions deployments/node/crds/reservation.fluidos.eu_contracts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -281,7 +278,6 @@ spec:
type: string
required:
- characteristics
- flavourID
- optionalFields
- owner
- policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -171,7 +166,6 @@ spec:
type: string
required:
- buyer
- buyerClusterID
- seller
- solverID
type: object
Expand Down
13 changes: 13 additions & 0 deletions pkg/rear-controller/gateway/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions pkg/utils/parseutil/parseutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
19 changes: 17 additions & 2 deletions pkg/utils/resourceforge/forge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(),
}
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f8583ed

Please sign in to comment.