diff --git a/models/booking/booking.go b/models/booking/booking.go index bdc031b..831f443 100644 --- a/models/booking/booking.go +++ b/models/booking/booking.go @@ -17,9 +17,9 @@ 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"` + 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"` ExecutionsID string `json:"executions_id,omitempty" bson:"executions_id,omitempty" validate:"required"` // ExecutionsID is the ID of the executions diff --git a/models/common/pricing/pricing_strategy.go b/models/common/pricing/pricing_strategy.go index fee356f..728e794 100755 --- a/models/common/pricing/pricing_strategy.go +++ b/models/common/pricing/pricing_strategy.go @@ -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} } diff --git a/models/order/order_mongo_accessor.go b/models/order/order_mongo_accessor.go index adbf43f..29a17cc 100644 --- a/models/order/order_mongo_accessor.go +++ b/models/order/order_mongo_accessor.go @@ -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) { diff --git a/models/resources/data.go b/models/resources/data.go index aecf190..9a26a20 100755 --- a/models/resources/data.go +++ b/models/resources/data.go @@ -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 { diff --git a/models/resources/priced_resource.go b/models/resources/priced_resource.go index 161be32..c479220 100755 --- a/models/resources/priced_resource.go +++ b/models/resources/priced_resource.go @@ -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 } diff --git a/models/resources/storage.go b/models/resources/storage.go index a1198ca..77a04c1 100755 --- a/models/resources/storage.go +++ b/models/resources/storage.go @@ -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 { diff --git a/models/workflow/workflow.go b/models/workflow/workflow.go index 3cfdf2b..71f0a1f 100644 --- a/models/workflow/workflow.go +++ b/models/workflow/workflow.go @@ -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 { diff --git a/tools/enums.go b/tools/enums.go index 4e1736b..5bc0620 100644 --- a/tools/enums.go +++ b/tools/enums.go @@ -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 {