id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c4800
return mongo.SetAdminMongoPassword(m.st.session, m.Tag().String(), password) }
c4801
:= utils.AgentPasswordHash(password) return agentHash == m.doc.PasswordHash }
c4802
!= txn.ErrAborted { return errors.Annotatef(err, "failed to run transaction: %s", pretty.Sprint(ops)) } return nil }
c4803
return parentId, parentId != "" }
c4804
errors.Cause(err).(*HasContainersError) return ok }
c4805
errors.Cause(err).(*HasAttachmentsError) return ok }
c4806
return nil, jujutxn.ErrNoOperations } if err != nil { return nil, errors.Trace(err) } } ops, err := machine.removeOps() if err != nil { return nil, errors.Trace(err) } return ops, nil } return m.st.db().Run(buildTxn) }
c4807
if errors.IsNotFound(err) { return err } return errors.Annotatef(err, "cannot refresh machine %v", m) } m.doc = *mdoc return nil }
c4808
// starts. This ensures that commands run immediately after bootstrap // like status or enable-ha will have an accurate values // for agent-state. // // TODO: Does not work for multiple controllers. Trigger a sync across all controllers. if m.IsManager() { m.st.workers.presenceWatcher().Sync() } return p, ni...
c4809
error) { instId, _, err := m.InstanceNames() return instId, err }
c4810
} if err != nil { return "", "", err } return instData.InstanceId, instData.DisplayName, nil }
c4811
if err != nil { logger.Warningf("error when retrieving instance status for machine: %s, %v", m.Id(), err) return status.StatusInfo{}, err } return machineStatus, nil }
c4812
message: sInfo.Message, rawData: sInfo.Data, updated: timeOrNow(sInfo.Since, m.st.clock()), }) }
c4813
logger.Warningf("error when retrieving instance status for machine: %s, %v", m.Id(), err) return status.StatusInfo{}, err } return machineStatus, nil }
c4814
%v", m.Id())) } if err != nil { return "", errors.Trace(err) } var zone string if instData.AvailZone != nil { zone = *instData.AvailZone } return zone, nil }
c4815
for _, unit := range units { apps.Add(unit.ApplicationName()) } return apps.SortedValues(), nil }
c4816
range pudocs { units = append(units, newUnit(m.st, model.Type(), &pudoc)) docs := []unitDoc{} err = unitsCollection.Find(bson.D{{"principal", pudoc.Name}}).All(&docs) if err != nil { return nil, err } for _, doc := range docs { units = append(units, newUnit(m.st, model.Type(), &doc)) } } return u...
c4817
nil { return nil, errors.Trace(err) } endpointBindings, err := app.EndpointBindings() for _, space := range endpointBindings { if space != "" { bindings.Add(space) } } } logger.Tracef("machine %q found constraints %s and bindings %s", m.Id(), network.QuoteSpaceSet(spaces), network.QuoteSpaceSe...
c4818
range volumes { volumeStatus[tag] = status.Attaching } for tag := range volumeAttachments { volumeStatus[tag] = status.Attached } for tag, volStatus := range volumeStatus { vol, err := sb.Volume(tag) if err != nil { return errors.Trace(err) } if err := vol.SetStatus(status.StatusInfo{ Status: vol...
c4819
network.MergedAddresses(networkAddresses(m.doc.MachineAddresses), networkAddresses(m.doc.Addresses)) }
c4820
== "" { return newAddr, newAddr.Value != "" } if !containsAddress(providerAddresses, addr) && !containsAddress(machineAddresses, addr) { return newAddr, true } if Origin(addr.Origin) != OriginProvider && Origin(newAddr.Origin) == OriginProvider { return newAddr, true } if !checkScope(addr) { // If addr.O...
c4821
err := m.setAddresses(nil, &addresses) return errors.Annotatef(err, "cannot set addresses of machine %v", m) }
c4822
= append(addresses, address.networkAddress()) } return }
c4823
append(addresses, address.networkAddress()) } return }
c4824
return nonce == m.doc.Nonce && nonce != "" }
c4825
readConstraints(m.st, m.globalKey()) }
c4826
m.UpdateOperation() op.Constraints = &cons return m.st.ApplyOperation(op) }
c4827
err != nil { return mStatus, err } return mStatus, nil }
c4828
return errors.Errorf("cannot set status %q", statusInfo.Status) default: return errors.Errorf("cannot set invalid status %q", statusInfo.Status) } return setStatus(m.st.db(), setStatusParams{ badge: "machine", globalKey: m.globalKey(), status: statusInfo.Status, message: statusInfo.Message, raw...
c4829
m.doc.SupportedContainers, m.doc.SupportedContainersKnown }
c4830
nil { return err } return m.markInvalidContainers() }
c4831
return fmt.Errorf("%q is not a valid container type", container) } } if err = m.updateSupportedContainers(containers); err != nil { return err } return m.markInvalidContainers() }
c4832
Id: m.doc.DocID, Assert: notDeadDoc, Update: bson.D{ {"$set", bson.D{ {"supportedcontainers", supportedContainers}, {"supportedcontainersknown", true}, }}}, }, } if err = m.st.db().RunTransaction(ops); err != nil { err = onAbort(err, ErrDead) logger.Errorf("cannot update supporte...
c4833
now := m.st.clock().Now() s := status.StatusInfo{ Status: status.Error, Message: "unsupported container", Data: map[string]interface{}{"type": containerType}, Since: &now, } container.SetStatus(s) } else { logger.Errorf("unsupported container %v has unexpected status %v...
c4834
setMachineBlockDevices(m.st, m.Id(), info) }
c4835
nil, errors.Trace(err) } return sb.MachineVolumeAttachments(m.MachineTag()) }
c4836
// Reject bad payloads before attempting to insert defaults. err := spec.ValidateParams(payload) if err != nil { return nil, err } payloadWithDefaults, err := spec.InsertDefaults(payload) if err != nil { return nil, err } model, err := m.st.Model() if err != nil { return nil, errors.Trace(err) } retu...
c4837
action.Finish(ActionResults{Status: ActionCancelled}) }
c4838
curl, _ := unit.CharmURL() ops = append(ops, txn.Op{ C: unitsC, Id: unit.doc.DocID, Assert: bson.D{{"life", Alive}, {"charmurl", curl}, {"subordinates", unit.SubordinateNames()}}, Update: bson.D{{"$set", bson.D{{"series", series}}}}, }) } return ops, nil } err := m.st.db().Run(b...
c4839
} subordinates := unit.SubordinateNames() subUnits, err := m.VerifyUnitsSeries(subordinates, series, force) if err != nil { return nil, err } results = append(results, unit) results = append(results, subUnits...) } return results, nil }
c4840
{ return &UpdateMachineOperation{m: &Machine{st: m.st, doc: m.doc}} }
c4841
*LifeGetter { return &LifeGetter{ st: st, getCanRead: getCanRead, } }
c4842
= ServerError(ErrPerm) continue } err = ErrPerm if canRead(tag) { result.Results[i].Life, err = lg.oneLife(tag) } result.Results[i].Error = ServerError(err) } return result, nil }
c4843
toTime(doc.Start), duration: doc.Duration, writer: doc.Writer, } return doc.Name, entry, nil }
c4844
Name: name, Holder: entry.holder, Start: toInt64(entry.start), Duration: entry.duration, Writer: entry.writer, } if err := doc.validate(); err != nil { return nil, errors.Trace(err) } return doc, nil }
c4845
err := res.Resource.Validate(); err != nil { return errors.Annotate(err, "bad info") } if res.ApplicationID == "" { return errors.NewNotValid(nil, "missing application ID") } // TODO(ericsnow) Require that Username be set if timestamp is? if res.Timestamp.IsZero() && res.Username != "" { return errors.Ne...
c4846
time.Unix(res.Timestamp.Unix(), 0) }
c4847
case resource.OriginStore: return fmt.Sprintf("%d", res.Revision) default: // note: this should probably never happen. return "-" } }
c4848
len(resources)) for _, res := range resources { results[res.Name] = res } return results }
c4849
nil { senderLogger.Warningf("failed to send metrics %v - will retry later", err) return nil } select { case notify <- "senderCalled": default: } return nil } return jworker.NewPeriodicWorker(f, senderPeriod, jworker.NewTimer) }
c4850
tabwidth = 1 padding = 2 padchar = ' ' flags = 0 ) return ansiterm.NewTabWriter(writer, minwidth, tabwidth, padding, padchar, flags) }
c4851
fmt.Fprintf(w, "%v\t", v) } }
c4852
...interface{}) { fmt.Fprintf(w, format+"\t", values...) }
c4853
if i != len(values)-1 { fmt.Fprintf(w, "%v\t", v) } else { fmt.Fprintf(w, "%v", v) } } fmt.Fprintln(w) }
c4854
"%v\t", value) } else { fmt.Fprintf(w, "%v\t", value) } }
c4855
w.PrintColor(statusColors[status], status) }
c4856
script := base64.StdEncoding.EncodeToString([]byte(unitdebug.ClientScript(debugctx, c.hooks))) innercmd := fmt.Sprintf(`F=$(mktemp); echo %s | base64 -d > $F; . $F`, script) args := []string{fmt.Sprintf("sudo /bin/bash -c '%s'", innercmd)} c.Args = args return c.sshCommand.Run(ctx) }
c4857
defer release() check := NewBlockChecker(modelSt) if err = check.DestroyAllowed(); err != nil { return errors.Trace(err) } err = sendMetrics(modelSt) if err != nil { logger.Errorf("failed to send leftover metrics: %v", err) } } } return destroyModel(st, state.DestroyModelParams{ Destr...
c4858
destroyStorage, Force: force, MaxWait: MaxWait(maxWait), }) }
c4859
caasenvironupgrader.Manifold(caasenvironupgrader.ManifoldConfig{ APICallerName: apiCallerName, GateName: environUpgradeGateName, ModelTag: modelTag, NewFacade: caasenvironupgrader.NewFacade, NewWorker: caasenvironupgrader.NewWorker, }), caasStorageProvisionerName: ifNotMigrating(if...
c4860
err := config.Hub.Publish(apiserver.DetailsRequestTopic, req); err != nil { return nil, errors.Annotate(err, "requesting current apiserver details") } if err := catacomb.Invoke(catacomb.Plan{ Site: &w.catacomb, Work: func() error { defer unsubscribe() return w.loop() }, }); err != nil { unsubscribe...
c4861
meterString[m] if !ok { return MeterNotAvailable.String() } return s }
c4862
s == str { return m } } return MeterNotAvailable }
c4863
} return []txn.Op{ { C: unitsC, Id: u.doc.DocID, Assert: isAliveDoc, }, { C: meterStatusC, Id: u.st.docID(u.globalMeterStatusKey()), Assert: txn.DocExists, Update: bson.D{{"$set", bson.D{{"code", code.String()}, {"info", info}}}}, }}, nil } return errors.Annot...
c4864
mb.modelUUID() return txn.Op{ C: meterStatusC, Id: mb.docID(globalKey), Assert: txn.DocMissing, Insert: doc, } }
c4865
return txn.Op{ C: meterStatusC, Id: mb.docID(globalKey), Remove: true, } }
c4866
MeterRed { return mmStatus, nil } status, err := u.getMeterStatusDoc() if err != nil { return MeterStatus{MeterNotAvailable, ""}, errors.Annotatef(err, "cannot retrieve meter status for unit %s", u.Name()) } code := MeterStatusFromString(status.Code) unitMeterStatus := MeterStatus{code, status.Info} retu...
c4867
StartDownload(req, dlr.OpenBlob) }
c4868
err != nil { return "", errors.Trace(err) } dl := dlr.Start(req) filename, err := dl.Wait() return filename, errors.Trace(err) }
c4869
ctrl} mock.recorder = &MockMachineProvisionerMockRecorder{mock} return mock }
c4870
_ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 }
c4871
:= ret[1].(string) ret2, _ := ret[2].(error) return ret0, ret1, ret2 }
c4872
_ := ret[0].(bool) ret1, _ := ret[1].(error) return ret0, ret1 }
c4873
{ ret := m.ctrl.Call(m, "MachineTag") ret0, _ := ret[0].(names_v2.MachineTag) return ret0 }
c4874
:= m.ctrl.Call(m, "ModelAgentVersion") ret0, _ := ret[0].(*version.Number) ret1, _ := ret[1].(error) return ret0, ret1 }
c4875
:= m.ctrl.Call(m, "ProvisioningInfo") ret0, _ := ret[0].(*params.ProvisioningInfo) ret1, _ := ret[1].(error) return ret0, ret1 }
c4876
m.ctrl.Call(m, "SetCharmProfiles", arg0) ret0, _ := ret[0].(error) return ret0 }
c4877
ret := m.ctrl.Call(m, "SetInstanceInfo", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) ret0, _ := ret[0].(error) return ret0 }
c4878
"SetInstanceInfo", reflect.TypeOf((*MockMachineProvisioner)(nil).SetInstanceInfo), arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) }
c4879
:= m.ctrl.Call(m, "SetStatus", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 }
c4880
"SetStatus", reflect.TypeOf((*MockMachineProvisioner)(nil).SetStatus), arg0, arg1, arg2) }
c4881
:= m.ctrl.Call(m, "SetSupportedContainers", varargs...) ret0, _ := ret[0].(error) return ret0 }
c4882
reflect.TypeOf((*MockMachineProvisioner)(nil).SetSupportedContainers), arg0...) }
c4883
:= ret[0].([]instance.ContainerType) ret1, _ := ret[1].(bool) ret2, _ := ret[2].(error) return ret0, ret1, ret2 }
c4884
:= m.ctrl.Call(m, "WatchAllContainers") ret0, _ := ret[0].(watcher.StringsWatcher) ret1, _ := ret[1].(error) return ret0, ret1 }
c4885
"WatchAllContainers", reflect.TypeOf((*MockMachineProvisioner)(nil).WatchAllContainers)) }
c4886
{ resource += "/" } return resource }
c4887
:= cmd.CombinedOutput() output := string(out) logger.Debugf("output: %v", output) return output, err }
c4888
:= m.ctrl.Call(m, "GetBundle", arg0) ret0, _ := ret[0].(charm_v6.Bundle) ret1, _ := ret[1].(error) return ret0, ret1 }
c4889
_, k := range reflect.ValueOf(m).MapKeys() { keys = append(keys, k.String()) } return }
c4890
fmt.Sprintf("%s%*s%s", prepend, level, "", append) }
c4891
len(fsm.logs)) copy(copied, fsm.logs) return copied }
c4892
fsm.logs = append(fsm.logs, log.Data) return len(fsm.logs) }
c4893
len(fsm.logs)) copy(copied, fsm.logs) return &SimpleSnapshot{copied, len(copied)}, nil }
c4894
return err } fsm.mu.Lock() fsm.logs = logs fsm.mu.Unlock() return nil }
c4895
sink.Cancel() return err } sink.Close() return nil }
c4896
&mongo.MongoInfo{ Info: mongo.Info{ Addrs: stateAddresses, CACert: caCert, }, } apiInfo := &api.Info{ Addrs: apiAddresses, CACert: caCert, ModelTag: names.NewModelTag(modelUUID), } return &simpleAuth{stateInfo, apiInfo}, nil }
c4897
simpleAuth{stateInfo, apiInfo} return auth.SetupAuthentication(machine) }
c4898
!authorizer.AuthClient() { return nil, common.ErrPerm } return &API{ backend: backend, authorizer: authorizer, check: blockChecker, }, nil }
c4899
logger.Debugf("saving firewall rule %+v", arg) err := api.backend.SaveFirewallRule(state.FirewallRule{ WellKnownService: state.WellKnownServiceType(arg.KnownService), WhitelistCIDRs: arg.WhitelistCIDRS, }) results[i].Error = common.ServerError(err) } errResults.Results = results return errResults, nil...