Skip to content

Commit

Permalink
更新使用说明
Browse files Browse the repository at this point in the history
  • Loading branch information
iiiusky committed Oct 27, 2020
1 parent 9204a2e commit ce67e2b
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 10 deletions.
46 changes: 36 additions & 10 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,75 @@
# 使用方式

```
该工具主要是方便快速使用阿里云api执行一些操作
Usage:
AliCloud-Tools [flags]
AliCloud-Tools [command]
Available Commands:
ecs ECS 操作(查询/执行命令),当前命令支持地域ID设置.
help Help about any command
sg 安全组操作,当前命令支持地域ID设置.
Flags:
-a, --ak string 阿里云 AccessKey
-h, --help help for AliCloud-Tools
--regions 显示所有地域信息
-r, --rid string 阿里云 地域ID,在其他支持rid的子命令中,如果设置了地域ID,则只显示指定区域的信息,否则为全部.
-s, --sk string 阿里云 SecretKey
```

## 查看所有地域信息
```
./AliCloud-Tools -a <AccessKey> -s <SecretKey> --regions
```
![regions](./img/regions.jpg)
## 查看所有实例信息
```
./AliCloud-Tools -a <AccessKey> -s <SecretKey> ecs --list
```
![list-1](./img/list-1.png)
![list-2](./img/list-2.png)


## 查看所有正在运行的实例信息
```
./AliCloud-Tools -a <AccessKey> -s <SecretKey> ecs --list --runner
```

![list-1](./img/list-1.png)
![list-2](./img/list-2.png)
## 查看指定实例的信息
```
./AliCloud-Tools -a <AccessKey> -s <SecretKey> ecs --eid <InstanceId>
./AliCloud-Tools -a <AccessKey> -s <SecretKey> [-r <regionId>] ecs --eid <InstanceId>
```
![instance-info](./img/instance-info.png)

## 执行命令
```
./AliCloud-Tools -a <AccessKey> -s <SecretKey> ecs exec -I <InstanceId[,InstanceId,InstanceId,...]> -c "touch /tmp/123123aaaa.txt"
./AliCloud-Tools -a <AccessKey> -s <SecretKey> [-r <regionId>] ecs exec -I <InstanceId[,InstanceId,InstanceId,...]> -c "touch /tmp/123123aaaa.txt"
```
![exec](./img/exec.jpg)
![exec-result](./img/exec-result.png)

## 查看安全组策略
```
./AliCloud-Tools -a <AccessKey> -s <SecretKey> sg --eid <SecruityGroupId>
./AliCloud-Tools -a <AccessKey> -s <SecretKey> -r <regionId> sg --eid <SecruityGroupId>
```
![sg-info](./img/sg-info.png)

## 增加安全组策略
```
./AliCloud-Tools -a <AccessKey> -s <SecretKey> --eid <SecruityGroupId> --action add --protocol tcp --port 0/0 --ip 0.0.0.0/0
./AliCloud-Tools -a <AccessKey> -s <SecretKey> -r <regionId> --eid <SecruityGroupId> --action add --protocol tcp --port 0/0 --ip 0.0.0.0/0
```
![sg-add](./img/sg-add.png)

## 删除安全组策略
```
./AliCloud-Tools -a <AccessKey> -s <SecretKey> --eid <SecruityGroupId> --action del --protocol tcp --port 0/0 --ip 0.0.0.0/0
./AliCloud-Tools -a <AccessKey> -s <SecretKey> -r <regionId> --eid <SecruityGroupId> --action del --protocol tcp --port 0/0 --ip 0.0.0.0/0
```
![sg-del](./img/sg-del.png)
36 changes: 36 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
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 cmd

import (
"alicloud-tools/common"
"fmt"

"github.com/spf13/cobra"
)

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Long: `显示版本.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Version is:%s \n", common.APPVersion)
},
}

func init() {
rootCmd.AddCommand(versionCmd)
}
Binary file added img/exec-result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/exec.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/instance-info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/list-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/list-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/regions.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/sg-add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/sg-del.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/sg-info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ce67e2b

Please sign in to comment.