コード例 #1
0
 def get_object(self):
     ngt_id = self.kwargs["template_id"]
     try:
         return saharaclient.nodegroup_template_get(self.request, ngt_id)
     except Exception:
         msg = _('Unable to retrieve details for '
                 'node group template "%s".') % ngt_id
         redirect = self.get_redirect_url()
         exceptions.handle(self.request, msg, redirect=redirect)
コード例 #2
0
ファイル: views.py プロジェクト: openstack/sahara-dashboard
 def get_object(self):
     ngt_id = self.kwargs["template_id"]
     try:
         return saharaclient.nodegroup_template_get(self.request, ngt_id)
     except Exception:
         msg = _('Unable to retrieve details for '
                 'node group template "%s".') % ngt_id
         redirect = self.get_redirect_url()
         exceptions.handle(self.request, msg, redirect=redirect)
コード例 #3
0
ファイル: tabs.py プロジェクト: wojiaoxulan/sahara-dashboard
 def get_context_data(self, request):
     template_id = self.tab_group.kwargs['template_id']
     try:
         template = saharaclient.nodegroup_template_get(
             request, template_id)
     except Exception as e:
         template = {}
         LOG.error("Unable to fetch node group template details: %s" %
                   str(e))
     return {"template": template}
コード例 #4
0
ファイル: tabs.py プロジェクト: openstack/sahara-dashboard
 def get_context_data(self, request):
     template_id = self.tab_group.kwargs['template_id']
     try:
         template = saharaclient.nodegroup_template_get(
             request, template_id)
     except Exception as e:
         template = {}
         LOG.error(
             "Unable to fetch node group template details: %s" % str(e))
     return {"template": template}
コード例 #5
0
ファイル: tabs.py プロジェクト: NeCTAR-RC/sahara-dashboard
    def get_context_data(self, request):
        template_id = self.tab_group.kwargs['template_id']
        try:
            template = saharaclient.nodegroup_template_get(
                request, template_id)
        except Exception as e:
            template = {}
            LOG.error("Unable to fetch node group template details: %s" %
                      str(e))
            return {"template": template}

        try:
            flavor = nova.flavor_get(request, template.flavor_id)
        except Exception:
            flavor = {}
            exceptions.handle(request,
                              _("Unable to fetch flavor for template."))

        floating_ip_pool_name = None
        if template.floating_ip_pool:
            try:
                floating_ip_pool_name = self._get_floating_ip_pool_name(
                    request, template.floating_ip_pool)
            except Exception:
                exceptions.handle(request,
                                  _("Unable to fetch floating ip pools."))

        base_image_name = None
        if template.image_id:
            try:
                base_image_name = saharaclient.image_get(
                    request, template.image_id).name
            except Exception:
                exceptions.handle(
                    request,
                    _("Unable to fetch Base Image with id: %s.") %
                    template.image_id)

        security_groups = helpers.get_security_groups(request,
                                                      template.security_groups)

        if getattr(template, 'boot_from_volume', None) is None:
            show_bfv = False
        else:
            show_bfv = True

        return {
            "template": template,
            "flavor": flavor,
            "floating_ip_pool_name": floating_ip_pool_name,
            "base_image_name": base_image_name,
            "security_groups": security_groups,
            "show_bfv": show_bfv
        }
コード例 #6
0
 def get_object(self, *args, **kwargs):
     if not hasattr(self, "_object"):
         template_id = self.kwargs['template_id']
         try:
             template = saharaclient.nodegroup_template_get(
                 self.request, template_id)
         except Exception:
             template = None
             exceptions.handle(self.request,
                               _("Unable to fetch template object."))
         self._object = template
     return self._object
コード例 #7
0
ファイル: views.py プロジェクト: openstack/sahara-dashboard
 def get_object(self, *args, **kwargs):
     if not hasattr(self, "_object"):
         template_id = self.kwargs['template_id']
         try:
             template = saharaclient.nodegroup_template_get(self.request,
                                                            template_id)
         except Exception:
             template = None
             exceptions.handle(self.request,
                               _("Unable to fetch template object."))
         self._object = template
     return self._object
