Merge branch 'main' of https://cloud.o-forge.io/core/oc-lib
This commit is contained in:
commit
34f01e9740
@ -17,7 +17,7 @@ import (
|
||||
*/
|
||||
type Booking struct {
|
||||
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name)
|
||||
PricedItem pricing.PricedItemITF `json:"priced_item,omitempty" bson:"priced_item,omitempty" validate:"required"`
|
||||
PricedItem pricing.PricedItemITF `json:"priced_item,omitempty" bson:"priced_item,omitempty"` // We need to add the validate:"required" tag once the pricing feature is implemented, removed to avoid handling the error
|
||||
|
||||
ResumeMetrics map[string]map[string]models.MetricResume `json:"resume_metrics,omitempty" bson:"resume_metrics,omitempty"`
|
||||
ExecutionMetrics map[string][]models.MetricsSnapshot `json:"metrics,omitempty" bson:"metrics,omitempty"`
|
||||
|
@ -93,6 +93,10 @@ func (t TimePricingStrategy) String() string {
|
||||
return [...]string{"ONCE", "PER SECOND", "PER MINUTE", "PER HOUR", "PER DAY", "PER WEEK", "PER MONTH"}[t]
|
||||
}
|
||||
|
||||
func TimePricingStrategyListStr() []string {
|
||||
return []string{"ONCE", "PER SECOND", "PER MINUTE", "PER HOUR", "PER DAY", "PER WEEK", "PER MONTH"}
|
||||
}
|
||||
|
||||
func TimePricingStrategyList() []TimePricingStrategy {
|
||||
return []TimePricingStrategy{ONCE, PER_SECOND, PER_MINUTE, PER_HOUR, PER_DAY, PER_WEEK, PER_MONTH}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ func (a *orderMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBO
|
||||
}
|
||||
|
||||
func (a *orderMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||
return nil, 404, errors.New("Not implemented")
|
||||
return utils.GenericStoreOne(data,a)
|
||||
}
|
||||
|
||||
func (a *orderMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||
|
@ -89,7 +89,9 @@ const (
|
||||
)
|
||||
|
||||
func (t DataResourcePricingStrategy) String() string {
|
||||
return [...]string{"PER DOWNLOAD", "PER TB DOWNLOADED", "PER GB DOWNLOADED", "PER MB DOWNLOADED", "PER KB DOWNLOADED"}[t]
|
||||
l := pricing.TimePricingStrategyListStr()
|
||||
l = append(l, []string{"PER DOWNLOAD", "PER TB DOWNLOADED", "PER GB DOWNLOADED", "PER MB DOWNLOADED", "PER KB DOWNLOADED"}...)
|
||||
return l[t]
|
||||
}
|
||||
|
||||
func DataResourcePricingStrategyList() []DataResourcePricingStrategy {
|
||||
@ -101,7 +103,9 @@ func ToDataResourcePricingStrategy(i int) DataResourcePricingStrategy {
|
||||
}
|
||||
|
||||
func (t DataResourcePricingStrategy) GetStrategy() string {
|
||||
return [...]string{"PER_DOWNLOAD", "PER_GB", "PER_MB", "PER_KB"}[t]
|
||||
l := pricing.TimePricingStrategyListStr()
|
||||
l = append(l, []string{"PER DATA STORED", "PER TB STORED", "PER GB STORED", "PER MB STORED", "PER KB STORED"}...)
|
||||
return l[t]
|
||||
}
|
||||
|
||||
func (t DataResourcePricingStrategy) GetStrategyValue() int {
|
||||
|
@ -46,6 +46,7 @@ func (abs *PricedResource) IsPurchasable() bool {
|
||||
}
|
||||
|
||||
func (abs *PricedResource) IsBooked() bool {
|
||||
return true // For dev purposes, prevent that DB objects that don't have a Pricing are considered as not booked
|
||||
if abs.SelectedPricing == nil {
|
||||
return false
|
||||
}
|
||||
|
@ -115,11 +115,15 @@ func StorageResourcePricingStrategyList() []StorageResourcePricingStrategy {
|
||||
}
|
||||
|
||||
func (t StorageResourcePricingStrategy) String() string {
|
||||
return [...]string{"PER DATA STORED", "PER TB STORED", "PER GB STORED", "PER MB STORED", "PER KB STORED"}[t]
|
||||
l := pricing.TimePricingStrategyListStr()
|
||||
l = append(l, []string{"PER DATA STORED", "PER TB STORED", "PER GB STORED", "PER MB STORED", "PER KB STORED"}...)
|
||||
return l[t]
|
||||
}
|
||||
|
||||
func (t StorageResourcePricingStrategy) GetStrategy() string {
|
||||
return [...]string{"PER_DATA_STORED", "PER_GB_STORED", "PER_MB_STORED", "PER_KB_STORED"}[t]
|
||||
l := pricing.TimePricingStrategyListStr()
|
||||
l = append(l, []string{"PER DATA STORED", "PER TB STORED", "PER GB STORED", "PER MB STORED", "PER KB STORED"}...)
|
||||
return l[t]
|
||||
}
|
||||
|
||||
func (t StorageResourcePricingStrategy) GetStrategyValue() int {
|
||||
|
@ -240,9 +240,10 @@ func plan[T resources.ResourceInterface](
|
||||
return resources, priceds, errors.New("could not load the processing resource")
|
||||
}
|
||||
priced := realItem.ConvertToPricedResource(dt, request)
|
||||
if priced.SelectPricing() == nil {
|
||||
return resources, priceds, errors.New("no pricings are selected... can't proceed")
|
||||
}
|
||||
// Should be commented once the Pricing selection feature has been implemented, related to the commit d35ad440fa77763ec7f49ab34a85e47e75581b61
|
||||
// if priced.SelectPricing() == nil {
|
||||
// return resources, priceds, errors.New("no pricings are selected... can't proceed")
|
||||
// }
|
||||
started, duration := start(realItem, priced)
|
||||
priced.SetLocationStart(started)
|
||||
if duration >= 0 {
|
||||
|
@ -29,6 +29,7 @@ const (
|
||||
LIVE_DATACENTER
|
||||
LIVE_STORAGE
|
||||
BILL
|
||||
MINIO_SVCACC
|
||||
)
|
||||
|
||||
var NOAPI = ""
|
||||
@ -44,6 +45,7 @@ var ADMIRALTY_TARGETAPI = DATACENTERAPI + "/admiralty/target"
|
||||
var ADMIRALTY_SECRETAPI = DATACENTERAPI + "/admiralty/secret"
|
||||
var ADMIRALTY_KUBECONFIGAPI = DATACENTERAPI + "/admiralty/kubeconfig"
|
||||
var ADMIRALTY_NODESAPI = DATACENTERAPI + "/admiralty/node"
|
||||
var MINIO = DATACENTERAPI + "/minio"
|
||||
|
||||
// Bind the standard API name to the data type
|
||||
var DefaultAPI = [...]string{
|
||||
@ -72,6 +74,7 @@ var DefaultAPI = [...]string{
|
||||
DATACENTERAPI,
|
||||
DATACENTERAPI,
|
||||
NOAPI,
|
||||
MINIO,
|
||||
}
|
||||
|
||||
// Bind the standard data name to the data type
|
||||
@ -101,6 +104,7 @@ var Str = [...]string{
|
||||
"live_datacenter",
|
||||
"live_storage",
|
||||
"bill",
|
||||
"service_account",
|
||||
}
|
||||
|
||||
func FromInt(i int) string {
|
||||
|
Loading…
Reference in New Issue
Block a user