本文整理匯總了Golang中github.com/docker/machine/log.Debugf函數的典型用法代碼示例。如果您正苦於以下問題:Golang Debugf函數的具體用法?Golang Debugf怎麽用?Golang Debugf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Debugf函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Start
func (d *Driver) Start() error {
log.Infof("Starting %s...", d.MachineName)
vmrun("start", d.vmxPath(), "nogui")
// Do not execute the rest of boot2docker specific configuration, exit here
if d.ConfigDriveURL != "" {
log.Debugf("Leaving start sequence early, configdrive found")
return nil
}
log.Debugf("Mounting Shared Folders...")
var shareName, shareDir string // TODO configurable at some point
switch runtime.GOOS {
case "darwin":
shareName = "Users"
shareDir = "/Users"
// TODO "linux" and "windows"
}
if shareDir != "" {
if _, err := os.Stat(shareDir); err != nil && !os.IsNotExist(err) {
return err
} else if !os.IsNotExist(err) {
// create mountpoint and mount shared folder
vmrun("-gu", B2DUser, "-gp", B2DPass, "runScriptInGuest", d.vmxPath(), "/bin/sh", "sudo mkdir "+shareDir+" && sudo mount -t vmhgfs .host:/"+shareName+" "+shareDir)
}
}
return nil
}
示例2: executeSSHCommand
// execute command over SSH with user / password authentication
func executeSSHCommand(command string, d *Driver) error {
log.Debugf("Execute executeSSHCommand: %s", command)
config := &cryptossh.ClientConfig{
User: d.SSHUser,
Auth: []cryptossh.AuthMethod{
cryptossh.Password(d.SSHPassword),
},
}
client, err := cryptossh.Dial("tcp", fmt.Sprintf("%s:%d", d.IPAddress, d.SSHPort), config)
if err != nil {
log.Debugf("Failed to dial:", err)
return err
}
session, err := client.NewSession()
if err != nil {
log.Debugf("Failed to create session: " + err.Error())
return err
}
defer session.Close()
var b bytes.Buffer
session.Stdout = &b
if err := session.Run(command); err != nil {
log.Debugf("Failed to run: " + err.Error())
return err
}
log.Debugf("Stdout from executeSSHCommand: %s", b.String())
return nil
}
示例3: GetIP
func (d *Driver) GetIP() (string, error) {
s, err := d.GetState()
if err != nil {
return "", err
}
if s != state.Running {
return "", drivers.ErrHostIsNotRunning
}
c, err := NewClient("http://localhost:" + strconv.Itoa(d.APIPort))
if err != nil {
return "", err
}
var ip string
for i := 1; i <= 60; i++ {
vmip, err := c.GetVMIPAddress(d.MachineName)
if err != nil && vmip.Code != 200 {
log.Debugf("Not there yet %d/%d, error code: %d, message %s", i, 60, vmip.Code, err)
time.Sleep(2 * time.Second)
continue
}
ip = vmip.Message
log.Debugf("Got an ip: %s", ip)
break
}
if ip == "" {
return "", fmt.Errorf("machine didn't return an IP after 120 seconds, aborting")
}
return ip, nil
}
示例4: sshAvailableFunc
func sshAvailableFunc(d Driver) func() bool {
return func() bool {
log.Debug("Getting to WaitForSSH function...")
hostname, err := d.GetSSHHostname()
if err != nil {
log.Debugf("Error getting IP address waiting for SSH: %s", err)
return false
}
port, err := d.GetSSHPort()
if err != nil {
log.Debugf("Error getting SSH port: %s", err)
return false
}
if err := ssh.WaitForTCP(fmt.Sprintf("%s:%d", hostname, port)); err != nil {
log.Debugf("Error waiting for TCP waiting for SSH: %s", err)
return false
}
if _, err := RunSSHCommandFromDriver(d, "exit 0"); err != nil {
log.Debugf("Error getting ssh command 'exit 0' : %s", err)
return false
}
return true
}
}
示例5: mountSharedFolder
func (d *Driver) mountSharedFolder(shareDir, shareName string) error {
// create mountpoint and mount shared folder
addr, err := d.GetSSHHostname()
if err != nil {
return err
}
port, err := d.GetSSHPort()
if err != nil {
return err
}
auth := &ssh.Auth{
Keys: []string{d.GetSSHKeyPath()},
}
client, err := ssh.NewClient(d.GetSSHUsername(), addr, port, auth)
if err != nil {
return err
}
command := "[ ! -d " + shareDir + " ]&& sudo mkdir " + shareDir + "; sudo mount -t vmhgfs .host:/" + shareName + " " + shareDir
log.Debugf("About to run SSH command:\n%s", command)
output, err := client.Output(command)
log.Debugf("SSH cmd err, output: %v: %s", err, output)
return err
}
示例6: addDockerEndpoints
func (d *Driver) addDockerEndpoints(vmConfig *vmClient.Role) error {
configSets := vmConfig.ConfigurationSets.ConfigurationSet
if len(configSets) == 0 {
return errors.New("no configuration set")
}
for i := 0; i < len(configSets); i++ {
if configSets[i].ConfigurationSetType != "NetworkConfiguration" {
continue
}
ep := vmClient.InputEndpoint{
Name: "docker",
Protocol: "tcp",
Port: d.DockerPort,
LocalPort: d.DockerPort,
}
if d.SwarmMaster {
swarm_ep := vmClient.InputEndpoint{
Name: "docker swarm",
Protocol: "tcp",
Port: d.DockerSwarmMasterPort,
LocalPort: d.DockerSwarmMasterPort,
}
configSets[i].InputEndpoints.InputEndpoint = append(configSets[i].InputEndpoints.InputEndpoint, swarm_ep)
log.Debugf("added Docker swarm master endpoint (port %d) to configuration", d.DockerSwarmMasterPort)
}
configSets[i].InputEndpoints.InputEndpoint = append(configSets[i].InputEndpoints.InputEndpoint, ep)
log.Debugf("added Docker endpoint (port %d) to configuration", d.DockerPort)
}
return nil
}
示例7: waitForSetupTransactions
func (d *Driver) waitForSetupTransactions() {
log.Infof("Waiting for host setup transactions to complete")
// sometimes we'll hit a case where there's no active transaction, but if
// we check again in a few seconds, it moves to the next transaction. We
// don't want to get false-positives, so we check a few times in a row to make sure!
noActiveCount, maxNoActiveCount := 0, 3
for {
t, err := d.GetActiveTransaction()
if err != nil {
noActiveCount = 0
log.Debugf("Failed to GetActiveTransaction - %+v", err)
continue
}
if t == "" {
if noActiveCount == maxNoActiveCount {
break
}
noActiveCount++
} else {
noActiveCount = 0
log.Debugf("Still waiting - active transaction is %s...", t)
}
time.Sleep(2 * time.Second)
}
}
示例8: fixRoutingRules
// Fix the routing rules
func fixRoutingRules(sshClient ssh.Client) {
output, err := sshClient.Output("route del -net 172.16.0.0/12")
log.Debugf("Delete route command err, output: %v: %s", err, output)
output, err = sshClient.Output("if [ -e /etc/network/interfaces ]; then sed -i -r 's/^(up route add \\-net 172\\.16\\.0\\.0\\..*)$/#\\1/' /etc/network/interfaces; fi")
log.Debugf("Fix route in /etc/network/interfaces command err, output: %v: %s", err, output)
output, err = sshClient.Output("if [ -e /etc/sysconfig/network-scripts/route-eth0 ]; then sed -i -r 's/^(172\\.16\\.0\\.0\\..* dev eth0)$/#\\1/' /etc/sysconfig/network-scripts/route-eth0; fi")
log.Debugf("Fix route in /etc/sysconfig/network-scripts/route-eth0 command err, output: %v: %s", err, output)
}
示例9: execute
func execute(args []string) (string, error) {
cmd := exec.Command(powershell, args...)
log.Debugf("[executing ==>] : %v %v", powershell, strings.Join(args, " "))
var stdout bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err := cmd.Run()
log.Debugf("[stdout =====>] : %s", stdout.String())
log.Debugf("[stderr =====>] : %s", stderr.String())
return stdout.String(), err
}
示例10: RunSSHCommandFromDriver
func RunSSHCommandFromDriver(d Driver, command string) (string, error) {
client, err := GetSSHClientFromDriver(d)
if err != nil {
return "", err
}
log.Debugf("About to run SSH command:\n%s", command)
output, err := client.Output(command)
log.Debugf("SSH cmd err, output: %v: %s", err, output)
return output, err
}
示例11: hostOnlyIpAvailable
func (d *Driver) hostOnlyIpAvailable() bool {
ip, err := d.GetIP()
if err != nil {
log.Debugf("ERROR getting IP: %s", err)
return false
}
if ip != "" {
log.Debugf("IP is %s", ip)
return true
}
log.Debug("Strangely, there was no error attempting to get the IP, but it was still empty.")
return false
}
示例12: WaitUntilDeleted
func (fwp *FirewallPolicy) WaitUntilDeleted() error {
exists := true
var err error
for exists {
exists, err = fwp.exists()
if err != nil {
return err
}
log.Debugf("Wait for firewall policy: '%s' to be deleted", fwp.Id)
time.Sleep(5 * time.Second)
}
log.Debugf("The firewall policy: '%s' is now deleted", fwp.Id)
return nil
}
示例13: Remove
func (d *Driver) Remove() error {
if d.InstanceId == "" {
return fmt.Errorf("unknown instance")
}
s, err := d.GetState()
if err == nil && s == state.Running {
if err := d.Stop(); err != nil {
log.Errorf("unable to stop instance: %s", err)
}
}
instance, err := d.getInstance()
if err != nil {
log.Errorf("unable to describe instance: %s", err)
} else {
// Check and release EIP if exists
if len(instance.EipAddress.AllocationId) != 0 {
allocationId := instance.EipAddress.AllocationId
err = d.getClient().UnassociateEipAddress(allocationId, instance.InstanceId)
if err != nil {
log.Errorf("Failed to unassociate EIP address: %v", err)
}
err = d.getClient().WaitForEip(instance.RegionId, allocationId, ecs.EipStatusAvailable, 0)
if err != nil {
log.Errorf("Failed to wait EIP %s: %v", allocationId, err)
}
err = d.getClient().ReleaseEipAddress(allocationId)
if err != nil {
log.Errorf("Failed to release EIP address: %v", err)
}
}
log.Debugf("instance: %++v\n", instance)
log.Debugf("instance.VpcAttributes: %++v\n", instance.VpcAttributes)
vpcId := instance.VpcAttributes.VpcId
if vpcId != "" {
// Remove route entry firstly
d.removeRouteEntry(vpcId, instance.RegionId, instance.InstanceId)
}
}
log.Debugf("terminating instance: %s", d.InstanceId)
if err := d.getClient().DeleteInstance(d.InstanceId); err != nil {
return fmt.Errorf("unable to terminate instance: %s", err)
}
return nil
}
示例14: WaitUntilDeleted
func (server *Server) WaitUntilDeleted() error {
exists := true
var err error
for exists {
exists, err = server.exists()
if err != nil {
return err
}
log.Debugf("Wait for server: '%s' to be deleted", server.Id)
time.Sleep(5 * time.Second)
}
log.Debugf("The server: '%s' is now deleted", server.Id)
return nil
}
示例15: Restart
func (d *Driver) Restart() error {
if err := d.Stop(); err != nil {
return err
}
// Check for 120 seconds for the machine to stop
for i := 1; i <= 60; i++ {
machineState, err := d.GetState()
if err != nil {
return err
}
if machineState == state.Running {
log.Debugf("Not there yet %d/%d", i, 60)
time.Sleep(2 * time.Second)
continue
}
if machineState == state.Stopped {
break
}
}
machineState, err := d.GetState()
// If the VM is still running after 120 seconds just kill it.
if machineState == state.Running {
if err = d.Kill(); err != nil {
return fmt.Errorf("can't stop VM: %s", err)
}
}
return d.Start()
}