コード例 #8
0
ファイル: tabs.py プロジェクト: openstack/sahara-dashboard
    def get_context_data(self, request):
        template_id = self.tab_group.kwargs['template_id']
        try:
            template = saharaclient.nodegroup_template_get(
                request, template_id)
        except Exception as e:
            template = {}
            LOG.error(
                "Unable to fetch node group template details: %s" % str(e))
            return {"template": template}

        try:
            flavor = nova.flavor_get(request, template.flavor_id)
        except Exception:
            flavor = {}
            exceptions.handle(request,
                              _("Unable to fetch flavor for template."))

        floating_ip_pool_name = None
        if template.floating_ip_pool:
            try:
                floating_ip_pool_name = self._get_floating_ip_pool_name(
                    request, template.floating_ip_pool)
            except Exception:
                exceptions.handle(request,
                                  _("Unable to fetch floating ip pools."))

        base_image_name = None
        if template.image_id:
            try:
                base_image_name = saharaclient.image_get(
                    request, template.image_id).name
            except Exception:
                exceptions.handle(request,
                                  _("Unable to fetch Base Image with id: %s.")
                                  % template.image_id)

        security_groups = helpers.get_security_groups(
            request, template.security_groups)

        if getattr(template, 'boot_from_volume', None) is None:
            show_bfv = False
        else:
            show_bfv = True

        return {"template": template, "flavor": flavor,
                "floating_ip_pool_name": floating_ip_pool_name,
                "base_image_name": base_image_name,
                "security_groups": security_groups,
                "show_bfv": show_bfv}
コード例 #9
0
ファイル: backup.py プロジェクト: Mhhli/sahara-backup-plugin
def save_node_groups_info(request, node_groups_template_ids, path):
    path = u.join_path(path, "node_groups.json")
    node_groups = []
    flavor_ids = []
    image_ids = []
    security_group_ids = []
    for ng_id in node_groups_template_ids:
        ng_info = sahara.nodegroup_template_get(request, ng_id).to_dict()
        node_groups.append(ng_info)
        flavor_ids = append_to_list(ng_info['flavor_id'], flavor_ids)
        image_ids = append_to_list(ng_info['image_id'], image_ids)
        for sgi in ng_info['security_groups']:
            security_group_ids = append_to_list(sgi, security_group_ids)
    ngs_info = {"node_groups": node_groups}
    u.save_to_json(path, ngs_info)
    return flavor_ids, image_ids, security_group_ids
コード例 #10
0
def recovery_ng(request,
                node_groups,
                instance,
                flavor_id=None,
                security_groups=None,
                flavors=None,
                sgs=None):
    ng = get_ng(node_groups, instance)
    if flavor_id is None:
        flavor_id = get_flavor_id(ng, flavors)
    if security_groups is None:
        security_groups = get_sgs_id(ng, sgs)
    new_ng = sahara.nodegroup_template_create(
        request,
        name=instance['instance_name'] + uuidutils.generate_uuid()[0:7],
        plugin_name=ng['plugin_name'],
        hadoop_version=ng['hadoop_version'],
        flavor_id=flavor_id,
        description=ng['description'],
        volumes_per_node=ng['volumes_per_node'],
        volumes_size=ng['volumes_size'],
        node_processes=ng['node_processes'],
        node_configs=ng['node_configs'],
        floating_ip_pool=ng['floating_ip_pool'],
        security_groups=security_groups,
        auto_security_group=ng['auto_security_group'],
        availability_zone=ng['availability_zone'],
        volumes_availability_zone=ng['volumes_availability_zone'],
        volume_type=ng['volume_type'],
        image_id=instance['image_id'],
        is_proxy_gateway=ng['is_proxy_gateway'],
        volume_local_to_instance=ng['volume_local_to_instance'],
        use_autoconfig=ng['use_autoconfig'],
        shares=ng['shares'],
        is_public=ng['is_public'],
        is_protected=ng['is_protected']).to_dict()
    new_ng = sahara.nodegroup_template_get(request, new_ng['id']).to_dict()
    new_ng['old_id'] = ng['id']
    return new_ng
