|
@@ -1,6 +1,8 @@
|
|
|
-/**
|
|
|
+/*
|
|
|
+*
|
|
|
阿里云ecs实例自动申请、部署、释放
|
|
|
-**/
|
|
|
+*
|
|
|
+*/
|
|
|
package vps
|
|
|
|
|
|
import (
|
|
@@ -28,7 +30,7 @@ const (
|
|
|
URL = "https://ecs.aliyuncs.com"
|
|
|
)
|
|
|
|
|
|
-//批量创建实例
|
|
|
+// 批量创建实例
|
|
|
func RunInstances(name, image, region, zoneid, launchTemplateId string, public bool, num, hours int, ok *bool) {
|
|
|
defer qu.Catch()
|
|
|
widthOut := "0"
|
|
@@ -59,7 +61,7 @@ func runInstances(name, widthOut, region, zoneid, launchTemplateId, imageId stri
|
|
|
applyOk := false
|
|
|
qu.Debug(launchTemplateId)
|
|
|
if hours == 0 { //表示无期限
|
|
|
- hours = 24 * 365 * 3 //阿里竞价服务器最长申请3年
|
|
|
+ hours = 24 * 365 * 1 //阿里竞价服务器最长申请3年
|
|
|
}
|
|
|
autoReleaseTime := time.Now().Add(time.Duration(hours) * time.Hour).UTC().Format("2006-01-02T15:04:05Z")
|
|
|
param := [][]string{
|
|
@@ -107,7 +109,7 @@ func runInstances(name, widthOut, region, zoneid, launchTemplateId, imageId stri
|
|
|
return applyOk
|
|
|
}
|
|
|
|
|
|
-//查询多台实例的详细信息
|
|
|
+// 查询多台实例的详细信息
|
|
|
func DescribeInstances(ok *bool) {
|
|
|
for regionid, _ := range VpsConfig.Regions {
|
|
|
qu.Debug("regionid:", regionid)
|
|
@@ -143,7 +145,7 @@ func DescribeInstances(ok *bool) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//停止实例
|
|
|
+// 停止实例
|
|
|
func StopInstance(InstanceId string) {
|
|
|
res := GET("StopInstance", [][]string{
|
|
|
[]string{"InstanceId", InstanceId},
|
|
@@ -152,7 +154,7 @@ func StopInstance(InstanceId string) {
|
|
|
log.Println("StopInstance", res)
|
|
|
}
|
|
|
|
|
|
-//释放实例
|
|
|
+// 释放实例
|
|
|
func DeleteInstance(InstanceId string, ok *bool) {
|
|
|
res := GET("DeleteInstance", [][]string{
|
|
|
[]string{"InstanceId", InstanceId},
|
|
@@ -164,7 +166,7 @@ func DeleteInstance(InstanceId string, ok *bool) {
|
|
|
qu.Debug("DeleteInstance", res)
|
|
|
}
|
|
|
|
|
|
-//实例自动释放时间
|
|
|
+// 实例自动释放时间
|
|
|
func ModifyInstanceAutoReleaseTime(InstanceId, regionId string, hours int, ok *bool) {
|
|
|
qu.Debug(VpsConfig.AccessId, time.Now().Add(time.Duration(hours)*time.Hour).UTC().Format("2006-01-02T15:04:05Z"))
|
|
|
res := GET("ModifyInstanceAutoReleaseTime", [][]string{
|
|
@@ -176,7 +178,7 @@ func ModifyInstanceAutoReleaseTime(InstanceId, regionId string, hours int, ok *b
|
|
|
qu.Debug("ModifyInstanceAutoReleaseTime", res)
|
|
|
}
|
|
|
|
|
|
-//GET请求
|
|
|
+// GET请求
|
|
|
func GET(action string, param [][]string) (mres map[string]interface{}) {
|
|
|
ps := ¶mSorter{[]string{
|
|
|
"Format",
|