コード例 #1
0
ファイル: main_Deployer.py プロジェクト: brandonkgarner/CEDAR
 def TEST(self, type_in, svc_in, acct, acctName, global_accts, config, targetAPI):
     accID = acct
     region = 'us-east-1'
     accountRole = global_accts[accID]['role']
     print(" ## OPTIONS TEST ## %s--> %s, role %s, account originDefinition %s, config %s, copyAnsible to %s" %
           (type_in, svc_in, accountRole, accID, config, sendto))
     print(" !!! [TEST] !! to assume <cross_acct_role> ROLE make sure you set 'assume_role' in 'ENVR.yaml' to True or False as needed")
     awsconnect.stsClient_init()
     sts_client = awsconnect.stsClient
     eID = 10000010001
     if 'eID' in global_accts[accID]:
         eID = global_accts[accID]['eID']
     aconnect = awsConnect(accID, eID, accountRole, sts_client, region)
     aconnect.connect()
     results = None
     if type_in == "-CF":
         cm = CloudFrontMolder("ansible")
         print("CF TEST here")
     elif type_in == "-L":
         lm = LambdaMolder("ansible")
         print("LAMBDA TEST here")
     elif type_in == "-G":
         gm = ApiGatewayTester("ansible")
         print("GATEWAY TEST here")
         if targetAPI == svc_in:
             errors = gm.test_GatewayALL(
                 svc_in, aconnect, acct, acctName, global_accts, targetAPI)
         else:
             errors = gm.test_GwResource(
                 svc_in, aconnect, acct, acctName, global_accts, targetAPI)
     elif type_in == "-DY":
         dy = DynamoMolder("ansible")
         print("DYNAMO TEST here")
     return errors
コード例 #2
0
ファイル: nanoReader.py プロジェクト: brandonkgarner/CEDAR
def main(api=None):
    start_time = time.time()
    isLambda = True
    jumpRole = False
    fullUpdate = False
    dir_path = '/tmp'
    config = 'ENVRFIG.yaml'
    svc_in = targetAPI = api
    sendto = '/tmp/%s' % targetAPI

    bucket = os.environ['bucket']
    bucketRoot = os.environ['initKey']
    g_reader = GwyReader(bucket, bucketRoot)

    logging.basicConfig(format='%(asctime)-15s %(message)s')
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)

    logger.info("Started")
    print("  ..... INIT..... 0002")

    fullpath = config
    origin, global_accts = loadConfig(fullpath)
    triggers = origin['triggers']
    if jumpRole:
        accountRole = global_accts[accID]['role']
        region = origin['region']
        accID = origin['account']
        print(
            " ## USING ## %s--> %s, role %s, account originDefinition %s, config %s, copyAnsible to %s"
            % (type_in, svc_in, accountRole, accID, config, sendto))
        print(
            " !!! !! to assume <cross_acct_role> ROLE make sure you set 'assume_role' in 'ENVRFIG.yaml' to True or False as needed"
        )

        awsconnect.stsClient_init()
        sts_client = awsconnect.stsClient
        if 'eID' in origin:
            eID = origin['eID']
        if 'services_map' in origin:
            mapfile = origin['services_map']
            eID = serviceID(origin['account'], mapfile, origin['all'])

        aconnect = awsConnect(accID, eID, origin['role_definer'], sts_client,
                              region)
        aconnect.connect()
    else:
        aconnect = type('obj', (object, ), {'__get_client__': boto3.client})

    lm = ApiGatewayMolder("ansible", isLambda)
    file_tasks, file_defaults = lm.describe_GatewayALL(svc_in, aconnect,
                                                       origin, global_accts,
                                                       triggers, sendto,
                                                       targetAPI, fullUpdate)
    #pushFiles(file_tasks, file_defaults)
    g_reader.s3_send(targetAPI, [file_tasks, file_defaults], aconnect)
    logger.info("Finished")

    print("--- %s seconds ---" % (time.time() - start_time))
