|
@@ -15,6 +15,8 @@ from aliyunsdkcore.acs_exception.exceptions import ClientException
|
|
|
from aliyunsdkcore.acs_exception.exceptions import ServerException
|
|
|
from aliyunsdkalidns.request.v20150109.AddDomainRecordRequest import AddDomainRecordRequest
|
|
|
from aliyunsdkalidns.request.v20150109.DeleteDomainRecordRequest import DeleteDomainRecordRequest
|
|
|
+from aliyunsdkalidns.request.v20150109.DescribeDomainRecordsRequest import DescribeDomainRecordsRequest
|
|
|
+
|
|
|
|
|
|
|
|
|
JNLP_ENV = os.getenv('JNLP_ENV')
|
|
@@ -34,8 +36,9 @@ JNLP_SVC_MODE = os.getenv('JNLP_SVC_MODE')
|
|
|
NGINX_SVC = str(JNLP_ENV) + '/' + str(JNLP_CONTROL_NAME) + '-svc:' + str(JNLP_CONTAINER_PORT)
|
|
|
NGINX_PORT = os.getenv('JNLP_CONTAINER_PORT')
|
|
|
RECORD_NAME = os.getenv('JNLP_ENV') + "-" + os.getenv('DRONE_REPO_NAME')
|
|
|
-INGRESS_LIST = ["10.26.30.12", "10.26.29.54", "10.26.30.102", "10.26.30.13"]
|
|
|
-NGINX_RECORD_IP = random.sample(INGRESS_LIST, 1)[0]
|
|
|
+INGRESS_LIST_IN = ["10.26.30.12", "10.26.29.54", "10.26.30.102", "10.26.30.13"]
|
|
|
+INGRESS_LIST_PUB = ["120.192.70.173", "120.192.70.172", "140.249.25.89", "140.249.25.90"]
|
|
|
+NGINX_RECORD_IP = random.sample(INGRESS_LIST_PUB, 1)[0]
|
|
|
DOMAINNAME = os.getenv('JNLP_DOMAIN').strip('.')
|
|
|
|
|
|
|
|
@@ -50,7 +53,7 @@ def deployYamlCreate():
|
|
|
f1.writelines(tmpctl)
|
|
|
f1.close()
|
|
|
status,output = commands.getstatusoutput("sh tempshell.sh && rm -f tempshell.sh")
|
|
|
- print("code:" + str(status) + str(output) + "; create deploy.yaml success !!!")
|
|
|
+ print("code:" + str(status) + str(output) + "; create deploy.yaml success !!!")
|
|
|
return status,output
|
|
|
|
|
|
|
|
@@ -65,7 +68,7 @@ def DockerfileCreate():
|
|
|
f2.writelines(tmp)
|
|
|
f2.close()
|
|
|
status,output = commands.getstatusoutput("sh tmp.sh && rm -f tmp.sh")
|
|
|
- print("code:" + str(status) + str(output) + "; create Dockerfile success !!!")
|
|
|
+ print("code:" + str(status) + str(output) + "; create Dockerfile success !!!")
|
|
|
return
|
|
|
|
|
|
|
|
@@ -177,15 +180,28 @@ def dnsAllocation():
|
|
|
def cloudDns():
|
|
|
if JNLP_INGRESS == "nginx":
|
|
|
client = AcsClient('LTAI4LibOCW5ilIa', 'NiA9OumXJDHp4TwLwXWcCKGoDgDjms', 'cn-hangzhou')
|
|
|
- # add record
|
|
|
- request = AddDomainRecordRequest()
|
|
|
+
|
|
|
+ # describe record
|
|
|
+ request = DescribeDomainRecordsRequest()
|
|
|
request.set_accept_format('json')
|
|
|
- request.set_Value(NGINX_RECORD_IP)
|
|
|
- request.set_Type("A")
|
|
|
- request.set_RR(RECORD_NAME)
|
|
|
request.set_DomainName(DOMAINNAME)
|
|
|
+ request.set_RRKeyWord(RECORD_NAME)
|
|
|
response = client.do_action_with_exception(request)
|
|
|
- print(response)
|
|
|
+ jsondata = json.loads(response)
|
|
|
+ # print(response)
|
|
|
+ if jsondata['TotalCount'] != 0:
|
|
|
+ print(RECORD_NAME + "." + DOMAINNAME + " is already exists <<<")
|
|
|
+ else :
|
|
|
+ # add record
|
|
|
+ request = AddDomainRecordRequest()
|
|
|
+ request.set_accept_format('json')
|
|
|
+ request.set_Value(NGINX_RECORD_IP)
|
|
|
+ request.set_Type("A")
|
|
|
+ request.set_RR(RECORD_NAME)
|
|
|
+ request.set_DomainName(DOMAINNAME)
|
|
|
+ response = client.do_action_with_exception(request)
|
|
|
+ # print(response)
|
|
|
+ print(RECORD_NAME + "." + DOMAINNAME + " add sucess <<<")
|
|
|
else :
|
|
|
print(">>> Ingress error, Only nginx !!! <<<")
|
|
|
return
|