id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c165000
return hyperv.GetVirtualMachineNetworkAdapterAddress(vmName) }
c165001
string, vlanId string) error { return hyperv.SetNetworkAdapterVlanId(switchName, vlanId) }
c165002
return hyperv.SetVirtualMachineVlanId(vmName, vlanId) }
c165003
hyperv.ConnectVirtualMachine(vmName) }
c165004
packer.Ui) multistep.Runner { runner, _ := newRunner(steps, config, ui) return runner }
c165005
multistep.Runner { runner, pauseFn := newRunner(steps, config, ui) if pauseFn != nil { state.Put("pauseFn", pauseFn) } return runner }
c165006
msg := aws.StringValue(result.DecodedMessage) return fmt.Errorf("%s Authorization failure message: '%s'%s", groups[1], msg, groups[3]) } log.Printf("[WARN] Attempted to decode authorization message, but received: %v", decodeErr) } return err }
c165007
Decoder: sts.New(sess), } sess.Handlers.UnmarshalError.AfterEachFn = azd.afterEachFn }
c165008
signer, err := c.createSSHAgentSigner() if err != nil { errs = append(errs, err) } c.signer = signer } else { signer, err := c.createPrivateKeySigner() if err != nil { errs = append(errs, err) } c.signer = signer } if len(errs) > 0 { return errs } return nil }
c165009
value=%s due to incorrect long value format, "+ "or entity does not exist", a.template.Id)) { return nil } return fmt.Errorf("Error destroying template %s: %s", a.template.Name, err) } return nil }
c165010
ui.Message(fmt.Sprintf("Internal IP: %s", ip)) } } ui.Message(fmt.Sprintf("IP: %s", ip)) state.Put("instance_ip", ip) return multistep.ActionContinue } else { ip, err := driver.GetNatIP(config.Zone, instanceName) if err != nil { err := fmt.Errorf("Error retrieving instance nat ip address: %s", e...
c165011
} done := status == StartupScriptStatusDone if !done { ui.Say("Startup script not finished yet. Waiting...") return errors.New("Startup script not done.") } return nil }) if err != nil { err := fmt.Errorf("Error waiting for startup script to finish: %s", err) state.Put("error", err) ui.Error(e...
c165012
interpolatedCmd, err := interpolate.Render(cmd, &config.Ctx) if err != nil { return nil, fmt.Errorf("Error processing command: %s", err) } interpolatedCmds[i] = interpolatedCmd } return interpolatedCmds, nil }
c165013
err := d.vagrantCmd(append([]string{"init"}, args...)...) return err }
c165014
err := d.vagrantCmd(append([]string{"up"}, args...)...) return stdout, stderr, err }
c165015
= append(args, id) } _, _, err := d.vagrantCmd(args...) return err }
c165016
filepath.Join(d.VagrantCWD, "package.box")) _, _, err := d.vagrantCmd(append([]string{"package"}, args...)...) return err }
c165017
err := version.NewVersion(vers) if err != nil { return fmt.Errorf("Error figuring out Vagrant version.") } if !constraints.Check(v) { return fmt.Errorf("installed Vagrant version must be >=2.0.2") } return nil }
c165018
Use regex to find version reg := regexp.MustCompile(`(\d+\.)?(\d+\.)?(\*|\d+)`) version := reg.FindString(stdoutString) if version == "" { return "", err } return version, nil }
c165019
case <-done: // We finished, so just exit the goroutine return default: // Keep going } } }() log.Printf("[DEBUG] Waiting for up to %d seconds for droplet to unlock", timeout/time.Second) select { case err := <-result: return err case <-time.After(timeout): return fmt.Errorf( "Timeou...
c165020
escapedString = strings.Replace(escapedString, "+", `%20`, -1) return escapedString }
c165021
{ // Bump this default to 30 minutes because the aws default // of ten minutes doesn't work for some of our long-running copies. waitOpts = append(waitOpts, request.WithWaiterMaxAttempts(120)) } err := conn.WaitUntilImageAvailableWithContext( ctx, &imageInput, waitOpts...) return err }
c165022
:= conn.WaitUntilSpotInstanceRequestFulfilledWithContext( ctx, &spotRequestInput, getWaiterOptions()...) return err }
c165023
:= WaitForVolumeToBeAttached(conn, ctx, &volumeInput, getWaiterOptions()...) return err }
c165024
case <-shutdownTimer: log.Printf("Shutdown stdout: %s", stdout.String()) log.Printf("Shutdown stderr: %s", stderr.String()) err := errors.New("Timeout while waiting for machine to shut down.") state.Put("error", err) ui.Error(err.Error()) return multistep.ActionHalt default: time.Sleep...
c165025
io.ReadCloser) io.ReadCloser { return stream }
c165026
c.Prlctl = make([][]string, 0) } return nil }
c165027
:= exec.Command(path, args...) command.Stdout = &stdout command.Stderr = &stderr err = command.Run() if ps.Stdout != nil { stdout.WriteTo(ps.Stdout) } if ps.Stderr != nil { stderr.WriteTo(ps.Stderr) } stderrString := strings.TrimSpace(stderr.String()) if _, ok := err.(*exec.ExitError); ok { err = f...
c165028
Command: fmt.Sprintf("Copy-Item -Path %s/%s -Destination %s", c.ContainerDir, filepath.Base(tempfile.Name()), dst), } ctx := context.TODO() if err := c.Start(ctx, cmd); err != nil { return err } // Wait for the copy to complete cmd.Wait() if cmd.ExitStatus() != 0 { return fmt.Errorf("Upload failed wit...
c165029
cmd.Wait() if cmd.ExitStatus() != 0 { return fmt.Errorf("Failed to copy file to shared drive: %s, %s, %d", stderr.String(), stdout.String(), cmd.ExitStatus()) } // Read that copied file into a new file opened on host machine fsrc, err := os.Open(filepath.Join(c.HostDir, filepath.Base(src))) if err != nil { ...
c165030
is deprecated, please use %s instead", funcName, useInstead) }) return deprecated(in) } }
c165031
} vcnClient, err := core.NewVirtualNetworkClientWithConfigurationProvider(cfg.ConfigProvider) if err != nil { return nil, err } return &driverOCI{ computeClient: coreClient, vcnClient: vcnClient, cfg: cfg, }, nil }
c165032
:= d.computeClient.DeleteImage(ctx, core.DeleteImageRequest{ImageId: &id}) return err }
c165033
return nil } return fmt.Errorf("Unexpected resource state %q, expecting a waiting state %s or terminal state %q ", state, waitStates, terminalState) } return fmt.Errorf("Maximum number of retries (%d) exceeded; resource did not reach state %q", maxRetries, terminalState) }
c165034
if elem == value { return true } } return false }
c165035
if err != nil { log.Printf("Error accepting connection: %s\n", err.Error()) return nil, err } // Eat the interrupts ch := make(chan os.Signal, 1) signal.Notify(ch, os.Interrupt, syscall.SIGTERM) go func() { var count int32 = 0 for { <-ch newCount := atomic.AddInt32(&count, 1) log.Printf("Receive...
c165036
ID: machineId, }) if machine == nil { return false, err } return machine.State == state, err }, 3*time.Second, timeout, ) }
c165037
// indicates that the machine is being deleted whereas a 410 indicates // that this process has completed. if terrors.IsSpecificStatusCode(err, http.StatusGone) { return true, nil } } return false, err }, 3*time.Second, timeout, ) }
c165038
case '#': endofline = true case '\n': if endofline { endofline = false } } if !endofline { out <- ch } } } close(eoc) }(in, out) return out, eoc }
c165039
continue } switch token { case "{": fallthrough case "}": fallthrough case ";": goto leave default: result.operand = append(result.operand, token) } } leave: return result }
c165040
} if len(tokens) > 0 { return tkGroup{}, fmt.Errorf("List of tokens was left unterminated : %v", tokens) } currentgroup = currentgroup.parent case ";": arg := toParameter(tokens) currentgroup.params = append(currentgroup.params, arg) default: tokens = append(tokens, tk) continue ...
c165041
VNET.") } value := row[1] result := networkingCommandEntry_answer{vnet: vnet, value: value} return &networkingCommandEntry{entry: result, answer: &result}, nil }
c165042
version := parsed_version.Number() if version != 1.0 { return NetworkingConfig{}, fmt.Errorf("Expected version %f of networking file. Received version %f.", 1.0, version) } // convert to a configuration result := flattenNetworkingConfig(eop, entries) return result, nil }
c165043
err := fd.Read(b) if err == io.EOF { break } fromfile <- b[0] } close(eof) }() return fromfile, eof }
c165044
%s already exists.\n"+ "Use the force flag to delete it prior to building.", c.ImageName) state.Put("error", err) ui.Error(err.Error()) return multistep.ActionHalt } return multistep.ActionContinue }
c165045
images.ImageVisibilityCommunity, images.ImageVisibilityShared, } for _, v := range visibilities { if string(v) == visibility { return &v, nil } } return nil, fmt.Errorf("Not a valid visibility: %s", visibility) }
c165046
if c.MachineMetadata == nil { c.MachineMetadata = make(map[string]string) } if c.MachineTags == nil { c.MachineTags = make(map[string]string) } if len(errs) > 0 { return errs } return nil }
c165047
for that name. No problem. return nil } for _, hook := range hooks { if err := ctx.Err(); err != nil { return err } if err := hook.Run(ctx, name, ui, comm, data); err != nil { return err } } return nil }
c165048
for _, addr := range iface.IPAddresses { if addr.IsLoopback() { continue } return addr.String(), nil } } return "", fmt.Errorf("Found no IP addresses on VM") }
c165049
err = os.Stat(td) if os.IsNotExist(err) { if err = os.MkdirAll(td, 0755); err != nil { return "", err } } else if err != nil { return "", err } return td, nil }
c165050
var errs []error if !validMode { errs = append(errs, fmt.Errorf("parallels_tools_mode is invalid. Must be one of: %v", validModes)) } if c.ParallelsToolsFlavor == "" { if c.ParallelsToolsMode != ParallelsToolsModeDisable { errs = append(errs, errors.New("parallels_tools_flavor must be specified")) ...
c165051
if err := filepath.Walk(dir, visit); err != nil { return nil, err } return &artifact{ dir: dir, f: files, }, nil }
c165052
return c.uploadReader(dst, src) } return c.uploadFile(dst, src, fi) }
c165053
} defer os.Remove(tempfile.Name()) defer tempfile.Close() if _, err := io.Copy(tempfile, src); err != nil { return fmt.Errorf("Failed to copy upload file to tempfile: %s", err) } tempfile.Seek(0, 0) fi, err := tempfile.Stat() if err != nil { return fmt.Errorf("Error getting tempfile info: %s", err) } re...
c165054
err := archive.Close(); err != nil { return fmt.Errorf("Failed to close archive: %s", err) } if err := stdin.Close(); err != nil { return fmt.Errorf("Failed to close stdin: %s", err) } stderrOut, err := ioutil.ReadAll(stderrP) if err != nil { return err } if err := localCmd.Wait(); err != nil { return...
c165055
file: %s", string(stderrOut)) } archive := tar.NewReader(pipe) _, err = archive.Next() if err != nil { return fmt.Errorf("Failed to read header from tar stream: %s", err) } numBytes, err := io.Copy(dst, archive) if err != nil { return fmt.Errorf("Failed to pipe download: %s", err) } log.Printf("Copied %...
c165056
be closed before exiting. stdin.Close() }() } wg.Wait() err := cmd.Wait() if exitErr, ok := err.(*exec.ExitError); ok { exitStatus = 1 // There is no process-independent way to get the REAL // exit status so we just try to go deeper. if status, ok := exitErr.Sys().(syscall.WaitStatus); ok { exit...
c165057
IDs out of the copied AMI describeImageResp, err := regionconn.DescribeImages(&ec2.DescribeImagesInput{ImageIds: []*string{resp.ImageId}}) if err != nil { return "", snapshotIds, fmt.Errorf("Error describing copied AMI (%s) in region (%s): %s", imageId, target, err) } for _, blockDeviceMapping := range descr...
c165058
nil { return "", fmt.Errorf("Error preparing powershell script: %s", err) } } if err := writer.Flush(); err != nil { return "", fmt.Errorf("Error preparing powershell script: %s", err) } return temp.Name(), nil }
c165059
flattenedEnvVars := p.createFlattenedEnvVars(elevated) // Create a powershell script on the target build fs containing the // flattened env vars err = p.uploadEnvVars(flattenedEnvVars) if err != nil { return err } return }
c165060
this point with the variables. result.builds = make(map[string]*template.Builder) for _, b := range c.Template.Builders { v, err := interpolate.Render(b.Name, result.Context()) if err != nil { return nil, fmt.Errorf( "Error interpolating builder '%s': %s", b.Name, err) } result.builds[v] = b } ...
c165061
r = append(r, n) } sort.Strings(r) return r }
c165062
c.Template.Path, UserVariables: c.variables, } }
c165063
numErrors, err) return err } log.Printf("[ERROR] %d error received, will ignore and retry: %s", errCode.Actual, err) time.Sleep(2 * time.Second) continue } return err } if image.Status == "active" { return nil } log.Printf("Waiting for image creation status: %s", image.Status) ...
c165064
}, }, &Player5Driver{ SSHConfig: config, }, } default: return nil, fmt.Errorf("can't find driver for OS: %s", runtime.GOOS) } } errs := "" for _, driver := range drivers { err := driver.Verify() log.Printf("Testing vmware driver %T. Success: %t", driver, err == nil) if err ...
c165065
return nil, err } defer fd.Close() return ReadDhcpConfiguration(fd) }
c165066
} defer f.Close() vmxBytes, err := ioutil.ReadAll(f) if err != nil { return map[string]string{}, err } return ParseVMX(string(vmxBytes)), nil }
c165067
:= vmxData["ethernet0.vnet"] if !ok || device == "" { return "", fmt.Errorf("Unable to determine the device name for the connection type \"%s\" : %s", connectionType, device) } return device, nil }
c165068
if !pc.PackerForce { if _, err := os.Stat(c.OutputDir); err == nil { errs = append(errs, fmt.Errorf( "Output directory '%s' already exists. It must not exist.", c.OutputDir)) } } return errs }
c165069
nil { state.Put("error", fmt.Errorf("Error opening Parallels Tools ISO: %s", err)) return multistep.ActionHalt } defer f.Close() s.Ctx.Data = &toolsPathTemplate{ Flavor: s.ParallelsToolsFlavor, } s.ParallelsToolsGuestPath, err = interpolate.Render(s.ParallelsToolsGuestPath, &s.Ctx) if err != nil { err ...
c165070
Error: func(e error) { ui.Error(e.Error()) }, Config: config, } step.CreateBlockStorageInstance = step.createBlockStorageInstance return step }
c165071
// Try to get it from the requested interface if addr := sshAddrFromPool(s, sshinterface, sshipversion); addr != "" { log.Printf("[DEBUG] Using IP address %s to connect", addr) return addr, nil } s, err := servers.Get(client, s.ID).Extract() if err != nil { return "", err } state.Put("server", ...
c165072
= append(names, currentDir) // Do some recursion subNames, err := listDirectories(currentDir) if err == nil { names = append(names, subNames...) } } } return names, nil }
c165073
derivedName, ImportName: deriveImport(x.Name.Name, derivedName), TypeName: x.Name.Name, Path: dir, }) // The AST stops parsing when we return false. Once we // find the symbol we want we can stop parsing. // DEBUG: // fmt.Printf("package %#v\n", goPackage) ...
c165074
} privateKey, err = ioutil.ReadFile(keyPath) if err != nil { return privateKey, fmt.Errorf("Error on reading SSH private key: %s", err) } } return privateKey, nil }
c165075
= append(privateKeys, []byte(iKey.(string))) } if len(c.SSHPrivateKey) != 0 { privateKeys = append(privateKeys, c.SSHPrivateKey) } for _, key := range privateKeys { signer, err := ssh.ParsePrivateKey(key) if err != nil { return nil, fmt.Errorf("Error on parsing SSH private key: %s", err) } ...
c165076
return c.WinRMPort default: return 0 } }
c165077
return c.WinRMHost default: return "" } }
c165078
return c.WinRMUser default: return "" } }
c165079
return c.WinRMPassword default: return "" } }
c165080
if errs := s.Validate(); errs != nil { return fmt.Errorf("Found an invalid boot command. This is likely an error in Packer, so please open a ticket.") } for _, exp := range s { if err := ctx.Err(); err != nil { return err } if err := exp.Do(ctx, b); err != nil { return err } } return b.Flush() }
c165081
exp.Validate(); err != nil { errs = append(errs, err) } } return }
c165082
nil, err } for _, exp := range got.([]interface{}) { seq = append(seq, exp.(expression)) } return seq, nil }
c165083
case <-time.After(w.d): return nil case <-ctx.Done(): return ctx.Err() } }
c165084
a positive wait value. Got %s", w.d) } return nil }
c165085
return driver.SendSpecial(s.s, s.action) }
c165086
return driver.SendKey(l.s, l.action) }
c165087
= time.ParseDuration(c.RawShutdownTimeout) if err != nil { errs = append(errs, fmt.Errorf("Failed parsing shutdown_timeout: %s", err)) } return errs }
c165088
v.(string) } // The export process exports the VM into a folder named 'vm name' // under the output directory. However, to maintain backwards // compatibility, we now need to shuffle around the exported folders // so the 'Snapshots', 'Virtual Hard Disks' and 'Virtual Machines' // directories appear *direct...
c165089
if err != nil { return nil, err } result := newServerWithMux(mux, 0) result.closeMux = true go mux.Run() return result, nil }
c165090
defer stream.Close() h := &codec.MsgpackHandle{ RawToString: true, WriteExt: true, } rpcCodec := codec.GoRpc.ServerCodec(stream, h) s.server.ServeCodec(rpcCodec) }
c165091
case []interface{}: for _, innerRawPP := range pp { if innerPP, ok := innerRawPP.(map[string]interface{}); ok { pps = append(pps, innerPP) } } } } return pps }
c165092
'The fdd0 device does not exist.' driver.Prlctl(delCommand...) ui.Say("Attaching floppy disk...") // Attaching the floppy disk addCommand := []string{ "set", vmName, "--device-add", "fdd", "--image", floppyPath, "--connect", } if err := driver.Prlctl(addCommand...); err != nil { state.Put("error", fmt...
c165093
command := []string{ "set", vmName, "--device-del", "fdd0", } driver.Prlctl(command...) }
c165094
sc { if err := d.sendImpl(b); err != nil { return err } time.Sleep(d.interval) } return nil }
c165095
append(d.buffer, codes) }
c165096
return KeyPair{}, fmt.Errorf("Unable to generate new key pair, type %s is not supported", config.Type.String()) }
c165097
bits", config.Bits) } privateKey, err := ecdsa.GenerateKey(curve, rand.Reader) if err != nil { return KeyPair{}, err } sshPublicKey, err := gossh.NewPublicKey(&privateKey.PublicKey) if err != nil { return KeyPair{}, err } privateRaw, err := x509.MarshalECPrivateKey(privateKey) if err != nil { return ...
c165098
x509.MarshalPKCS1PrivateKey(privateKey), }) if err != nil { return KeyPair{}, err } return KeyPair{ PrivateKeyPemBlock: privatePemBlock, PublicKeyAuthorizedKeysLine: authorizedKeysLine(sshPublicKey, config.Comment), Comment: config.Comment, }, nil }
c165099
!= nil { return []byte{}, err } return buffer.Bytes(), nil }