xuekailun 3 bulan lalu
induk
melakukan
56f887ee12
3 mengubah file dengan 32 tambahan dan 23 penghapusan
  1. 0 1
      dns/conf.py
  2. 1 1
      dns/dns_weight.py
  3. 31 21
      dns/utils.py

+ 0 - 1
dns/conf.py

@@ -1,7 +1,6 @@
 from datetime import datetime, timedelta
 
 
-
 metrics_client={
     'access_key_id': 'dfghj',
     'access_key_secret': 'dtfyvgubh',

+ 1 - 1
dns/dns_weight.py

@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# This file is auto-generated, don't edit it. Thanks.
+
 import os
 import sys
 import json

+ 31 - 21
dns/utils.py

@@ -21,6 +21,10 @@ from alibabacloud_tea_util.client import Client as UtilClient
 
 
 def update_dns_weights(bandwidth):
+    '''
+    @param bandwidth: 带宽值
+    @return:
+    '''
     if bandwidth > 1800:
         alb_weight = round(1800 / bandwidth * 100)
         backup_weight = (100 - alb_weight) // 2
@@ -33,7 +37,6 @@ def update_dns_weights(bandwidth):
         return backup_weight
 
 
-
 def client(access_key_id, access_key_secret, endpoint) -> Cms20190101Client:
     """
     使用AK&SK初始化账号Client
@@ -54,6 +57,16 @@ def client(access_key_id, access_key_secret, endpoint) -> Cms20190101Client:
 
 
 def DescribeMetricList(metrics_client, namespace, metric_name, period, dimensions, start_time, end_time):
+    '''
+    @param metrics_client: 云监控客户端
+    @param namespace: 云产品的数据命名空间 共享带宽
+    @param metric_name: 云产品的监控项名称 入流量
+    @param period: 监控数据的统计周期 秒
+    @param dimensions: 指定资源的监控维度 共享带宽
+    @param start_time: 监控开始时间
+    @param end_time:  监控结束时间
+    @return:
+    '''
     metrics_client()
     describe_metric_list_request = cms_20190101_models.DescribeMetricListRequest(
         namespace=namespace,
@@ -78,8 +91,10 @@ def DescribeMetricList(metrics_client, namespace, metric_name, period, dimension
 
 
 def get_records(response):
-    # 提取longvideoapi的Value和RecordId
-    # longvideoapi_records = [
+    '''
+    @param response:
+    @return:
+    '''
     records = [
         {
             "Value": record["Value"],
@@ -92,6 +107,12 @@ def get_records(response):
 
 
 def DescribeDomainRecords(dns_client, lang, domain_name):
+    '''
+    @param dns_client: dns客户端
+    @param lang: 语言
+    @param domain_name: 解析记录的ID 主域名
+    @return:
+    '''
     dns_client()
     describe_domain_records_request = alidns_20150109_models.DescribeDomainRecordsRequest(
         lang=lang,
@@ -101,26 +122,8 @@ def DescribeDomainRecords(dns_client, lang, domain_name):
     )
     runtime = util_models.RuntimeOptions()
     try:
-        # 复制代码运行请自行打印 API 的返回值
         response=dns_client.describe_domain_records_with_options(describe_domain_records_request, runtime)
-        # record_id = response["DomainRecords"]["Record"][0]["RecordId"]
-        # print(f"RecordId: {record_id}")
-        # return record_id
-        # longvideoapi_records = [
-        #     {
-        #         "Value": record["Value"],
-        #         "RecordId": record["RecordId"]
-        #     }
-        #     for record in response["DomainRecords"]["Record"]
-        #     if record["RR"] == "longvideoapi"
-        # ]
-        #
-        # # 打印结果
-        # for record in longvideoapi_records:
-        #     print(f"Value: {record['Value']}, RecordId: {record['RecordId']}")
-        # 调用函数并获取结果
         result = get_records(response)
-        # 打印结果
         for record in result:
             print(record)
     except Exception as error:
@@ -129,6 +132,13 @@ def DescribeDomainRecords(dns_client, lang, domain_name):
 
 
 def update_dnsslbweight(dns_client, lang, record, backup_weight):
+    '''
+    @param dns_client: dns客户端
+    @param lang: 语言
+    @param record: 解析记录ID
+    @param backup_weight: 权重
+    @return:
+    '''
     dns_client()
     update_dnsslbweight_request = alidns_20150109_models.UpdateDNSSLBWeightRequest(
         lang=lang,