yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/ctyun/shell/instance.go (about) 1 // Copyright 2019 Yunion 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package shell 16 17 import ( 18 "yunion.io/x/cloudmux/pkg/multicloud/ctyun" 19 "yunion.io/x/onecloud/pkg/util/shellutils" 20 ) 21 22 func init() { 23 type InstanceListOptions struct { 24 Id string `help:"ID of instance to show"` 25 } 26 shellutils.R(&InstanceListOptions{}, "instance-list", "List intances", func(cli *ctyun.SRegion, args *InstanceListOptions) error { 27 instances, e := cli.GetInstances(args.Id) 28 if e != nil { 29 return e 30 } 31 printList(instances, 0, 0, 0, []string{}) 32 return nil 33 }) 34 35 type InstanceCreateOptions struct { 36 ZoneId string `help:"zone ID of instance"` 37 NAME string `help:"name of instance"` 38 ADMINPASS string `help:"admin password of instance"` 39 ImageId string `help:"image Id of instance"` 40 OsType string `help:"Os type of image"` 41 VolumeType string `help:"volume type of instance"` 42 VolumeSize int `help:"volume size(GB) of instance"` 43 Flavor string `help:"Flavor of instance"` 44 VpcId string `help:"Vpc of instance"` 45 SubnetId string `help:"subnet Id of instance"` 46 SecGroupId string `help:"security group Id of instance"` 47 } 48 49 shellutils.R(&InstanceCreateOptions{}, "instance-create", "Create intance", func(cli *ctyun.SRegion, args *InstanceCreateOptions) error { 50 _, e := cli.CreateInstance(args.ZoneId, args.NAME, args.ImageId, args.OsType, args.Flavor, args.VpcId, args.SubnetId, args.SecGroupId, args.ADMINPASS, args.VolumeType, args.VolumeSize, nil) 51 if e != nil { 52 return e 53 } 54 55 return nil 56 }) 57 }