def handle(self, request, context): try: # TODO(nkonovalov) Implement AJAX Node Groups. node_groups = None plugin, hadoop_version = whelpers.\ get_plugin_and_hadoop_version(request) cluster_template_id = context["general_cluster_template"] or None user_keypair = context["general_keypair"] or None image_id = context["general_image"] or None saharaclient.cluster_create( request, context["general_cluster_name"], plugin, hadoop_version, cluster_template_id=cluster_template_id, default_image_id=image_id, description=context["general_description"], node_groups=node_groups, user_keypair_id=user_keypair, count=context['general_cluster_count'], net_id=context.get("general_neutron_management_network", None), is_public=context['general_is_public'], is_protected=context['general_is_protected'] ) return True except api_base.APIException as e: self.error_description = str(e) return False except Exception: exceptions.handle(request, _('Unable to create the cluster')) return False
def handle(self, request, context): try: # TODO(nkonovalov) Implement AJAX Node Groups. node_groups = None plugin, hadoop_version = whelpers.\ get_plugin_and_hadoop_version(request) cluster_template_id = context["general_cluster_template"] or None user_keypair = context["general_keypair"] or None image_id = context["general_image"] or None saharaclient.cluster_create( request, context["general_cluster_name"], plugin, hadoop_version, cluster_template_id=cluster_template_id, default_image_id=image_id, description=context["general_description"], node_groups=node_groups, user_keypair_id=user_keypair, count=context['general_cluster_count'], net_id=context.get("general_neutron_management_network", None), is_public=context['general_is_public'], is_protected=context['general_is_protected']) return True except api_base.APIException as e: self.error_description = str(e) return False except Exception: exceptions.handle(request, _('Unable to create the cluster')) return False
def handle(self, request, context): node_groups = None plugin, hadoop_version = ( whelpers.get_plugin_and_hadoop_version(request)) ct_id = context["cluster_general_cluster_template"] or None user_keypair = context["cluster_general_keypair"] or None argument_ids = json.loads(context['argument_ids']) interface = {name: context["argument_" + str(arg_id)] for arg_id, name in argument_ids.items()} try: cluster = saharaclient.cluster_create( request, context["cluster_general_cluster_name"], plugin, hadoop_version, cluster_template_id=ct_id, default_image_id=context["cluster_general_image"], description=context["cluster_general_description"], node_groups=node_groups, user_keypair_id=user_keypair, is_transient=not(context["cluster_general_persist_cluster"]), net_id=context.get( "cluster_general_neutron_management_network", None)) except Exception: exceptions.handle(request, _("Unable to create new cluster for job.")) return False try: saharaclient.job_execution_create( request, context["job_general_job"], cluster.id, context["job_general_job_input"], context["job_general_job_output"], context["job_config"], interface, is_public=context['job_general_is_public'], is_protected=context['job_general_is_protected'] ) except Exception: exceptions.handle(request, _("Unable to launch job.")) return False return True
def recovery_cluster(request, ct, cluster, net_id, name, keypair, default_image_id): cluster = sahara.cluster_create( request, name=name, plugin_name=cluster['plugin_name'], hadoop_version=cluster['hadoop_version'], cluster_template_id=ct['id'], is_transient=cluster['is_transient'], description=cluster['description'] + "backup", cluster_configs=cluster['cluster_configs'], user_keypair_id=keypair, anti_affinity=cluster['anti_affinity'], default_image_id=default_image_id, net_id=net_id, count=1, use_autoconfig=cluster['use_autoconfig'], is_public=cluster['is_public'], is_protected=cluster['is_protected']).to_dict() cluster = sahara.cluster_get(request, cluster['id']).to_dict() return cluster