本文整理汇总了Golang中github.com/docker/machine/libmachine/log.Infof函数的典型用法代码示例。如果您正苦于以下问题:Golang Infof函数的具体用法?Golang Infof怎么用?Golang Infof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Infof函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Create
func (d *Driver) Create() error {
client, err := d.getClient()
if err != nil {
return err
}
log.Infof("Creating SSH key...")
err = d.createSSHkey()
if err != nil {
return err
}
userdata, err := d.getCloudInit()
if err != nil {
return err
}
encoded := base64.StdEncoding.EncodeToString(userdata)
d.UserData = &encoded
log.Infof("Creating Brightbox Server...")
log.Debugf("with the following Userdata")
log.Debugf("%s", string(userdata))
log.Debugf("Brightbox API Call: Create Server using image %s", d.Image)
server, err := client.CreateServer(&d.ServerOptions)
if err != nil {
return err
}
d.MachineID = server.Id
return nil
}
开发者ID:brightbox,项目名称:docker-machine-driver-brightbox,代码行数:27,代码来源:driver.go
示例2: Remove
func (d *Driver) Remove() error {
s, err := d.GetState()
if err != nil {
if err == ErrMachineNotExist {
log.Infof("machine does not exist, assuming it has been removed already")
return nil
}
return err
}
if s == state.Running {
if err := d.Stop(); err != nil {
return err
}
}
if err := d.removeDiskImage(); err != nil {
return err
}
if d.NFSShare {
log.Infof("Remove NFS share folder must be root. Please insert root password.")
if _, err := nfsexports.Remove("", d.nfsExportIdentifier()); err != nil {
log.Errorf("failed removing nfs share: %s", err.Error())
}
if err := nfsexports.ReloadDaemon(); err != nil {
log.Errorf("failed reload nfs daemon: %s", err.Error())
}
}
return nil
}
开发者ID:johanneswuerbach,项目名称:docker-machine-xhyve,代码行数:31,代码来源:xhyve.go
示例3: SubmitPowerState
// Submit desired power state
func (pt *PowerTask) SubmitPowerState(s PowerState) {
if err := pt.GetCurrentPowerState(); err != nil {
pt.TaskIsDone = true
log.Errorf("Error getting current power state: %s", err)
return
}
if s != pt.State {
log.Infof("Powering %s server %s for %s.", s, pt.Blade.Name, pt.Blade.SerialNumber)
var (
body = PowerRequest{PowerState: s.String(), PowerControl: P_PRESSANDHOLD.String()}
uri = strings.Join([]string{pt.Blade.URI.String(),
"/powerState"}, "")
)
log.Debugf("REST : %s \n %+v\n", uri, body)
log.Debugf("pt -> %+v", pt)
data, err := pt.Blade.Client.RestAPICall(rest.PUT, uri, body)
if err != nil {
pt.TaskIsDone = true
log.Errorf("Error with power state request: %s", err)
return
}
log.Debugf("SubmitPowerState %s", data)
if err := json.Unmarshal([]byte(data), &pt); err != nil {
pt.TaskIsDone = true
log.Errorf("Error with power state un-marshal: %s", err)
return
}
} else {
log.Infof("Desired Power State already set -> %s", pt.State)
pt.TaskIsDone = true
}
return
}
开发者ID:wenlock,项目名称:oneview-golang,代码行数:36,代码来源:power_state.go
示例4: PowerExecutor
// Submit desired power state and wait
// Most of our concurrency will happen in PowerExecutor
func (pt *PowerTask) PowerExecutor(s PowerState) error {
currenttime := 0
pt.State = P_UKNOWN
pt.ResetTask()
go pt.SubmitPowerState(s)
for !pt.TaskIsDone && (currenttime < pt.Timeout) {
if err := pt.GetCurrentTaskStatus(); err != nil {
return err
}
if pt.URI != "" && T_COMPLETED.Equal(pt.TaskState) {
pt.TaskIsDone = true
}
if pt.URI != "" {
log.Debugf("Waiting to set power state %s for blade %s, %s", s, pt.Blade.Name)
log.Infof("Working on power state,%d%%, %s.", pt.ComputedPercentComplete, pt.TaskStatus)
} else {
log.Info("Working on power state.")
}
// wait time before next check
time.Sleep(time.Millisecond * (1000 * pt.WaitTime)) // wait 10sec before checking the status again
currenttime++
}
if !(currenttime < pt.Timeout) {
log.Warnf("Power %s state timed out for %s.", s, pt.Blade.Name)
}
log.Infof("Power Task Execution Completed")
return nil
}
开发者ID:wenlock,项目名称:oneview-golang,代码行数:31,代码来源:power_state.go
示例5: mountShareFolder
func (d *Driver) mountShareFolder(shareName string, mountPoint string) error {
// Check the host path is available
if _, err := os.Stat(mountPoint); err != nil {
if os.IsNotExist(err) {
log.Infof("Host path '%s' does not exist. Skipping mount to VM...", mountPoint)
return nil
}
return err
}
// Ensure that share is available on the guest side
checkCmd := "sudo modprobe prl_fs && grep -w " + shareName + " /proc/fs/prl_fs/sf_list"
if _, err := drivers.RunSSHCommandFromDriver(d, checkCmd); err != nil {
log.Infof("Shared folder '%s' is unavailable. Skipping mount to VM...", shareName)
return nil
}
// Mount shared folder
mountCmd := "sudo mkdir -p " + mountPoint + " && sudo mount -t prl_fs " + shareName + " " + mountPoint
if _, err := drivers.RunSSHCommandFromDriver(d, mountCmd); err != nil {
return fmt.Errorf("Error mounting shared folder: %s", err)
}
return nil
}
开发者ID:ianbytchek,项目名称:docker-machine-parallels,代码行数:25,代码来源:parallels.go
示例6: PreCreateCheck
// PreCreateCheck is called to enforce pre-creation steps
func (d *Driver) PreCreateCheck() error {
c, err := newComputeUtil(d)
if err != nil {
return err
}
// Check that the project exists. It will also check the credentials
// at the same time.
log.Infof("Check that the project exists")
if _, err = c.service.Projects.Get(d.Project).Do(); err != nil {
return fmt.Errorf("Project with ID %q not found. %v", d.Project, err)
}
// Check if the instance already exists. There will be an error if the instance
// doesn't exist, so just check instance for nil.
log.Infof("Check if the instance already exists")
instance, _ := c.instance()
if d.UseExisting {
if instance == nil {
return fmt.Errorf("Unable to find instance %q in zone %q.", d.MachineName, d.Zone)
}
} else {
if instance != nil {
return fmt.Errorf("Instance %q already exists in zone %q.", d.MachineName, d.Zone)
}
}
return nil
}
开发者ID:RaulKite,项目名称:machine,代码行数:32,代码来源:google.go
示例7: Remove
func (d *Driver) Remove() error {
client := d.getClient()
log.Debugf("removing %s", d.MachineName)
if err := client.DeleteServer(d.MachineID); err != nil {
if strings.Contains(err.Error(), "Invalid server") {
log.Infof("VPS doesn't exist, assuming it is already deleted")
} else {
return err
}
}
if err := client.DeleteSSHKey(d.SSHKeyID); err != nil {
if strings.Contains(err.Error(), "Invalid SSH Key") {
log.Infof("SSH key doesn't exist, assuming it is already deleted")
} else {
return err
}
}
if d.ScriptID != 0 && !d.HasCustomScript {
if err := client.DeleteStartupScript(strconv.Itoa(d.ScriptID)); err != nil {
if strings.Contains(err.Error(), "Check SCRIPTID") {
log.Infof("PXE boot script doesn't exist, assuming it is already deleted")
} else {
return err
}
}
}
return nil
}
开发者ID:mtrofimm,项目名称:docker-machine-vultr,代码行数:28,代码来源:vultr.go
示例8: Create
func (d *Driver) Create() error {
spec := d.buildHostSpec()
log.Infof("Creating SSH key...")
key, err := d.createSSHKey()
if err != nil {
return err
}
log.Infof("SSH key %s (%d) created in SoftLayer", key.Label, key.Id)
d.SSHKeyID = key.Id
spec.SshKeys = []*SSHKey{key}
id, err := d.getClient().VirtualGuest().Create(spec)
if err != nil {
return fmt.Errorf("Error creating host: %q", err)
}
d.Id = id
d.getIP()
d.waitForStart()
d.waitForSetupTransactions()
return nil
}
开发者ID:rogaha,项目名称:machine,代码行数:25,代码来源:driver.go
示例9: Stop
func (d *Driver) Stop() error {
currentState, err := d.GetState()
if err != nil {
return err
}
if currentState == state.Paused {
if err := d.vbm("controlvm", d.MachineName, "resume"); err != nil { // , "--type", "headless"
return err
}
log.Infof("Resuming VM ...")
}
if err := d.vbm("controlvm", d.MachineName, "acpipowerbutton"); err != nil {
return err
}
for {
s, err := d.GetState()
if err != nil {
return err
}
if s == state.Running {
time.Sleep(1 * time.Second)
} else {
break
}
}
log.Infof("Stopping VM...")
d.IPAddress = ""
return nil
}
开发者ID:usmanismail,项目名称:machine,代码行数:33,代码来源:virtualbox.go
示例10: CopyIsoToMachineDir
func (b *B2dUtils) CopyIsoToMachineDir(isoURL, machineName string) error {
// TODO: This is a bit off-color.
machineDir := filepath.Join(b.storePath, "machines", machineName)
machineIsoPath := filepath.Join(machineDir, b.isoFilename)
// just in case the cache dir has been manually deleted,
// check for it and recreate it if it's gone
if _, err := os.Stat(b.imgCachePath); os.IsNotExist(err) {
log.Infof("Image cache does not exist, creating it at %s...", b.imgCachePath)
if err := os.Mkdir(b.imgCachePath, 0700); err != nil {
return err
}
}
// By default just copy the existing "cached" iso to
// the machine's directory...
if isoURL == "" {
if err := b.copyDefaultIsoToMachine(machineIsoPath); err != nil {
return err
}
} else {
//if ISO is specified, check if it matches a github releases url or fallback
//to a direct download
if downloadUrl, err := b.GetLatestBoot2DockerReleaseURL(isoURL); err == nil {
log.Infof("Downloading %s from %s...", b.isoFilename, downloadUrl)
if err := b.DownloadISO(machineDir, b.isoFilename, downloadUrl); err != nil {
return err
}
} else {
return err
}
}
return nil
}
开发者ID:rhendric,项目名称:machine,代码行数:35,代码来源:b2d.go
示例11: Start
func (h *Host) Start() error {
log.Infof("Starting %q...", h.Name)
if err := h.runActionForState(h.Driver.Start, state.Running); err != nil {
return err
}
log.Infof("Machine %q was started.", h.Name)
return nil
}
开发者ID:sheltowt,项目名称:machine,代码行数:9,代码来源:host.go
示例12: Stop
func (h *Host) Stop() error {
log.Infof("Stopping %q...", h.Name)
if err := h.runActionForState(h.Driver.Stop, state.Stopped); err != nil {
return err
}
log.Infof("Machine %q was stopped.", h.Name)
return nil
}
开发者ID:sheltowt,项目名称:machine,代码行数:9,代码来源:host.go
示例13: Kill
func (h *Host) Kill() error {
log.Infof("Killing %q...", h.Name)
if err := h.runActionForState(h.Driver.Kill, state.Stopped); err != nil {
return err
}
log.Infof("Machine %q was killed.", h.Name)
return nil
}
开发者ID:sheltowt,项目名称:machine,代码行数:9,代码来源:host.go
示例14: Create
func (d *Driver) Create() error {
log.Infof("Creating SSH key...")
key, err := d.createSSHKey()
if err != nil {
return err
}
d.SSHKeyID = key.ID
log.Infof("Creating Digital Ocean droplet...")
client := d.getClient()
createRequest := &godo.DropletCreateRequest{
Image: d.Image,
Name: d.MachineName,
Region: d.Region,
Size: d.Size,
IPv6: d.IPv6,
PrivateNetworking: d.PrivateNetworking,
Backups: d.Backups,
SSHKeys: []interface{}{d.SSHKeyID},
}
newDroplet, _, err := client.Droplets.Create(createRequest)
if err != nil {
return err
}
d.DropletID = newDroplet.Droplet.ID
log.Info("Waiting for IP address to be assigned to the Droplet...")
for {
newDroplet, _, err = client.Droplets.Get(d.DropletID)
if err != nil {
return err
}
for _, network := range newDroplet.Droplet.Networks.V4 {
if network.Type == "public" {
d.IPAddress = network.IPAddress
}
}
if d.IPAddress != "" {
break
}
time.Sleep(1 * time.Second)
}
log.Debugf("Created droplet ID %d, IP address %s",
newDroplet.Droplet.ID,
d.IPAddress)
return nil
}
开发者ID:mschygulla,项目名称:machine,代码行数:57,代码来源:digitalocean.go
示例15: deleteDisk
// deleteDisk deletes the persistent disk.
func (c *ComputeUtil) deleteDisk() error {
log.Infof("Deleting disk.")
op, err := c.service.Disks.Delete(c.project, c.zone, c.diskName()).Do()
if err != nil {
return err
}
log.Infof("Waiting for disk to delete.")
return c.waitForRegionalOp(op.Name)
}
开发者ID:rowancarr,项目名称:machine,代码行数:10,代码来源:compute_util.go
示例16: PreCreateCheck
// PreCreateCheck allows for pre-create operations to make sure a driver is ready for creation
func (d *Driver) PreCreateCheck() error {
// Check platform type
if runtime.GOOS != "darwin" {
return fmt.Errorf("Driver \"parallels\" works only on OS X!")
}
// Check Parallels Desktop version
ver, err := getParallelsVersion()
if err != nil {
return err
}
if ver < 10 {
return fmt.Errorf("Driver \"parallels\" supports only Parallels Desktop 10 and higher. You use: Parallels Desktop %d.", ver)
}
if ver < 11 {
log.Debugf("Found Parallels Desktop version: %d", ver)
log.Infof("Driver \"parallels\" integration with Parallels Desktop 10 is maintained by open source community.")
log.Infof("For Parallels supported configuration you should use it with Parallels Desktop 11 or later (Pro or Business edition).")
return nil
}
// Check Parallels Desktop edition
edit, err := getParallelsEdition()
if err != nil {
return err
}
log.Debugf("Found Parallels Desktop version: %d, edition: %s", ver, edit)
switch edit {
case "pro", "business":
break
default:
return fmt.Errorf("Docker Machine can be used only with Parallels Desktop Pro or Business edition. You use: %s edition", edit)
}
// Check whether the host is connected to Shared network
ok, err := isSharedConnected()
if err != nil {
return err
}
if !ok {
return errSharedNotConnected
}
// Downloading boot2docker to cache should be done here to make sure
// that a download failure will not leave a machine half created.
b2dutils := mcnutils.NewB2dUtils(d.StorePath)
if err := b2dutils.UpdateISOCache(d.Boot2DockerURL); err != nil {
return err
}
return nil
}
开发者ID:Parallels,项目名称:docker-machine-parallels,代码行数:57,代码来源:parallels_darwin.go
示例17: Start
func (d *Driver) Start() error {
s, err := d.GetState()
if err != nil {
return err
}
if s == state.Stopped {
// check network to re-create if needed
if err := d.setupHostOnlyNetwork(d.MachineName); err != nil {
return fmt.Errorf("Error setting up host only network on machine start: %s", err)
}
}
switch s {
case state.Stopped, state.Saved:
d.SSHPort, err = setPortForwarding(d, 1, "ssh", "tcp", 22, d.SSHPort)
if err != nil {
return err
}
if err := d.vbm("startvm", d.MachineName, "--type", "headless"); err != nil {
return err
}
log.Infof("Starting VM...")
case state.Paused:
if err := d.vbm("controlvm", d.MachineName, "resume", "--type", "headless"); err != nil {
return err
}
log.Infof("Resuming VM ...")
default:
log.Infof("VM not in restartable state")
}
// Verify that VT-X is not disabled in the started VM
disabled, err := d.IsVTXDisabledInTheVM()
if err != nil {
return fmt.Errorf("Checking if hardware virtualization is enabled failed: %s", err)
}
if disabled {
return ErrMustEnableVTX
}
// Wait for SSH over NAT to be available before returning to user
if err := drivers.WaitForSSH(d); err != nil {
return err
}
// Bail if we don't get an IP from DHCP after a given number of seconds.
if err := mcnutils.WaitForSpecific(d.hostOnlyIPAvailable, 5, 4*time.Second); err != nil {
return err
}
d.IPAddress, err = d.GetIP()
return err
}
开发者ID:usmanismail,项目名称:machine,代码行数:56,代码来源:virtualbox.go
示例18: deleteInstance
// deleteInstance deletes the instance, leaving the persistent disk.
func (c *ComputeUtil) deleteInstance() error {
log.Infof("Deleting instance.")
op, err := c.service.Instances.Delete(c.project, c.zone, c.instanceName).Do()
if err != nil {
return err
}
log.Infof("Waiting for instance to delete.")
return c.waitForRegionalOp(op.Name)
}
开发者ID:bgokden,项目名称:machine,代码行数:11,代码来源:compute_util.go
示例19: Restart
func (d *Driver) Restart() error {
p, err := govcloudair.NewClient()
if err != nil {
return err
}
log.Infof("Connecting to vCloud Air...")
// Authenticate to vCloud Air
v, err := p.Authenticate(d.UserName, d.UserPassword, d.ComputeID, d.VDCID)
if err != nil {
return err
}
vapp, err := v.FindVAppByID(d.VAppID)
if err != nil {
return err
}
status, err := vapp.GetStatus()
if err != nil {
return err
}
if status == "POWERED_ON" {
// If it's powered on, restart the machine
log.Infof("Restarting %s...", d.MachineName)
task, err := vapp.Reset()
if err != nil {
return err
}
if err = task.WaitTaskCompletion(); err != nil {
return err
}
} else {
// If it's not powered on, start it.
log.Infof("Docker host %s is powered off, powering it back on...", d.MachineName)
task, err := vapp.PowerOn()
if err != nil {
return err
}
if err = task.WaitTaskCompletion(); err != nil {
return err
}
}
if err = p.Disconnect(); err != nil {
return err
}
d.IPAddress, err = d.GetIP()
return err
}
开发者ID:rominirani,项目名称:machine,代码行数:55,代码来源:vcloudair.go
示例20: Create
func (d *Driver) Create() error {
b2dutils := mcnutils.NewB2dUtils(d.StorePath)
if err := b2dutils.CopyIsoToMachineDir(d.Boot2DockerURL, d.MachineName); err != nil {
return err
}
log.Infof("Creating SSH key...")
if err := ssh.GenerateSSHKey(d.GetSSHKeyPath()); err != nil {
return err
}
log.Infof("Creating VM...")
virtualSwitch, err := d.chooseVirtualSwitch()
if err != nil {
return err
}
log.Infof("Using switch %q", virtualSwitch)
diskImage, err := d.generateDiskImage()
if err != nil {
return err
}
if err := cmd("New-VM",
d.MachineName,
"-Path", fmt.Sprintf("'%s'", d.ResolveStorePath(".")),
"-SwitchName", quote(virtualSwitch),
"-MemoryStartupBytes", toMb(d.MemSize)); err != nil {
return err
}
if d.CPU > 1 {
if err := cmd("Set-VMProcessor",
d.MachineName,
"-Count", fmt.Sprintf("%d", d.CPU)); err != nil {
return err
}
}
if err := cmd("Set-VMDvdDrive",
"-VMName", d.MachineName,
"-Path", quote(d.ResolveStorePath("boot2docker.iso"))); err != nil {
return err
}
if err := cmd("Add-VMHardDiskDrive",
"-VMName", d.MachineName,
"-Path", quote(diskImage)); err != nil {
return err
}
log.Infof("Starting VM...")
return d.Start()
}
开发者ID:sergey-stratoscale,项目名称:machine,代码行数:55,代码来源:hyperv.go
注:本文中的github.com/docker/machine/libmachine/log.Infof函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论