本文整理汇总了Golang中github.com/coreos/mantle/platform.Cluster.NewMachine方法的典型用法代码示例。如果您正苦于以下问题:Golang Cluster.NewMachine方法的具体用法?Golang Cluster.NewMachine怎么用?Golang Cluster.NewMachine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coreos/mantle/platform.Cluster
的用法示例。
在下文中一共展示了Cluster.NewMachine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: runTest
// create a cluster and run test
func runTest(t *Test, pltfrm string) error {
var err error
var cluster platform.Cluster
if pltfrm == "qemu" {
cluster, err = platform.NewQemuCluster(*QemuImage)
} else if pltfrm == "gce" {
cluster, err = platform.NewGCECluster(GCEOpts())
} else {
plog.Errorf("Invalid platform: %v", pltfrm)
}
if err != nil {
return fmt.Errorf("Cluster failed: %v", err)
}
defer func() {
if err := cluster.Destroy(); err != nil {
plog.Errorf("cluster.Destroy(): %v", err)
}
}()
url, err := cluster.GetDiscoveryURL(t.ClusterSize)
if err != nil {
return fmt.Errorf("Failed to create discovery endpoint: %v", err)
}
cfgs := makeConfigs(url, t.CloudConfig, t.ClusterSize)
for i := 0; i < t.ClusterSize; i++ {
_, err := cluster.NewMachine(cfgs[i])
if err != nil {
return fmt.Errorf("Cluster failed starting machine: %v", err)
}
plog.Infof("%v instance up", pltfrm)
}
// pass along all registered native functions
var names []string
for k := range t.NativeFuncs {
names = append(names, k)
}
// Cluster -> TestCluster
tcluster := platform.TestCluster{t.Name, names, cluster}
// drop kolet binary on machines
if t.NativeFuncs != nil {
err = scpKolet(tcluster)
if err != nil {
return fmt.Errorf("dropping kolet binary: %v", err)
}
}
// run test
err = t.Run(tcluster)
return err
}
示例2: runBootchart
func runBootchart(cmd *cobra.Command, args []string) {
if len(args) != 0 {
fmt.Fprintf(os.Stderr, "No args accepted\n")
os.Exit(2)
}
var (
cluster platform.Cluster
err error
)
if kolaPlatform == "qemu" {
cluster, err = platform.NewQemuCluster(kola.QEMUOptions)
} else if kolaPlatform == "gce" {
cluster, err = platform.NewGCECluster(kola.GCEOptions)
} else if kolaPlatform == "aws" {
cluster, err = platform.NewAWSCluster(kola.AWSOptions)
} else {
fmt.Fprintf(os.Stderr, "Invalid platform: %v", kolaPlatform)
}
if err != nil {
fmt.Fprintf(os.Stderr, "Cluster failed: %v\n", err)
os.Exit(1)
}
defer cluster.Destroy()
m, err := cluster.NewMachine("")
if err != nil {
fmt.Fprintf(os.Stderr, "Machine failed: %v\n", err)
os.Exit(1)
}
defer m.Destroy()
ssh, err := m.SSHSession()
if err != nil {
fmt.Fprintf(os.Stderr, "SSH failed: %v\n", err)
os.Exit(1)
}
ssh.Stdout = os.Stdout
ssh.Stderr = os.Stderr
if err = ssh.Run("systemd-analyze plot"); err != nil {
fmt.Fprintf(os.Stderr, "SSH failed: %v\n", err)
os.Exit(1)
}
}
示例3: runSpawn
func runSpawn(cmd *cobra.Command, args []string) {
var userdata []byte
var err error
var cluster platform.Cluster
if spawnUserData != "" {
userdata, err = ioutil.ReadFile(spawnUserData)
if err != nil {
die("Reading userdata failed: %v", err)
}
}
switch kolaPlatform {
case "qemu":
cluster, err = platform.NewQemuCluster(kola.QEMUOptions)
case "gce":
cluster, err = platform.NewGCECluster(kola.GCEOptions)
case "aws":
cluster, err = platform.NewAWSCluster(kola.AWSOptions)
default:
err = fmt.Errorf("invalid platform %q", kolaPlatform)
}
if err != nil {
die("Cluster failed: %v", err)
}
mach, err := cluster.NewMachine(string(userdata))
if err != nil {
die("Spawning instance failed: %v", err)
}
if spawnRemove {
defer mach.Destroy()
}
if spawnShell {
if err := platform.Manhole(mach); err != nil {
die("Manhole failed: %v", err)
}
}
}