コード例 #11
0
ファイル: copy.py プロジェクト: openstack/sahara-dashboard
    def __init__(self, request, context_seed, entry_point, *args, **kwargs):
        self.template_id = context_seed["template_id"]
        self.template = saharaclient.nodegroup_template_get(request,
                                                            self.template_id)
        self._set_configs_to_copy(self.template.node_configs)

        plugin = self.template.plugin_name
        if saharaclient.VERSIONS.active == '2':
            version_attr = 'plugin_version'
        else:
            version_attr = 'hadoop_version'
        hadoop_version = getattr(self.template, version_attr)

        request.GET = request.GET.copy()
        request.GET.update(
            {"plugin_name": plugin, version_attr: hadoop_version})

        super(CopyNodegroupTemplate, self).__init__(request, context_seed,
                                                    entry_point, *args,
                                                    **kwargs)

        g_fields = None
        snp_fields = None
        s_fields = None
        share_fields = None
        for step in self.steps:
            if isinstance(step, create_flow.GeneralConfig):
                g_fields = step.action.fields
            if isinstance(step, create_flow.SecurityConfig):
                s_fields = step.action.fields
            if isinstance(step, create_flow.SelectNodeProcesses):
                snp_fields = step.action.fields
            if isinstance(step, create_flow.SelectNodeGroupShares):
                share_fields = step.action.fields

        g_fields["nodegroup_name"].initial = self.template.name + "-copy"
        g_fields["description"].initial = self.template.description
        g_fields["flavor"].initial = self.template.flavor_id

        if hasattr(self.template, "availability_zone"):
            g_fields["availability_zone"].initial = (
                self.template.availability_zone)

        if hasattr(self.template, "volumes_availability_zone"):
            g_fields["volumes_availability_zone"].initial = \
                self.template.volumes_availability_zone

        storage = "cinder_volume" if self.template.volumes_per_node > 0 \
            else "ephemeral_drive"
        volumes_per_node = self.template.volumes_per_node
        volumes_size = self.template.volumes_size
        volume_type = self.template.volume_type
        volume_local_to_instance = self.template.volume_local_to_instance
        g_fields["storage"].initial = storage
        g_fields["volumes_per_node"].initial = volumes_per_node
        g_fields["volumes_size"].initial = volumes_size
        g_fields["volumes_availability_zone"].initial = \
            self.template.volumes_availability_zone
        g_fields['volume_type'].initial = volume_type
        g_fields['volume_local_to_instance'].initial = volume_local_to_instance
        g_fields["proxygateway"].initial = self.template.is_proxy_gateway
        g_fields["use_autoconfig"].initial = self.template.use_autoconfig
        g_fields["is_public"].initial = self.template.is_public
        g_fields['is_protected'].initial = self.template.is_protected
        g_fields["image"].initial = self.template.image_id

        if self.template.floating_ip_pool:
            g_fields['floating_ip_pool'].initial = (
                self.template.floating_ip_pool)

        s_fields["security_autogroup"].initial = (
            self.template.auto_security_group)

        if self.template.security_groups:
            s_fields["security_groups"].initial = dict(
                [(sg, sg) for sg in self.template.security_groups])

        processes_dict = dict()
        try:
            plugin_details = saharaclient.plugin_get_version_details(
                request,
                plugin,
                hadoop_version)
            plugin_node_processes = plugin_details.node_processes
        except Exception:
            plugin_node_processes = dict()
            exceptions.handle(request,
                              _("Unable to fetch plugin details."))
        for process in self.template.node_processes:
            # need to know the service
            _service = None
            for service, processes in plugin_node_processes.items():
                if process in processes:
                    _service = service
                    break
            processes_dict["%s:%s" % (_service, process)] = process
        snp_fields["processes"].initial = processes_dict

        if share_fields:
            share_fields["shares"].initial = (
                self._get_share_defaults(share_fields))
