Merge pull request #447 in YUNIONIO/onecloud from ~QIUJIAN/onecloud:hotfix/qj-policy-admin-capable-test to release/2.3.0

* commit 'dbab380d734d0de1684f5cb4472869d5d981d773':
  增加climc policy-admin-capable命令
This commit is contained in:
邱剑
2018-11-10 15:30:57 +08:00
2 changed files with 16 additions and 2 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)
}
}