本文整理汇总了Golang中github.com/juju/errors.IsNotSupported函数的典型用法代码示例。如果您正苦于以下问题:Golang IsNotSupported函数的具体用法?Golang IsNotSupported怎么用?Golang IsNotSupported使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsNotSupported函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: maybeReleaseContainerAddresses
func maybeReleaseContainerAddresses(
api APICalls,
instanceID instance.Id,
namespace string,
log loggo.Logger,
) {
if environs.AddressAllocationEnabled() {
// The addresser worker will take care of the addresses.
return
}
// If we're not using addressable containers, we might still have used MAAS
// 1.8+ device to register the container when provisioning. In that case we
// need to attempt releasing the device, but ignore a NotSupported error
// (when we're not using MAAS 1.8+).
namespacePrefix := fmt.Sprintf("%s-", namespace)
tagString := strings.TrimPrefix(string(instanceID), namespacePrefix)
containerTag, err := names.ParseMachineTag(tagString)
if err != nil {
// Not a reason to cause StopInstances to fail though..
log.Warningf("unexpected container tag %q: %v", instanceID, err)
return
}
err = api.ReleaseContainerAddresses(containerTag)
switch {
case err == nil:
log.Infof("released all addresses for container %q", containerTag.Id())
case errors.IsNotSupported(err):
log.Warningf("not releasing all addresses for container %q: %v", containerTag.Id(), err)
default:
log.Warningf(
"unexpected error trying to release container %q addreses: %v",
containerTag.Id(), err,
)
}
}
开发者ID:imoapps,项目名称:juju,代码行数:35,代码来源:lxc-broker.go
示例2: Run
// Run implements Command.Run.
func (c *addCommand) Run(ctx *cmd.Context) error {
return c.RunWithAPI(ctx, func(api SpaceAPI, ctx *cmd.Context) error {
// Prepare a nicer message and proper arguments to use in case
// there are not CIDRs given.
var subnetIds []string
msgSuffix := "no subnets"
if !c.CIDRs.IsEmpty() {
subnetIds = c.CIDRs.SortedValues()
msgSuffix = fmt.Sprintf("subnets %s", strings.Join(subnetIds, ", "))
}
// Add the new space.
// TODO(dimitern): Accept --public|--private and pass it here.
err := api.AddSpace(c.Name, subnetIds, true)
if err != nil {
if errors.IsNotSupported(err) {
ctx.Infof("cannot add space %q: %v", c.Name, err)
}
if params.IsCodeUnauthorized(err) {
common.PermissionsMessage(ctx.Stderr, "add a space")
}
return errors.Annotatef(err, "cannot add space %q", c.Name)
}
ctx.Infof("added space %q with %s", c.Name, msgSuffix)
return nil
})
}
开发者ID:bac,项目名称:juju,代码行数:29,代码来源:add.go
示例3: TestFindDisallowedMethod
func (r *restrictedRootSuite) TestFindDisallowedMethod(c *gc.C) {
caller, err := r.root.FindMethod("Client", 0, "Status")
c.Assert(err, gc.ErrorMatches, `logged in to server, no environment, "Client" not supported`)
c.Assert(errors.IsNotSupported(err), jc.IsTrue)
c.Assert(caller, gc.IsNil)
}
开发者ID:imoapps,项目名称:juju,代码行数:7,代码来源:restricted_root_test.go
示例4: getOneMachineProviderNetworkConfig
func (api *MachinerAPI) getOneMachineProviderNetworkConfig(m *state.Machine) ([]params.NetworkConfig, error) {
instId, err := m.InstanceId()
if err != nil {
return nil, errors.Trace(err)
}
netEnviron, err := networkingcommon.NetworkingEnvironFromModelConfig(
stateenvirons.EnvironConfigGetter{api.st},
)
if errors.IsNotSupported(err) {
logger.Infof("not updating provider network config: %v", err)
return nil, nil
} else if err != nil {
return nil, errors.Annotate(err, "cannot get provider network config")
}
interfaceInfos, err := netEnviron.NetworkInterfaces(instId)
if err != nil {
return nil, errors.Annotatef(err, "cannot get network interfaces of %q", instId)
}
if len(interfaceInfos) == 0 {
logger.Infof("not updating provider network config: no interfaces returned")
return nil, nil
}
providerConfig := networkingcommon.NetworkConfigFromInterfaceInfo(interfaceInfos)
logger.Tracef("provider network config instance %q: %+v", instId, providerConfig)
return providerConfig, nil
}
开发者ID:bac,项目名称:juju,代码行数:30,代码来源:machiner.go
示例5: MaybeReleaseAddresses
// MaybeReleaseAddresses releases any addresses that have been
// allocated to this machine by the provider (if the provider supports
// that).
func (u *Undertaker) MaybeReleaseAddresses(machine names.MachineTag) error {
if u.Releaser == nil {
// This environ doesn't support releasing addresses.
return nil
}
if !names.IsContainerMachine(machine.Id()) {
// At the moment, only containers need their addresses releasing.
return nil
}
interfaceInfos, err := u.API.GetProviderInterfaceInfo(machine)
if err != nil {
return errors.Trace(err)
}
if len(interfaceInfos) == 0 {
logger.Debugf("%s has no addresses to release", machine)
return nil
}
err = u.Releaser.ReleaseContainerAddresses(interfaceInfos)
// Some providers say they support networking but don't
// actually support container addressing; don't freak out
// about those.
if errors.IsNotSupported(err) {
logger.Debugf("%s has addresses but provider doesn't support releasing them", machine)
} else if err != nil {
return errors.Trace(err)
}
return nil
}
开发者ID:bac,项目名称:juju,代码行数:31,代码来源:undertaker.go
示例6: ServerError
// ServerError returns an error suitable for returning to an API
// client, with an error code suitable for various kinds of errors
// generated in packages outside the API.
func ServerError(err error) *params.Error {
if err == nil {
return nil
}
logger.Tracef("server RPC error %v", errors.Details(err))
msg := err.Error()
// Skip past annotations when looking for the code.
err = errors.Cause(err)
code, ok := singletonCode(err)
var info *params.ErrorInfo
switch {
case ok:
case errors.IsUnauthorized(err):
code = params.CodeUnauthorized
case errors.IsNotFound(err):
code = params.CodeNotFound
case errors.IsUserNotFound(err):
code = params.CodeUserNotFound
case errors.IsAlreadyExists(err):
code = params.CodeAlreadyExists
case errors.IsNotAssigned(err):
code = params.CodeNotAssigned
case state.IsHasAssignedUnitsError(err):
code = params.CodeHasAssignedUnits
case state.IsHasHostedModelsError(err):
code = params.CodeHasHostedModels
case isNoAddressSetError(err):
code = params.CodeNoAddressSet
case errors.IsNotProvisioned(err):
code = params.CodeNotProvisioned
case IsUpgradeInProgressError(err):
code = params.CodeUpgradeInProgress
case state.IsHasAttachmentsError(err):
code = params.CodeMachineHasAttachedStorage
case isUnknownModelError(err):
code = params.CodeModelNotFound
case errors.IsNotSupported(err):
code = params.CodeNotSupported
case errors.IsBadRequest(err):
code = params.CodeBadRequest
case errors.IsMethodNotAllowed(err):
code = params.CodeMethodNotAllowed
default:
if err, ok := err.(*DischargeRequiredError); ok {
code = params.CodeDischargeRequired
info = ¶ms.ErrorInfo{
Macaroon: err.Macaroon,
// One macaroon fits all.
MacaroonPath: "/",
}
break
}
code = params.ErrCode(err)
}
return ¶ms.Error{
Message: msg,
Code: code,
Info: info,
}
}
开发者ID:bac,项目名称:juju,代码行数:63,代码来源:errors.go
示例7: releaseContainerAddresses
func releaseContainerAddresses(
api APICalls,
instanceID instance.Id,
namespace instance.Namespace,
log loggo.Logger,
) {
containerTag, err := namespace.MachineTag(string(instanceID))
if err != nil {
// Not a reason to cause StopInstances to fail though..
log.Warningf("unexpected container tag %q: %v", instanceID, err)
return
}
err = api.ReleaseContainerAddresses(containerTag)
switch {
case err == nil:
log.Infof("released all addresses for container %q", containerTag.Id())
case errors.IsNotSupported(err):
log.Warningf("not releasing all addresses for container %q: %v", containerTag.Id(), err)
default:
log.Warningf(
"unexpected error trying to release container %q addreses: %v",
containerTag.Id(), err,
)
}
}
开发者ID:bac,项目名称:juju,代码行数:25,代码来源:broker.go
示例8: StorageProviderTypes
// StorageProviderTypes implements storage.ProviderRegistry.
func (env *Environ) StorageProviderTypes() ([]storage.ProviderType, error) {
var types []storage.ProviderType
if _, err := env.cinderProvider(); err == nil {
types = append(types, CinderProviderType)
} else if !errors.IsNotSupported(err) {
return nil, errors.Trace(err)
}
return types, nil
}
开发者ID:bac,项目名称:juju,代码行数:10,代码来源:cinder.go
示例9: SupportsSpaces
// SupportsSpaces checks if the environment implements NetworkingEnviron
// and also if it supports spaces.
func SupportsSpaces(env Environ) bool {
netEnv, ok := supportsNetworking(env)
if !ok {
return false
}
ok, err := netEnv.SupportsSpaces()
if err != nil {
if !errors.IsNotSupported(err) {
logger.Errorf("checking model spaces support failed with: %v", err)
}
return false
}
return ok
}
开发者ID:bac,项目名称:juju,代码行数:16,代码来源:networking.go
示例10: AddAvailabilityZoneToInstanceData
// AddAvailabilityZoneToInstanceData sets the AvailZone field on
// instanceData docs that don't have it already.
func AddAvailabilityZoneToInstanceData(st *State, azFunc func(*State, instance.Id) (string, error)) error {
err := st.ResumeTransactions()
if err != nil {
return errors.Trace(err)
}
instDatas, closer := st.getRawCollection(instanceDataC)
defer closer()
var ops []txn.Op
// Using bson.M instead of a struct is important because we need to
// know if the "availzone" key is set on the raw doc.
var doc bson.M
iter := instDatas.Find(nil).Iter()
defer iter.Close()
for iter.Next(&doc) {
zone, ok := doc["availzone"]
if ok || ParentId(doc["machineid"].(string)) != "" {
continue
}
zone, err := azFunc(st, instance.Id(doc["instanceid"].(string)))
if err != nil {
if errors.IsNotFound(err) {
continue
}
if !errors.IsNotSupported(err) {
return errors.Trace(err)
}
zone = ""
}
// Set AvailZone.
ops = append(ops, txn.Op{
C: instanceDataC,
Id: doc["_id"].(string),
Assert: txn.DocExists,
Update: bson.D{
{"$set", bson.D{{"availzone", zone}}},
},
})
}
if err = iter.Err(); err != nil {
return errors.Trace(err)
}
err = st.runTransaction(ops)
return errors.Trace(err)
}
开发者ID:vonwenm,项目名称:juju,代码行数:51,代码来源:upgrades.go
示例11: Addresses
func (mi *maasInstance) Addresses() ([]network.Address, error) {
interfaceAddresses, err := mi.interfaceAddresses()
if errors.IsNotSupported(err) {
logger.Warningf(
"using legacy approach to get instance addresses as %q API capability is not supported: %v",
capNetworkDeploymentUbuntu, err,
)
return mi.legacyAddresses()
} else if err != nil {
return nil, errors.Annotate(err, "getting node interfaces")
}
logger.Debugf("instance %q has interface addresses: %+v", mi.Id(), interfaceAddresses)
return interfaceAddresses, nil
}
开发者ID:OSBI,项目名称:juju,代码行数:15,代码来源:instance.go
示例12: TestUpgradeStepsStateServer
func (s *UpgradeSuite) TestUpgradeStepsStateServer(c *gc.C) {
coretesting.SkipIfI386(c, "lp:1444576")
coretesting.SkipIfPPC64EL(c, "lp:1444576")
coretesting.SkipIfWindowsBug(c, "lp:1446885")
s.setInstantRetryStrategy(c)
// Upload tools to provider storage, so they can be migrated to environment storage.
stor, err := environs.LegacyStorage(s.State)
if !errors.IsNotSupported(err) {
c.Assert(err, jc.ErrorIsNil)
envtesting.AssertUploadFakeToolsVersions(
c, stor, "releases", s.Environ.Config().AgentStream(), s.oldVersion)
}
s.assertUpgradeSteps(c, state.JobManageEnviron)
s.assertStateServerUpgrades(c)
}
开发者ID:snailwalker,项目名称:juju,代码行数:15,代码来源:upgrade_test.go
示例13: environmentDataSources
// environmentDataSources returns simplestreams datasources for the environment
// by calling the functions registered in RegisterImageDataSourceFunc.
// The datasources returned will be in the same order the functions were registered.
func environmentDataSources(env Environ) ([]simplestreams.DataSource, error) {
datasourceFuncsMu.RLock()
defer datasourceFuncsMu.RUnlock()
var datasources []simplestreams.DataSource
for _, f := range datasourceFuncs {
datasource, err := f.f(env)
if err != nil {
if errors.IsNotSupported(err) {
continue
}
return nil, err
}
datasources = append(datasources, datasource)
}
return datasources, nil
}
开发者ID:pmatulis,项目名称:juju,代码行数:19,代码来源:imagemetadata.go
示例14: environmentDataSources
// environmentDataSources returns simplestreams datasources for the environment
// by calling the functions registered in RegisterToolsDataSourceFunc.
// The datasources returned will be in the same order the functions were registered.
func environmentDataSources(env environs.Environ) ([]simplestreams.DataSource, error) {
toolsDatasourceFuncsMu.RLock()
defer toolsDatasourceFuncsMu.RUnlock()
var datasources []simplestreams.DataSource
for _, f := range toolsDatasourceFuncs {
logger.Debugf("trying datasource %q", f.id)
datasource, err := f.f(env)
if err != nil {
if errors.IsNotSupported(err) {
continue
}
return nil, err
}
datasources = append(datasources, datasource)
}
return datasources, nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:20,代码来源:urls.go
示例15: Run
// Run retrieves the debug log via the API.
func (c *DebugLogCommand) Run(ctx *cmd.Context) (err error) {
client, err := getDebugLogAPI(c.EnvName)
if err != nil {
return err
}
defer client.Close()
debugLog, err := client.WatchDebugLog(c.params)
if err != nil {
if errors.IsNotSupported(err) {
return c.watchDebugLog1dot18(ctx)
}
return err
}
defer debugLog.Close()
_, err = io.Copy(ctx.Stdout, debugLog)
return err
}
开发者ID:rogpeppe,项目名称:juju,代码行数:18,代码来源:debuglog.go
示例16: migrateCustomImageMetadata
// migrateCustomImageMetadata copies uploaded image metadata from provider
// storage to environment storage, preserving paths.
func migrateCustomImageMetadata(st *state.State, agentConfig agent.Config) error {
logger.Debugf("migrating custom image metadata to environment storage")
estor := newStateStorage(st.EnvironUUID(), st.MongoSession())
// Local and manual provider host storage on the state server's
// filesystem, and serve via HTTP storage. The storage worker
// doesn't run yet, so we just open the files directly.
var pstor storage.StorageReader
providerType := agentConfig.Value(agent.ProviderType)
if providerType == provider.Local || provider.IsManual(providerType) {
storageDir := agentConfig.Value(agent.StorageDir)
var err error
pstor, err = filestorage.NewFileStorageReader(storageDir)
if err != nil {
return errors.Annotate(err, "cannot get local filesystem storage reader")
}
} else {
var err error
pstor, err = environs.LegacyStorage(st)
if errors.IsNotSupported(err) {
return nil
} else if err != nil {
return errors.Annotate(err, "cannot get provider storage")
}
}
paths, err := pstor.List(storage.BaseImagesPath)
if err != nil {
return err
}
for _, path := range paths {
logger.Infof("migrating image metadata at path %q", path)
data, err := readImageMetadata(pstor, path)
if err != nil {
return errors.Annotate(err, "failed to read image metadata")
}
err = estor.Put(path, bytes.NewReader(data), int64(len(data)))
if err != nil {
return errors.Annotate(err, "failed to write image metadata")
}
}
return nil
}
开发者ID:Pankov404,项目名称:juju,代码行数:45,代码来源:customimagemetadata.go
示例17: getNetworkingEnviron
// getNetworkingEnviron checks if the environment implements NetworkingEnviron
// and also if it supports IP address allocation.
func (api *AddresserAPI) getNetworkingEnviron() (environs.NetworkingEnviron, bool, error) {
config, err := api.st.EnvironConfig()
if err != nil {
return nil, false, errors.Annotate(err, "getting environment config")
}
env, err := environs.New(config)
if err != nil {
return nil, false, errors.Annotate(err, "validating environment config")
}
netEnv, ok := environs.SupportsNetworking(env)
if !ok {
return nil, false, nil
}
ok, err = netEnv.SupportsAddressAllocation(network.AnySubnet)
if err != nil && !errors.IsNotSupported(err) {
return nil, false, errors.Annotate(err, "checking allocation support")
}
return netEnv, ok, nil
}
开发者ID:felicianotech,项目名称:juju,代码行数:21,代码来源:addresser.go
示例18: ServerError
// ServerError returns an error suitable for returning to an API
// client, with an error code suitable for various kinds of errors
// generated in packages outside the API.
func ServerError(err error) *params.Error {
if err == nil {
return nil
}
msg := err.Error()
// Skip past annotations when looking for the code.
err = errors.Cause(err)
code, ok := singletonCode(err)
switch {
case ok:
case errors.IsUnauthorized(err):
code = params.CodeUnauthorized
case errors.IsNotFound(err):
code = params.CodeNotFound
case errors.IsAlreadyExists(err):
code = params.CodeAlreadyExists
case errors.IsNotAssigned(err):
code = params.CodeNotAssigned
case state.IsHasAssignedUnitsError(err):
code = params.CodeHasAssignedUnits
case IsNoAddressSetError(err):
code = params.CodeNoAddressSet
case errors.IsNotProvisioned(err):
code = params.CodeNotProvisioned
case state.IsUpgradeInProgressError(err):
code = params.CodeUpgradeInProgress
case state.IsHasAttachmentsError(err):
code = params.CodeMachineHasAttachedStorage
case IsUnknownEnviromentError(err):
code = params.CodeNotFound
case errors.IsNotSupported(err):
code = params.CodeNotSupported
default:
code = params.ErrCode(err)
}
return ¶ms.Error{
Message: msg,
Code: code,
}
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:43,代码来源:errors.go
示例19: SupportsSpaces
// SupportsSpaces checks if the environment implements NetworkingEnviron
// and also if it supports spaces.
func SupportsSpaces(backing NetworkBacking) error {
config, err := backing.ModelConfig()
if err != nil {
return errors.Annotate(err, "getting model config")
}
env, err := environs.New(config)
if err != nil {
return errors.Annotate(err, "validating model config")
}
netEnv, ok := environs.SupportsNetworking(env)
if !ok {
return errors.NotSupportedf("networking")
}
ok, err = netEnv.SupportsSpaces()
if !ok {
if err != nil && !errors.IsNotSupported(err) {
logger.Warningf("checking model spaces support failed with: %v", err)
}
return errors.NotSupportedf("spaces")
}
return nil
}
开发者ID:OSBI,项目名称:juju,代码行数:24,代码来源:spaces.go
示例20: destroyControllerManagedEnvirons
// destroyControllerManagedEnvirons destroys all environments managed by this
// environment's controller.
func (e *Environ) destroyControllerManagedEnvirons() error {
// Terminate all instances managed by the controller.
insts, err := e.allControllerManagedInstances(nil, false)
if err != nil {
return errors.Annotate(err, "listing instances")
}
instIds := make([]instance.Id, len(insts))
for i, inst := range insts {
instIds[i] = inst.Id()
}
if err := e.terminateInstances(instIds); err != nil {
return errors.Annotate(err, "terminating instances")
}
// Delete all volumes managed by the controller.
cfg := e.Config()
storageAdapter, err := newOpenstackStorageAdapter(cfg)
if err == nil {
volIds, err := allControllerManagedVolumes(storageAdapter, cfg.ControllerUUID())
if err != nil {
return errors.Annotate(err, "listing volumes")
}
errs := destroyVolumes(storageAdapter, volIds)
for i, err := range errs {
if err == nil {
continue
}
return errors.Annotatef(err, "destroying volume %q", volIds[i], err)
}
} else if !errors.IsNotSupported(err) {
return errors.Trace(err)
}
// Security groups for hosted models are destroyed by the
// DeleteAllGroups method call from Destroy().
return nil
}
开发者ID:xushiwei,项目名称:juju,代码行数:39,代码来源:provider.go
注:本文中的github.com/juju/errors.IsNotSupported函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论