AjayTripathy преди 7 години
родител
ревизия
c8c734572e
променени са 4 файла, в които са добавени 34 реда и са изтрити 26 реда
  1. 2 1
      cloud/default.json
  2. 1 0
      cloud/gcpprovider.go
  3. 29 25
      cloud/provider.go
  4. 2 0
      main.go

+ 2 - 1
cloud/default.json

@@ -4,5 +4,6 @@
     "CPU": "0.031611",
     "spotCPU": "0.006655",
     "RAM": "0.004237",
-    "spotRAM": "0.000892"
+    "spotRAM": "0.000892",
+    "GPU": "0.95"
 }

+ 1 - 0
cloud/gcpprovider.go

@@ -533,6 +533,7 @@ func (gcp *GCP) DownloadPricingData() error {
 	c, err := GetDefaultPricingData("gcp.json")
 	if err != nil {
 		klog.V(2).Infof("Error downloading default pricing data: %s", err.Error())
+		return err
 	}
 	gcp.BaseCPUPrice = c.CPU
 	gcp.ProjectID = c.ProjectID

+ 29 - 25
cloud/provider.go

@@ -94,12 +94,14 @@ func GetDefaultPricingData(fname string) (*CustomPricing, error) {
 		return customPricing, nil
 	} else if os.IsNotExist(err) {
 		c := &CustomPricing{
-			Provider:    fname,
-			Description: "Default prices based on GCP us-central1",
-			CPU:         "0.031611",
-			SpotCPU:     "0.006655",
-			RAM:         "0.004237",
-			SpotRAM:     "0.000892",
+			Provider:            fname,
+			Description:         "Default prices based on GCP us-central1",
+			CPU:                 "0.031611",
+			SpotCPU:             "0.006655",
+			RAM:                 "0.004237",
+			SpotRAM:             "0.000892",
+			GPU:                 "0.95",
+			CustomPricesEnabled: "false",
 		}
 		cj, err := json.Marshal(c)
 		if err != nil {
@@ -119,25 +121,27 @@ func GetDefaultPricingData(fname string) (*CustomPricing, error) {
 const KeyUpdateType = "athenainfo"
 
 type CustomPricing struct {
-	Provider           string `json:"provider"`
-	Description        string `json:"description"`
-	CPU                string `json:"CPU"`
-	SpotCPU            string `json:"spotCPU"`
-	RAM                string `json:"RAM"`
-	SpotRAM            string `json:"spotRAM"`
-	SpotLabel          string `json:"spotLabel,omitempty"`
-	SpotLabelValue     string `json:"spotLabelValue,omitempty"`
-	ServiceKeyName     string `json:"awsServiceKeyName,omitempty"`
-	ServiceKeySecret   string `json:"awsServiceKeySecret,omitempty"`
-	SpotDataRegion     string `json:"awsSpotDataRegion,omitempty"`
-	SpotDataBucket     string `json:"awsSpotDataBucket,omitempty"`
-	SpotDataPrefix     string `json:"awsSpotDataPrefix,omitempty"`
-	ProjectID          string `json:"projectID,omitempty"`
-	AthenaBucketName   string `json:"athenaBucketName"`
-	AthenaRegion       string `json:"athenaRegion"`
-	AthenaDatabase     string `json:"athenaDatabase"`
-	AthenaTable        string `json:"athenaTable"`
-	BillingDataDataset string `json:"billingDataDataset,omitempty"`
+	Provider            string `json:"provider"`
+	Description         string `json:"description"`
+	CPU                 string `json:"CPU"`
+	SpotCPU             string `json:"spotCPU"`
+	RAM                 string `json:"RAM"`
+	SpotRAM             string `json:"spotRAM"`
+	GPU                 string `json:"GPU"`
+	SpotLabel           string `json:"spotLabel,omitempty"`
+	SpotLabelValue      string `json:"spotLabelValue,omitempty"`
+	ServiceKeyName      string `json:"awsServiceKeyName,omitempty"`
+	ServiceKeySecret    string `json:"awsServiceKeySecret,omitempty"`
+	SpotDataRegion      string `json:"awsSpotDataRegion,omitempty"`
+	SpotDataBucket      string `json:"awsSpotDataBucket,omitempty"`
+	SpotDataPrefix      string `json:"awsSpotDataPrefix,omitempty"`
+	ProjectID           string `json:"projectID,omitempty"`
+	AthenaBucketName    string `json:"athenaBucketName"`
+	AthenaRegion        string `json:"athenaRegion"`
+	AthenaDatabase      string `json:"athenaDatabase"`
+	AthenaTable         string `json:"athenaTable"`
+	BillingDataDataset  string `json:"billingDataDataset,omitempty"`
+	CustomPricesEnabled string `json:"customPricesEnabled"`
 }
 
 func SetCustomPricingField(obj *CustomPricing, name string, value string) error {

+ 2 - 0
main.go

@@ -173,6 +173,8 @@ func (p *Accesses) UpdateBigQueryInfoConfigs(w http.ResponseWriter, r *http.Requ
 }
 
 func (p *Accesses) UpdateConfigByKey(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
+	w.Header().Set("Content-Type", "application/json")
+	w.Header().Set("Access-Control-Allow-Origin", "*")
 	data, err := p.Cloud.UpdateConfig(r.Body, "")
 	if err != nil {
 		w.Write(wrapData(data, err))