コード例 #3
0
ファイル: main_Deployer.py プロジェクト: brandonkgarner/CEDAR
    def Define(self, type_in, svc_in, origin, global_accts, sendto, config, triggers=None, targetAPI=None, fullUpdate=None):
        accID = origin['account']
        region = origin['region']
        accountRole = global_accts[accID]['role']
        print(" ## USING ## %s--> %s, role %s, account originDefinition %s, config %s, copyAnsible to %s" %
              (type_in, svc_in, accountRole, accID, config, sendto))
        print(" !!! !! to assume <cross_acct_role> ROLE make sure you set 'assume_role' in 'ENVR.yaml' to True or False as needed")
        awsconnect.stsClient_init()
        sts_client = awsconnect.stsClient
        print(" ________________-")
        print("         %s" % (accID))
        print(" ________________-")
        if 'eID' in origin:
            eID = origin['eID']
        if 'services_map' in origin:
            mapfile = origin['services_map']
            eID = serviceID(origin['account'], mapfile, origin['all'])

        aconnect = awsConnect(
            accID, eID, origin['role_definer'], sts_client, region)
        aconnect.connect()
        results = None
        if type_in == "-CF":
            cm = CloudFrontMolder("ansible")
            acctID, target, acctTitle, ready = cm.cfront_describe(
                svc_in, aconnect, origin, global_accts, sendto)
            print("CF here")
        elif type_in == "-L":
            lm = LambdaMolder("ansible")
            acctID, target, acctTitle, ready = lm.lambda_describe(
                svc_in, aconnect, origin, global_accts, triggers, sendto, targetAPI, fullUpdate)
        elif type_in == "-G":
            gm = ApiGatewayMolder("ansible")
            if targetAPI == svc_in:
                acctID, target, acctTitle, ready = gm.describe_GatewayALL(
                    svc_in, aconnect, origin, global_accts, triggers, sendto, targetAPI, fullUpdate, True)
            else:
                acctID, target, acctTitle, ready = gm.describe_GwResource(
                    svc_in, aconnect, origin, global_accts, triggers, sendto, targetAPI, fullUpdate, True)
        elif type_in == "-DY":
            dy = DynamoMolder("ansible")
            acctID, target, acctTitle, ready = dy.define(
                svc_in, aconnect, origin, global_accts, sendto)
        return acctID, target, acctTitle, ready
コード例 #4
0
ファイル: main_tester.py プロジェクト: brandonkgarner/CEDAR
    def define_tests(self, type_in, target_roles, origin, global_accts, role_alias):
        region = origin['region']
        accID = origin['account']
        # print("**********")
        # print(origin)
        # print("**********")
        accountRole = global_accts[accID]['role']
        awsconnect.stsClient_init()
        sts_client = awsconnect.stsClient
        if 'eID' in origin:
            eID = origin['eID']
        if 'services_map' in origin:
            mapfile = origin['services_map']
            eID = serviceID(origin['account'], mapfile, origin['all'])

        print(eID)
        aconnect = awsConnect(accID, eID, accountRole, sts_client, region)
        aconnect.connect()
        errors = []
        results = []
        total = []
        for i, svc_in in enumerate(target_roles):
            # roleString = roleCleaner(role)
            self.incremented = i
            print(" ## OPTIONS TEST ## %s--> [%s]%s, role %s, account originDefinition %s" %
                  (type_in, role_alias, svc_in, accountRole, accID))
            print(
                " !!! [TEST] !! to assume <cross_acct_role> ROLE make sure you set 'assume_role' in 'ENVR.yaml' to True or False as needed")
            test_time = time.time()
            e = self.test_define(type_in, svc_in, aconnect,
                                 origin, global_accts, role_alias)
            if e is None:
                print("[E] %s no tests found" % (svc_in))
                continue
            errors = errors + e
            if not e:
                results.append(svc_in)
            total.append(svc_in)
            print("-[COMPLETED][SVC]-- %s seconds ---" %
                  (time.time() - test_time))
        return errors, results, total
コード例 #5
0
        print("  ..... INIT..... 0002. %s ,   %s" % (dir_path, config))

        fullpath = "%s/%s" % (dir_path, config)
        env = 'dev'
        origin, global_accts = loadConfig(fullpath, env)
        triggers = origin['triggers']
        if triggers is None:
            raise ValueError(
                "[E] config file [ %s ] did not load correctly.. PLEASE check / fix and try again" % (fullpath))
        accID = origin['account']
        region = origin['region']
        accountRole = global_accts[accID]['role']
        print(" ## USING ## %s--> %s, role %s, account originDefinition %s, config %s, copyAnsible to %s" %
              (type_in, svc_in, accountRole, accID, config, sendto))
        print(" !!! !! to assume <cross_acct_role> ROLE make sure you set 'assume_role' in 'ENVR.yaml' to True or False as needed")
        awsconnect.stsClient_init()
        sts_client = awsconnect.stsClient
        aconnect = awsConnect(
            accID, origin['eID'], origin['role_definer'], sts_client, region)
        aconnect.connect()

        if type_in == "-CF":
            cm = CloudFrontMolder("ansible")
            cm.cfront_describe(svc_in, aconnect, origin, global_accts, sendto)
            print("CF here")
        elif type_in == "-L":
            lm = LambdaMolder("ansible")
            lm.lambda_describe(svc_in, aconnect, origin, global_accts,
                               triggers, sendto, targetAPI, fullUpdate)
        elif type_in == "-G":
            lm = ApiGatewayMolder("ansible")