Example #1
0
    def execute(self, parameter_pool):

        func_matrix = []
        # Loop over default settings
        for name, _, to_file in CredentialFileParameters:
            if not parameter_pool.has(name):
                continue
            elif ParameterSource.is_ahead(ParameterSource.Terminal,\
                                        parameter_pool.get_source(name)):
                continue
            else:
                func_matrix.append((None, name, to_file))

        # Loop over current branch settings
        cur_branch = parameter_pool.get_value(ParameterName.CurrentBranch)\
            if parameter_pool.has(ParameterName.CurrentBranch) else None
        if cur_branch and ParameterSource.is_ahead(
                parameter_pool.get_source(ParameterName.Branches),
                ParameterSource.ConfigFile):
            branch_setting = parameter_pool.get_value(
                ParameterName.Branches)[cur_branch]
            for name, _, to_file in CredentialFileParameters:
                if not name in branch_setting:
                    continue
                else:
                    func_matrix.append((cur_branch, name, to_file))

        if len(func_matrix) < 1:
            log.info(
                'Skipped updating credential file as credentials are not changed.'
            )
            return

        location = config_file.default_aws_credential_file_location()
        # Create directory if needed
        try:
            config_file.create_directory(
                config_file.default_aws_credential_file_path())
            config_file.write_aws_credential_file(location, parameter_pool,
                                                  func_matrix)
        except BaseException as ex:
            log.error('Encountered error when creating AWS Credential file at "{0}", because {1}.'.\
                      format(location, ex))
            return

        else:
            log.info(WriteAwsCredentialFileOpMessage.Succeed.format(location))
            prompt.result(
                WriteAwsCredentialFileOpMessage.Succeed.format(location))

            parameter_pool.put(
                Parameter(ParameterName.AwsCredentialFile, location,
                          ParameterSource.OperationOutput), True)

            ret_result = OperationResult(self, None, None, None)
            return ret_result
    def execute(self, parameter_pool):

        func_matrix = []
        # Loop over default settings
        for name, _, to_file in CredentialFileParameters:
            if not parameter_pool.has(name):
                continue
            elif ParameterSource.is_ahead(ParameterSource.Terminal, parameter_pool.get_source(name)):
                continue
            else:
                func_matrix.append((None, name, to_file))

        # Loop over current branch settings
        cur_branch = (
            parameter_pool.get_value(ParameterName.CurrentBranch)
            if parameter_pool.has(ParameterName.CurrentBranch)
            else None
        )
        if cur_branch and ParameterSource.is_ahead(
            parameter_pool.get_source(ParameterName.Branches), ParameterSource.ConfigFile
        ):
            branch_setting = parameter_pool.get_value(ParameterName.Branches)[cur_branch]
            for name, _, to_file in CredentialFileParameters:
                if not name in branch_setting:
                    continue
                else:
                    func_matrix.append((cur_branch, name, to_file))

        if len(func_matrix) < 1:
            log.info(u"Skipped updating credential file as credentials are not changed.")
            return

        location = config_file.default_aws_credential_file_location()
        # Create directory if needed
        try:
            config_file.create_directory(config_file.default_aws_credential_file_path())
            config_file.write_aws_credential_file(location, parameter_pool, func_matrix)
        except BaseException as ex:
            log.error(
                u'Encountered error when creating AWS Credential file at "{0}", because {1}.'.format(location, ex)
            )
            return

        else:
            log.info(WriteAwsCredentialFileOpMessage.Succeed.format(location))
            prompt.result(WriteAwsCredentialFileOpMessage.Succeed.format(location))

            parameter_pool.put(
                Parameter(ParameterName.AwsCredentialFile, location, ParameterSource.OperationOutput), True
            )

            ret_result = OperationResult(self, None, None, None)
            return ret_result
Example #3
0
    def execute(self, parameter_pool):

        func_matrix = []
        for param in CredentialFileParameters:
            if not parameter_pool.has(param[0]):
                continue
            elif ParameterSource.is_ahead(ParameterSource.Terminal,\
                                        parameter_pool.get_source(param[0])):
                continue
            else:
                func_matrix.append((param[0], param[2]))

        if len(func_matrix) < 1:
            log.info(
                'Skipped updating credential file as credentials are not changed.'
            )
            return

        location = config_file.default_aws_credential_file_location()
        # Create directory if needed
        try:
            config_file.create_directory(
                config_file.default_aws_credential_file_path())
            config_file.write_aws_credential_file(location, parameter_pool,
                                                  func_matrix)
        except BaseException as ex:
            log.error('Encountered error when creating AWS Credential file at "{0}", because {1}.'.\
                      format(location, ex))
            return

        else:
            log.info(WriteAwsCredentialFileOpMessage.Succeed.format(location))
            prompt.result(
                WriteAwsCredentialFileOpMessage.Succeed.format(location))

            parameter_pool.put(
                Parameter(ParameterName.AwsCredentialFile, location,
                          ParameterSource.OperationOutput), True)

            ret_result = OperationResult(self, None, None, None)
            return ret_result
Example #4
0
    def execute(self, parameter_pool):
        
        func_matrix = []        
        for param in CredentialFileParameters:
            if not parameter_pool.has(param[0]):
                continue
            elif ParameterSource.is_ahead(ParameterSource.Terminal,\
                                        parameter_pool.get_source(param[0])):
                continue
            else:
                func_matrix.append((param[0], param[2]))
        
        if len(func_matrix) < 1:
            log.info('Skipped updating credential file as credentials are not changed.')
            return 

        location = config_file.default_aws_credential_file_location()        
        # Create directory if needed
        try:
            config_file.create_directory(config_file.default_aws_credential_file_path())
            config_file.write_aws_credential_file(location, parameter_pool, func_matrix)
        except BaseException as ex:
            log.error('Encountered error when creating AWS Credential file at "{0}", because {1}.'.\
                      format(location, ex))
            return
        
        else:
            log.info(WriteAwsCredentialFileOpMessage.Succeed.format(location))
            prompt.result(WriteAwsCredentialFileOpMessage.Succeed.format(location))
            
            parameter_pool.put(Parameter(ParameterName.AwsCredentialFile,
                                         location,
                                         ParameterSource.OperationOutput),
                               True)
            
            ret_result = OperationResult(self, None, None, None)
            return ret_result