model

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

README

Computing Infrastructure Migration Model

This repository provides computing infrastructure migration features. This is a sub-system of Cloud-Barista platform, and intended to deploy a multi-cloud infra as a target computing infrastructure.

Overview

As a Cloud Computing Infrastructure Migration Framework (codename: cm-damselply) is going to support:

  • Target cloud computing infra migration model (Defined using the JSON format and Go Structure.)
  • Migration model management test codes for target cloud computing infra

Execution and development environment

  • Operating system (OS):
    • Ubuntu 22.04
  • Languages:
    • Go: 1.19

How to run CM-Damselfly

Source code based installation and execution
Configure build environment
  1. Install dependencies
# 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
  1. Install Go

Note - Install the stable version of Go. For example, install Go v1.19 or v1.21.x

# Set Go version
GO_VERSION=1.21.4

# Get Go archive
wget https://go.dev/dl/go${GO_VERSION}.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 go${GO_VERSION}.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 the source code

Clone CM-Damselfly repository

git clone https://github.com/cloud-barista/cm-damselfly.git ${HOME}/cm-damselfly
Run Test code

Run Migration Model Management Test code

cd ${HOME}/cm-damselfly/Test

go run model-test.go
or
./model-test.sh

Documentation

Index

Constants

View Source
const (
	ReplicationModelDir string = "/.replication_model"
)

Variables

This section is empty.

Functions

func CheckFolderAndCreate

func CheckFolderAndCreate(folderPath string) error

Check if the Folder Exists. If Not, Create it

func ConvertJsonString

func ConvertJsonString(v interface{}) (string, error)

Cloud Object를 JSON String 타입으로 변환

func DeleteModel

func DeleteModel(modelIID IID) (bool, error)

func InitLog

func InitLog()

Types

type Application

type Application struct {
	Name         string   `json:"name"`
	Version      string   `json:"version"`
	Language     string   `json:"language"`
	Dependencies []string `json:"dependencies"`
}

type CSP

type CSP struct {
	Name       string `yaml:"Name"`
	RegionCode string `yaml:"Region"`
	ZoneCode   string `yaml:"Zone"`
}

type DataDisk

type DataDisk struct {
	ConnectionName string `json:"connectionName"`
	CspDataDiskId  string `json:"cspDataDiskId"`
	Description    string `json:"description"`
	DiskSize       string `json:"diskSize"`
	DiskType       string `json:"diskType"`
	Name           string `json:"name"`
}

type Database

type Database struct {
	DatabaseType     string `json:"databaseType"`
	Version          string `json:"version"`
	Size             string `json:"size"`
	Tables           string `json:"tables"`
	StoredProcedures string `json:"storedProcedures"`
}

type EnvironmentDetails

type EnvironmentDetails struct {
	Region    string     `json:"region"`
	Zone      string     `json:"zone"`
	Resources []Resource `json:"resources"`
}

type FirewallRule

type FirewallRule struct {
	Cidr       string `json:"cidr,omitempty"`
	Direction  string `json:"direction,omitempty"`
	FromPort   string `json:"fromPort,omitempty"`
	IpProtocol string `json:"ipprotocol,omitempty"`
	ToPort     string `json:"toPort,omitempty"`
}

type HealthCheck

type HealthCheck struct {
	Target             string `yaml:"Target"`
	HealthyThreshold   string `yaml:"HealthyThreshold"`
	UnhealthyThreshold string `yaml:"UnhealthyThreshold"`
	Interval           string `yaml:"Interval"`
	Timeout            string `yaml:"Timeout"`
}

type HealthChecker

type HealthChecker struct {
	Interval  string `json:"interval,omitempty"`
	Threshold string `json:"threshold,omitempty"`
	Timeout   string `json:"timeout,omitempty"`
}

type IID

type IID struct {
	NameId   string
	SystemId string
}

type IngressRule

type IngressRule struct {
	IpProtocol string `yaml:"IpProtocol"`
	FromPort   string `yaml:"FromPort"`
	ToPort     string `yaml:"ToPort"`
	CidrIp     string `yaml:"CidrIp"`
}

type JSON_Model

type JSON_Model struct {
	MigrationModel MigrationModel `json:"migrationModel"`
}

func GetModel

func GetModel(modelIID IID) (JSON_Model, error)

