Skip to content

Commit

Permalink
remove underscore from variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
computerphilosopher committed Aug 21, 2021
1 parent 6d8d7f3 commit ca77b3f
Show file tree
Hide file tree
Showing 17 changed files with 384 additions and 384 deletions.
4 changes: 2 additions & 2 deletions src/api/grpc/request/test/test_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,9 @@ func CreateMCIRApiTest() {
ConnectionName: "openstack-config01",
CidrBlock: "192.168.0.0/16",
SubnetInfoList: []core_mcir.SpiderSubnetReqInfo{
core_mcir.SpiderSubnetReqInfo{
{
Name: "openstack-config01-test",
IPv4_CIDR: "192.168.1.0/24",
IPv4CIDR: "192.168.1.0/24",
KeyValueList: []core_common.KeyValue{},
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/api/grpc/server/mcis/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ func (s *MCISService) RecommendMcis(ctx context.Context, req *pb.McisRecommendCr
}

content := rest_mcis.RestPostMcisRecommendResponse{}
content.Vm_recommend = result
content.VmRecommend = result
content.PlacementAlgo = mcisObj.PlacementAlgo
content.PlacementParam = mcisObj.PlacementParam

Expand Down
4 changes: 2 additions & 2 deletions src/api/rest/server/mcis/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func RestDelAllMcis(c echo.Context) error {

type RestPostMcisRecommendResponse struct {
//VmReq []TbVmRecommendReq `json:"vmReq"`
Vm_recommend []mcis.TbVmRecommendInfo `json:"vm_recommend"`
VmRecommend []mcis.TbVmRecommendInfo `json:"vm_recommend"`
PlacementAlgo string `json:"placementAlgo"`
PlacementParam []common.KeyValue `json:"placementParam"`
}
Expand Down Expand Up @@ -316,7 +316,7 @@ func RestPostMcisRecommend(c echo.Context) error {
}

content := RestPostMcisRecommendResponse{}
content.Vm_recommend = result
content.VmRecommend = result
content.PlacementAlgo = req.PlacementAlgo
content.PlacementParam = req.PlacementParam

Expand Down
34 changes: 17 additions & 17 deletions src/core/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ type IdList struct {
var CBLog *logrus.Logger
var CBStore icbs.Store

var SPIDER_REST_URL string
var DRAGONFLY_REST_URL string
var DB_URL string
var DB_DATABASE string
var DB_USER string
var DB_PASSWORD string
var AUTOCONTROL_DURATION_MS string
var MYDB *sql.DB
var SpiderRestUrl string
var DragonflyRestUrl string
var DBUrl string
var DBDatabase string
var DBUser string
var DBPassword string
var AutocontrolDurationMs string
var MyDB *sql.DB
var err error
var ORM *xorm.Engine

const (
StrSPIDER_REST_URL string = "SPIDER_REST_URL"
StrDRAGONFLY_REST_URL string = "DRAGONFLY_REST_URL"
StrDB_URL string = "DB_URL"
StrDB_DATABASE string = "DB_DATABASE"
StrDB_USER string = "DB_USER"
StrDB_PASSWORD string = "DB_PASSWORD"
StrAUTOCONTROL_DURATION_MS string = "AUTOCONTROL_DURATION_MS"
StrSpiderRestUrl string = "SPIDER_REST_URL"
StrDragonflyRestUrl string = "DRAGONFLY_REST_URL"
StrDBUrl string = "DB_URL"
StrDBDatabase string = "DB_DATABASE"
StrDBUser string = "DB_USER"
StrDBPassword string = "DB_PASSWORD"
StrAutocontrolDurationMs string = "AUTOCONTROL_DURATION_MS"
CbStoreKeyNotFoundErrorString string = "key not found"
StrAdd string = "add"
StrDelete string = "delete"
Expand Down Expand Up @@ -82,13 +82,13 @@ func OpenSQL(path string) error {
*/

fullPathString := "file:" + path
MYDB, err = sql.Open("sqlite3", fullPathString)
MyDB, err = sql.Open("sqlite3", fullPathString)
return err
}

func SelectDatabase(database string) error {
query := "USE " + database + ";"
_, err = MYDB.Exec(query)
_, err = MyDB.Exec(query)
return err
}

Expand Down
84 changes: 42 additions & 42 deletions src/core/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,27 @@ func UpdateGlobalVariable(id string) error {
}

switch id {
case StrSPIDER_REST_URL:
SPIDER_REST_URL = configInfo.Value
fmt.Println("<SPIDER_REST_URL> " + SPIDER_REST_URL)
case StrDRAGONFLY_REST_URL:
DRAGONFLY_REST_URL = configInfo.Value
fmt.Println("<DRAGONFLY_REST_URL> " + DRAGONFLY_REST_URL)
case StrDB_URL:
DB_URL = configInfo.Value
fmt.Println("<DB_URL> " + DB_URL)
case StrDB_DATABASE:
DB_DATABASE = configInfo.Value
fmt.Println("<DB_DATABASE> " + DB_DATABASE)
case StrDB_USER:
DB_USER = configInfo.Value
fmt.Println("<DB_USER> " + DB_USER)
case StrDB_PASSWORD:
DB_PASSWORD = configInfo.Value
fmt.Println("<DB_PASSWORD> " + DB_PASSWORD)
case StrAUTOCONTROL_DURATION_MS:
AUTOCONTROL_DURATION_MS = configInfo.Value
fmt.Println("<AUTOCONTROL_DURATION_MS> " + AUTOCONTROL_DURATION_MS)
case StrSpiderRestUrl:
SpiderRestUrl = configInfo.Value
fmt.Println("<SPIDER_REST_URL> " + SpiderRestUrl)
case StrDragonflyRestUrl:
DragonflyRestUrl = configInfo.Value
fmt.Println("<DRAGONFLY_REST_URL> " + DragonflyRestUrl)
case StrDBUrl:
DBUrl = configInfo.Value
fmt.Println("<DB_URL> " + DBUrl)
case StrDBDatabase:
DBDatabase = configInfo.Value
fmt.Println("<DB_DATABASE> " + DBDatabase)
case StrDBUser:
DBUser = configInfo.Value
fmt.Println("<DB_USER> " + DBUser)
case StrDBPassword:
DBPassword = configInfo.Value
fmt.Println("<DB_PASSWORD> " + DBPassword)
case StrAutocontrolDurationMs:
AutocontrolDurationMs = configInfo.Value
fmt.Println("<AUTOCONTROL_DURATION_MS> " + AutocontrolDurationMs)
default:

}
Expand All @@ -102,27 +102,27 @@ func UpdateGlobalVariable(id string) error {
func InitConfig(id string) error {

switch id {
case StrSPIDER_REST_URL:
SPIDER_REST_URL = NVL(os.Getenv("SPIDER_REST_URL"), "http://localhost:1024/spider")
fmt.Println("<SPIDER_REST_URL> " + SPIDER_REST_URL)
case StrDRAGONFLY_REST_URL:
DRAGONFLY_REST_URL = NVL(os.Getenv("DRAGONFLY_REST_URL"), "http://localhost:9090/dragonfly")
fmt.Println("<DRAGONFLY_REST_URL> " + DRAGONFLY_REST_URL)
case StrDB_URL:
DB_URL = NVL(os.Getenv("DB_URL"), "localhost:3306")
fmt.Println("<DB_URL> " + DB_URL)
case StrDB_DATABASE:
DB_DATABASE = NVL(os.Getenv("DB_DATABASE"), "cb_tumblebug")
fmt.Println("<DB_DATABASE> " + DB_DATABASE)
case StrDB_USER:
DB_USER = NVL(os.Getenv("DB_USER"), "cb_tumblebug")
fmt.Println("<DB_USER> " + DB_USER)
case StrDB_PASSWORD:
DB_PASSWORD = NVL(os.Getenv("DB_PASSWORD"), "cb_tumblebug")
fmt.Println("<DB_PASSWORD> " + DB_PASSWORD)
case StrAUTOCONTROL_DURATION_MS:
AUTOCONTROL_DURATION_MS = NVL(os.Getenv("AUTOCONTROL_DURATION_MS"), "10000")
fmt.Println("<AUTOCONTROL_DURATION_MS> " + AUTOCONTROL_DURATION_MS)
case StrSpiderRestUrl:
SpiderRestUrl = NVL(os.Getenv("SPIDER_REST_URL"), "http://localhost:1024/spider")
fmt.Println("<SPIDER_REST_URL> " + SpiderRestUrl)
case StrDragonflyRestUrl:
DragonflyRestUrl = NVL(os.Getenv("DRAGONFLY_REST_URL"), "http://localhost:9090/dragonfly")
fmt.Println("<DRAGONFLY_REST_URL> " + DragonflyRestUrl)
case StrDBUrl:
DBUrl = NVL(os.Getenv("DB_URL"), "localhost:3306")
fmt.Println("<DB_URL> " + DBUrl)
case StrDBDatabase:
DBDatabase = NVL(os.Getenv("DB_DATABASE"), "cb_tumblebug")
fmt.Println("<DB_DATABASE> " + DBDatabase)
case StrDBUser:
DBUser = NVL(os.Getenv("DB_USER"), "cb_tumblebug")
fmt.Println("<DB_USER> " + DBUser)
case StrDBPassword:
DBPassword = NVL(os.Getenv("DB_PASSWORD"), "cb_tumblebug")
fmt.Println("<DB_PASSWORD> " + DBPassword)
case StrAutocontrolDurationMs:
AutocontrolDurationMs = NVL(os.Getenv("AUTOCONTROL_DURATION_MS"), "10000")
fmt.Println("<AUTOCONTROL_DURATION_MS> " + AutocontrolDurationMs)
default:

}
Expand Down
8 changes: 4 additions & 4 deletions src/core/common/utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func GetConnConfig(ConnConfigName string) (ConnConfig, error) {

if os.Getenv("SPIDER_CALL_METHOD") == "REST" {

url := SPIDER_REST_URL + "/connectionconfig/" + ConnConfigName
url := SpiderRestUrl + "/connectionconfig/" + ConnConfigName

client := resty.New().SetCloseConnection(true)

Expand Down Expand Up @@ -295,7 +295,7 @@ func GetConnConfigList() (ConnConfigList, error) {

if os.Getenv("SPIDER_CALL_METHOD") == "REST" {

url := SPIDER_REST_URL + "/connectionconfig"
url := SpiderRestUrl + "/connectionconfig"

client := resty.New().SetCloseConnection(true)

Expand Down Expand Up @@ -368,7 +368,7 @@ func GetRegion(RegionName string) (Region, error) {

if os.Getenv("SPIDER_CALL_METHOD") == "REST" {

url := SPIDER_REST_URL + "/region/" + RegionName
url := SpiderRestUrl + "/region/" + RegionName

client := resty.New().SetCloseConnection(true)

Expand Down Expand Up @@ -441,7 +441,7 @@ func GetRegionList() (RegionList, error) {

if os.Getenv("SPIDER_CALL_METHOD") == "REST" {

url := SPIDER_REST_URL + "/region"
url := SpiderRestUrl + "/region"

client := resty.New().SetCloseConnection(true)

Expand Down
26 changes: 13 additions & 13 deletions src/core/mcir/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func DelResource(nsId string, resourceType string, resourceId string, forceFlag
}

//delete related recommend spec
err = DelRecommendSpec(nsId, resourceId, content.Num_vCPU, content.Mem_GiB, content.Storage_GiB)
err = DelRecommendSpec(nsId, resourceId, content.NumvCPU, content.MemGiB, content.StorageGiB)
if err != nil {
common.CBLog.Error(err)
return err
Expand All @@ -178,7 +178,7 @@ func DelResource(nsId string, resourceType string, resourceId string, forceFlag
return err
}
tempReq.ConnectionName = temp.ConnectionName
url = common.SPIDER_REST_URL + "/keypair/" + temp.Name
url = common.SpiderRestUrl + "/keypair/" + temp.Name
case common.StrVNet:
temp := TbVNetInfo{}
err = json.Unmarshal([]byte(keyValue.Value), &temp)
Expand All @@ -187,7 +187,7 @@ func DelResource(nsId string, resourceType string, resourceId string, forceFlag
return err
}
tempReq.ConnectionName = temp.ConnectionName
url = common.SPIDER_REST_URL + "/vpc/" + temp.Name
url = common.SpiderRestUrl + "/vpc/" + temp.Name
case common.StrSecurityGroup:
temp := TbSecurityGroupInfo{}
err = json.Unmarshal([]byte(keyValue.Value), &temp)
Expand All @@ -196,7 +196,7 @@ func DelResource(nsId string, resourceType string, resourceId string, forceFlag
return err
}
tempReq.ConnectionName = temp.ConnectionName
url = common.SPIDER_REST_URL + "/securitygroup/" + temp.Name
url = common.SpiderRestUrl + "/securitygroup/" + temp.Name
/*
case "subnet":
temp := subnetInfo{}
Expand Down Expand Up @@ -328,7 +328,7 @@ func DelResource(nsId string, resourceType string, resourceId string, forceFlag
}

//delete related recommend spec
err = DelRecommendSpec(nsId, resourceId, content.Num_vCPU, content.Mem_GiB, content.Storage_GiB)
err = DelRecommendSpec(nsId, resourceId, content.NumvCPU, content.MemGiB, content.StorageGiB)
if err != nil {
common.CBLog.Error(err)
return err
Expand Down Expand Up @@ -532,11 +532,11 @@ func InspectResources(connConfig string, resourceType string) (interface{}, erro
var spiderRequestURL string
switch resourceType {
case common.StrVNet:
spiderRequestURL = common.SPIDER_REST_URL + "/allvpc"
spiderRequestURL = common.SpiderRestUrl + "/allvpc"
case common.StrSecurityGroup:
spiderRequestURL = common.SPIDER_REST_URL + "/allsecuritygroup"
spiderRequestURL = common.SpiderRestUrl + "/allsecuritygroup"
case common.StrSSHKey:
spiderRequestURL = common.SPIDER_REST_URL + "/allkeypair"
spiderRequestURL = common.SpiderRestUrl + "/allkeypair"
}

resp, err := client.R().
Expand Down Expand Up @@ -970,18 +970,18 @@ func UpdateAssociatedObjectList(nsId string, resourceType string, resourceId str
var anyJson map[string]interface{}
json.Unmarshal([]byte(keyValue.Value), &anyJson)
if anyJson["associatedObjectList"] == nil {
array_to_be := []string{objectKey}
arrayToBe := []string{objectKey}
// fmt.Println("array_to_be: ", array_to_be) // for debug

anyJson["associatedObjectList"] = array_to_be
anyJson["associatedObjectList"] = arrayToBe
} else { // anyJson["associatedObjectList"] != nil
array_as_is := anyJson["associatedObjectList"].([]interface{})
arrayAsIs := anyJson["associatedObjectList"].([]interface{})
// fmt.Println("array_as_is: ", array_as_is) // for debug

array_to_be := append(array_as_is, objectKey)
arrayToBe := append(arrayAsIs, objectKey)
// fmt.Println("array_to_be: ", array_to_be) // for debug

anyJson["associatedObjectList"] = array_to_be
anyJson["associatedObjectList"] = arrayToBe
}
updatedJson, _ := json.Marshal(anyJson)
// fmt.Println(string(updatedJson)) // for debug
Expand Down
4 changes: 2 additions & 2 deletions src/core/mcir/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func LookupImageList(connConfig string) (SpiderImageList, error) {

if os.Getenv("SPIDER_CALL_METHOD") == "REST" {

url := common.SPIDER_REST_URL + "/vmimage"
url := common.SpiderRestUrl + "/vmimage"

// Create Req body
tempReq := common.SpiderConnectionName{}
Expand Down Expand Up @@ -332,7 +332,7 @@ func LookupImage(connConfig string, imageId string) (SpiderImageInfo, error) {

if os.Getenv("SPIDER_CALL_METHOD") == "REST" {

url := common.SPIDER_REST_URL + "/vmimage/" + url.QueryEscape(imageId)
url := common.SpiderRestUrl + "/vmimage/" + url.QueryEscape(imageId)

// Create Req body
tempReq := common.SpiderConnectionName{}
Expand Down
2 changes: 1 addition & 1 deletion src/core/mcir/securitygroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func CreateSecurityGroup(nsId string, u *TbSecurityGroupReq) (TbSecurityGroupInf

if os.Getenv("SPIDER_CALL_METHOD") == "REST" {

url := common.SPIDER_REST_URL + "/securitygroup"
url := common.SpiderRestUrl + "/securitygroup"

client := resty.New().SetCloseConnection(true)

Expand Down
Loading

0 comments on commit ca77b3f

Please sign in to comment.