webterm init

This commit is contained in:
Zexi Li
2018-09-04 18:44:52 +08:00
parent 031ed3a3e8
commit a6736da35e
16 changed files with 955 additions and 1 deletions
+19
View File
@@ -3,6 +3,8 @@ package k8s
import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules/k8s"
)
@@ -28,6 +30,23 @@ func initPod() {
return nil
})
type getOpt struct {
resourceGetOptions
}
R(&getOpt{}, cmdN("show"), "Get pod details", func(s *mcclient.ClientSession, args *getOpt) error {
id := args.NAME
params := args.ClusterParams()
if args.Namespace != "" {
params.Add(jsonutils.NewString(args.Namespace), "namespace")
}
ret, err := k8s.Pods.Get(s, id, params)
if err != nil {
return err
}
printObjectYAML(ret)
return nil
})
type deleteOpt struct {
resourceGetOptions
}
+35
View File
@@ -0,0 +1,35 @@
package shell
import (
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules"
o "yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
R(&o.PodShellOptions{}, "webconsole-k8s-pod", "Show TTY console of given pod", func(s *mcclient.ClientSession, args *o.PodShellOptions) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := modules.WebConsole.DoK8sShellConnect(s, args.NAME, params)
if err != nil {
return err
}
printObject(ret)
return nil
})
R(&o.PodLogOptoins{}, "webconsole-k8s-pod-log", "Get logs of given pod", func(s *mcclient.ClientSession, args *o.PodLogOptoins) error {
params, err := args.Params()
if err != nil {
return err
}
ret, err := modules.WebConsole.DoK8sLogConnect(s, args.NAME, params)
if err != nil {
return err
}
printObject(ret)
return nil
})
}
+9
View File
@@ -0,0 +1,9 @@
package main
import (
"yunion.io/x/onecloud/pkg/webconsole/service"
)
func main() {
service.StartService()
}