Documentation
¶
Overview ¶
Package builder is the High Level APIs for creating resources on SakuraCloud.
さくらのクラウドでのリソース作成用の高レベルAPIです。 サーバー/ディスク作成時の手順を単純化します。
Building resources ¶
リソースの作成は以下のように行います。
import (
"github.com/sacloud/libsacloud/api"
"github.com/sacloud/libsacloud/builder"
"github.com/sacloud/libsacloud/sacloud/ostype"
)
func main() {
// APIクライアントの作成
client := api.NewClient("PUT-YOUR-TOKEN", "PUT-YOUR-SECRET", "tk1a")
// パブリックアーカイブ(CentOS)から作成するビルダー、共有セグメントに接続、以外はデフォルト値で作成
b := builder.serverPublicArchiveUnix(builder.NewAPIClient(client), ostype.CentOS, "ServerName", "Password")
b.AddPublicNWConnectedNIC()
res , err := b.WithAddPublicNWConnectedNIC().Build()
if err != nil {
panic(err)
}
fmt.Printf("%v" , res.Server)
}
1) 作成したいサーバーのディスク/ソースアーカイブの種類ごとにビルダーを作成します。
2) 必要に応じてNICやディスク、サーバースペックなどをビルダーのメソッドで設定します。
3) Buildメソッドを呼び出すことでサーバーが作成されます。
Server builder types ¶
ビルダーはディスク構成やソースアーカイブ/ディスクにより以下のような種類に分かれています。
それぞれに対応するビルダー作成用関数を用意しています。
Linux(Unix)系パブリックアーカイブ // ビルダー type PublicArchiveUnixServerBuilder interface { ... }
// ビルダー作成用関数 func serverPublicArchiveUnix(client APIClient, os ostype.ArchiveOSTypes, name string, password string) PublicArchiveUnixServerBuilder
Windows系パブリックアーカイブ // ビルダー type PublicArchiveWindowsServerBuilder interface { ... }
// ビルダー作成用関数 func serverPublicArchiveWindows(client APIClient, name string, archiveID int64) PublicArchiveWindowsServerBuilder
汎用 // ビルダー type CommonServerBuilder interface { ... }
// ビルダー作成用関数(アーカイブから作成) func serverFromArchive(client APIClient, name string, sourceArchiveID int64) CommonServerBuilder
// ビルダー作成用関数(ディスクから作成) func serverFromDisk(client APIClient, name string, sourceDiskID int64) CommonServerBuilder
ディスクレス // ビルダー type DisklessServerBuilder interface { ... }
// ビルダー作成用関数 func ServerDiskless(client APIClient, name string) DisklessServerBuilder
空のディスク // ビルダー type BlankDiskServerBuilder interface { ... }
// ビルダー作成用関数 func ServerBlankDisk(client APIClient, name string) BlankDiskServerBuilder
Event handling ¶
ビルダーでは各タイミングごとにイベントハンドラ(コールバック)が利用可能です。
func main() {
// APIクライアントの作成
client := api.NewClient("PUT-YOUR-TOKEN", "PUT-YOUR-SECRET", "tk1a")
// ディスクレスビルダー、イベントハンドラ(ServerBuildOnComplete)を登録
b := builder.ServerDiskless(builder.NewAPIClient(client), "example")
b.SetEventHandler(builder.ServerBuildOnComplete, callbackFunc).
b.Build()
}
func callbackFunc(value *builder.ServerBuildValue, result *builder.ServerBuildResult) {
// Do someting here
}
Example ¶
package main
import (
"fmt"
"github.com/sacloud/libsacloud/api"
"github.com/sacloud/libsacloud/builder"
"github.com/sacloud/libsacloud/sacloud/ostype"
)
func main() {
/**********************************************************************
* CentOSベースのサーバー作成例:
* NIC:共有セグメントに接続 / コア数:2 / メモリ: 4GB / ディスク: 100GB /
* 公開鍵を登録+パスワード認証無効化 / スタートアップスクリプトでyum update実施
*********************************************************************/
token := "PUT-YOUR-TOKEN" // APIトークン
secret := "PUT-YOUR-SECRET" // APIシークレット
zone := "tk1a" // 対象ゾーン[ tk1a or is1b ]
serverName := "example-server" // サーバー名
password := "PUT-YOUR-PASSWORD" // パスワード
core := 2 // コア数
memory := 4 // メモリ(GB)
diskSize := 100 // ディスクサイズ(GB)
// SSH公開鍵
sshKey := "ssh-rsa AAAA..."
// スタートアップスクリプト
script := `#!/bin/bash
yum -y update || exit 1
exit 0`
//---------------------------------------------------------------------
// APIクライアントの作成
client := api.NewClient(token, secret, zone)
// CentOSパブリックアーカイブからサーバー作成
builder := builder.ServerPublicArchiveUnix(builder.NewAPIClient(client), ostype.CentOS, serverName, password)
builder.AddPublicNWConnectedNIC() // NIC:共有セグメントに接続
builder.SetCore(core) // スペック指定(コア数)
builder.SetMemory(memory) // スペック指定(メモリ)
builder.SetDiskSize(diskSize) // スペック指定(ディスクサイズ)
builder.AddSSHKey(sshKey) // SSH公開鍵を登録
builder.SetDisablePWAuth(true) // パスワード認証を無効化
builder.AddNote(script) // スタートアップスクリプトを登録
result, err := builder.Build()
if err != nil {
panic(err)
}
fmt.Printf("%#v", result.Server)
}
Index ¶
- Constants
- Variables
- type APIClient
- type AdditionalDiskProperty
- type BlankDiskServerBuilder
- type Builder
- type CommonProperty
- type CommonServerBuilder
- type ConnectDiskServerBuilder
- type DiskBuildEventHandler
- type DiskBuildEvents
- type DiskBuildResult
- type DiskBuildValue
- type DiskBuilder
- func (b *DiskBuilder) AddDistantFrom(diskID sacloud.ID) *DiskBuilder
- func (b *DiskBuilder) AddNote(note string)
- func (b *DiskBuilder) AddNoteID(noteID sacloud.ID)
- func (b *DiskBuilder) AddSSHKey(sshKey string)
- func (b *DiskBuilder) AddSSHKeyID(sshKeyID sacloud.ID)
- func (b *DiskBuilder) Build() (*DiskBuildResult, error)
- func (b *DiskBuilder) ClearDistantFrom()
- func (b *DiskBuilder) ClearEventHandler(event DiskBuildEvents)
- func (b *DiskBuilder) ClearNoteIDs()
- func (b *DiskBuilder) ClearNotes()
- func (b *DiskBuilder) ClearSSHKey()
- func (b *DiskBuilder) ClearSSHKeyIDs()
- func (b *DiskBuilder) GetAutoBoot() bool
- func (b *DiskBuilder) GetConnection() sacloud.EDiskConnection
- func (b *DiskBuilder) GetDefaultRoute() string
- func (b *DiskBuilder) GetDescription() string
- func (b *DiskBuilder) GetDistantFrom() []sacloud.ID
- func (b *DiskBuilder) GetEventHandler(event DiskBuildEvents) *DiskBuildEventHandler
- func (b *DiskBuilder) GetGenerateSSHKeyDescription() string
- func (b *DiskBuilder) GetGenerateSSHKeyName() string
- func (b *DiskBuilder) GetGenerateSSHKeyPassPhrase() string
- func (b *DiskBuilder) GetHostName() string
- func (b *DiskBuilder) GetIPAddress() string
- func (b *DiskBuilder) GetIconID() sacloud.ID
- func (b *DiskBuilder) GetName() string
- func (b *DiskBuilder) GetNetworkMaskLen() int
- func (b *DiskBuilder) GetNoteIDs() []sacloud.ID
- func (b *DiskBuilder) GetNotes() []string
- func (b *DiskBuilder) GetPassword() string
- func (b *DiskBuilder) GetPlanID() sacloud.DiskPlanID
- func (b *DiskBuilder) GetSSHKeyIds() []sacloud.ID
- func (b *DiskBuilder) GetSSHKeys() []string
- func (b *DiskBuilder) GetServerID() sacloud.ID
- func (b *DiskBuilder) GetSize() int
- func (b *DiskBuilder) GetSourceArchiveID() sacloud.ID
- func (b *DiskBuilder) GetSourceDiskID() sacloud.ID
- func (b *DiskBuilder) GetTags() []string
- func (b *DiskBuilder) IsDisablePWAuth() bool
- func (b *DiskBuilder) IsNotesEphemeral() bool
- func (b *DiskBuilder) IsSSHKeysEphemeral() bool
- func (b *DiskBuilder) SetAutoBoot(autoBoot bool)
- func (b *DiskBuilder) SetConnection(connection sacloud.EDiskConnection)
- func (b *DiskBuilder) SetDefaultRoute(route string)
- func (b *DiskBuilder) SetDescription(desc string)
- func (b *DiskBuilder) SetDisablePWAuth(disable bool)
- func (b *DiskBuilder) SetDistantFrom(diskIDs []sacloud.ID)
- func (b *DiskBuilder) SetEventHandler(event DiskBuildEvents, handler DiskBuildEventHandler)
- func (b *DiskBuilder) SetGenerateSSHKeyDescription(desc string)
- func (b *DiskBuilder) SetGenerateSSHKeyName(name string)
- func (b *DiskBuilder) SetGenerateSSHKeyPassPhrase(pass string)
- func (b *DiskBuilder) SetHostName(name string)
- func (b *DiskBuilder) SetIPAddress(ip string)
- func (b *DiskBuilder) SetIconID(id sacloud.ID)
- func (b *DiskBuilder) SetName(name string)
- func (b *DiskBuilder) SetNetworkMaskLen(masklen int)
- func (b *DiskBuilder) SetNotesEphemeral(isEphemeral bool)
- func (b *DiskBuilder) SetPassword(password string)
- func (b *DiskBuilder) SetPlan(plan string)
- func (b *DiskBuilder) SetPlanID(planID sacloud.DiskPlanID)
- func (b *DiskBuilder) SetSSHKeysEphemeral(isEphemeral bool)
- func (b *DiskBuilder) SetServerID(id sacloud.ID)
- func (b *DiskBuilder) SetSize(size int)
- func (b *DiskBuilder) SetSourceArchiveID(id sacloud.ID)
- func (b *DiskBuilder) SetSourceDiskID(id sacloud.ID)
- func (b *DiskBuilder) SetTags(tags []string)
- type DiskEditProperty
- type DiskEventProperty
- type DiskProperty
- type DiskSourceProperty
- type DisklessServerBuilder
- type FixedUnixArchiveServerBuilder
- type NetworkInterfaceProperty
- type PublicArchiveUnixServerBuilder
- type PublicArchiveWindowsServerBuilder
- type ServerBuildEventHandler
- type ServerBuildEvents
- type ServerBuildResult
- type ServerBuildValue
- type ServerEventProperty
Examples ¶
Constants ¶
const ( // DefaultDiskPlanID ディスクプラン(デフォルト値) DefaultDiskPlanID = sacloud.DiskPlanSSDID // DefaultDiskConnection ディスク接続方法(デフォルト値) DefaultDiskConnection = sacloud.DiskConnectionVirtio // DefaultDiskSize ディスクサイズ(デフォルト値) DefaultDiskSize = 20 // DefaultDiskIsSSHKeysEphemeral ディスク作成後の公開鍵削除フラグ(デフォルト値) DefaultDiskIsSSHKeysEphemeral = true // DefaultDiskIsNotesEphemeral ディスク作成後のスタートアップスクリプト削除フラグ(デフォルト値) DefaultDiskIsNotesEphemeral = true )
const ( // DefaultCore コア数(デフォルト値) DefaultCore = 1 // DefaultMemory メモリサイズ(デフォルト値) DefaultMemory = 1 // DefaultDescription 説明 (デフォルト値) DefaultDescription = "" // DefaultIconID アイコンID(デフォルト値) DefaultIconID = sacloud.EmptyID // DefaultBootAfterCreate サーバー作成後すぐに起動フラグ(デフォルト値) DefaultBootAfterCreate = true )
Variables ¶
var ( // DefaultInterfaceDriver インターフェースドライバ(デフォルト値) DefaultInterfaceDriver = sacloud.InterfaceDriverVirtIO )
Functions ¶
This section is empty.
Types ¶
type APIClient ¶ added in v1.2.0
type APIClient interface {
ServerNew() *sacloud.Server
ServerRead(serverID sacloud.ID) (*sacloud.Server, error)
ServerCreate(value *sacloud.Server) (*sacloud.Server, error)
ServerSleepUntilUp(serverID sacloud.ID, timeout time.Duration) error
ServerInsertCDROM(serverID sacloud.ID, cdromID sacloud.ID) (bool, error)
ServerBoot(serverID sacloud.ID) (bool, error)
SSHKeyNew() *sacloud.SSHKey
SSHKeyCreate(value *sacloud.SSHKey) (*sacloud.SSHKey, error)
SSHKeyDelete(sshKeyID sacloud.ID) (*sacloud.SSHKey, error)
SSHKeyGenerate(name string, passPhrase string, desc string) (*sacloud.SSHKeyGenerated, error)
NoteNew() *sacloud.Note
NoteCreate(value *sacloud.Note) (*sacloud.Note, error)
NoteDelete(noteID sacloud.ID) (*sacloud.Note, error)
DiskNew() *sacloud.Disk
DiskNewCondig() *sacloud.DiskEditValue
DiskCreate(value *sacloud.Disk) (*sacloud.Disk, error)
DiskCreateWithConfig(value *sacloud.Disk, config *sacloud.DiskEditValue, bootAtAvailable bool) (*sacloud.Disk, error)
DiskSleepWhileCopying(id sacloud.ID, timeout time.Duration) error
DiskConnectToServer(diskID sacloud.ID, serverID sacloud.ID) (bool, error)
InterfaceConnectToPacketFilter(interfaceID sacloud.ID, packetFilterID sacloud.ID) (bool, error)
InterfaceSetDisplayIPAddress(interfaceID sacloud.ID, ip string) (bool, error) // Interface
ServerPlanGetBySpec(core, memGB int, gen sacloud.PlanGenerations, commitment sacloud.ECommitment) (*sacloud.ProductServer, error)
ArchiveFindByOSType(os ostype.ArchiveOSTypes) (*sacloud.Archive, error)
GetTimeoutDuration() time.Duration
}
APIClient represents SAKURA CLOUD api client
func NewAPIClient ¶ added in v1.2.0
NewAPIClient create new APICLient from *api.Client
type AdditionalDiskProperty ¶
type AdditionalDiskProperty interface {
// AddAdditionalDisk 追加ディスク 追加
AddAdditionalDisk(diskBuilder *DiskBuilder)
// ClearAdditionalDisks 追加ディスク クリア
ClearAdditionalDisks()
// GetAdditionalDisks 追加ディスク 取得
GetAdditionalDisks() []*DiskBuilder
}
AdditionalDiskProperty 追加ディスクプロパティ
type BlankDiskServerBuilder ¶
type BlankDiskServerBuilder interface {
Builder
CommonProperty
NetworkInterfaceProperty
DiskProperty
ServerEventProperty
DiskEventProperty
AdditionalDiskProperty
}
BlankDiskServerBuilder ブランクディスクを利用して構築を行うサーバービルダー
空のディスクを持ちます。基本的なディスク設定やディスクの追加に対応していますが、ディスクの修正機能には非対応です。
func ServerBlankDisk ¶
func ServerBlankDisk(client APIClient, name string) BlankDiskServerBuilder
ServerBlankDisk 空のディスクを利用するビルダー
type Builder ¶
type Builder interface {
Build() (*ServerBuildResult, error)
HasCommonProperty() bool
HasNetworkInterfaceProperty() bool
HasDiskProperty() bool
HasAdditionalDiskProperty() bool
HasServerEventProperty() bool
HasDiskEventProperty() bool
HasDiskSourceProperty() bool
HasDiskEditProperty() bool
}
Builder ビルダー基本インターフェース
type CommonProperty ¶
type CommonProperty interface {
// GetServerName サーバー名 取得
GetServerName() string
// SetServerName サーバー名 設定
SetServerName(serverName string)
// GetCore CPUコア数 取得
GetCore() int
// SetCore CPUコア数 設定
SetCore(core int)
// GetMemory メモリサイズ(GB単位) 取得
GetMemory() int
// SetMemory メモリサイズ(GB単位) 設定
SetMemory(memory int)
// GetCommitment サーバプランCPUコミットメント 取得
GetCommitment() sacloud.ECommitment
// SetCommitment サーバプランCPUコミットメント 設定
SetCommitment(commitment sacloud.ECommitment)
// GetInterfaceDriver インターフェースドライバ 取得
GetInterfaceDriver() sacloud.EInterfaceDriver
// SetInterfaceDriver インターフェースドライバ 設定
SetInterfaceDriver(interfaceDriver sacloud.EInterfaceDriver)
// GetDescription 説明 取得
GetDescription() string
// SetDescription 説明 設定
SetDescription(description string)
// GetIconID アイコンID 取得
GetIconID() sacloud.ID
// SetIconID アイコンID 設定
SetIconID(iconID sacloud.ID)
// GetPrivateHostID アイコンID 取得
GetPrivateHostID() sacloud.ID
// SetPrivateHostID アイコンID 設定
SetPrivateHostID(privateHostID sacloud.ID)
// IsBootAfterCreate サーバー作成後すぐに起動フラグ 取得
IsBootAfterCreate() bool
// SetBootAfterCreate サーバー作成後すぐに起動フラグ 設定
SetBootAfterCreate(bootAfterCreate bool)
// GetTags タグ 取得
GetTags() []string
// SetTags タグ 設定
SetTags(tags []string)
// GetISOImageID ISOイメージ(CDROM)ID 取得
GetISOImageID() sacloud.ID
// SetISOImageID ISOイメージ(CDROM)ID 設定
SetISOImageID(id sacloud.ID)
}
CommonProperty ビルダー共通のプロパティ
type CommonServerBuilder ¶
type CommonServerBuilder interface {
Builder
CommonProperty
NetworkInterfaceProperty
DiskProperty
DiskEditProperty
DiskSourceProperty
ServerEventProperty
DiskEventProperty
AdditionalDiskProperty
}
CommonServerBuilder 既存のアーカイブ or ディスクを利用して構築を行うサーバービルダー
基本的なディスク設定やディスクの追加、ディスクの修正機能に対応しています。 ただし、ディスクの修正機能はソースアーカイブ or ソースディスクが対応していない場合は さくらのクラウドAPIコール時にエラーとなるため、適切にハンドリングするように実装する必要があります。
func ServerFromArchive ¶
func ServerFromArchive(client APIClient, name string, sourceArchiveID sacloud.ID) CommonServerBuilder
ServerFromArchive 既存アーカイブをコピーして新たなディスクを作成するビルダー
func ServerFromDisk ¶
func ServerFromDisk(client APIClient, name string, sourceDiskID sacloud.ID) CommonServerBuilder
ServerFromDisk 既存ディスクをコピーして新たなディスクを作成するビルダー
type ConnectDiskServerBuilder ¶
type ConnectDiskServerBuilder interface {
Builder
CommonProperty
NetworkInterfaceProperty
AdditionalDiskProperty
}
ConnectDiskServerBuilder ブランクディスクを利用して構築を行うサーバービルダー
すでに存在するディスクを持ちます。ディスクの追加に対応していますが、ディスクの修正機能には非対応です。
func ServerFromExistsDisk ¶
func ServerFromExistsDisk(client APIClient, name string, sourceDiskID sacloud.ID) ConnectDiskServerBuilder
ServerFromExistsDisk 既存ディスクを接続するビルダー
type DiskBuildEventHandler ¶
type DiskBuildEventHandler func(value *DiskBuildValue, result *DiskBuildResult)
DiskBuildEventHandler ディスク構築時イベントハンドラ型
type DiskBuildEvents ¶
type DiskBuildEvents int
DiskBuildEvents ディスク構築時イベント種別
const ( // DiskBuildOnStart ディスク作成 開始 DiskBuildOnStart DiskBuildEvents = iota // DiskBuildOnCreateSSHKeyBefore SSHキー作成 開始時 DiskBuildOnCreateSSHKeyBefore // DiskBuildOnCreateSSHKeyAfter SSHキー作成 終了時 DiskBuildOnCreateSSHKeyAfter // DiskBuildOnCreateNoteBefore スタートアップスクリプト作成 開始時 DiskBuildOnCreateNoteBefore // DiskBuildOnCreateNoteAfter スタートアップスクリプト作成 終了時 DiskBuildOnCreateNoteAfter // DiskBuildOnCreateDiskBefore ディスク作成 開始時 DiskBuildOnCreateDiskBefore // DiskBuildOnCreateDiskAfter ディスク作成 終了時 DiskBuildOnCreateDiskAfter // DiskBuildOnCleanupSSHKeyBefore SSHキークリーンアップ 開始時 DiskBuildOnCleanupSSHKeyBefore // DiskBuildOnCleanupSSHKeyAfter SSHキークリーンアップ 終了時 DiskBuildOnCleanupSSHKeyAfter // DiskBuildOnCleanupNoteBefore スタートアップスクリプトクリーンアップ 開始時 DiskBuildOnCleanupNoteBefore // DiskBuildOnCleanupNoteAfter スタートアップスクリプトクリーンアップ 終了時 DiskBuildOnCleanupNoteAfter // DiskBuildOnComplete ディスク作成 完了 DiskBuildOnComplete )
type DiskBuildResult ¶
type DiskBuildResult struct {
// Disk ディスク
Disk *sacloud.Disk
// Notes スタートアップスクリプト
Notes []*sacloud.Note
// SSHKeys 公開鍵
SSHKeys []*sacloud.SSHKey
// GeneratedSSHKey 生成されたSSHキー
GeneratedSSHKey *sacloud.SSHKeyGenerated
}
DiskBuildResult ディスク構築結果
type DiskBuildValue ¶
type DiskBuildValue struct {
// Disk ディスク作成用パラメータ
Disk *sacloud.Disk
// Edit ディスクの編集用パラメータ
Edit *sacloud.DiskEditValue
}
DiskBuildValue ディスク構築用パラメータ
type DiskBuilder ¶
type DiskBuilder struct {
// contains filtered or unexported fields
}
DiskBuilder ディスクビルダー
func (*DiskBuilder) AddDistantFrom ¶
func (b *DiskBuilder) AddDistantFrom(diskID sacloud.ID) *DiskBuilder
AddDistantFrom ストレージ隔離対象ディスク 追加
func (*DiskBuilder) AddNoteID ¶
func (b *DiskBuilder) AddNoteID(noteID sacloud.ID)
AddNoteID スタートアップスクリプトID 追加
func (*DiskBuilder) AddSSHKeyID ¶
func (b *DiskBuilder) AddSSHKeyID(sshKeyID sacloud.ID)
AddSSHKeyID 公開鍵ID 追加
func (*DiskBuilder) ClearDistantFrom ¶
func (b *DiskBuilder) ClearDistantFrom()
ClearDistantFrom ストレージ隔離対象ディスク クリア
func (*DiskBuilder) ClearEventHandler ¶
func (b *DiskBuilder) ClearEventHandler(event DiskBuildEvents)
ClearEventHandler イベントハンドラ クリア
func (*DiskBuilder) ClearNoteIDs ¶
func (b *DiskBuilder) ClearNoteIDs()
ClearNoteIDs スタートアップスクリプトID クリア
func (*DiskBuilder) ClearSSHKeyIDs ¶
func (b *DiskBuilder) ClearSSHKeyIDs()
ClearSSHKeyIDs 公開鍵ID クリア
func (*DiskBuilder) GetConnection ¶
func (b *DiskBuilder) GetConnection() sacloud.EDiskConnection
GetConnection ディスク接続方法(VirtIO/IDE) 取得
func (*DiskBuilder) GetDefaultRoute ¶
func (b *DiskBuilder) GetDefaultRoute() string
GetDefaultRoute デフォルトルート 取得
func (*DiskBuilder) GetDescription ¶
func (b *DiskBuilder) GetDescription() string
GetDescription 説明 取得
func (*DiskBuilder) GetDistantFrom ¶
func (b *DiskBuilder) GetDistantFrom() []sacloud.ID
GetDistantFrom ストレージ隔離対象ディスク 取得
func (*DiskBuilder) GetEventHandler ¶
func (b *DiskBuilder) GetEventHandler(event DiskBuildEvents) *DiskBuildEventHandler
GetEventHandler イベントハンドラ取得
func (*DiskBuilder) GetGenerateSSHKeyDescription ¶
func (b *DiskBuilder) GetGenerateSSHKeyDescription() string
GetGenerateSSHKeyDescription SSHキー生成 説明 取得
func (*DiskBuilder) GetGenerateSSHKeyName ¶
func (b *DiskBuilder) GetGenerateSSHKeyName() string
GetGenerateSSHKeyName SSHキー生成 名称 取得
func (*DiskBuilder) GetGenerateSSHKeyPassPhrase ¶
func (b *DiskBuilder) GetGenerateSSHKeyPassPhrase() string
GetGenerateSSHKeyPassPhrase SSHキー生成 パスフレーズ 取得
func (*DiskBuilder) GetIPAddress ¶
func (b *DiskBuilder) GetIPAddress() string
GetIPAddress IPアドレス 取得
func (*DiskBuilder) GetNetworkMaskLen ¶
func (b *DiskBuilder) GetNetworkMaskLen() int
GetNetworkMaskLen ネットワークマスク長 取得
func (*DiskBuilder) GetNoteIDs ¶
func (b *DiskBuilder) GetNoteIDs() []sacloud.ID
GetNoteIDs スタートアップスクリプトID 取得
func (*DiskBuilder) GetPlanID ¶
func (b *DiskBuilder) GetPlanID() sacloud.DiskPlanID
GetPlanID ディスクプラン(SSD/HDD) 取得
func (*DiskBuilder) GetSSHKeyIds ¶
func (b *DiskBuilder) GetSSHKeyIds() []sacloud.ID
GetSSHKeyIds 公開鍵ID 取得
func (*DiskBuilder) GetServerID ¶
func (b *DiskBuilder) GetServerID() sacloud.ID
GetServerID サーバーID 取得
func (*DiskBuilder) GetSourceArchiveID ¶
func (b *DiskBuilder) GetSourceArchiveID() sacloud.ID
GetSourceArchiveID ソースアーカイブID 取得
func (*DiskBuilder) GetSourceDiskID ¶
func (b *DiskBuilder) GetSourceDiskID() sacloud.ID
GetSourceDiskID ソースディスクID 取得
func (*DiskBuilder) IsDisablePWAuth ¶
func (b *DiskBuilder) IsDisablePWAuth() bool
IsDisablePWAuth パスワード認証無効化フラグ 取得
func (*DiskBuilder) IsNotesEphemeral ¶
func (b *DiskBuilder) IsNotesEphemeral() bool
IsNotesEphemeral ディスク作成後のスタートアップスクリプト削除フラグ 取得
func (*DiskBuilder) IsSSHKeysEphemeral ¶
func (b *DiskBuilder) IsSSHKeysEphemeral() bool
IsSSHKeysEphemeral ディスク作成後の公開鍵削除フラグ 取得
func (*DiskBuilder) SetAutoBoot ¶
func (b *DiskBuilder) SetAutoBoot(autoBoot bool)
SetAutoBoot サーバ自動起動 設定
func (*DiskBuilder) SetConnection ¶
func (b *DiskBuilder) SetConnection(connection sacloud.EDiskConnection)
SetConnection ディスク接続方法(VirtIO/IDE) 設定
func (*DiskBuilder) SetDefaultRoute ¶
func (b *DiskBuilder) SetDefaultRoute(route string)
SetDefaultRoute デフォルトルート 設定
func (*DiskBuilder) SetDescription ¶
func (b *DiskBuilder) SetDescription(desc string)
SetDescription 説明 設定
func (*DiskBuilder) SetDisablePWAuth ¶
func (b *DiskBuilder) SetDisablePWAuth(disable bool)
SetDisablePWAuth パスワード認証無効化フラグ 設定
func (*DiskBuilder) SetDistantFrom ¶
func (b *DiskBuilder) SetDistantFrom(diskIDs []sacloud.ID)
SetDistantFrom ストレージ隔離対象ディスク 設定
func (*DiskBuilder) SetEventHandler ¶
func (b *DiskBuilder) SetEventHandler(event DiskBuildEvents, handler DiskBuildEventHandler)
SetEventHandler イベントハンドラ 登録
func (*DiskBuilder) SetGenerateSSHKeyDescription ¶
func (b *DiskBuilder) SetGenerateSSHKeyDescription(desc string)
SetGenerateSSHKeyDescription SSHキー生成 説明 設定
func (*DiskBuilder) SetGenerateSSHKeyName ¶
func (b *DiskBuilder) SetGenerateSSHKeyName(name string)
SetGenerateSSHKeyName SSHキー生成 名称 設定
func (*DiskBuilder) SetGenerateSSHKeyPassPhrase ¶
func (b *DiskBuilder) SetGenerateSSHKeyPassPhrase(pass string)
SetGenerateSSHKeyPassPhrase SSHキー生成 パスフレーズ 設定
func (*DiskBuilder) SetHostName ¶
func (b *DiskBuilder) SetHostName(name string)
SetHostName ホスト名 設定
func (*DiskBuilder) SetIPAddress ¶
func (b *DiskBuilder) SetIPAddress(ip string)
SetIPAddress IPアドレス 設定
func (*DiskBuilder) SetNetworkMaskLen ¶
func (b *DiskBuilder) SetNetworkMaskLen(masklen int)
SetNetworkMaskLen ネットワークマスク長 設定
func (*DiskBuilder) SetNotesEphemeral ¶
func (b *DiskBuilder) SetNotesEphemeral(isEphemeral bool)
SetNotesEphemeral ディスク作成後のスタートアップスクリプト削除フラグ 設定
func (*DiskBuilder) SetPassword ¶
func (b *DiskBuilder) SetPassword(password string)
SetPassword パスワード 設定
func (*DiskBuilder) SetPlan ¶
func (b *DiskBuilder) SetPlan(plan string)
SetPlan ディスクプラン(ssd/hdd) 設定(文字列から)
func (*DiskBuilder) SetPlanID ¶
func (b *DiskBuilder) SetPlanID(planID sacloud.DiskPlanID)
SetPlanID ディスクプラン(SSD/HDD) 設定
func (*DiskBuilder) SetSSHKeysEphemeral ¶
func (b *DiskBuilder) SetSSHKeysEphemeral(isEphemeral bool)
SetSSHKeysEphemeral ディスク作成後の公開鍵削除フラグ 設定
func (*DiskBuilder) SetServerID ¶
func (b *DiskBuilder) SetServerID(id sacloud.ID)
SetServerID サーバーID 設定
func (*DiskBuilder) SetSourceArchiveID ¶
func (b *DiskBuilder) SetSourceArchiveID(id sacloud.ID)
SetSourceArchiveID ソースアーカイブID 設定
func (*DiskBuilder) SetSourceDiskID ¶
func (b *DiskBuilder) SetSourceDiskID(id sacloud.ID)
SetSourceDiskID ソースディスクID 設定
type DiskEditProperty ¶
type DiskEditProperty interface {
// GetPassword パスワード 取得
GetPassword() string
// SetPassword パスワード 設定
SetPassword(password string)
// GetHostName ホスト名 取得
GetHostName() string
// SetHostName ホスト名 設定
SetHostName(hostName string)
// GetIPAddress IPアドレス 取得
GetIPAddress() string
// SetIPAddress IPアドレス 設定
SetIPAddress(ipAddress string)
// NetworkMaskLen ネットワークマスク長 取得
GetNetworkMaskLen() int
// SetNetworkMaskLen ネットワークマスク長 設定
SetNetworkMaskLen(maskLen int)
// GetDefaultRoute デフォルトルート 取得
GetDefaultRoute() string
// SetDefaultRoute デフォルトルート 設定
SetDefaultRoute(route string)
// IsDisablePWAuth パスワード認証無効化フラグ 取得
IsDisablePWAuth() bool
// SetDisablePWAuth パスワード認証無効化フラグ 設定
SetDisablePWAuth(disable bool)
// GetSSHKeys 公開鍵 取得
GetSSHKeys() []string
// GetSSHKeyIds 公開鍵ID 取得
GetSSHKeyIds() []sacloud.ID
// AddSSHKey 公開鍵 追加
AddSSHKey(sshKey string)
// AddSSHKeyID 公開鍵ID 追加
AddSSHKeyID(sshKeyID sacloud.ID)
// ClearSSHKey 公開鍵 クリア
ClearSSHKey()
// ClearSSHKeyIDs 公開鍵ID クリア
ClearSSHKeyIDs()
// AddNote スタートアップスクリプト 追加
AddNote(note string)
// ClearNotes スタートアップスクリプト クリア
ClearNotes()
// GetNotes スタートアップスクリプト 取得
GetNotes() []string
// AddNoteID スタートアップスクリプト 追加
AddNoteID(noteID sacloud.ID)
// ClearNoteIDs スタートアップスクリプト クリア
ClearNoteIDs()
// GetNoteIDs スタートアップスクリプトID 取得
GetNoteIDs() []sacloud.ID
// IsSSHKeysEphemeral ディスク作成後の公開鍵削除フラグ 取得
IsSSHKeysEphemeral() bool
// SetSSHKeysEphemeral ディスク作成後の公開鍵削除フラグ 設定
SetSSHKeysEphemeral(isEphemeral bool)
// IsNotesEphemeral ディスク作成後のスタートアップスクリプト削除フラグ 取得
IsNotesEphemeral() bool
// SetNotesEphemeral ディスク作成後のスタートアップスクリプト削除フラグ 設定
SetNotesEphemeral(isEphemeral bool)
// GetGenerateSSHKeyName SSHキー生成 名称 取得
GetGenerateSSHKeyName() string
// SetGenerateSSHKeyName SSHキー生成 名称 設定
SetGenerateSSHKeyName(name string)
// GetGenerateSSHKeyPassPhrase SSHキー生成 パスフレーズ 取得
GetGenerateSSHKeyPassPhrase() string
// SetGenerateSSHKeyPassPhrase SSHキー生成 パスフレーズ 設定
SetGenerateSSHKeyPassPhrase(pass string)
// GetGenerateSSHKeyDescription SSHキー生成 説明 取得
GetGenerateSSHKeyDescription() string
// SetGenerateSSHKeyDescription SSHキー生成 説明 設定
SetGenerateSSHKeyDescription(desc string)
}
DiskEditProperty ディスクの修正関連プロパティ
type DiskEventProperty ¶
type DiskEventProperty interface {
// GetDiskEventHandler ディスクイベントハンドラ 取得
GetDiskEventHandler(event DiskBuildEvents) *DiskBuildEventHandler
// SetDiskEventHandler ディスクイベントハンドラ 設定
SetDiskEventHandler(event DiskBuildEvents, handler DiskBuildEventHandler)
// ClearDiskEventHandler ディスクイベントハンドラ クリア
ClearDiskEventHandler(event DiskBuildEvents)
}
DiskEventProperty ディスク作成時イベントプロパティ
type DiskProperty ¶
type DiskProperty interface {
// GetDiskSize ディスクサイズ(GB単位) 取得
GetDiskSize() int
// SetDiskSize ディスクサイズ(GB単位) 設定
SetDiskSize(diskSize int)
// GetDistantFrom ストレージ隔離対象ディスク 取得
GetDistantFrom() []sacloud.ID
// SetDistantFrom ストレージ隔離対象ディスク 設定
SetDistantFrom(distantFrom []sacloud.ID)
// AddDistantFrom ストレージ隔離対象ディスク 追加
AddDistantFrom(diskID sacloud.ID)
// ClearDistantFrom ストレージ隔離対象ディスク クリア
ClearDistantFrom()
// GetDiskPlanID ディスクプラン(SSD/HDD) 取得
GetDiskPlanID() sacloud.DiskPlanID
// SetDiskPlanID ディスクプラン(SSD/HDD) 設定
SetDiskPlanID(diskPlanID sacloud.DiskPlanID)
// WithDiskPlanID ディスクプラン(SSD/HDD) 設定
SetDiskPlan(plan string)
// GetDiskConnection ディスク接続方法(VirtIO/IDE) 取得
GetDiskConnection() sacloud.EDiskConnection
// SetDiskConnection ディスク接続方法(VirtIO/IDE) 設定
SetDiskConnection(diskConnection sacloud.EDiskConnection)
}
DiskProperty ディスク関連プロパティ
type DiskSourceProperty ¶
type DiskSourceProperty interface {
// GetSourceArchiveID ソースアーカイブID 取得
GetSourceArchiveID() sacloud.ID
// GetSourceDiskID ソースディスクID 設定
GetSourceDiskID() sacloud.ID
}
DiskSourceProperty コピー元アーカイブ/ディスクプロパティ
type DisklessServerBuilder ¶
type DisklessServerBuilder interface {
Builder
CommonProperty
NetworkInterfaceProperty
ServerEventProperty
}
DisklessServerBuilder ディスクレス サーバービルダー
ディスクレスのサーバーを構築します。 ディスク関連の設定に非対応です。
func ServerDiskless ¶
func ServerDiskless(client APIClient, name string) DisklessServerBuilder
ServerDiskless ディスクレスサーバービルダー
type FixedUnixArchiveServerBuilder ¶
type FixedUnixArchiveServerBuilder interface {
Builder
CommonProperty
NetworkInterfaceProperty
DiskProperty
DiskSourceProperty
ServerEventProperty
DiskEventProperty
AdditionalDiskProperty
}
FixedUnixArchiveServerBuilder ディスクの修正不可なUNIX系パブリックアーカイブを利用して構築を行うサーバービルダー
基本的なディスク設定やディスクの追加に対応していますが、ディスクの修正機能には非対応です。
func ServerPublicArchiveFixedUnix ¶
func ServerPublicArchiveFixedUnix(client APIClient, os ostype.ArchiveOSTypes, name string) FixedUnixArchiveServerBuilder
ServerPublicArchiveFixedUnix ディスクの編集が不可なLinux(Unix)系パブリックアーカイブを利用するビルダー
type NetworkInterfaceProperty ¶
type NetworkInterfaceProperty interface {
// ClearNICConnections NIC接続設定 クリア
ClearNICConnections()
// AddPublicNWConnectedNIC 共有セグメントへの接続追加(注:共有セグメントはeth0のみ接続可能)
AddPublicNWConnectedNIC()
// AddExistsSwitchConnectedNIC スイッチ or ルーター+スイッチへの接続追加(注:ルーター+スイッチはeth0のみ接続可能)
AddExistsSwitchConnectedNIC(switchID string)
// AddExistsSwitchConnectedNICWithDisplayIP スイッチ or ルーター+スイッチへの接続追加(注:ルーター+スイッチはeth0のみ接続可能)
AddExistsSwitchConnectedNICWithDisplayIP(switchID, displayIP string)
// AddDisconnectedNIC 切断されたNIC追加
AddDisconnectedNIC()
// GetPacketFilterIDs パケットフィルタID 取得
GetPacketFilterIDs() []sacloud.ID
// SetPacketFilterIDs パケットフィルタID 設定
SetPacketFilterIDs(ids []sacloud.ID)
}
NetworkInterfaceProperty NIC関連プロパティ
type PublicArchiveUnixServerBuilder ¶
type PublicArchiveUnixServerBuilder interface {
Builder
CommonProperty
NetworkInterfaceProperty
DiskProperty
DiskSourceProperty
DiskEditProperty
ServerEventProperty
DiskEventProperty
AdditionalDiskProperty
}
PublicArchiveUnixServerBuilder Linux(Unix)系パブリックアーカイブを利用して構築を行うサーバービルダー
基本的なディスク設定やディスクの追加、ディスクの修正機能に対応しています。
func ServerPublicArchiveUnix ¶
func ServerPublicArchiveUnix(client APIClient, os ostype.ArchiveOSTypes, name string, password string) PublicArchiveUnixServerBuilder
ServerPublicArchiveUnix ディスクの編集が可能なLinux(Unix)系パブリックアーカイブを利用するビルダー
type PublicArchiveWindowsServerBuilder ¶
type PublicArchiveWindowsServerBuilder interface {
Builder
CommonProperty
NetworkInterfaceProperty
DiskProperty
DiskSourceProperty
ServerEventProperty
DiskEventProperty
AdditionalDiskProperty
}
PublicArchiveWindowsServerBuilder Windows系パブリックアーカイブを利用して構築を行うサーバービルダー
基本的なディスク設定やディスクの追加に対応していますが、ディスクの修正機能には非対応です。
func ServerPublicArchiveWindows ¶
func ServerPublicArchiveWindows(client APIClient, os ostype.ArchiveOSTypes, name string) PublicArchiveWindowsServerBuilder
ServerPublicArchiveWindows Windows系パブリックアーカイブを利用するビルダー
type ServerBuildEventHandler ¶
type ServerBuildEventHandler func(value *ServerBuildValue, result *ServerBuildResult)
ServerBuildEventHandler サーバー構築時イベントハンドラ
type ServerBuildEvents ¶
type ServerBuildEvents int
ServerBuildEvents サーバー構築時イベント種別
const ( // ServerBuildOnStart サーバー構築 開始 ServerBuildOnStart ServerBuildEvents = iota // ServerBuildOnSetPlanBefore サーバープラン設定 開始時 ServerBuildOnSetPlanBefore // ServerBuildOnSetPlanAfter サーバープラン設定 終了時 ServerBuildOnSetPlanAfter // ServerBuildOnCreateServerBefore サーバー作成 開始時 ServerBuildOnCreateServerBefore // ServerBuildOnCreateServerAfter サーバー作成 終了時 ServerBuildOnCreateServerAfter // ServerBuildOnInsertCDROMBefore ISOイメージ挿入 開始時 ServerBuildOnInsertCDROMBefore // ServerBuildOnInsertCDROMAfter ISOイメージ挿入 終了時 ServerBuildOnInsertCDROMAfter // ServerBuildOnBootBefore サーバー起動 開始時 ServerBuildOnBootBefore // ServerBuildOnBootAfter サーバー起動 終了時 ServerBuildOnBootAfter // ServerBuildOnComplete サーバー構築 完了 ServerBuildOnComplete )
type ServerBuildResult ¶
type ServerBuildResult struct {
// Server サーバー
Server *sacloud.Server
// Disks ディスク構築結果
Disks []*DiskBuildResult
}
ServerBuildResult サーバー構築結果
type ServerBuildValue ¶
ServerBuildValue サーバー構築用パラメータ
type ServerEventProperty ¶
type ServerEventProperty interface {
// GetEventHandler イベントハンドラ 取得
GetEventHandler(event ServerBuildEvents) *ServerBuildEventHandler
// SetEventHandler イベントハンドラ 設定
SetEventHandler(event ServerBuildEvents, handler ServerBuildEventHandler)
// ClearEventHandler イベントハンドラ クリア
ClearEventHandler(event ServerBuildEvents)
}
ServerEventProperty サーバ構築時イベントプロパティ