func ListModel

func ListModel() ([]*JSON_Model, error)

func UpdateModel

func UpdateModel(modelIId IID, rsInfo JSON_Model) (JSON_Model, error)

func UpdateSubnetInfoList

func UpdateSubnetInfoList(modelIId IID, newSubnetInfoList []SubnetInfo) (JSON_Model, error)

Function to update SubnetInfoList in the first vNet resource

func WriteModel

func WriteModel(modelName string, rsInfo JSON_Model) (JSON_Model, error)

type KeyPair

type KeyPair struct {
	ConnectionName   string `json:"connectionName"`
	CspSshKeyId      string `json:"cspSshKeyId"`
	Description      string `json:"description"`
	Fingerprint      string `json:"fingerprint"`
	Name             string `json:"name"`
	PrivateKey       string `json:"privateKey"`
	PublicKey        string `json:"publicKey"`
	Username         string `json:"username"`
	VerifiedUsername string `json:"verifiedUsername"`
}

type KeyValue

type KeyValue struct {
	Key   string `json:"key,omitempty"`
	Value string `json:"value,omitempty"`
}

type LbListener

type LbListener struct {
	Port     string `json:"port,omitempty"`
	Protocol string `json:"protocol,omitempty"`
}

type Listener

type Listener struct {
	LoadBalancerPort string `yaml:"LoadBalancerPort"`
	InstancePort     string `yaml:"InstancePort"`
	Protocol         string `yaml:"Protocol"`
}

type LoadBalancer

type LoadBalancer struct {
	Name        string       `yaml:"Name"`
	Listeners   []Listener   `yaml:"Listeners"`
	HealthCheck HealthCheck  `yaml:"HealthCheck"`
	VMInstances []VMInstance `yaml:"VMInstances"`
}

type MCIS

type MCIS struct {
	Description     string `json:"description"`
	InstallMonAgent string `json:"installMonAgent"`
	Label           string `json:"label"`
	Name            string `json:"name"`
	PlacementAlgo   string `json:"placementAlgo"`
	SystemLabel     string `json:"systemLabel"`
	VM              []VM   `json:"vm"`
}

type MigrationModel

type MigrationModel struct {
	Description       string            `json:"description"`
	Name              string            `json:"name"`
	Version           string            `json:"version"`
	ModelId           string            `json:"modelId"`
	MigrationStep     string            `json:"migrationStep"`
	TargetEnvironment TargetEnvironment `json:"targetEnvironment"`
}

type NLB

type NLB struct {
	CspNLBId      string        `json:"cspNLBId"`
	Description   string        `json:"description"`
	HealthChecker HealthChecker `json:"healthChecker"`
	Listener      Listener      `json:"listener"`
	Scope         string        `json:"scope"`
	TargetGroup   TargetGroup   `json:"targetGroup"`
	Type          string        `json:"type"`
}

type Namespace

type Namespace struct {
	Description string `json:"description"`
	Name        string `json:"name"`
}

Define structs for each specification

type Replica_RS

type Replica_RS struct {
	VMInstance   VMInstance   `yaml:"VMInstance"`
	LoadBalancer LoadBalancer `yaml:"LoadBalancer"`
}

type Replication

type Replication struct {
	TemplateFormatVersion string     `yaml:"TemplateFormatVersion"`
	Description           string     `yaml:"Description"`
	CSP                   CSP        `yaml:"CSP"`
	Resources             Replica_RS `yaml:"Resources"`
}

func GetReplicaResources

func GetReplicaResources(yamlName string) (Replication, error)

type Resource

type Resource struct {
	Type                 string       `json:"type"`
	NsSpecifications     *Namespace   `json:"nsSpecifications,omitempty"`
	VNetSpecifications   *VNet        `json:"vNetSpecifications,omitempty"`
	McisSpecifications   *MCIS        `json:"mcisSpecifications,omitempty"`
	ImgSpecifications    *VMImage     `json:"imgSpecifications,omitempty"`
	SgSpecifications     *SG          `json:"sgSpecifications,omitempty"`
	KeySpecifications    *KeyPair     `json:"keySpecifications,omitempty"`
	DbSpecifications     *Database    `json:"dbSpecifications,omitempty"`
	DiskSpecifications   *DataDisk    `json:"diskSpecifications,omitempty"`
	NlbSpecifications    *NLB         `json:"nlbSpecifications,omitempty"`
	AppSpecifications    *Application `json:"appSpecifications,omitempty"`
	WebSvrSpecifications *WebServer   `json:"webSvrSpecifications,omitempty"`
}