コード例 #12
0
ファイル: copy.py プロジェクト: venkatgalikm/sahara-dashboard
    def __init__(self, request, context_seed, entry_point, *args, **kwargs):
        self.template_id = context_seed["template_id"]
        self.template = saharaclient.nodegroup_template_get(
            request, self.template_id)
        self._set_configs_to_copy(self.template.node_configs)

        plugin = self.template.plugin_name
        if saharaclient.VERSIONS.active == '2':
            version_attr = 'plugin_version'
        else:
            version_attr = 'hadoop_version'
        hadoop_version = getattr(self.template, version_attr)

        request.GET = request.GET.copy()
        request.GET.update({
            "plugin_name": plugin,
            version_attr: hadoop_version
        })

        super(CopyNodegroupTemplate,
              self).__init__(request, context_seed, entry_point, *args,
                             **kwargs)

        g_fields = None
        snp_fields = None
        s_fields = None
        share_fields = None
        for step in self.steps:
            if isinstance(step, create_flow.GeneralConfig):
                g_fields = step.action.fields
            if isinstance(step, create_flow.SecurityConfig):
                s_fields = step.action.fields
            if isinstance(step, create_flow.SelectNodeProcesses):
                snp_fields = step.action.fields
            if isinstance(step, create_flow.SelectNodeGroupShares):
                share_fields = step.action.fields

        g_fields["nodegroup_name"].initial = self.template.name + "-copy"
        g_fields["description"].initial = self.template.description
        g_fields["flavor"].initial = self.template.flavor_id

        if hasattr(self.template, "availability_zone"):
            g_fields["availability_zone"].initial = (
                self.template.availability_zone)

        if hasattr(self.template, "volumes_availability_zone"):
            g_fields["volumes_availability_zone"].initial = \
                self.template.volumes_availability_zone

        storage = "cinder_volume" if self.template.volumes_per_node > 0 \
            else "ephemeral_drive"
        volumes_per_node = self.template.volumes_per_node
        volumes_size = self.template.volumes_size
        volume_type = self.template.volume_type
        volume_local_to_instance = self.template.volume_local_to_instance
        g_fields["storage"].initial = storage
        g_fields["volumes_per_node"].initial = volumes_per_node
        g_fields["volumes_size"].initial = volumes_size
        g_fields["volumes_availability_zone"].initial = \
            self.template.volumes_availability_zone
        g_fields['volume_type'].initial = volume_type
        g_fields['volume_local_to_instance'].initial = volume_local_to_instance
        g_fields["proxygateway"].initial = self.template.is_proxy_gateway
        g_fields["use_autoconfig"].initial = self.template.use_autoconfig
        g_fields["is_public"].initial = self.template.is_public
        g_fields['is_protected'].initial = self.template.is_protected
        g_fields["image"].initial = self.template.image_id

        if self.template.floating_ip_pool:
            g_fields['floating_ip_pool'].initial = (
                self.template.floating_ip_pool)

        s_fields["security_autogroup"].initial = (
            self.template.auto_security_group)

        if self.template.security_groups:
            s_fields["security_groups"].initial = dict([
                (sg, sg) for sg in self.template.security_groups
            ])

        processes_dict = dict()
        try:
            plugin_details = saharaclient.plugin_get_version_details(
                request, plugin, hadoop_version)
            plugin_node_processes = plugin_details.node_processes
        except Exception:
            plugin_node_processes = dict()
            exceptions.handle(request, _("Unable to fetch plugin details."))
        for process in self.template.node_processes:
            # need to know the service
            _service = None
            for service, processes in plugin_node_processes.items():
                if process in processes:
                    _service = service
                    break
            processes_dict["%s:%s" % (_service, process)] = process
        snp_fields["processes"].initial = processes_dict

        if share_fields:
            share_fields["shares"].initial = (
                self._get_share_defaults(share_fields))