@@ -4,10 +4,17 @@ import (
4
4
"fmt"
5
5
"strings"
6
6
7
+ "github.com/airdb/adb/internal/adblib"
7
8
"github.com/airdb/sailor"
8
9
"github.com/airdb/sailor/osutil"
9
10
"github.com/aliyun/alibaba-cloud-sdk-go/services/alidns"
10
11
"github.com/spf13/cobra"
12
+ "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
13
+ "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
14
+ "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
15
+ "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/regions"
16
+ cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312"
17
+ lh "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/lighthouse/v20200324"
11
18
)
12
19
13
20
var hostCmd = & cobra.Command {
@@ -60,10 +67,68 @@ var hostListCmd = &cobra.Command{
60
67
DisableFlagParsing : true ,
61
68
Run : func (cmd * cobra.Command , args []string ) {
62
69
host ()
70
+ hostDNS ()
63
71
},
64
72
}
65
73
66
74
func host () {
75
+ getLightHouse (regions .Singapore )
76
+ getHostByRegion (regions .Shanghai )
77
+ getHostByRegion (regions .Singapore )
78
+ getHostByRegion (regions .Nanjing )
79
+ }
80
+
81
+ func getHostByRegion (region string ) {
82
+ credential := common .NewCredential (adblib .AdbConfig .TencentyunAccessKeyID , adblib .AdbConfig .TencentyunAccessKeySecret )
83
+ client , _ := cvm .NewClient (credential , region , profile .NewClientProfile ())
84
+
85
+ request := cvm .NewDescribeInstancesRequest ()
86
+ output , err := client .DescribeInstances (request )
87
+
88
+ if _ , ok := err .(* errors.TencentCloudSDKError ); ok {
89
+ fmt .Printf ("An API error has returned: %s" , err )
90
+
91
+ return
92
+ }
93
+
94
+ for _ , instance := range output .Response .InstanceSet {
95
+ fmt .Printf ("%s\t %s\t %s\t %s\t %s\t %s\n " ,
96
+ * instance .InstanceId ,
97
+ * instance .ExpiredTime ,
98
+ region ,
99
+ * instance .InstanceName ,
100
+ * instance .PublicIpAddresses [0 ],
101
+ * instance .PrivateIpAddresses [0 ],
102
+ )
103
+ }
104
+ }
105
+
106
+ func getLightHouse (region string ) {
107
+ credential := common .NewCredential (adblib .AdbConfig .TencentyunAccessKeyID , adblib .AdbConfig .TencentyunAccessKeySecret )
108
+ client , _ := lh .NewClient (credential , region , profile .NewClientProfile ())
109
+
110
+ request := lh .NewDescribeInstancesRequest ()
111
+ output , err := client .DescribeInstances (request )
112
+
113
+ if _ , ok := err .(* errors.TencentCloudSDKError ); ok {
114
+ fmt .Printf ("An API error has returned: %s" , err )
115
+
116
+ return
117
+ }
118
+
119
+ for _ , instance := range output .Response .InstanceSet {
120
+ fmt .Printf ("%s\t %s\t %s\t %s\t %s\t %s\n " ,
121
+ * instance .InstanceId ,
122
+ * instance .ExpiredTime ,
123
+ region ,
124
+ * instance .InstanceName ,
125
+ * instance .PublicAddresses [0 ],
126
+ * instance .PrivateAddresses [0 ],
127
+ )
128
+ }
129
+ }
130
+
131
+ func hostDNS () {
67
132
client , err := aliyunConfigInit ()
68
133
if err != nil {
69
134
panic (err )
0 commit comments