def register_cloud(cloud_name, cloud_config=None, endpoint_management=None, endpoint_resource_manager=None, endpoint_sql_management=None, endpoint_gallery=None, endpoint_active_directory=None, endpoint_active_directory_resource_id=None, endpoint_active_directory_graph_resource_id=None, suffix_sql_server_hostname=None, suffix_storage_endpoint=None, suffix_keyvault_dns=None, suffix_azure_datalake_store_file_system_endpoint=None, suffix_azure_datalake_analytics_catalog_and_job_endpoint=None): if cloud_config: # Using JSON format so convert the keys to snake case for key in cloud_config: cloud_config[to_snake_case(key)] = cloud_config.pop(key) cloud_args = cloud_config else: cloud_args = locals() c = Cloud(cloud_name) for arg in cloud_args: if arg.startswith('endpoint_') and cloud_args[arg]: setattr(c.endpoints, arg.replace('endpoint_', ''), cloud_args[arg]) elif arg.startswith('suffix_') and cloud_args[arg]: setattr(c.suffixes, arg.replace('suffix_', ''), cloud_args[arg]) try: add_cloud(c) except CloudAlreadyRegisteredException as e: raise CLIError(e)
def _build_cloud(cloud_name, cloud_config=None, cloud_args=None): if cloud_config: # Using JSON format so convert the keys to snake case for key in cloud_config: cloud_config[to_snake_case(key)] = cloud_config.pop(key) cloud_args = cloud_config c = Cloud(cloud_name) for arg in cloud_args: if arg.startswith("endpoint_") and cloud_args[arg] is not None: setattr(c.endpoints, arg.replace("endpoint_", ""), cloud_args[arg]) elif arg.startswith("suffix_") and cloud_args[arg] is not None: setattr(c.suffixes, arg.replace("suffix_", ""), cloud_args[arg]) return c
def _build_cloud(cloud_name, cloud_config=None, cloud_args=None): if cloud_config: # Using JSON format so convert the keys to snake case for key in cloud_config: cloud_config[to_snake_case(key)] = cloud_config.pop(key) cloud_args = cloud_config c = Cloud(cloud_name) for arg in cloud_args: if arg.startswith('endpoint_') and cloud_args[arg] is not None: setattr(c.endpoints, arg.replace('endpoint_', ''), cloud_args[arg]) elif arg.startswith('suffix_') and cloud_args[arg] is not None: setattr(c.suffixes, arg.replace('suffix_', ''), cloud_args[arg]) return c
def test_to_snake_case_already_snake(self): the_input = 'this_is_snake_cased' expected = 'this_is_snake_cased' actual = to_snake_case(the_input) self.assertEqual(expected, actual)
def test_to_snake_case_empty(self): the_input = '' expected = '' actual = to_snake_case(the_input) self.assertEqual(expected, actual)
def test_to_snake_case_from_camel(self): the_input = 'thisIsCamelCase' expected = 'this_is_camel_case' actual = to_snake_case(the_input) self.assertEqual(expected, actual)