// TODO(axw) 2017-03-16 #1673323
// Drop this in Juju 3.0.
164424
func (c *removeUnitCommand) removeUnitsDeprecated(ctx *cmd.Context, client RemoveApplicationAPI) error {
	err := client.DestroyUnitsDeprecated(c.EntityNames...)
	return block.ProcessBlockedError(err, block.BlockRemove)
}
694281
func (c *Client) MongoVersion() (string, error) {
	if c.BestAPIVersion() < 6 {
		return "", errors.NotSupportedf("MongoVersion not supported by this version of Juju")
	}
	var result params.StringResult
	err := c.facade.FacadeCall("MongoVersion", nil, &result)
	if err != nil {
		return "", errors.Trace(err)
	}
	if result.Error != nil {
		return "", result.Error
	}
	return result.Result, nil
}
1165083
func Drop(in interface{}, n int) interface{} {
	value := reflect.ValueOf(in)
	valueType := value.Type()

	kind := value.Kind()

	if kind == reflect.Array || kind == reflect.Slice {
		length := value.Len()

		resultSlice := makeSlice(value, length-n)

		j := 0
		for i := n; i < length; i++ {
			resultSlice.Index(j).Set(value.Index(i))
			j++
		}

		return resultSlice.Interface()

	}

	panic(fmt.Sprintf("Type %s is not supported by Drop", valueType.String()))
}
934372
func (l reflectWithStringSlice) Less(i, j int) bool {
	return l[i].s < l[j].s
}
1183978
func OldJujuHomeDir() string {
	JujuHomeDir := os.Getenv(oldJujuHomeEnvKey)
	if JujuHomeDir == "" {
		if runtime.GOOS == "windows" {
			JujuHomeDir = oldJujuHomeWin()
		} else {
			JujuHomeDir = oldJujuHomeLinux()
		}
	}
	return JujuHomeDir
}
1136605
func (v *Version) WithMajor(major uint) *Version {
	result := *v
	result.components = []uint{major, v.Minor(), v.Patch()}
	return &result
}
352394
func ProfileReplaceRevision(profile string, rev int) (string, error) {
	if !IsValidName(profile) {
		return "", errors.BadRequestf("not a juju profile name: %q", profile)
	}
	split := strings.Split(profile, "-")
	notRev := split[:len(split)-1]
	return strings.Join(append(notRev, strconv.Itoa(rev)), "-"), nil
}
532716
func (co *Context) DropoutGetStatesSize() (sizeInBytes uintptr, err error) {
	var sizeInBytesC C.size_t
	// call cudnnDropoutGetStatesSize
	err = result(C.cudnnDropoutGetStatesSize(co.internal, &sizeInBytesC))
	sizeInBytes = uintptr(sizeInBytesC)
	return
}
279582
func JujuClientVersionFromRequest(req *http.Request) (version.Number, error) {
	verStr := req.URL.Query().Get("jujuclientversion")
	if verStr == "" {
		return version.Zero, errors.New(`missing "jujuclientversion" in URL query`)
	}
	ver, err := version.Parse(verStr)
	if err != nil {
		return version.Zero, errors.Annotatef(err, "invalid jujuclientversion %q", verStr)
	}
	return ver, nil
}
328507
func DropTxIndex(db database.DB, interrupt <-chan struct{}) error {
	err := dropIndex(db, addrIndexKey, addrIndexName, interrupt)
	if err != nil {
		return err
	}

	return dropIndex(db, txIndexKey, txIndexName, interrupt)
}
329840
func DropReason(reason uint8) string {
	if err, ok := errors[reason]; ok {
		return err
	}
	return fmt.Sprintf("%d", reason)
}
147460
func (mr *MockAdminClientMockRecorder) DropScope(arg0, arg1 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DropScope", reflect.TypeOf((*MockAdminClient)(nil).DropScope), arg0, arg1)
}
535989
func (a byEvictionPriority) Less(i, j int) bool {
	_, jSignalHasResource := signalToResource[a[j].Signal]
	return a[i].Signal == evictionapi.SignalMemoryAvailable || a[i].Signal == evictionapi.SignalAllocatableMemoryAvailable || !jSignalHasResource
}
1031309
func Drop(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "drop", Listener: listener}
}
304377
func (api *API) LogWriter() (LogWriter, error) {
	attrs := make(url.Values)
	attrs.Set("jujuclientversion", version.Current.String())
	// Version 1 does ping/pong handling.
	attrs.Set("version", "1")
	conn, err := api.connector.ConnectStream("/logsink", attrs)
	if err != nil {
		return nil, errors.Annotatef(err, "cannot connect to /logsink")
	}
	logWriter := writer{conn}
	go logWriter.readLoop()
	return logWriter, nil
}
269869
func (e *manualEnviron) DestroyController(ctx context.ProviderCallContext, controllerUUID string) error {
	script := `
# Signal the jujud process to stop, then check it has done so before cleaning-up
# after it.
set -x
touch %[1]s

stopped=0
function wait_for_jujud {
    for i in {1..30}; do
        if pgrep jujud > /dev/null ; then
            sleep 1
        else
            echo jujud stopped
            stopped=1
            logger --id jujud stopped on attempt $i
            break
        fi
    done
}

# There might be no jujud at all (for example, after a failed deployment) so
# don't require pkill to succeed before looking for a jujud process.
# SIGABRT not SIGTERM, as abort lets the worker know it should uninstall itself,
# rather than terminate normally.
pkill -SIGABRT jujud
wait_for_jujud

[[ $stopped -ne 1 ]] && {
    # If jujud didn't stop nicely, we kill it hard here.
    %[2]spkill -SIGKILL jujud && wait_for_jujud
}
[[ $stopped -ne 1 ]] && {
    echo jujud removal failed
    logger --id $(ps -o pid,cmd,state -p $(pgrep jujud) | awk 'NR != 1 {printf("Process %%d (%%s) has state %%s\n", $1, $2, $3)}')
    exit 1
}
service %[3]s stop && logger --id stopped %[3]s
apt-get -y purge juju-mongo*
apt-get -y autoremove
rm -f /etc/init/juju*
rm -f /etc/systemd/system{,/multi-user.target.wants}/juju*
rm -fr %[4]s %[5]s
exit 0
`
	var diagnostics string
	if featureflag.Enabled(feature.DeveloperMode) {
		diagnostics = `
    echo "Dump engine report and goroutines for stuck jujud"
    source /etc/profile.d/juju-introspection.sh
    juju-engine-report
    juju-goroutines
`
	}
	script = fmt.Sprintf(
		script,
		// WARNING: this is linked with the use of uninstallFile in
		// the agent package. Don't change it without extreme care,
		// and handling for mismatches with already-deployed agents.
		utils.ShQuote(path.Join(
			agent.DefaultPaths.DataDir,
			agent.UninstallFile,
		)),
		diagnostics,
		mongo.ServiceName,
		utils.ShQuote(agent.DefaultPaths.DataDir),
		utils.ShQuote(agent.DefaultPaths.LogDir),
	)
	logger.Tracef("destroy controller script: %s", script)
	stdout, stderr, err := runSSHCommand(
		"ubuntu@"+e.host,
		[]string{"sudo", "/bin/bash"}, script,
	)
	logger.Debugf("script stdout: \n%s", stdout)
	logger.Debugf("script stderr: \n%s", stderr)
	return err
}
937926
func (versions Versions) Less(i, j int) bool {
	return versions[i] < versions[j]
}