type SG

type SG struct {
	CspSecurityGroupId string         `json:"cspSecurityGroupId"`
	Description        string         `json:"description"`
	FirewallRules      []FirewallRule `json:"firewallRules"`
	Name               string         `json:"name"`
	VNetId             string         `json:"vNetId"`
}

type SecurityGroup

type SecurityGroup struct {
	GroupDescription     string        `yaml:"GroupDescription"`
	SecurityGroupIngress []IngressRule `yaml:"SecurityGroupIngress"`
}

type Subnet

type Subnet struct {
	Name             string `yaml:"Name"`
	CidrBlock        string `yaml:"CidrBlock"`
	AvailabilityZone string `yaml:"AvailabilityZone"`
}

type SubnetInfo

type SubnetInfo struct {
	Description  string     `json:"description,omitempty"`
	Ipv4CIDR     string     `json:"ipv4_CIDR,omitempty"`
	KeyValueList []KeyValue `json:"keyValueList,omitempty"`
	Name         string     `json:"name,omitempty"`
}

Sub structs for nested objects in specifications

type TargetEnvironment

type TargetEnvironment struct {
	Provider string             `json:"provider"`
	Details  EnvironmentDetails `json:"details"`
}

type TargetGroup

type TargetGroup struct {
	Port       string `json:"port,omitempty"`
	Protocol   string `json:"protocol,omitempty"`
	SubGroupId string `json:"subGroupId,omitempty"`
}

type VM

type VM struct {
	DataDiskIds      []string `json:"dataDiskIds,omitempty"`
	Description      string   `json:"description,omitempty"`
	IdByCsp          string   `json:"idByCsp,omitempty"`
	ImageId          string   `json:"imageId,omitempty"`
	Label            string   `json:"label,omitempty"`
	Name             string   `json:"name,omitempty"`
	RootDiskSize     string   `json:"rootDiskSize,omitempty"`
	RootDiskType     string   `json:"rootDiskType,omitempty"`
	SecurityGroupIds []string `json:"securityGroupIds,omitempty"`
	SpecId           string   `json:"specId,omitempty"`
	SshKeyId         string   `json:"sshKeyId,omitempty"`
	SubGroupSize     string   `json:"subGroupSize,omitempty"`
	VNetId           string   `json:"vNetId,omitempty"`
	SubnetId         string   `json:"subnetId,omitempty"`
	VmUserAccount    string   `json:"vmUserAccount,omitempty"`
	VmUserPassword   string   `json:"vmUserPassword,omitempty"`
}

type VMImage

type VMImage struct {
	CspImageId  string `json:"cspImageId"`
	Description string `json:"description"`
	Name        string `json:"name"`
}

type VMInstance

type VMInstance struct {
	Name           string          `yaml:"Name"`
	ImageId        string          `yaml:"ImageId"`
	VMSpecId       string          `yaml:"VMSpecId"`
	KeyPairName    string          `yaml:"KeyPairName"`
	SecurityGroups []SecurityGroup `yaml:"SecurityGroups"`
	VPC            VPCInstance     `yaml:"VPCInstance"`
	Subnets        []Subnet        `yaml:"Subnets"`
}

type VNet

type VNet struct {
	CidrBlock      string       `json:"cidrBlock"`
	CspVNetId      string       `json:"cspVNetId"`
	Description    string       `json:"description"`
	Name           string       `json:"name"`
	SubnetInfoList []SubnetInfo `json:"subnetInfoList"`
}

type VPCInstance

type VPCInstance struct {
	Name               string `yaml:"Name"`
	CidrBlock          string `yaml:"CidrBlock"`
	EnableDnsSupport   bool   `yaml:"EnableDnsSupport"`
	EnableDnsHostnames bool   `yaml:"EnableDnsHostnames"`
}

type WebServer

type WebServer struct {
	Software       string `json:"software"`
	Version        string `json:"version"`
	HostedWebsites string `json:"hostedWebsites"`
	Traffic        string `json:"traffic"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL