增加climc policy-admin-capable命令

This commit is contained in:
Qiu Jian
2018-11-09 15:52:46 +08:00
parent f98c3275ba
commit dbab380d73
3 changed files with 18 additions and 4 deletions
+12
View File
@@ -184,6 +184,18 @@ func init() {
return nil
})
type PolicyAdminCapableOptions struct {
}
R(&PolicyAdminCapableOptions{}, "policy-admin-capable", "Check admin capable", func(s *mcclient.ClientSession, args *PolicyAdminCapableOptions) error {
auth.InitFromClientSession(s)
policy.EnableGlobalRbac(15*time.Second, 15*time.Second)
capable := policy.PolicyManager.IsAdminCapable(s.GetToken())
fmt.Printf("%v\n", capable)
return nil
})
type PolicyExplainOptions struct {
Request []string `help:"explain request, in format of key:is_admin:service:resource:action:extra"`
}
+4 -2
View File
@@ -6,6 +6,8 @@ import (
)
func EnableGlobalRbac(refreshInterval time.Duration, retryInterval time.Duration) {
consts.EnableRbac()
PolicyManager.start(refreshInterval, retryInterval)
if !consts.IsRbacEnabled() {
consts.EnableRbac()
PolicyManager.start(refreshInterval, retryInterval)
}
}
+2 -2
View File
@@ -200,8 +200,8 @@ type TaskManager struct {
func NewTaskManager(stopCh <-chan struct{}) *TaskManager {
return &TaskManager{
taskExecutorQueueManager: NewTaskExecutorQueueManager(stopCh),
stopCh: stopCh,
lock: sync.Mutex{},
stopCh: stopCh,
lock: sync.Mutex{},
}
}