Skip to content

Commit

Permalink
System support for initializing multi-cloud info
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-github-robot authored Apr 22, 2024
2 parents 74ac865 + 94a4da1 commit 81c3e1c
Show file tree
Hide file tree
Showing 16 changed files with 286 additions and 285 deletions.
163 changes: 0 additions & 163 deletions assets/cloudlocation.csv

This file was deleted.

11 changes: 7 additions & 4 deletions conf/setup.env
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ export DB_PASSWORD=cb_tumblebug
## Set period for auto control goroutine invocation
export AUTOCONTROL_DURATION_MS=10000

# Environment variables that you don't need to touch
## Swagger UI API document file path
export API_DOC_PATH=$CBTUMBLEBUG_ROOT/src/api/rest/docs/swagger.json
## Set name of default objects
export DEFAULT_NAMESPACE=ns01

## Logger configuration
# Set log file path (default logfile path: ./log/tumblebug.log)
Expand All @@ -47,4 +46,8 @@ export LOGLEVEL=debug
# Set log writer, such as file, stdout, or both
export LOGWRITER=both
# Set execution environment, such as development or production
export NODE_ENV=development
export NODE_ENV=development

# Environment variables that you don't need to touch
## Swagger UI API document file path
export API_DOC_PATH=$CBTUMBLEBUG_ROOT/src/api/rest/docs/swagger.json
2 changes: 0 additions & 2 deletions scripts/initMultiCloudEnv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ fi

$CBTUMBLEBUG_ROOT/src/testclient/scripts/1.configureSpider/register-cloud-interactive.sh -n tb

$CBTUMBLEBUG_ROOT/src/testclient/scripts/2.configureTumblebug/create-ns.sh -x ns01

echo -e "${BOLD}"
while true; do
echo "Loading common Specs and Images takes time."
Expand Down
9 changes: 6 additions & 3 deletions src/api/rest/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,12 @@ func RunServer(port string) {
selfEndpoint := os.Getenv("SELF_ENDPOINT")
apidashboard := " http://" + selfEndpoint + "/tumblebug/api"

fmt.Println(" Default Namespace: " + common.DefaultNamespace + "\n")

if enableAuth {
fmt.Println(" Access to API dashboard" + " (username: " + apiUser + " / password: " + apiPass + ")")
}

fmt.Printf(noticeColor, apidashboard)
fmt.Println("\n ")

Expand All @@ -454,12 +457,12 @@ func RunServer(port string) {
// Block until a signal is triggered
<-gracefulShutdownContext.Done()

log.Info().Msg("Stopping CB-Tumblebug API Server gracefully... (within 5s)")
ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
log.Info().Msg("Stopping CB-Tumblebug API Server gracefully... (within 10s)")
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
defer cancel()

if err := e.Shutdown(ctx); err != nil {
log.Error().Err(err).Msg("Error in Stopping CB-Tumblebug API Server")
log.Error().Err(err).Msg("Error in Gracefully Stopping CB-Tumblebug API Server")
e.Logger.Panic(err)
}
}(&wg)
Expand Down
1 change: 1 addition & 0 deletions src/core/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ var DBDatabase string
var DBUser string
var DBPassword string
var AutocontrolDurationMs string
var DefaultNamespace string
var MyDB *sql.DB
var err error
var ORM *xorm.Engine
Expand Down
4 changes: 2 additions & 2 deletions src/core/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ func PrintCloudInfoTable(cloudInfo CloudInfo) {
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"CSP", "Region", "Location", "(Lati:Long)", "Zones"})

for cspName, cspDetail := range cloudInfo.CSPs {
for providerName, cspDetail := range cloudInfo.CSPs {
for regionName, regionDetail := range cspDetail.Regions {
latLong := formatLatLong(regionDetail.Location.Latitude, regionDetail.Location.Longitude)
zones := formatZones(regionDetail.Zones)
t.AppendRow(table.Row{cspName, regionName, regionDetail.Location.Display, latLong, zones})
t.AppendRow(table.Row{providerName, regionName, regionDetail.Location.Display, latLong, zones})
}
}
t.SortBy([]table.SortBy{
Expand Down
8 changes: 1 addition & 7 deletions src/core/common/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,15 @@ func CreateNs(u *NsReq) (NsInfo, error) {
content.Name = u.Name
content.Description = u.Description

// TODO here: implement the logic

fmt.Println("CreateNs();")
Key := "/ns/" + content.Id
//mapA := map[string]string{"name": content.Name, "description": content.Description}
Val, _ := json.Marshal(content)
err = CBStore.Put(Key, string(Val))
if err != nil {
log.Error().Err(err).Msg("")
return content, err
}
keyValue, _ := CBStore.Get(Key)
fmt.Println("CreateNs(); ===========================")
fmt.Println("CreateNs(); Key: " + keyValue.Key + "\nValue: " + keyValue.Value)
fmt.Println("CreateNs(); ===========================")
fmt.Println("CreateNs: Key: " + keyValue.Key + "\nValue: " + keyValue.Value)
return content, nil
}

Expand Down
Loading

0 comments on commit 81c3e1c

Please sign in to comment.