def __init__(self, request, *args, **kwargs): super(UploadFileForm, self).__init__(request, *args, **kwargs) sahara = saharaclient.client(request) self._generate_plugin_version_fields(sahara) self.fields['template_file'] = forms.FileField(label=_("Template"))
def get_context_data(self, request): cluster_id = self.tab_group.kwargs['cluster_id'] try: sahara = saharaclient.client(request) cluster = sahara.clusters.get(cluster_id) for ng in cluster.node_groups: if ng["flavor_id"]: ng["flavor_name"] = ( nova.flavor_get(request, ng["flavor_id"]).name) if ng["floating_ip_pool"]: ng["floating_ip_pool_name"] = ( self._get_floating_ip_pool_name( request, ng["floating_ip_pool"])) if ng.get("node_group_template_id", None): ng["node_group_template"] = saharaclient.safe_call( sahara.node_group_templates.get, ng["node_group_template_id"]) ng["security_groups_full"] = helpers.get_security_groups( request, ng["security_groups"]) except Exception: cluster = {} exceptions.handle(request, _("Unable to get node group details.")) return {"cluster": cluster}
def populate_anti_affinity_choices(self, request, context): try: sahara = saharaclient.client(request) plugin, version = whelpers.get_plugin_and_hadoop_version(request) version_details = sahara.plugins.get_version_details(plugin, version) process_choices = [] for processes in version_details.node_processes.values(): for process in processes: process_choices.append((process, process)) cluster_template_id = request.REQUEST.get("cluster_template_id", None) if cluster_template_id is None: selected_processes = request.REQUEST.get("aa_groups", []) else: cluster_template = ( sahara.cluster_templates.get(cluster_template_id)) selected_processes = cluster_template.anti_affinity checked_dict = dict() for process in selected_processes: checked_dict[process] = process self.fields['anti_affinity'].initial = checked_dict except Exception: process_choices = [] exceptions.handle(request, _("Unable to populate anti-affinity processes.")) return process_choices
def get_context_data(self, request): cluster_id = self.tab_group.kwargs['cluster_id'] cluster = {} try: sahara = saharaclient.client(request) cluster = sahara.clusters.get(cluster_id) except Exception as e: LOG.error("Unable to fetch cluster details: %s" % str(e)) return {'cluster': cluster}
def __init__(self, request, *args, **kwargs): super(GeneralConfigAction, self).__init__(request, *args, **kwargs) sahara = saharaclient.client(request) hlps = helpers.Helpers(sahara) plugin, hadoop_version = ( workflow_helpers.get_plugin_and_hadoop_version(request)) process_choices = [] try: version_details = saharaclient.plugin_get_version_details(request, plugin, hadoop_version) for service, processes in version_details.node_processes.items(): for process in processes: process_choices.append( (str(service) + ":" + str(process), process)) except Exception: exceptions.handle(request, _("Unable to generate process choices.")) if not saharaclient.SAHARA_AUTO_IP_ALLOCATION_ENABLED: pools = network.floating_ip_pools_list(request) pool_choices = [(pool.id, pool.name) for pool in pools] pool_choices.insert(0, (None, "Do not assign floating IPs")) self.fields['floating_ip_pool'] = forms.ChoiceField( label=_("Floating IP pool"), choices=pool_choices, required=False) self.fields["processes"] = forms.MultipleChoiceField( label=_("Processes"), widget=forms.CheckboxSelectMultiple(), help_text=_("Processes to be launched in node group"), choices=process_choices) self.fields["plugin_name"] = forms.CharField( widget=forms.HiddenInput(), initial=plugin ) self.fields["hadoop_version"] = forms.CharField( widget=forms.HiddenInput(), initial=hadoop_version ) node_parameters = hlps.get_general_node_group_configs(plugin, hadoop_version) for param in node_parameters: self.fields[param.name] = workflow_helpers.build_control(param)
def __init__(self, request, context_seed, entry_point, *args, **kwargs): ConfigureClusterTemplate._cls_registry = set([]) sahara = saharaclient.client(request) hlps = helpers.Helpers(sahara) plugin, hadoop_version = whelpers.get_plugin_and_hadoop_version(request) general_parameters = hlps.get_cluster_general_configs(plugin, hadoop_version) service_parameters = hlps.get_targeted_cluster_configs(plugin, hadoop_version) self._populate_tabs(general_parameters, service_parameters) super(ConfigureClusterTemplate, self).__init__(request, context_seed, entry_point, *args, **kwargs)
def get_context_data(self, request): cluster_id = self.tab_group.kwargs['cluster_id'] try: sahara = saharaclient.client(request) cluster = sahara.clusters.get(cluster_id) for ng in cluster.node_groups: if not ng["flavor_id"]: continue ng["flavor_name"] = ( nova.flavor_get(request, ng["flavor_id"]).name) ng["node_group_template"] = helpers.safe_call( sahara.node_group_templates.get, ng.get("node_group_template_id", None)) except Exception: cluster = {} exceptions.handle(request, _("Unable to get node group details.")) return {"cluster": cluster}
def __init__(self, request, context_seed, entry_point, *args, **kwargs): sahara = saharaclient.client(request) hlps = helpers.Helpers(sahara) plugin, hadoop_version = ( workflow_helpers.get_plugin_and_hadoop_version(request)) general_parameters = hlps.get_general_node_group_configs( plugin, hadoop_version) service_parameters = hlps.get_targeted_node_group_configs( plugin, hadoop_version) self._populate_tabs(general_parameters, service_parameters) super(ConfigureNodegroupTemplate, self).__init__(request, context_seed, entry_point, *args, **kwargs)
def get_cluster_instances_data(self): cluster_id = self.tab_group.kwargs['cluster_id'] try: sahara = saharaclient.client(self.request) cluster = sahara.clusters.get(cluster_id) instances = [] for ng in cluster.node_groups: for instance in ng["instances"]: instances.append(Instance( name=instance["instance_name"], id=instance["instance_id"], internal_ip=instance.get("internal_ip", "Not assigned"), management_ip=instance.get("management_ip", "Not assigned"))) except Exception: instances = [] exceptions.handle(self.request, _("Unable to fetch instance details.")) return instances
def get_context_data(self, request): cluster_id = self.tab_group.kwargs['cluster_id'] cluster_info = {} try: sahara = saharaclient.client(request) cluster = sahara.clusters.get(cluster_id) for info_key, info_val in cluster.info.items(): for key, val in info_val.items(): if str(val).startswith(('http://', 'https://')): cluster.info[info_key][key] = build_link(val) base_image = glance.image_get(request, cluster.default_image_id) if getattr(cluster, 'cluster_template_id', None): cluster_template = helpers.safe_call( sahara.cluster_templates.get, cluster.cluster_template_id) else: cluster_template = None if getattr(cluster, 'neutron_management_network', None): net_id = cluster.neutron_management_network network = neutron.network_get(request, net_id) network.set_id_as_name_if_empty() net_name = network.name else: net_name = None cluster_info.update({"cluster": cluster, "base_image": base_image, "cluster_template": cluster_template, "network": net_name}) except Exception as e: LOG.error("Unable to fetch cluster details: %s" % str(e)) return cluster_info
def _generate_plugin_version_fields(self, request): sahara = saharaclient.client(request) plugins = sahara.plugins.list() plugin_choices = [(plugin.name, plugin.title) for plugin in plugins] self.fields["plugin_name"] = forms.ChoiceField( label=_("Plugin Name"), choices=plugin_choices, widget=forms.Select(attrs={"class": "switchable", "data-slug": "plugin"})) for plugin in plugins: field_name = plugin.name + "_version" choice_field = forms.ChoiceField( label=_("Version"), required=False, choices=[(version, version) for version in plugin.versions], widget=forms.Select( attrs={"class": "switched", "data-switch-on": "plugin", "data-plugin-" + plugin.name: plugin.title}) ) self.fields[field_name] = choice_field
def __init__(self, request, *args, **kwargs): super(SelectPluginAction, self).__init__(request, *args, **kwargs) sahara = saharaclient.client(request) self._generate_plugin_version_fields(sahara)