| 1482 | |
| 1483 | |
| 1484 | class BotoProvider(CredentialProvider): |
| 1485 | METHOD = 'boto-config' |
| 1486 | CANONICAL_NAME = 'Boto2Config' |
| 1487 | |
| 1488 | BOTO_CONFIG_ENV = 'BOTO_CONFIG' |
| 1489 | DEFAULT_CONFIG_FILENAMES = ['/etc/boto.cfg', '~/.boto'] |
| 1490 | ACCESS_KEY = 'aws_access_key_id' |
| 1491 | SECRET_KEY = 'aws_secret_access_key' |
| 1492 | |
| 1493 | def __init__(self, environ=None, ini_parser=None): |
| 1494 | if environ is None: |
| 1495 | environ = os.environ |
| 1496 | if ini_parser is None: |
| 1497 | ini_parser = botocore.configloader.raw_config_parse |
| 1498 | self._environ = environ |
| 1499 | self._ini_parser = ini_parser |
| 1500 | |
| 1501 | def load(self): |
| 1502 | """ |
| 1503 | Look for credentials in boto config file. |
| 1504 | """ |
| 1505 | if self.BOTO_CONFIG_ENV in self._environ: |
| 1506 | potential_locations = [self._environ[self.BOTO_CONFIG_ENV]] |
| 1507 | else: |
| 1508 | potential_locations = self.DEFAULT_CONFIG_FILENAMES |
| 1509 | for filename in potential_locations: |
| 1510 | try: |
| 1511 | config = self._ini_parser(filename) |
| 1512 | except ConfigNotFound: |
| 1513 | # Move on to the next potential config file name. |
| 1514 | continue |
| 1515 | if 'Credentials' in config: |
| 1516 | credentials = config['Credentials'] |
| 1517 | if self.ACCESS_KEY in credentials: |
| 1518 | logger.info( |
| 1519 | "Found credentials in boto config file: %s", filename |
| 1520 | ) |
| 1521 | access_key, secret_key = self._extract_creds_from_mapping( |
| 1522 | credentials, self.ACCESS_KEY, self.SECRET_KEY |
| 1523 | ) |
| 1524 | register_feature_id('CREDENTIALS_BOTO2_CONFIG_FILE') |
| 1525 | return Credentials( |
| 1526 | access_key, secret_key, method=self.METHOD |
| 1527 | ) |
| 1528 | |
| 1529 | |
| 1530 | class AssumeRoleProvider(CredentialProvider): |
no outgoing calls
no test coverage detected