def _s3_conn(context): # NOTE(vish): access and secret keys for s3 server are not # checked in nova-objectstore ec2_creds = clients.keystone(context).ec2.list(context.user_id) access = ec2_creds[0].access if CONF.s3_affix_tenant: access = '%s:%s' % (access, context.project_id) secret = ec2_creds[0].secret calling = boto.s3.connection.OrdinaryCallingFormat() return boto.s3.connection.S3Connection(aws_access_key_id=access, aws_secret_access_key=secret, is_secure=CONF.s3_use_ssl, calling_format=calling, port=CONF.s3_port, host=CONF.s3_host)
def _s3_conn(context): region = CONF.s3_region ec2_creds = clients.keystone(context).ec2.list(context.user_id) # Here we a) disable user's default config to let ec2api works independetly # of user's local settings; # b) specify region to be used by botocore; # c) do not change standard botocore keys to get these settings # from environment connection_data = { 'config_file': (None, 'AWS_CONFIG_FILE', None, None), 'region': ('region', 'AWS_DEFAULT_REGION', region, None), } session = botocore.session.get_session(connection_data) return session.create_client( 's3', region_name=region, endpoint_url=CONF.s3_url, aws_access_key_id=ec2_creds[0].access, aws_secret_access_key=ec2_creds[0].secret, config=botocore.config.Config(signature_version='s3v4'))