本文整理匯總了Golang中github.com/docker/machine/log.Info函數的典型用法代碼示例。如果您正苦於以下問題:Golang Info函數的具體用法?Golang Info怎麽用?Golang Info使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Info函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CreateInstance
func (c *GenericClient) CreateInstance(d *Driver) (string, error) {
serverOpts := servers.CreateOpts{
Name: d.MachineName,
FlavorRef: d.FlavorId,
ImageRef: d.ImageId,
SecurityGroups: d.SecurityGroups,
AvailabilityZone: d.AvailabilityZone,
}
if d.NetworkId != "" {
serverOpts.Networks = []servers.Network{
{
UUID: d.NetworkId,
},
}
}
log.Info("Creating machine...")
server, err := servers.Create(c.Compute, keypairs.CreateOptsExt{
serverOpts,
d.KeyPairName,
}).Extract()
if err != nil {
return "", err
}
return server.ID, nil
}
示例2: Create
func (d *Driver) Create() error {
if err := d.setUserSubscription(); err != nil {
return err
}
log.Info("Creating Azure machine...")
vmConfig, err := vmClient.CreateAzureVMConfiguration(d.MachineName, d.Size, d.Image, d.Location)
if err != nil {
return err
}
log.Debug("Generating certificate for Azure...")
if err := d.generateCertForAzure(); err != nil {
return err
}
log.Debug("Adding Linux provisioning...")
vmConfig, err = vmClient.AddAzureLinuxProvisioningConfig(vmConfig, d.GetSSHUsername(), d.UserPassword, d.azureCertPath(), d.SSHPort)
if err != nil {
return err
}
log.Debug("Authorizing ports...")
if err := d.addDockerEndpoints(vmConfig); err != nil {
return err
}
log.Debug("Creating VM...")
if err := vmClient.CreateAzureVM(vmConfig, d.MachineName, d.Location); err != nil {
return err
}
return nil
}
示例3: Restart
func (d *Driver) Restart() error {
log.Info("Restarting...")
_, err := d.getClient().Instance.RebootInstance(map[string]string{
"InstanceId": d.InstanceId,
})
return err
}
示例4: Stop
func (d *Driver) Stop() error {
log.Info("Stopping...")
_, err := d.getClient().Instance.StopInstance(map[string]string{
"InstanceId": d.InstanceId,
})
return err
}
示例5: cmdStatus
func cmdStatus(c *cli.Context) {
host := getHost(c)
currentState, err := host.Driver.GetState()
if err != nil {
log.Errorf("error getting state for host %s: %s", host.Name, err)
}
log.Info(currentState)
}
示例6: Kill
func (d *Driver) Kill() error {
log.Info("Killing...")
_, err := d.getClient().Instance.StopInstance(map[string]string{
"InstanceId": d.InstanceId,
"ForceStop": "true",
})
return err
}
示例7: upgradeIso
func (provisioner *Boot2DockerProvisioner) upgradeIso() error {
log.Info("Stopping machine to do the upgrade...")
if err := provisioner.Driver.Stop(); err != nil {
return err
}
if err := utils.WaitFor(drivers.MachineInState(provisioner.Driver, state.Stopped)); err != nil {
return err
}
machineName := provisioner.GetDriver().GetMachineName()
log.Infof("Upgrading machine %s...", machineName)
isoFilename := ""
switch provisioner.GetDriver().DriverName() {
case "virtualbox":
isoFilename = "boot2docker-virtualbox.iso"
case "vmwarefusion", "vmwarevsphere", "vmwareworkstation":
isoFilename = "boot2docker-vmware.iso"
case "hyper-v":
isoFilename = "boot2docker-hyperv.iso"
default:
return ErrUnknownDriver
}
b2dutils := utils.NewB2dUtils("", "", isoFilename)
// Usually we call this implicitly, but call it here explicitly to get
// the latest boot2docker ISO.
if err := b2dutils.DownloadLatestBoot2Docker(); err != nil {
return err
}
// Copy the latest version of boot2docker ISO to the machine's directory
if err := b2dutils.CopyIsoToMachineDir("", machineName); err != nil {
return err
}
if err := provisioner.Driver.Start(); err != nil {
return err
}
return utils.WaitFor(drivers.MachineInState(provisioner.Driver, state.Running))
}
示例8: copyDefaultIsoToMachine
func (b *B2dUtils) copyDefaultIsoToMachine(machineIsoPath string) error {
if _, err := os.Stat(b.commonIsoPath); os.IsNotExist(err) {
log.Info("No default boot2docker iso found locally, downloading the latest release...")
if err := b.DownloadLatestBoot2Docker(); err != nil {
return err
}
}
if err := CopyFile(b.commonIsoPath, machineIsoPath); err != nil {
return err
}
return nil
}
示例9: createSSHKey
func (d *Driver) createSSHKey() error {
log.Info("Creating SSH Key Pair...")
if err := ssh.GenerateSSHKey(d.GetSSHKeyPath()); err != nil {
return err
}
publicKey, err := ioutil.ReadFile(d.publicSSHKeyPath())
if err != nil {
return err
}
d.PublicKey = publicKey[0 : len(publicKey)-1]
log.Debugf("------------%s\n")
log.Debug(string(publicKey))
return nil
}
示例10: tokenFromWeb
func tokenFromWeb(config *oauth.Config) *oauth.Token {
randState := fmt.Sprintf("st%d", time.Now().UnixNano())
config.RedirectURL = RedirectURI
authURL := config.AuthCodeURL(randState)
log.Info("Opening auth URL in browser.")
log.Info(authURL)
log.Info("If the URL doesn't open please open it manually and copy the code here.")
openURL(authURL)
code := getCodeFromStdin()
log.Infof("Got code: %s", code)
t := &oauth.Transport{
Config: config,
Transport: http.DefaultTransport,
}
_, err := t.Exchange(code)
if err != nil {
log.Fatalf("Token exchange error: %v", err)
}
return t.Token
}
示例11: Remove
func (d *Driver) Remove() error {
log.WithField("MachineId", d.MachineId).Debug("deleting instance...")
log.Info("Deleting OpenStack instance...")
if err := d.initCompute(); err != nil {
return err
}
if err := d.client.DeleteInstance(d); err != nil {
return err
}
log.WithField("Name", d.KeyPairName).Debug("deleting key pair...")
if err := d.client.DeleteKeyPair(d, d.KeyPairName); err != nil {
return err
}
return nil
}
示例12: upgradeIso
func (provisioner *RancherProvisioner) upgradeIso() error {
// Largely copied from Boot2Docker provisioner, we should find a way to share this code
log.Info("Stopping machine to do the upgrade...")
if err := provisioner.Driver.Stop(); err != nil {
return err
}
if err := utils.WaitFor(drivers.MachineInState(provisioner.Driver, state.Stopped)); err != nil {
return err
}
machineName := provisioner.GetDriver().GetMachineName()
log.Infof("Upgrading machine %s...", machineName)
b2dutils := utils.NewB2dUtils("", "", isoFilename)
url, err := provisioner.getLatestISOURL()
if err != nil {
return err
}
if err := b2dutils.DownloadISOFromURL(url); err != nil {
return err
}
// Copy the latest version of boot2docker ISO to the machine's directory
if err := b2dutils.CopyIsoToMachineDir("", machineName); err != nil {
return err
}
log.Infof("Starting machine back up...")
if err := provisioner.Driver.Start(); err != nil {
return err
}
return utils.WaitFor(drivers.MachineInState(provisioner.Driver, state.Running))
}
示例13: upgradeIso
func (provisioner *Boot2DockerProvisioner) upgradeIso() error {
log.Info("Stopping machine to do the upgrade...")
if err := provisioner.Driver.Stop(); err != nil {
return err
}
if err := utils.WaitFor(drivers.MachineInState(provisioner.Driver, state.Stopped)); err != nil {
return err
}
machineName := provisioner.GetDriver().GetMachineName()
log.Infof("Upgrading machine %s...", machineName)
b2dutils := utils.NewB2dUtils("", "")
// Usually we call this implicitly, but call it here explicitly to get
// the latest boot2docker ISO.
if err := b2dutils.DownloadLatestBoot2Docker(); err != nil {
return err
}
// Copy the latest version of boot2docker ISO to the machine's directory
if err := b2dutils.CopyIsoToMachineDir("", machineName); err != nil {
return err
}
log.Infof("Starting machine back up...")
if err := provisioner.Driver.Start(); err != nil {
return err
}
return utils.WaitFor(drivers.MachineInState(provisioner.Driver, state.Running))
}
示例14: Remove
func (d *Driver) Remove() error {
log.Info("Deleting...")
if d.InstanceId == "" {
// Instance id is empty due to some errors while creating,
log.Warn("InstanceId is empty, assuming it has already bean removed from aliyun.")
return nil
}
// If instance is running, kill it
if st, _ := d.GetState(); st == state.Running {
err := d.Kill()
if err != nil {
return err
}
}
// Wait for instance to stop
utils.WaitForSpecific(d.waitToStopInstance, 10, 6*time.Second)
_, err := d.getClient().Instance.DeleteInstance(map[string]string{
"InstanceId": d.InstanceId,
})
return err
}
示例15: Create
func (d *Driver) Create() error {
if err := d.checkPrereqs(); err != nil {
return err
}
log.Infof("Launching instance...")
if err := d.createKeyPair(); err != nil {
return fmt.Errorf("unable to create key pair: %s", err)
}
if err := d.configureSecurityGroup(d.SecurityGroupName); err != nil {
return err
}
bdm := &amz.BlockDeviceMapping{
DeviceName: "/dev/sda1",
VolumeSize: d.RootSize,
DeleteOnTermination: true,
VolumeType: "gp2",
}
log.Debugf("launching instance in subnet %s", d.SubnetId)
var instance amz.EC2Instance
if d.RequestSpotInstance {
spotInstanceRequestId, err := d.getClient().RequestSpotInstances(d.AMI, d.InstanceType, d.Zone, 1, d.SecurityGroupId, d.KeyName, d.SubnetId, bdm, d.IamInstanceProfile, d.SpotPrice, d.Monitoring)
if err != nil {
return fmt.Errorf("Error request spot instance: %s", err)
}
var instanceId string
var spotInstanceRequestStatus string
log.Info("Waiting for spot instance...")
// check until fulfilled
for instanceId == "" {
time.Sleep(time.Second * 5)
spotInstanceRequestStatus, instanceId, err = d.getClient().DescribeSpotInstanceRequests(spotInstanceRequestId)
if err != nil {
return fmt.Errorf("Error describe spot instance request: %s", err)
}
log.Debugf("spot instance request status: %s", spotInstanceRequestStatus)
}
instance, err = d.getClient().GetInstance(instanceId)
if err != nil {
return fmt.Errorf("Error get instance: %s", err)
}
} else {
inst, err := d.getClient().RunInstance(d.AMI, d.InstanceType, d.Zone, 1, 1, d.SecurityGroupId, d.KeyName, d.SubnetId, bdm, d.IamInstanceProfile, d.PrivateIPOnly, d.Monitoring)
if err != nil {
return fmt.Errorf("Error launching instance: %s", err)
}
instance = inst
}
d.InstanceId = instance.InstanceId
log.Debug("waiting for ip address to become available")
if err := utils.WaitFor(d.instanceIpAvailable); err != nil {
return err
}
if len(instance.NetworkInterfaceSet) > 0 {
d.PrivateIPAddress = instance.NetworkInterfaceSet[0].PrivateIpAddress
}
d.waitForInstance()
log.Debugf("created instance ID %s, IP address %s, Private IP address %s",
d.InstanceId,
d.IPAddress,
d.PrivateIPAddress,
)
log.Debug("Settings tags for instance")
tags := map[string]string{
"Name": d.MachineName,
}
if err := d.getClient().CreateTags(d.InstanceId, tags); err != nil {
return err
}
return nil
}