yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/huawei/shell/modelarts_pool.go (about) 1 // @@ -0,0 +1,46 @@ 2 // Copyright 2019 Yunion 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 package shell 17 18 import ( 19 "yunion.io/x/log" 20 21 "yunion.io/x/cloudmux/pkg/cloudprovider" 22 "yunion.io/x/cloudmux/pkg/multicloud/huawei" 23 "yunion.io/x/onecloud/pkg/util/shellutils" 24 ) 25 26 func init() { 27 type ModelartsPoolListOption struct { 28 PoolId string `help:"Pool Id"` 29 } 30 31 shellutils.R(&ModelartsPoolListOption{}, "modelarts-pool-list", "List Modelarts Pool", func(cli *huawei.SRegion, args *ModelartsPoolListOption) error { 32 pools, err := cli.GetIModelartsPools() 33 if err != nil { 34 return err 35 } 36 printList(pools, len(pools), 0, 0, nil) 37 return nil 38 }) 39 40 shellutils.R(&ModelartsPoolListOption{}, "modelarts-pool-detail", "List pool", func(cli *huawei.SRegion, args *ModelartsPoolListOption) error { 41 pools, err := cli.GetIModelartsPoolById(args.PoolId) 42 if err != nil { 43 return err 44 } 45 log.Infoln(pools) 46 return nil 47 }) 48 49 shellutils.R(&cloudprovider.ModelartsPoolCreateOption{}, "modelarts-pool-create", "Create Modelarts Pool", func(cli *huawei.SRegion, args *cloudprovider.ModelartsPoolCreateOption) error { 50 res, err := cli.CreateIModelartsPool(args) 51 if err != nil { 52 return err 53 } 54 // printList(pools, len(pools), 0, 0, nil) 55 log.Infoln("this is res:", res) 56 return nil 57 }) 58 59 shellutils.R(&ModelartsPoolListOption{}, "modelarts-pool-delete", "Delete Modelarts Pool", func(cli *huawei.SRegion, args *ModelartsPoolListOption) error { 60 res, err := cli.DeletePool(args.PoolId) 61 if err != nil { 62 return err 63 } 64 // printList(pools, len(pools), 0, 0, nil) 65 log.Infoln("this is res:", res) 66 return nil 67 }) 68 69 shellutils.R(&ModelartsPoolListOption{}, "modelarts-pool-monitor", "Delete Modelarts Pool", func(cli *huawei.SRegion, args *ModelartsPoolListOption) error { 70 res, err := cli.MonitorPool(args.PoolId) 71 if err != nil { 72 return err 73 } 74 // log.Println("this is res:", res) 75 printList(res.Metrics, len(res.Metrics), 0, 0, nil) 76 return nil 77 }) 78 }