github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/apiserver/restrict_restore.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package apiserver 5 6 import ( 7 "github.com/juju/errors" 8 "github.com/juju/utils/set" 9 ) 10 11 var aboutToRestoreError = errors.New("juju restore is in progress - functionality is limited to avoid data loss") 12 var restoreInProgressError = errors.New("juju restore is in progress - API is disabled to prevent data loss") 13 14 // aboutToRestoreMethodsOnly can be used with restrictRoot to restrict 15 // the API to the methods allowed when the server is in 16 // state.RestorePreparing mode. 17 func aboutToRestoreMethodsOnly(facadeName string, methodName string) error { 18 fullName := facadeName + "." + methodName 19 if !allowedMethodsAboutToRestore.Contains(fullName) { 20 return aboutToRestoreError 21 } 22 return nil 23 } 24 25 var allowedMethodsAboutToRestore = set.NewStrings( 26 "Client.FullStatus", // for "juju status" 27 "Client.ModelGet", // for "juju ssh" 28 "Client.PrivateAddress", // for "juju ssh" 29 "Client.PublicAddress", // for "juju ssh" 30 "Client.WatchDebugLog", // for "juju debug-log" 31 "Backups.Restore", // for "juju backups restore" 32 "Backups.FinishRestore", // for "juju backups restore" 33 "Bundle.GetChanges", // for retrieving bundle changes 34 "Pinger.Ping", // for connection health checks 35 )