1# Copyright (c) 2014 Hewlett-Packard Development Company, L.P. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may 4# not use this file except in compliance with the License. You may obtain 5# a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations 13# under the License. 14 15import sys 16 17from openstack.config.loader import OpenStackConfig # noqa 18 19 20def get_cloud_region( 21 service_key=None, options=None, 22 app_name=None, app_version=None, 23 load_yaml_config=True, 24 load_envvars=True, 25 **kwargs): 26 config = OpenStackConfig( 27 load_yaml_config=load_yaml_config, 28 load_envvars=load_envvars, 29 app_name=app_name, app_version=app_version) 30 if options: 31 config.register_argparse_arguments(options, sys.argv, service_key) 32 parsed_options = options.parse_known_args(sys.argv) 33 else: 34 parsed_options = None 35 36 return config.get_one(options=parsed_options, **kwargs) 37