コード例 #1
0
    def __init__(self):
        self.name = QC_NAME
        self.region = REGION
        self.logger = getLogger()
        self.logger.info("Init Qcloud SCF Client...\n")
        self.logger.info("The region is: %s\n" % self.region)
        cred = credential.Credential(QC_API_ID, QC_API_KEY)
        self.logger.info("The secert info:")
        self.logger.info("Secret Id: %s" % (QC_API_ID[0:5]+"******"))
        self.logger.info("Secret Key: %s\n" % (QC_API_KEY[0:5]+"******"))
        httpProfile = HttpProfile()
        httpProfile.reqMethod = "GET"
        httpProfile.reqTimeout = 30
        httpProfile.endpoint = QC_ENDPOINT_MODEL % self.region
        self.logger.info("The request endpoint is: %s\n" % httpProfile.endpoint)
        httpProfile.keepAlive = True

        clientProfile = ClientProfile()

        clientProfile.signMethod = "HmacSHA256"
        clientProfile.httpProfile = httpProfile

        self.client = scf_client.ScfClient(cred, 'ap-' + self.region, clientProfile)

        self.logger.info("SCF client init success!\n")

        self.logger.info("Start to get VPC info...")
        self.logger.info("VPC id is: %s"% QC_VPC)
        self.logger.info("VPC-Subnet id is: %s\n" % QC_SUBNET)
コード例 #2
0
    def __init__(self):
        self.name = AWS_NAME
        self.region = AWS_REGION
        self.logger = getLogger()
        self.logger.info("Init AWS Client...\n")
        self.logger.info("The region is: %s\n" % self.region)
        self.logger.info("The secert info:")
        self.logger.info("AccessKey ID: %s" %
                         (AWS_ACCESSKEY_ID[0:5] + "******"))
        self.logger.info("Access Key Secret: %s\n" %
                         (AWS_ACCESSKEY_KEY[0:5] + "******"))
        self.client = boto3.client(AWS_PRODUCT_NAME,
                                   region_name=self.region,
                                   aws_access_key_id=AWS_ACCESSKEY_ID,
                                   aws_secret_access_key=AWS_ACCESSKEY_KEY)

        self.logger.info("AWS client init success!\n")
コード例 #3
0
    def __init__(self):
        self.name = ALI_NAME
        self.region = REGION
        self.servicename = ALI_NORMAL_SERVICE
        self.logger = getLogger()
        self.logger.info("Init ALIYUN Client...\n")
        self.logger.info("The region is: %s\n" % self.region)
        self.logger.info("The user id is: %s\n" % ALI_USER_ID)
        self.logger.info("The secert info:")
        self.logger.info("AccessKey ID: %s" %
                         (ALI_ACCESSKEY_ID[0:5] + "******"))
        self.logger.info("Access Key Secret: %s\n" %
                         (ALI_ACCESSKEY_KEY[0:5] + "******"))
        endpoint = ALI_ENDPOINT_MODEL % (ALI_USER_ID, self.region)
        self.logger.info("The request endpoint is: %s\n" % endpoint)
        self.client = fc2.Client(endpoint=endpoint,
                                 accessKeyID=ALI_ACCESSKEY_ID,
                                 accessKeySecret=ALI_ACCESSKEY_KEY)

        self.logger.info("ALIYUN client init success!\n")

        self.logger.info("Start to get FC Service info...")
        self.logger.info("VPC-SERVICE name is: %s" % ALI_VPC_SERVICE)
        self.logger.info("NORMAL-SERVICE name is: %s\n" % ALI_NORMAL_SERVICE)
コード例 #4
0
# -*- coding: utf-8 -*-
import time, os
from common.invoke_model import Invoker
from common.utils import getLogger, setResultDataToFile
from config.config import RESULT_DATA_PATH, NUMBER_OF_INVOKES, NUMBER_HOT_WARM_UP_INVOKES, BASCI_LOGGING_CODE, BASIC_PRINT_CODE, NET_CODE, FILE_IO_CODE, FILE_RANDOM_IO_CODE, COMPUTE_CODE

from common.clients.qcloud_client import QcloudClient
from common.clients.aliyun_client import AliClient
from common.clients.aws_client import AwsClient

if __name__ == '__main__':
    logger = getLogger()
    _time = str(int(time.time()))
    if os.path.exists(RESULT_DATA_PATH):
        logger.info("备份数据文件...\n")

        filename = (RESULT_DATA_PATH + ".bak." + _time)
        os.rename(RESULT_DATA_PATH, filename)

    logger.info('Result data file in: %s' % RESULT_DATA_PATH)
    dataFile = open(RESULT_DATA_PATH, 'w')

    for client in [AliClient(), AwsClient(), QcloudClient()]:
        invoker = Invoker(invokeClient=client, count=NUMBER_OF_INVOKES)
        # 普通函数
        setResultDataToFile(dataFile,
                            invoker.hotInvoke,
                            isVpc=False,
                            warmUpCount=NUMBER_HOT_WARM_UP_INVOKES,
                            scenesType=BASCI_LOGGING_CODE)
        setResultDataToFile(dataFile,
コード例 #5
0
    def __init__(self, invokeClient, count):

        self.invokeClient = invokeClient
        self.count = count

        self.logger = getLogger()