id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c4300
virsh, "undefine", "--nvram", c.Name()) if err != nil { logger.Infof("`%s undefine --nvram %s` failed: %q", virsh, c.Name(), err) } guestBase, err := guestPath(c.pathfinder) if err != nil { return errors.Trace(err) } err = os.Remove(filepath.Join(guestBase, fmt.Sprintf("%s.qcow", c.Name()))) if err != nil { logger.Errorf("failed to remove system disk for %q: %s", c.Name(), err) } err = os.Remove(filepath.Join(guestBase, fmt.Sprintf("%s-ds.iso", c.Name()))) if err != nil { logger.Errorf("failed to remove cloud-init data disk for %q: %s", c.Name(), err) } return nil }
c4301
return errors.Annotatef(err, "failed to autostart domain %q", c.Name()) }
c4302
"", errors.Trace(err) } return filepath.Join(baseDir, kvm, guestDir), nil }
c4303
outputting the iso image to the guests // (AKA libvirt storage pool) directory. guestBase, err := guestPath(params.findPath) if err != nil { return "", errors.Trace(err) } dsPath := filepath.Join(guestBase, fmt.Sprintf("%s-ds.iso", params.Host())) // Use the template path as the working directory. // This allows us to run the command with user-data and meta-data as // relative paths to appease the NoCloud script. out, err := params.runCmd( templateDir, "genisoimage", "-output", dsPath, "-volid", "cidata", "-joliet", "-rock", userdata, metadata, networkconfig) if err != nil { return "", errors.Trace(err) } logger.Debugf("create ds image: %s", out) return dsPath, nil }
c4304
} defer func() { err = f.Close() if err != nil { logger.Debugf("failed defer %q", errors.Trace(err)) } }() _, err = f.Write(ml) if err != nil { return "", errors.Trace(err) } return domainPath, nil }
c4305
return nil, errors.Trace(err) } return newAPIWithBacking(stateshim, state.CallContext(st), res, auth) }
c4306
results, errors.Trace(err) } results.Results = make([]params.SpaceResult, len(spaces)) for i, space := range spaces { // TODO(dimitern): Add a Tag() a method and use it here. Too // early to do it now as it will just complicate the tests. tag := names.NewSpaceTag(space.Name()) results.Results[i].Tag = tag.String() } return results, nil }
c4307
params.ErrorResults{}, err } return networkingcommon.AddSubnets(api.context, api.backing, args) }
c4308
&leaderGetCommand{ctx: ctx}, nil }
c4309
nil && os.IsNotExist(err) { return nil, nil } return clouds, err }
c4310
if err != nil { return nil, err } clouds, err := ParseCloudMetadata(data) if err != nil { return nil, err } return clouds, err }
c4311
errors.Trace(err) } return ioutil.WriteFile(JujuPersonalCloudsPath(), data, os.FileMode(0600)) }
c4312
logger.Debugf("container has no desired spaces, " + "and host has no known spaces, triggering fallback " + "to bridge all devices") return set.NewStrings(""), nil } return nil, errors.Errorf("no obvious space for container %q, host machine has spaces: %s", containerId, network.QuoteSpaceSet(hostSpaces)) }
c4313
can come up with // something useful. containerSpaces, err = p.inferContainerSpaces(m, containerMachine.Id(), defaultSpaceName) if err != nil { return nil, errors.Trace(err) } } return containerSpaces, nil }
c4314
nil { logger.Errorf("findSpacesAndDevicesForContainer(%q) got error looking for host spaces: %v", containerMachine.Id(), err) return nil, nil, errors.Trace(err) } return containerSpaces, devicesPerSpace, nil }
c4315
errors.Annotate(err, "getting state serving info") } err = agent.ChangeConfig(func(config coreagent.ConfigSetter) error { existing, hasInfo := config.StateServingInfo() if hasInfo { // Use the existing cert and key as they appear to // have been already updated by the cert updater // worker to have this machine's IP address as // part of the cert. This changed cert is never // put back into the database, so it isn't // reflected in the copy we have got from // apiState. info.Cert = existing.Cert info.PrivateKey = existing.PrivateKey } config.SetStateServingInfo(info) if mongoProfileChanged { logger.Debugf("setting agent config mongo memory profile: %q => %q", agentsMongoMemoryProfile, configMongoMemoryProfile) config.SetMongoMemoryProfile(configMongoMemoryProfile) } return nil }) if err != nil { return nil, errors.Trace(err) } // If we need a restart, return the fatal error. if mongoProfileChanged { logger.Infof("restarting agent for new mongo memory profile") return nil, jworker.ErrRestartAgent } // Only get the hub if we are a controller and we haven't updated // the memory profile. var hub *pubsub.StructuredHub if err := context.Get(config.CentralHubName, &hub); err != nil { logger.Tracef("hub dependency not available") return nil, err } return NewWorker(WorkerConfig{ Agent: agent, Hub: hub, MongoProfile: configMongoMemoryProfile, Logger: config.Logger, }) }, } }
c4316
of type %T, got %T", pools, value) } formatPoolsTabular(writer, pools) return nil }
c4317
for key := range pool.Attrs { keys = append(keys, key) } sort.Strings(keys) attrs := make([]string, len(pool.Attrs)) for i, key := range keys { attrs[i] = fmt.Sprintf("%v=%v", key, pool.Attrs[key]) } print(name, pool.Provider, strings.Join(attrs, " ")) } tw.Flush() }
c4318
serverFaultCode { return false } _, isPermissionError := fault.Detail.Fault.(types.NoPermission) if isPermissionError { return true } // Otherwise it could be a login error. return strings.Contains(fault.String, loginErrorFragment) }
c4319
if n := len(modelUUIDs) - 1; n > 0 { return errors.Trace(hasHostedModelsError(n)) } } modelEntityRefsDoc, err := model.getEntityRefs() if err != nil { return errors.Trace(err) } if _, err := checkModelEntityRefsEmpty(modelEntityRefsDoc); err != nil { return errors.Trace(err) } return nil }
c4320
return nil, common.ErrPerm } return &MetricsDebugAPI{ state: st, }, nil }
c4321
} case names.ApplicationTagKind: batches, err = api.state.MetricBatchesForApplication(tag.Id()) if err != nil { err = errors.Annotate(err, "failed to get metrics") results.Results[i].Error = common.ServerError(err) continue } default: err := errors.Errorf("invalid tag %v", arg.Tag) results.Results[i].Error = common.ServerError(err) } results.Results[i].Metrics = api.filterLastValuePerKeyPerUnit(batches) } return results, nil }
c4322
names.ParseTag(arg.Tag) if err != nil { results.Results[i].Error = common.ServerError(err) continue } err = api.setEntityMeterStatus(tag, state.MeterStatus{ Code: state.MeterStatusFromString(arg.Code), Info: arg.Info, }) if err != nil { results.Results[i].Error = common.ServerError(err) continue } } return results, nil }
c4323
*PasswordChanger { return &PasswordChanger{ st: st, getCanChange: getCanChange, } }
c4324
continue } if !canChange(tag) { result.Results[i].Error = ServerError(ErrPerm) continue } if err := pc.setPassword(tag, param.Password); err != nil { result.Results[i].Error = ServerError(err) } } return result, nil }
c4325
func() (AddCloudAPI, error) { root, err := cmd.NewAPIRoot(cmd.store, cmd.controllerName, "") if err != nil { return nil, errors.Trace(err) } return cloudapi.NewClient(root), nil } cmd.brokerGetter = cmd.newK8sClusterBroker cmd.getAllCloudDetails = jujucmdcloud.GetAllCloudDetails return modelcmd.WrapBase(cmd) }
c4326
if (stat.Mode()&os.ModeCharDevice) == 0 && len(content) > 0 { // workaround to get piped stdIn size because stat.Size() always == 0 return bytes.NewReader(content), nil } } return nil, nil }
c4327
{ return &UnitsWatcher{ st: st, resources: resources, getCanWatch: getCanWatch, } }
c4328
We'll keep going if this // fails, and the user can manually update it if they need to. logger.Infof("updating distro-info") err := updateDistroInfo() return errors.Annotate(err, "failed to update distro-info") } return nil }
c4329
disk space on %q for upgrade: %s available, require %dMiB", dir, humanize.IBytes(available), thresholdMib) } return nil }
c4330
msg := fmt.Sprintf(`status %q not supported; expected one of ["%s"]`, state, states) return errors.NewNotValid(nil, msg) } return nil }
c4331
backend.ModelConfig() if err != nil { return nil, errors.Trace(err) } backupDir := config.BackupDir() paths := backups.Paths{ BackupDir: backupDir, DataDir: dataDir, LogsDir: logsDir, } // Build the API. machineID, err := extractResourceValue(resources, "machineID") if err != nil { return nil, errors.Trace(err) } b := API{ backend: backend, paths: &paths, machineID: machineID, } return &b, nil }
c4332
used by the restore CLI when re-bootstrapping. // We will use a better solution but the way restore currently // works, we need them and they are no longer available via // bootstrap config. We will need to fix how re-bootstrap deals // with these keys to address the issue. result.CACert = meta.CACert result.CAPrivateKey = meta.CAPrivateKey result.Filename = filename return result }
c4333
LifeGetter: common.NewLifeGetter(st, getAuthFunc), st: st, model: model, resources: resources, authorizer: authorizer, getAuthFunc: getAuthFunc, }, nil }
c4334
if err != nil { result.Error = common.ServerError(errors.Annotatef(err, "%s", tag)) } // use the results from the machineLXDProfileInfo and apply them to the // result result.InstanceId = lxdProfileInfo.InstanceId result.ModelName = lxdProfileInfo.ModelName result.CurrentProfiles = lxdProfileInfo.MachineProfiles result.ProfileChanges = lxdProfileInfo.ProfileUnits return result, nil }
c4335
range args.Args { err := api.setOneMachineCharmProfiles(a.Entity.Tag, a.Profiles, canAccess) results[i].Error = common.ServerError(err) } return params.ErrorResults{Results: results}, nil }
c4336
changes, ok := <-watch.Changes(); ok { result.StringsWatcherId = api.resources.Register(watch) result.Changes = changes } else { return result, errors.Errorf("cannot obtain initial model machines") } return result, nil }
c4337
return result, err } if changes, ok := <-watch.Changes(); ok { result.StringsWatcherId = api.resources.Register(watch) result.Changes = changes } else { return result, errors.Errorf("cannot obtain initial machine containers") } return result, nil }
c4338
result.Results[i].Error = common.ServerError(common.ErrPerm) continue } entityResult, err := api.watchOneEntityApplication(canAccess, tag) result.Results[i] = entityResult result.Results[i].Error = common.ServerError(err) } return result, nil }
c4339
an error, status.HostedModelCount will be 0, the polling // loop will stop and we'll go directly to destroying the model. ctrStatus, modelsStatus, err := newData(api, controllerModelUUID) if err != nil { ctx.Infof("Unable to get the controller summary from the API: %s.", err) } return environmentStatus{ controller: ctrStatus, models: modelsStatus, } } }
c4340
// both state and model but only model. // TODO (manadart 2018-02-15): This potentially frees the state from // the pool. Release is called, but the state reference survives. return stateenvirons.EnvironConfigGetter{State: st.State, Model: m}.CloudSpec() } }
c4341
m} if tag.Id() != st.ModelUUID() { return environs.CloudSpec{}, errors.New("cannot get cloud spec for this model") } return configGetter.CloudSpec() } }
c4342
return nil, errors.Trace(err) } if tag.Id() != st.ModelUUID() { return nil, errors.New("cannot get cloud spec for this model") } return m.WatchCloudSpecChanges(), nil } }
c4343
UpgradeSeriesStatusOrder[status]; !ok { return UpgradeSeriesNotStarted, errors.NotValidf("upgrade series status of %q is", status) } return status, nil }
c4344
UpgradeSeriesStatusOrder[st1] == UpgradeSeriesStatusOrder[st2] { return 0, nil } if UpgradeSeriesStatusOrder[st1] < UpgradeSeriesStatusOrder[st2] { return -1, nil } return 1, nil }
c4345
return nil, errors.Trace(err) } return &Authenticator{ statePool: statePool, authContext: authContext, }, nil }
c4346
:= a.authContext.clock.Now() a.authContext.localUserInteractions.Expire(now) } } }
c4347
return a.authContext.CreateLocalLoginMacaroon(tag) }
c4348
authCtxt: a.authContext, finder: a.statePool.SystemState(), } h.AddHandlers(mux) }
c4349
return httpcontext.AuthInfo{}, errors.Trace(err) } return a.AuthenticateLoginRequest(req.Host, modelUUID, loginRequest) }
c4350
(humanize.GiByte / humanize.GByte) }
c4351
nil { return nil, errors.Trace(err) } info := volumeInfo{ name: v.Tag.Id(), sizeInGB: mibToGb(v.Size), tags: cfg.tags, } volumes[i+1] = info } return volumes, nil }
c4352
defer closeColl() err := coll.FindId(id).One(doc) if err == mgo.ErrNotFound { return errors.NotFoundf(id) } if err != nil { return errors.Trace(err) } return nil }
c4353
coll.Find(query).All(docs); err != nil { return errors.Trace(err) } return nil }
c4354
error { if err := sp.st.db().Run(transactions); err != nil { return errors.Trace(err) } return nil }
c4355
sp.st.session store := storage.NewStorage(modelUUID, session) return store }
c4356
applicationsC, Id: applicationID, Assert: isAliveDoc, }} }
c4357
panic("inappropriate method called before init finished") } return c.store }
c4358
// other model details if not already done. if err := c.maybeInitModel(); err != nil { return errors.Trace(err) } return nil }
c4359
return "", errors.Trace(err) } return c._modelName, nil }
c4360
nil { return "", errors.Trace(err) } details, err := c.store.ModelByName(c._controllerName, c._modelName) if err != nil { if !c.runStarted { return "", errors.Trace(err) } details, err = c.modelDetails(c._controllerName, c._modelName) if err != nil { return "", errors.Trace(err) } } c._modelType = details.ModelType return c._modelType, nil }
c4361
if err = c.store.UpdateModel(c._controllerName, c._modelName, *modelDetails); err != nil { return err } c._activeBranch = branchName return nil }
c4362
} details, err = c.modelDetails(c._controllerName, c._modelName) if err != nil { return "", errors.Trace(err) } } c._activeBranch = details.ActiveBranch return c._activeBranch, nil }
c4363
return "", errors.Trace(err) } return c._controllerName, nil }
c4364
_, err := c.ModelDetails() if err != nil { return nil, errors.Trace(err) } return c.newAPIRoot(modelName) }
c4365
return nil, errors.Trace(err) } return c.CommandBase.NewAPIRoot(c.store, controllerName, modelName) }
c4366
can embed the ModelCommand // interface one level deeper than cmd.Command, so that // we'll get the Command methods from WrapBase // and all the ModelCommand methods not in cmd.Command // from modelCommandWrapper. type embed struct { *modelCommandWrapper } return struct { embed cmd.Command }{ Command: WrapBase(wrapper), embed: embed{wrapper}, } }
c4367
errors.Trace(err) } return nil } if modelType == model.CAAS && iaasOnly { err = errors.Errorf("Juju command %q not supported on kubernetes models", w.Info().Name) } if modelType == model.IAAS && caasOnly { err = errors.Errorf("Juju command %q not supported on non-container models", w.Info().Name) } if c, ok := w.inner().(modelSpecificCommand); ok { return c.IncompatibleModel(err) } return err }
c4368
cmdContext, verifyCredentials: true, } }
c4369
cmdContext, verifyCredentials: false, } }
c4370
return name[:i], name[i+1:] } return "", name }
c4371
// on Azure. return nil, errors.NotSupportedf("CustomScript extension for OS %q", os) } extensionSettings := map[string]interface{}{ "commandToExecute": commandToExecute, } return &compute.VirtualMachineExtensionProperties{ Publisher: to.StringPtr(extensionPublisher), Type: to.StringPtr(extensionType), TypeHandlerVersion: to.StringPtr(extensionVersion), AutoUpgradeMinorVersion: to.BoolPtr(true), Settings: &extensionSettings, }, nil }
c4372
return modelconfig.NewClient(conn) }, NewResourceLister: func(conn base.APICallCloser) (ResourceLister, error) { resclient, err := resourceadapters.NewAPIClient(conn) if err != nil { return nil, err } return resclient, nil }, CharmStoreURLGetter: getCharmStoreAPIURL, } return modelcmd.Wrap(cmd) }
c4373
&& !charmrepo.IsInvalidPathError(err) { return id, nil, err } refURL, err := charm.ParseURL(charmRef) if err != nil { return id, nil, errors.Trace(err) } // Charm has been supplied as a URL so we resolve and deploy using the store. newURL, channel, supportedSeries, err := c.ResolveCharm(charmRepo.ResolveWithChannel, refURL) if err != nil { return id, nil, errors.Trace(err) } id.Channel = channel _, seriesSupportedErr := charm.SeriesForCharm(deployedSeries, supportedSeries) if !c.ForceSeries && deployedSeries != "" && newURL.Series == "" && seriesSupportedErr != nil { series := []string{"no series"} if len(supportedSeries) > 0 { series = supportedSeries } return id, nil, errors.Errorf( "cannot upgrade from single series %q charm to a charm supporting %q. Use --force-series to override.", deployedSeries, series, ) } // If no explicit revision was set with either SwitchURL // or Revision flags, discover the latest. if *newURL == *oldURL { if refURL.Revision != -1 { return id, nil, errors.Errorf("already running specified charm %q", newURL) } // No point in trying to upgrade a charm store charm when // we just determined that's the latest revision // available. return id, nil, errors.Errorf("already running latest charm %q", newURL) } curl, csMac, err := addCharmFromURL(charmAdder, newURL, channel, force) if err != nil { return id, nil, errors.Trace(err) } id.URL = curl return id, csMac, nil }
c4374
u.WorkloadStatusInfo.Current, ) fmt.Fprintf(out, format, uName, u.PublicAddress, status, ) }) }
c4375
var callback ProgressCallback if params.StatusCallback != nil { callback = func(msg string) { _ = params.StatusCallback(status.Provisioning, msg, nil) } } if err := Sync(sp, nil, callback); err != nil { if !errors.IsAlreadyExists(err) { return errors.Trace(err) } logger.Debugf("image already cached %s", err) } return nil }
c4376
bridge, Memory: params.Memory, CpuCores: params.CpuCores, RootDisk: params.RootDisk, Interfaces: interfaces, }); err != nil { return err } logger.Debugf("Set machine %s to autostart", c.name) if params.StatusCallback != nil { _ = params.StatusCallback(status.Provisioning, "Starting instance", nil) } return AutostartMachine(c) }
c4377
zones := make([]string, len(instances)) for idx := range instances { zones[idx] = "default" } return zones, nil }
c4378
env.namespace, err = instance.NewNamespace(env.cfg.UUID()) if err != nil { return nil, errors.Trace(err) } env.Firewaller = oraclenet.NewFirewall(env, client, c) env.Networking = oraclenet.NewEnviron(client, env) source := rand.NewSource(env.clock.Now().UTC().UnixNano()) r := rand.New(source) env.rand = r return env, nil }
c4379
on this might be able to chip in. spaces, err := e.Spaces(ctx) if err != nil { return nil, providerIdMap, errors.Trace(err) } spaceMap := make(map[string]network.SpaceInfo) for _, space := range spaces { jujuName := network.ConvertSpaceName(space.Name, empty) spaceMap[jujuName] = space empty.Add(jujuName) providerIdMap[string(space.ProviderId)] = space.Name } return spaceMap, providerIdMap, nil }
c4380
return err } logger.Debugf("terminating instances %v", ids) if err := o.terminateInstances(oracleInstances...); err != nil { return err } return nil }
c4381
if err != nil { return nil, errors.Trace(err) } if oInst.Id() == id { ret = append(ret, oInst) break } } } if len(ret) < len(ids) { return ret, environs.ErrPartialInstances } return ret, nil }
c4382
} ret := make([]envinstance.Instance, len(all)) for i, val := range all { ret[i] = val } return ret, nil }
c4383
args environs.StartInstanceParams) error { return nil }
c4384
defer o.mutex.Unlock() return o.cfg }
c4385
validator.RegisterUnsupported(unsupportedConstraints) validator.RegisterVocabulary(constraints.Arch, []string{arch.I386, arch.AMD64}) logger.Infof("Returning constraints validator: %v", validator) return validator, nil }
c4386
environs.ErrNoInstances { return nil } return errors.Trace(err) } ids := make([]instance.Id, len(instances)) for i, val := range instances { ids[i] = val.Id() } return o.StopInstances(ctx, ids...) }
c4387
var i envinstance.InstanceTypesWithCostMetadata return i, nil }
c4388
return nil, errors.Trace(err) } instance, err := newInstance(resp.Instances[0], e) if err != nil { return nil, errors.Trace(err) } return instance, nil }
c4389
return err.AvailabilityZoneIndependent() } return false }
c4390
jujuos.CentOS: return centosEnv(paths) case jujuos.OpenSUSE: return opensuseEnv(paths) } return nil }
c4391
paths.GetToolsDir() + ";" + os.Getenv("Path"), "PSModulePath=" + os.Getenv("PSModulePath") + ";" + charmModules, } }
c4392
settings", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().AddActionPruneSettings() }, }, } }
c4393
destroyStorage := true args.DestroyStorage = &destroyStorage return destroyController(c.state, c.statePool, c.authorizer, args) }
c4394
destroyController(c.state, c.statePool, c.authorizer, args) }
c4395
res.PendingID, ApplicationID: res.ApplicationID, Username: res.Username, Timestamp: res.Timestamp, } }
c4396
} if len(unitRes.DownloadProgress) > 0 { unitResources.DownloadProgress = make(map[string]int64) for resName, progress := range unitRes.DownloadProgress { if _, ok := resNames[resName]; !ok { err := errors.Errorf("got progress from unrecognized resource %q", resName) return resource.ApplicationResources{}, errors.Annotate(err, "got bad data from server") } unitResources.DownloadProgress[resName] = progress } } result.UnitResources = append(result.UnitResources, unitResources) } for _, chRes := range apiResult.CharmStoreResources { res, err := API2CharmResource(chRes) if err != nil { return resource.ApplicationResources{}, errors.Annotate(err, "got bad data from server") } result.CharmStoreResources = append(result.CharmStoreResources, res) } return result, nil }
c4397
ApplicationID: apiRes.ApplicationID, Username: apiRes.Username, Timestamp: apiRes.Timestamp, } if err := res.Validate(); err != nil { return res, errors.Trace(err) } return res, nil }
c4398
Origin: res.Origin.String(), Revision: res.Revision, Fingerprint: res.Fingerprint.Bytes(), Size: res.Size, } }
c4399
apiInfo.Name, Type: rtype, Path: apiInfo.Path, Description: apiInfo.Description, }, Origin: origin, Revision: apiInfo.Revision, Fingerprint: fp, Size: apiInfo.Size, } if err := res.Validate(); err != nil { return res, errors.Trace(err) } return res, nil }