本文整理汇总了Golang中github.com/docker/machine/libmachine/log.Info函数的典型用法代码示例。如果您正苦于以下问题:Golang Info函数的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UpdateISOCache
func (b *B2dUtils) UpdateISOCache(isoURL string) error {
// recreate the cache dir if it has been manually deleted
if _, err := os.Stat(b.imgCachePath); os.IsNotExist(err) {
log.Infof("Image cache directory does not exist, creating it at %s...", b.imgCachePath)
if err := os.Mkdir(b.imgCachePath, 0700); err != nil {
return err
}
}
exists := b.exists()
if isoURL != "" {
if exists {
// Warn that the b2d iso won't be updated if isoURL is set
log.Warnf("Boot2Docker URL was explicitly set to %q at create time, so Docker Machine cannot upgrade this machine to the latest version.", isoURL)
}
// Non-default B2D are not cached
return nil
}
if !exists {
log.Info("No default Boot2Docker ISO found locally, downloading the latest release...")
return b.DownloadLatestBoot2Docker("")
}
latest := b.isLatest()
if !latest {
log.Info("Default Boot2Docker ISO is out-of-date, downloading the latest release...")
return b.DownloadLatestBoot2Docker("")
}
return nil
}
示例2: Start
// Start a host
func (d *Driver) Start() error {
vmstate, err := d.GetState()
if err != nil {
return err
}
if vmstate == state.Running {
log.Info("Machine is already running")
return nil
}
if vmstate == state.Starting {
log.Info("Machine is already starting")
return nil
}
cs := d.getClient()
p := cs.VirtualMachine.NewStartVirtualMachineParams(d.Id)
if _, err = cs.VirtualMachine.StartVirtualMachine(p); err != nil {
return err
}
return nil
}
示例3: CreateVirtualNetworkIfNotExists
func (a AzureClient) CreateVirtualNetworkIfNotExists(resourceGroup, name, location string) error {
f := logutil.Fields{
"name": name,
"location": location}
log.Info("Querying if virtual network already exists.", f)
if exists, err := a.virtualNetworkExists(resourceGroup, name); err != nil {
return err
} else if exists {
log.Info("Virtual network already exists.", f)
return nil
}
log.Debug("Creating virtual network.", f)
_, err := a.virtualNetworksClient().CreateOrUpdate(resourceGroup, name,
network.VirtualNetwork{
Location: to.StringPtr(location),
Properties: &network.VirtualNetworkPropertiesFormat{
AddressSpace: &network.AddressSpace{
AddressPrefixes: to.StringSlicePtr(defaultVnetAddressPrefixes),
},
},
}, nil)
return err
}
示例4: DetectProvisioner
func (detector StandardDetector) DetectProvisioner(d drivers.Driver) (Provisioner, error) {
log.Info("Waiting for SSH to be available...")
if err := drivers.WaitForSSH(d); err != nil {
return nil, err
}
log.Info("Detecting the provisioner...")
osReleaseOut, err := drivers.RunSSHCommandFromDriver(d, "cat /etc/os-release")
if err != nil {
return nil, fmt.Errorf("Error getting SSH command: %s", err)
}
osReleaseInfo, err := NewOsRelease([]byte(osReleaseOut))
if err != nil {
return nil, fmt.Errorf("Error parsing /etc/os-release file: %s", err)
}
for _, p := range provisioners {
provisioner := p.New(d)
provisioner.SetOsReleaseInfo(osReleaseInfo)
if provisioner.CompatibleWithHost() {
log.Debugf("found compatible host: %s", osReleaseInfo.ID)
return provisioner, nil
}
}
return nil, ErrDetectionFailed
}
示例5: Create
// Create is the wrapper method which covers all of the boilerplate around
// actually creating, provisioning, and persisting an instance in the store.
func (api *Client) Create(h *host.Host) error {
if err := cert.BootstrapCertificates(h.HostOptions.AuthOptions); err != nil {
return fmt.Errorf("Error generating certificates: %s", err)
}
log.Info("Running pre-create checks...")
if err := h.Driver.PreCreateCheck(); err != nil {
return fmt.Errorf("Error with pre-create check: %s", err)
}
if err := api.Save(h); err != nil {
return fmt.Errorf("Error saving host to store before attempting creation: %s", err)
}
log.Info("Creating machine...")
if err := api.performCreate(h); err != nil {
sendCrashReport(err, api, h)
return err
}
log.Debug("Reticulating splines...")
return nil
}
示例6: Upgrade
func (h *Host) Upgrade() error {
machineState, err := h.Driver.GetState()
if err != nil {
return err
}
if machineState != state.Running {
return errMachineMustBeRunningForUpgrade
}
provisioner, err := provision.DetectProvisioner(h.Driver)
if err != nil {
return crashreport.CrashError{
Cause: err,
Command: "Upgrade",
Context: "provision.DetectProvisioner",
DriverName: h.Driver.DriverName(),
}
}
log.Info("Upgrading docker...")
if err := provisioner.Package("docker", pkgaction.Upgrade); err != nil {
return crashreport.CrashError{
Cause: err,
Command: "Upgrade",
Context: "provisioner.Package",
DriverName: h.Driver.DriverName(),
}
}
log.Info("Restarting docker...")
return provisioner.Service("docker", serviceaction.Restart)
}
示例7: UpdateISOCache
func (b *B2dUtils) UpdateISOCache(isoURL string) error {
// recreate the cache dir if it has been manually deleted
if _, err := os.Stat(b.imgCachePath); os.IsNotExist(err) {
log.Infof("Image cache directory does not exist, creating it at %s...", b.imgCachePath)
if err := os.Mkdir(b.imgCachePath, 0700); err != nil {
return err
}
}
if isoURL != "" {
// Non-default B2D are not cached
return nil
}
exists := b.exists()
if !exists {
log.Info("No default Boot2Docker ISO found locally, downloading the latest release...")
return b.DownloadLatestBoot2Docker("")
}
latest := b.isLatest()
if !latest {
log.Info("Default Boot2Docker ISO is out-of-date, downloading the latest release...")
return b.DownloadLatestBoot2Docker("")
}
return nil
}
示例8: Create
// Create is the wrapper method which covers all of the boilerplate around
// actually creating, provisioning, and persisting an instance in the store.
func (api *Client) Create(h *host.Host) error {
if err := cert.BootstrapCertificates(h.AuthOptions()); err != nil {
return fmt.Errorf("Error generating certificates: %s", err)
}
log.Info("Running pre-create checks...")
if err := h.Driver.PreCreateCheck(); err != nil {
return mcnerror.ErrDuringPreCreate{
Cause: err,
}
}
if err := api.Save(h); err != nil {
return fmt.Errorf("Error saving host to store before attempting creation: %s", err)
}
log.Info("Creating machine...")
if err := api.performCreate(h); err != nil {
return fmt.Errorf("Error creating machine: %s", err)
}
log.Debug("Reticulating splines...")
return nil
}
示例9: upgradeIso
func (provisioner *Boot2DockerProvisioner) upgradeIso() error {
// TODO: Ideally, we should not read from mcndirs directory at all.
// The driver should be able to communicate how and where to place the
// relevant files.
b2dutils := mcnutils.NewB2dUtils(mcndirs.GetBaseDir())
// Check if the driver has specified a custom b2d url
jsonDriver, err := json.Marshal(provisioner.GetDriver())
if err != nil {
return err
}
var d struct {
Boot2DockerURL string
}
json.Unmarshal(jsonDriver, &d)
log.Info("Downloading latest boot2docker iso...")
// Usually we call this implicitly, but call it here explicitly to get
// the latest default boot2docker ISO.
if d.Boot2DockerURL == "" {
if err := b2dutils.DownloadLatestBoot2Docker(d.Boot2DockerURL); err != nil {
return err
}
}
log.Info("Stopping machine to do the upgrade...")
if err := provisioner.Driver.Stop(); err != nil {
return err
}
if err := mcnutils.WaitFor(drivers.MachineInState(provisioner.Driver, state.Stopped)); err != nil {
return err
}
machineName := provisioner.GetDriver().GetMachineName()
log.Infof("Upgrading machine %q...", machineName)
// Either download the latest version of the b2d url that was explicitly
// specified when creating the VM or copy the (updated) default ISO
if err := b2dutils.CopyIsoToMachineDir(d.Boot2DockerURL, machineName); err != nil {
return err
}
log.Infof("Starting machine back up...")
if err := provisioner.Driver.Start(); err != nil {
return err
}
return mcnutils.WaitFor(drivers.MachineInState(provisioner.Driver, state.Running))
}
示例10: Create
// Create is the wrapper method which covers all of the boilerplate around
// actually creating, provisioning, and persisting an instance in the store.
func (api *Client) Create(h *host.Host) error {
if err := cert.BootstrapCertificates(h.HostOptions.AuthOptions); err != nil {
return fmt.Errorf("Error generating certificates: %s", err)
}
log.Info("Running pre-create checks...")
if err := h.Driver.PreCreateCheck(); err != nil {
return fmt.Errorf("Error with pre-create check: %s", err)
}
if err := api.Save(h); err != nil {
return fmt.Errorf("Error saving host to store before attempting creation: %s", err)
}
log.Info("Creating machine...")
if err := h.Driver.Create(); err != nil {
return fmt.Errorf("Error in driver during machine creation: %s", err)
}
if err := api.Save(h); err != nil {
return fmt.Errorf("Error saving host to store after attempting creation: %s", err)
}
// TODO: Not really a fan of just checking "none" here.
if h.Driver.DriverName() != "none" {
log.Info("Waiting for machine to be running, this may take a few minutes...")
if err := mcnutils.WaitFor(drivers.MachineInState(h.Driver, state.Running)); err != nil {
return fmt.Errorf("Error waiting for machine to be running: %s", err)
}
log.Info("Machine is running, waiting for SSH to be available...")
if err := drivers.WaitForSSH(h.Driver); err != nil {
return fmt.Errorf("Error waiting for SSH: %s", err)
}
log.Info("Detecting operating system of created instance...")
provisioner, err := provision.DetectProvisioner(h.Driver)
if err != nil {
return fmt.Errorf("Error detecting OS: %s", err)
}
log.Infof("Provisioning with %s...", provisioner.String())
if err := provisioner.Provision(*h.HostOptions.SwarmOptions, *h.HostOptions.AuthOptions, *h.HostOptions.EngineOptions); err != nil {
return fmt.Errorf("Error running provisioning: %s", err)
}
}
log.Debug("Reticulating splines...")
return nil
}
示例11: TestPreApplyDeploymentJobs
// TestPreApplyDeploymentJobs - setup some information from icsp
//TODO: This test requires a server profile to have been created
func TestPreApplyDeploymentJobs(t *testing.T) {
var (
d *ICSPTest
c *icsp.ICSPClient
serialNumber, macAddr string
)
if os.Getenv("ICSP_TEST_ACCEPTANCE") == "true" {
log.Debug("implements acceptance test for ApplyDeploymentJobs")
d, c = getTestDriverA()
if c == nil {
t.Fatalf("Failed to execute getTestDriver() ")
}
if os.Getenv("ONEVIEW_TEST_PROVISION") != "true" {
log.Info("env ONEVIEW_TEST_PROVISION != true")
log.Info("Skipping FreeBlade testing")
serialNumber = d.Tc.GetTestData(d.Env, "SerialNumber").(string)
macAddr = d.Tc.GetTestData(d.Env, "MacAddr").(string)
} else {
// serialNumber := d.Tc.GetTestData(d.Env, "FreeBladeSerialNumber").(string)
serialNumber = d.Tc.GetTestData(d.Env, "FreeICSPSerialNumber").(string)
macAddr = d.Tc.GetTestData(d.Env, "FreeMacAddr").(string)
}
s, err := c.GetServerBySerialNumber(serialNumber)
assert.NoError(t, err, "GetServerBySerialNumber threw error -> %s, %+v\n", err, s)
pubinet, err := s.GetInterface(1)
assert.NoError(t, err, "GetInterface(1) threw error -> %s, %+v\n", err, s)
assert.Equal(t, macAddr, pubinet.MACAddr, fmt.Sprintf("should get a valid interface -> %+v", pubinet))
s, err = c.PreApplyDeploymentJobs(s, pubinet) // responsible for configuring the Pulbic IP CustomAttributes
assert.NoError(t, err, "ApplyDeploymentJobs threw error -> %+v, %+v", err, s)
s, err = s.ReloadFull(c)
assert.NoError(t, err, "ReloadFull threw error -> %+v, %+v", err, s)
// verify that the server attribute was saved by getting the server again and checking the value
_, testValue2 := s.GetValueItem("public_interface", "server")
// unmarshal the custom attribute
var inet *icsp.Interface
log.Debugf("public_interface value -> %+v", testValue2.Value)
assert.NotEqual(t, "", testValue2.Value,
fmt.Sprintf("public_interface for %s Should have a value", serialNumber))
if testValue2.Value != "" {
err = json.Unmarshal([]byte(testValue2.Value), &inet)
assert.NoError(t, err, "Unmarshal Interface threw error -> %s, %+v\n", err, testValue2.Value)
log.Infof("We got public ip addr -> %s", inet.MACAddr)
assert.Equal(t, macAddr, inet.MACAddr, "Should return the saved custom attribute for mac address")
}
}
}
示例12: Stop
// Stop issues a power off for the virtual machine instance.
func (d *Driver) Stop() error {
if err := d.checkLegacyDriver(true); err != nil {
return err
}
c, err := d.newAzureClient()
if err != nil {
return err
}
log.Info("NOTICE: Stopping an Azure Virtual Machine is just going to power it off, not deallocate.")
log.Info("NOTICE: You should remove the machine if you would like to avoid unexpected costs.")
return c.StopVirtualMachine(d.ResourceGroup, d.naming().VM())
}
示例13: deleteResourceIfExists
// deleteResourceIfExists is an utility method to determine if a resource exists
// from the error returned from its Get response. If so, deletes it. name is
// used only for logging purposes.
func deleteResourceIfExists(resourceType, name string, getFunc func() error, deleteFunc func() (autorest.Response, error)) error {
f := logutil.Fields{"name": name}
log.Debug(fmt.Sprintf("Querying if %s exists.", resourceType), f)
if exists, err := checkResourceExistsFromError(getFunc()); err != nil {
return err
} else if !exists {
log.Info(fmt.Sprintf("%s does not exist. Skipping.", resourceType), f)
return nil
}
log.Info(fmt.Sprintf("Removing %s resource.", resourceType), f)
_, err := deleteFunc()
return err
}
示例14: CreateAvailabilitySetIfNotExists
func (a AzureClient) CreateAvailabilitySetIfNotExists(ctx *DeploymentContext, resourceGroup, name, location string) error {
f := logutil.Fields{"name": name}
if ctx.AvailabilitySetID != "" {
log.Info("Availability Set already exists.", f)
return nil
}
log.Debug("Could not find existing availability set.", f)
log.Info("Creating availability set...", f)
as, err := a.availabilitySetsClient().CreateOrUpdate(resourceGroup, name,
compute.AvailabilitySet{
Location: to.StringPtr(location),
})
ctx.AvailabilitySetID = to.String(as.ID)
return err
}
示例15: checkImage
func (d *Driver) checkImage() error {
client, err := d.getClient()
if err != nil {
return err
}
var image *brightbox.Image
if d.Image == "" {
log.Info("No image specified. Looking for default image")
log.Debugf("Brightbox API Call: List of Images")
images, err := client.Images()
if err != nil {
return err
}
image, err = GetDefaultImage(images)
if err != nil {
return err
}
d.Image = image.Id
} else {
log.Debugf("Brightbox API Call: Image Details for %s", d.Image)
image, err = client.Image(d.Image)
if err != nil {
return err
}
}
if image.Arch != "x86_64" {
return fmt.Errorf("Docker requires a 64 bit image. Image %s not suitable", d.Image)
}
if d.SSHUser == "" {
log.Debug("Setting SSH Username from image details")
d.SSHUser = image.Username
}
log.Debugf("Image %s selected. SSH user is %s", d.Image, d.SSHUser)
return nil
}