yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/hcso/shell/modelarts.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/cloudmux/pkg/cloudprovider"
    20  	huawei "yunion.io/x/cloudmux/pkg/multicloud/hcso"
    21  	"yunion.io/x/onecloud/pkg/util/shellutils"
    22  )
    23  
    24  func init() {
    25  	type ModelartsPoolListOption struct {
    26  		PoolId string `help:"Pool Id"`
    27  	}
    28  
    29  	shellutils.R(&ModelartsPoolListOption{}, "modelarts-pool-list", "List Modelarts Pool", func(cli *huawei.SRegion, args *ModelartsPoolListOption) error {
    30  		pools, err := cli.GetIModelartsPools()
    31  		if err != nil {
    32  			return err
    33  		}
    34  		printList(pools, len(pools), 0, 0, nil)
    35  		return nil
    36  	})
    37  
    38  	shellutils.R(&ModelartsPoolListOption{}, "modelarts-pool-detail", "List pool", func(cli *huawei.SRegion, args *ModelartsPoolListOption) error {
    39  		pool, err := cli.GetIModelartsPoolById(args.PoolId)
    40  		if err != nil {
    41  			return err
    42  		}
    43  		printObject(pool)
    44  		return nil
    45  	})
    46  
    47  	shellutils.R(&cloudprovider.ModelartsPoolCreateOption{}, "modelarts-pool-create", "Create Modelarts Pool", func(cli *huawei.SRegion, args *cloudprovider.ModelartsPoolCreateOption) error {
    48  		res, err := cli.CreateIModelartsPool(args)
    49  		if err != nil {
    50  			return err
    51  		}
    52  		printObject(res)
    53  		return nil
    54  	})
    55  
    56  	shellutils.R(&ModelartsPoolListOption{}, "modelarts-pool-delete", "Delete Modelarts Pool", func(cli *huawei.SRegion, args *ModelartsPoolListOption) error {
    57  		res, err := cli.DeletePool(args.PoolId)
    58  		if err != nil {
    59  			return err
    60  		}
    61  		printObject(res)
    62  		return nil
    63  	})
    64  
    65  	shellutils.R(&ModelartsPoolListOption{}, "modelarts-pool-monitor", "Modelarts Pool Monitor", func(cli *huawei.SRegion, args *ModelartsPoolListOption) error {
    66  		res, err := cli.MonitorPool(args.PoolId)
    67  		if err != nil {
    68  			return err
    69  		}
    70  		printList(res.Metrics, len(res.Metrics), 0, 0, nil)
    71  		return nil
    72  	})
    73  
    74  	shellutils.R(&ModelartsPoolListOption{}, "modelarts-pool-by-id", "Modelarts Pool By Id", func(cli *huawei.SRegion, args *ModelartsPoolListOption) error {
    75  		res, err := cli.GetIModelartsPoolById(args.PoolId)
    76  		if err != nil {
    77  			return err
    78  		}
    79  		printObject(res)
    80  		return nil
    81  	})
    82  }