<s> import logging <EOL> from django . conf import settings <EOL> from horizon . utils . memoized import memoized <EOL> from openstack_dashboard . api import base <EOL> from saharaclient import client as api_client <EOL> LOG = logging . getLogger ( __name__ ) <EOL> SAHARA_SERVICE = '<STR_LIT>' <EOL> SAHARA_AUTO_IP_ALLOCATION_ENABLED = getattr ( <EOL> settings , <EOL> '<STR_LIT>' , <EOL> False ) <EOL> VERSIONS = base . APIVersionManager ( <EOL> SAHARA_SERVICE , <EOL> preferred_version = getattr ( settings , <EOL> '<STR_LIT>' , <EOL> { } ) . get ( SAHARA_SERVICE , <NUM_LIT> ) ) <EOL> VERSIONS . load_supported_version ( <NUM_LIT> , { "<STR_LIT>" : api_client , <EOL> "<STR_LIT:version>" : <NUM_LIT> } ) <EOL> @ memoized <EOL> def client ( request ) : <EOL> return api_client . Client ( VERSIONS . get_active_version ( ) [ "<STR_LIT:version>" ] , <EOL> sahara_url = base . url_for ( request , SAHARA_SERVICE ) , <EOL> service_type = SAHARA_SERVICE , <EOL> project_id = request . user . project_id , <EOL> input_auth_token = request . user . token . id ) <EOL> def image_list ( request ) : <EOL> return client ( request ) . images . list ( ) <EOL> def image_get ( request , image_id ) : <EOL> return client ( request ) . images . get ( image_id ) <EOL> def image_unregister ( request , image_id ) : <EOL> client ( request ) . images . unregister_image ( image_id ) <EOL> def image_update ( request , image_id , user_name , desc ) : <EOL> client ( request ) . images . update_image ( image_id , user_name , desc ) <EOL> def image_tags_update ( request , image_id , image_tags ) : <EOL> client ( request ) . images . update_tags ( image_id , image_tags ) <EOL> def plugin_list ( request ) : <EOL> return client ( request ) . plugins . list ( ) <EOL> def plugin_get ( request , plugin_name ) : <EOL> return client ( request ) . plugins . get ( plugin_name ) <EOL> def plugin_get_version_details ( request , plugin_name , hadoop_version ) : <EOL> return client ( request ) . plugins . get_version_details ( plugin_name , <EOL> hadoop_version ) <EOL> def plugin_convert_to_template ( request , plugin_name , hadoop_version , <EOL> template_name , file_content ) : <EOL> return client ( request ) . plugins . convert_to_cluster_template ( plugin_name , <EOL> hadoop_version , <EOL> template_name , <EOL> file_content ) <EOL> def nodegroup_template_create ( request , name , plugin_name , hadoop_version , <EOL> flavor_id , description = None , <EOL> volumes_per_node = None , volumes_size = None , <EOL> node_processes = None , node_configs = None , <EOL> floating_ip_pool = None , security_groups = None , <EOL> auto_security_group = False , <EOL> availability_zone = False ) : <EOL> return client ( request ) . node_group_templates . create ( name , plugin_name , <EOL> hadoop_version , <EOL> flavor_id , description , <EOL> volumes_per_node , <EOL> volumes_size , <EOL> node_processes , <EOL> node_configs , <EOL> floating_ip_pool , <EOL> security_groups , <EOL> auto_security_group , <EOL> availability_zone ) <EOL> def nodegroup_template_list ( request ) : <EOL> return client ( request ) . node_group_templates . list ( ) <EOL> def nodegroup_template_get ( request , ngt_id ) : <EOL> return client ( request ) . node_group_templates . get ( ngt_id ) <EOL> def nodegroup_template_find ( request , ** kwargs ) : <EOL> return client ( request ) . node_group_templates . find ( ** kwargs ) <EOL> def nodegroup_template_delete ( request , ngt_id ) : <EOL> client ( request ) . node_group_templates . delete ( ngt_id ) <EOL> def nodegroup_template_update ( request , ngt_id , name , plugin_name , <EOL> hadoop_version , flavor_id , <EOL> description = None , volumes_per_node = None , <EOL> volumes_size = None , node_processes = None , <EOL> node_configs = None , floating_ip_pool = None , <EOL> security_groups = None , auto_security_group = False , <EOL> availability_zone = False ) : <EOL> return client ( request ) . node_group_templates . update ( ngt_id , name , <EOL> plugin_name , <EOL> hadoop_version , <EOL> flavor_id , <EOL> description , <EOL> volumes_per_node , <EOL> volumes_size , <EOL> node_processes , <EOL> node_configs , <EOL> floating_ip_pool , <EOL> security_groups , <EOL> auto_security_group , <EOL> availability_zone ) <EOL> def cluster_template_create ( request , name , plugin_name , hadoop_version , <EOL> description = None , cluster_configs = None , <EOL> node_groups = None , anti_affinity = None , <EOL> net_id = None ) : <EOL> return client ( request ) . cluster_templates . create ( name , plugin_name , <EOL> hadoop_version , <EOL> description , <EOL> cluster_configs , <EOL> node_groups , <EOL> anti_affinity , <EOL> net_id ) <EOL> def cluster_template_list ( request ) : <EOL> return client ( request ) . cluster_templates . list ( ) <EOL> def cluster_template_get ( request , ct_id ) : <EOL> return client ( request ) . cluster_templates . get ( ct_id ) <EOL> def cluster_template_delete ( request , ct_id ) : <EOL> client ( request ) . cluster_templates . delete ( ct_id ) <EOL> def cluster_template_update ( request , ct_id , name , plugin_name , <EOL> hadoop_version , description = None , <EOL> cluster_configs = None , node_groups = None , <EOL> anti_affinity = None , net_id = None ) : <EOL> return client ( request ) . cluster_templates . update ( ct_id , name , <EOL> plugin_name , <EOL> hadoop_version , <EOL> description , <EOL> cluster_configs , <EOL> node_groups , <EOL> anti_affinity , <EOL> net_id ) <EOL> def cluster_create ( request , name , plugin_name , hadoop_version , <EOL> cluster_template_id = None , default_image_id = None , <EOL> is_transient = None , description = None , cluster_configs = None , <EOL> node_groups = None , user_keypair_id = None , <EOL> anti_affinity = None , net_id = None ) : <EOL> return client ( request ) . clusters . create ( name , plugin_name , hadoop_version , <EOL> cluster_template_id , <EOL> default_image_id , <EOL> is_transient , description , <EOL> cluster_configs , node_groups , <EOL> user_keypair_id , anti_affinity , <EOL> net_id ) <EOL> def cluster_scale ( request , cluster_id , scale_object ) : <EOL> return client ( request ) . clusters . scale ( cluster_id , scale_object ) <EOL> def cluster_list ( request ) : <EOL> return client ( request ) . clusters . list ( ) <EOL> def cluster_get ( request , cluster_id ) : <EOL> return client ( request ) . clusters . get ( cluster_id ) <EOL> def cluster_delete ( request , cluster_id ) : <EOL> client ( request ) . clusters . delete ( cluster_id ) <EOL> def data_source_create ( request , name , description , ds_type , url , <EOL> credential_user = None , credential_pass = None ) : <EOL> return client ( request ) . data_sources . create ( name , description , ds_type , <EOL> url , credential_user , <EOL> credential_pass ) <EOL> def data_source_list ( request ) : <EOL> return client ( request ) . data_sources . list ( ) <EOL> def data_source_get ( request , ds_id ) : <EOL> return client ( request ) . data_sources . get ( ds_id ) <EOL> def data_source_delete ( request , ds_id ) : <EOL> client ( request ) . data_sources . delete ( ds_id ) <EOL> def job_binary_create ( request , name , url , description , extra ) : <EOL> return client ( request ) . job_binaries . create ( name , url , description , extra ) <EOL> def job_binary_list ( request ) : <EOL> return client ( request ) . job_binaries . list ( ) <EOL> def job_binary_get ( request , jb_id ) : <EOL> return client ( request ) . job_binaries . get ( jb_id ) <EOL> def job_binary_delete ( request , jb_id ) : <EOL> client ( request ) . job_binaries . delete ( jb_id ) <EOL> def job_binary_get_file ( request , jb_id ) : <EOL> return client ( request ) . job_binaries . get_file ( jb_id ) <EOL> def job_binary_internal_create ( request , name , data ) : <EOL> return client ( request ) . job_binary_internals . create ( name , data ) <EOL> def job_binary_internal_list ( request ) : <EOL> return client ( request ) . job_binary_internals . list ( ) <EOL> def job_binary_internal_get ( request , jbi_id ) : <EOL> return client ( request ) . job_binary_internals . get ( jbi_id ) <EOL> def job_binary_internal_delete ( request , jbi_id ) : <EOL> client ( request ) . job_binary_internals . delete ( jbi_id ) <EOL> def job_create ( request , name , j_type , mains , libs , description ) : <EOL> return client ( request ) . jobs . create ( name , j_type , mains , libs , description ) <EOL> def job_list ( request ) : <EOL> return client ( request ) . jobs . list ( ) <EOL> def job_get ( request , job_id ) : <EOL> return client ( request ) . jobs . get ( job_id ) <EOL> def job_delete ( request , job_id ) : <EOL> client ( request ) . jobs . delete ( job_id ) <EOL> def job_get_configs ( request , job_type ) : <EOL> return client ( request ) . jobs . get_configs ( job_type ) <EOL> def job_execution_create ( request , job_id , cluster_id , <EOL> input_id , output_id , configs ) : <EOL> return client ( request ) . job_executions . create ( job_id , cluster_id , <EOL> input_id , output_id , <EOL> configs ) <EOL> def job_execution_list ( request ) : <EOL> jex_list = client ( request ) . job_executions . list ( ) <EOL> job_dict = dict ( ( j . id , j ) for j in job_list ( request ) ) <EOL> cluster_dict = dict ( ( c . id , c ) for c in cluster_list ( request ) ) <EOL> for jex in jex_list : <EOL> setattr ( jex , '<STR_LIT>' , job_dict . get ( jex . job_id ) . name ) <EOL> setattr ( jex , '<STR_LIT>' , cluster_dict . get ( jex . cluster_id ) . name ) <EOL> return jex_list <EOL> def job_execution_get ( request , jex_id ) : <EOL> return client ( request ) . job_executions . get ( jex_id ) <EOL> def job_execution_delete ( request , jex_id ) : <EOL> client ( request ) . job_executions . delete ( jex_id ) </s>
