Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README and related things #23

Merged
merged 6 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/continuous-delivery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ on:
# A "push" event is occurred after the pull request "close" event with "merged" true condition.
# The "push" event could replace "merged" event.
push:
branches:
- main
# branches:
# - main
# # workflow trigger button
# workflow_dispatch:
tags:
Expand Down Expand Up @@ -52,6 +52,8 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v4

# About billing for GitHub Packages
# https://docs.github.com/en/billing/managing-billing-for-github-packages/about-billing-for-github-packages
- name: Extract metadata from Git reference and GitHub events
id: meta
uses: docker/metadata-action@v5
Expand All @@ -67,8 +69,8 @@ jobs:
type=semver,enable=true,pattern={{version}}
# type=semver,pattern={{major}}.{{minor}}
## Tags for a push branch event
# minimal (short sha)
type=sha,enable=true,format=short
# minimal (short sha)
# type=sha,enable=true,format=short
## Other types (currently the followings may be out of scope)
## Tags for a push or pull_request event
# type=ref,event=branch
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ ENV DB_PASSWORD cm_beetle
# API Setting
# ALLOW_ORIGINS (ex: https://cloud-barista.org,xxx.xxx.xxx.xxx or * for all)
ENV ALLOW_ORIGINS *
## Set ENABLE_AUTH=true currently for basic auth for all routes (i.e., url or path)
ENV ENABLE_AUTH true
ENV API_USERNAME default
ENV API_PASSWORD default

