mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
fix: host nics api (#18184)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/httputils"
|
||||
"yunion.io/x/pkg/util/printutils"
|
||||
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -69,6 +70,23 @@ func init() {
|
||||
cmd.Get("vnc", &options.BaseIdOptions{})
|
||||
cmd.Get("app-options", &options.BaseIdOptions{})
|
||||
cmd.Get("tap-config", &options.BaseIdOptions{})
|
||||
cmd.GetWithCustomShow("nics", func(data jsonutils.JSONObject) {
|
||||
results := printutils.ListResult{}
|
||||
err := data.Unmarshal(&results)
|
||||
if err == nil {
|
||||
printutils.PrintJSONList(&results, []string{
|
||||
"mac",
|
||||
"vlan_id",
|
||||
"interface",
|
||||
"bridge",
|
||||
"ip_addr",
|
||||
"net",
|
||||
"wire",
|
||||
})
|
||||
} else {
|
||||
fmt.Println("error", err)
|
||||
}
|
||||
}, &options.BaseIdOptions{})
|
||||
|
||||
R(&options.BaseIdOptions{}, "host-logininfo", "Get SSH login information of a host", func(s *mcclient.ClientSession, args *options.BaseIdOptions) error {
|
||||
i, e := modules.Hosts.PerformAction(s, args.ID, "login_info", nil)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/util/printutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
func (h *SHost) GetDetailsNics(ctx context.Context, userCred mcclient.TokenCredential, input jsonutils.JSONObject) (*printutils.ListResult, error) {
|
||||
ret := &printutils.ListResult{}
|
||||
nics := h.GetNics()
|
||||
for i := range nics {
|
||||
ret.Data = append(ret.Data, jsonutils.Marshal(nics[i]))
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
Reference in New Issue
Block a user