Expand Down
113 changes: 113 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,121 @@ This is a sub-system on [Cloud-Barista platform](https://github.com/cloud-barist
and utilizes [CB-Tumblebug](https://github.com/cloud-barista/cb-tumblebug)
to depoly a multi-cloud infra as a target computing infrastructure.


## Overview

Computing Infrastructure Migration framework (codename: cm-beetle) is going to support:
- migration execution and control from source to target computing infrastructure, and
- recommendation of optimal configuration of target cloud infrastructure.


## Execution and development environment

- Operating system (OS):
- Ubuntu 20.04
- Languages:
- Go: 1.19
- Python: 3.8.10
- Container runtime:
- Docker: 20.10.12


## How to run CM-Beetle

### Source code based installation and execution

#### Configure build environment

1. Install dependencies

```bash
# Ensure that your system is up to date
sudo apt update -y

# Ensure that you have installed the dependencies,
# such as `ca-certificates`, `curl`, and `gnupg` packages.
sudo apt install make gcc git
```
2. Install Go

To install Go v1.19+, see [Go all releases](https://golang.org/dl/) and [Download and install](https://go.dev/doc/install)

Example - Go 1.19 installtion

```bash
# Get Go archive
wget https://go.dev/dl/go1.19.linux-amd64.tar.gz

# Remove any previous Go installation and
# Extract the archive into /usr/local/
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.19.linux-amd64.tar.gz

# Append /usr/local/go/bin to .bashrc
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> ~/.bashrc
echo 'export GOPATH=$HOME/go' >> ~/.bashrc

# Apply the .bashrc changes
source ~/.bashrc

# Verify the installation
echo $GOPATH
go version
```

#### Download source code

1. Clone CM-Beetle repository

```bash
git clone https://github.com/cloud-barista/cm-beetle.git ${HOME}/cm-beetle
```

#### Build CM-Beetle

```bash
cd ${HOME}/cm-beetle/pkg
make
```

(Optional) Update Swagger API document
```bash
cd ${HOME}/cm-beetle/pkg
make swag
```

#### Run CM-Beetle binary

```bash
cd ${HOME}/cm-beetle/pkg
make run
```

#### Health-check CM-Beetle

```bash
curl http://localhost:8056/beetle/health

# Output if it's running successfully
# {"message":"CM-Beetle API server is running"}
```


### Container based execution

Check a tag of CM-Beetle container image in [cloudbaristaorg/cm-beetle](https://hub.docker.com/r/cloudbaristaorg/cm-beetle/tags)

#### Run CM-Beetle container

```bash
docker run -p 8056:8056 \
--name cm-beetle \
cloudbaristaorg/cm-beetle:latest
```

#### Health-check CM-Beetle
```bash
curl http://localhost:8056/beetle/health

# Output if it's running successfully
# {"message":"CM-Beetle API server is running"}
```
2 changes: 2 additions & 0 deletions conf/setup.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export DB_PASSWORD=cm_beetle
# Set API access config
## ALLOW_ORIGINS (ex: https://cloud-barista.org,http://localhost:8080 or * for all)
export ALLOW_ORIGINS=*
## Set ENABLE_AUTH=true currently for basic auth for all routes (i.e., url or path)
export ENABLE_AUTH=true
export API_USERNAME=default
export API_PASSWORD=default

Expand Down
218 changes: 218 additions & 0 deletions pkg/api/rest/server/migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,221 @@ func createVMInfra(nsId string, infraModel *TbMcisDynamicReq) (TbMcisInfo, error

return responseBody, nil
}

////////////////////////

type Network struct {
Name string `json:"name"`
Id string `json:"id"`
IPv4CIDRBlock string `json:"ipv4CidrBlock"`
IPv6CIDRBlock string `json:"ipv6CidrBlock"`
}

type Subnet struct {
Network
ParentNetworkId string `json:"parentNetworkId"`
}

type DummyNetwork struct {
Network
Subnets []Subnet `json:"subnets"`
}

type MigrateNetworkRequest struct {
DummyNetwork
}

type MigrateNetworkResponse struct {
DummyNetwork
}

// MigrateNetwork godoc
// @Summary (Skeleton) Migrate network on a cloud platform
// @Description It migrates network on a cloud platform. Network includes name, ID, IPv4 CIDR block, IPv6 CIDR block, and so on.
// @Tags [Migration] Infrastructure
// @Accept json
// @Produce json
// @Param NetworkInfo body MigrateNetworkRequest true "Specify name, IPv4 CIDR block, etc."
// @Success 200 {object} MigrateNetworkResponse "Successfully migrated network on a cloud platform"
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
// @Router /migration/infra/network [post]
func (rh *Handlers) MigrateNetwork(c echo.Context) error {

// [Note] Input section
req := &MigrateNetworkRequest{}
if err := c.Bind(req); err != nil {
return err
}

fmt.Printf("RequestBody: %v\n", req)
fmt.Print(req)
fmt.Print(req.DummyNetwork)

// [Note] Process section
// Something to process here like,
// Perform some functions,
// Calls external APIs and so on

res := &MigrateNetworkResponse{}
fmt.Print(res)
fmt.Print(res.DummyNetwork)

// This is an intentionally created variable.
// You will have to delete this later.
var err error = nil

// [Note] Ouput section
if err != nil {
common.CBLog.Error(err)
mapA := map[string]string{"message": err.Error()}
return c.JSON(http.StatusInternalServerError, &mapA)
}

return c.JSON(http.StatusOK, res)

}

////////////////////////

////////////////////////

type Storage struct {
Name string `json:"name"`
Id string `json:"id"`
Type string `json:"type"`
Size string `json:"size"`
}

type DummyStorage struct {
Storage
NetworkID string `json:"NetworkId"`
}

type MigrateStorageRequest struct {
DummyStorage
}

type MigrateStorageResponse struct {
DummyStorage
}

// MigrateStorage godoc
// @Summary (Skeleton) Migrate storage on a cloud platform
// @Description It migrates storage on a cloud platform. Storage includes name, ID, type, size, and so on.
// @Tags [Migration] Infrastructure
// @Accept json
// @Produce json
// @Param StorageInfo body MigrateStorageRequest true "Specify name, type, size, affiliated Network ID, and so on."
// @Success 200 {object} MigrateStorageResponse "Successfully migrated storage on a cloud platform"
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
// @Router /migration/infra/storage [post]
func (rh *Handlers) MigrateStorage(c echo.Context) error {

// [Note] Input section
req := &MigrateStorageRequest{}
if err := c.Bind(req); err != nil {
return err
}

fmt.Printf("RequestBody: %v\n", req)
fmt.Print(req)
fmt.Print(req.DummyStorage)

// [Note] Process section
// Something to process here like,
// Perform some functions,
// Calls external APIs and so on

res := &MigrateStorageResponse{}
fmt.Print(res)
fmt.Print(res.DummyStorage)

// This is an intentionally created variable.
// You will have to delete this later.
var err error = nil

// [Note] Ouput section
if err != nil {
common.CBLog.Error(err)
mapA := map[string]string{"message": err.Error()}
return c.JSON(http.StatusInternalServerError, &mapA)
}

return c.JSON(http.StatusOK, res)

}

////////////////////////

////////////////////////

type Instance struct {
Name string `json:"name"`
Id string `json:"id"`
Spec string `json:"type"`
OS string `json:"os"`
}

type DummyInstance struct {
Instance
NetworkID string `json:"NetworkId"`
}

type MigrateInstanceRequest struct {
DummyInstance
}

type MigrateInstanceResponse struct {
DummyInstance
}

// MigrateInstance godoc
// @Summary (Skeleton) Migrate instance on a cloud platform
// @Description It migrates instance on a cloud platform. Storage includes name, spec, OS, and so on.
// @Tags [Migration] Infrastructure
// @Accept json
// @Produce json
// @Param InstanceInfo body MigrateInstanceRequest true "Specify name, spec, OS, and so on."
// @Success 200 {object} MigrateInstanceResponse "Successfully migrated storage on a cloud platform"
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
// @Router /migration/infra/instance [post]
func (rh *Handlers) MigrateInstance(c echo.Context) error {

// [Note] Input section
req := &MigrateInstanceRequest{}
if err := c.Bind(req); err != nil {
return err
}

fmt.Printf("RequestBody: %v\n", req)
fmt.Print(req)
fmt.Print(req.DummyInstance)

// [Note] Process section
// Something to process here like,
// Perform some functions,
// Calls external APIs and so on

res := &MigrateInstanceResponse{}
fmt.Print(res)
fmt.Print(res.DummyInstance)

// This is an intentionally created variable.
// You will have to delete this later.
var err error = nil

// [Note] Ouput section
if err != nil {
common.CBLog.Error(err)
mapA := map[string]string{"message": err.Error()}
return c.JSON(http.StatusInternalServerError, &mapA)
}

return c.JSON(http.StatusOK, res)

}

////////////////////////
Loading