Beispiel #1
0
 def get_data(self, request, share_net_id):
     share_net = manila.share_network_get(request, share_net_id)
     neutron_enabled = base.is_service_enabled(request, 'network')
     if neutron_enabled:
         share_net.neutron_net = neutron.network_get(
             request, share_net.neutron_net_id).name_or_id
         share_net.neutron_subnet = neutron.subnet_get(
             request, share_net.neutron_subnet_id).name_or_id
     return share_net
Beispiel #2
0
 def get_data(self, request, share_net_id):
     share_net = manila.share_network_get(request, share_net_id)
     neutron_enabled = base.is_service_enabled(request, 'network')
     if neutron_enabled:
         share_net.neutron_net = neutron.network_get(
             request, share_net.neutron_net_id).name_or_id
         share_net.neutron_subnet = neutron.subnet_get(
             request, share_net.neutron_subnet_id).name_or_id
     else:
         share_net.nova_net = network.network_get(
             request, share_net.nova_net_id).name_or_id
     return share_net
Beispiel #3
0
    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)

            try:
                base_image = glance.image_get(request,
                                              cluster.default_image_id)
            except Exception:
                exceptions.handle(
                    request, _("Unable to fetch base image details"))
                base_image = {}

            if getattr(cluster, 'cluster_template_id', None):
                cluster_template = saharaclient.safe_call(
                    sahara.cluster_templates.get,
                    cluster.cluster_template_id)
            else:
                cluster_template = None
            try:
                if getattr(cluster, 'neutron_management_network', None):
                    net_id = cluster.neutron_management_network
                    network = neutron.network_get(request, net_id)
                    net_name = network.name_or_id
                else:
                    net_name = None
            except Exception:
                exceptions.handle(
                    request, _("Unable to fetch network details"))
                net_name = None

            cluster_info.update({"cluster": cluster,
                                 "base_image": base_image,
                                 "cluster_template": cluster_template,
                                 "network": net_name})

            if saharaclient.VERSIONS.active == '2':
                cluster_info["cluster"].hadoop_version = (
                    cluster_info["cluster"].plugin_version
                )
        except Exception as e:
            LOG.error("Unable to fetch cluster details: %s" % str(e))

        return cluster_info
Beispiel #4
0
    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)

            try:
                base_image = glance.image_get(request,
                                              cluster.default_image_id)
            except Exception:
                exceptions.handle(request,
                                  _("Unable to fetch base image details"))
                base_image = {}

            if getattr(cluster, 'cluster_template_id', None):
                cluster_template = saharaclient.safe_call(
                    sahara.cluster_templates.get, cluster.cluster_template_id)
            else:
                cluster_template = None
            try:
                if getattr(cluster, 'neutron_management_network', None):
                    net_id = cluster.neutron_management_network
                    network = neutron.network_get(request, net_id)
                    net_name = network.name_or_id
                else:
                    net_name = None
            except Exception:
                exceptions.handle(request,
                                  _("Unable to fetch network details"))
                net_name = None

            cluster_info.update({
                "cluster": cluster,
                "base_image": base_image,
                "cluster_template": cluster_template,
                "network": net_name
            })

            if saharaclient.VERSIONS.active == '2':
                cluster_info["cluster"].hadoop_version = (
                    cluster_info["cluster"].plugin_version)
        except Exception as e:
            LOG.error("Unable to fetch cluster details: %s" % str(e))

        return cluster_info
Beispiel #5
0
def get_project_assigned_network(request):
    tenant_id = request.user.tenant_id

    tenant = keystone.tenant_get(request, tenant_id)
    network_name = getattr(settings, 'FIXED_MURANO_NETWORK', 'murano_network')
    tenant_network_id = getattr(tenant, network_name, None)
    if not tenant_network_id:
        LOG.warning(("murano_network property is not "
                     "defined for project '%s'") % tenant_id)
        return []

    try:
        tenant_network = neutron.network_get(request, tenant_network_id)
        return [((tenant_network.id, None), tenant_network.name_or_id)]
    except exc.NeutronClientException:
        return []
Beispiel #6
0
def get_project_assigned_network(request):
    tenant_id = request.user.tenant_id

    tenant = keystone.tenant_get(request, tenant_id)
    network_name = getattr(settings, 'FIXED_MURANO_NETWORK', 'murano_network')
    tenant_network_id = getattr(tenant, network_name, None)
    if not tenant_network_id:
        LOG.warning(("murano_network property is not "
                     "defined for project '%s'") % tenant_id)
        return []

    try:
        tenant_network = neutron.network_get(request, tenant_network_id)
        return [((tenant_network.id, None), tenant_network.name_or_id)]
    except exc.NeutronClientException:
        return []
Beispiel #7
0
    def get_data(self):
        try:
            share_net_id = self.kwargs['share_network_id']
            share_net = manila.share_network_get(self.request, share_net_id)
            if base.is_service_enabled(self.request, 'network'):
                try:
                    share_net.neutron_net = neutron.network_get(
                        self.request, share_net.neutron_net_id).name_or_id
                except (
                    neutron.neutron_client.exceptions.NeutronClientException):
                    share_net.neutron_net = _("Unknown")
                try:
                    share_net.neutron_subnet = neutron.subnet_get(
                        self.request, share_net.neutron_subnet_id).name_or_id
                except (
                    neutron.neutron_client.exceptions.NeutronClientException):
                    share_net.neutron_subnet = _("Unknown")
            else:
                try:
                    share_net.nova_net = network.network_get(
                        self.request, share_net.nova_net_id).name_or_id
                except Exception:
                    share_net.nova_net = _("Unknown")

            share_net.sec_services = (
                manila.share_network_security_service_list(
                    self.request, share_net_id))
            for ss in share_net.sec_services:
                ss.type = utils.get_nice_security_service_type(ss)
            server_search_opts = {'share_network_id': share_net_id}
            try:
                share_servs = manila.share_server_list(
                    self.request,
                    search_opts=server_search_opts)
            #  Non admins won't be able to get share servers
            except Exception:
                share_servs = []
            if share_servs:
                share_net.share_servers = share_servs
        except Exception:
            exceptions.handle(self.request,
                              _('Unable to retrieve share network details.'),
                              redirect=self.redirect_url)
        return share_net
Beispiel #8
0
    def get_data(self):
        try:
            share_net_id = self.kwargs['share_network_id']
            share_net = manila.share_network_get(self.request, share_net_id)
            if base.is_service_enabled(self.request, 'network'):
                try:
                    share_net.neutron_net = neutron.network_get(
                        self.request, share_net.neutron_net_id).name_or_id
                except (neutron.neutron_client.exceptions.
                        NeutronClientException):
                    share_net.neutron_net = _("Unknown")
                try:
                    share_net.neutron_subnet = neutron.subnet_get(
                        self.request, share_net.neutron_subnet_id).name_or_id
                except (neutron.neutron_client.exceptions.
                        NeutronClientException):
                    share_net.neutron_subnet = _("Unknown")
            else:
                try:
                    share_net.nova_net = network.network_get(
                        self.request, share_net.nova_net_id).name_or_id
                except Exception:
                    share_net.nova_net = _("Unknown")

            share_net.sec_services = (
                manila.share_network_security_service_list(
                    self.request, share_net_id))
            for ss in share_net.sec_services:
                ss.type = utils.get_nice_security_service_type(ss)
            server_search_opts = {'share_network_id': share_net_id}
            try:
                share_servs = manila.share_server_list(
                    self.request, search_opts=server_search_opts)
            #  Non admins won't be able to get share servers
            except Exception:
                share_servs = []
            if share_servs:
                share_net.share_servers = share_servs
        except Exception:
            exceptions.handle(self.request,
                              _('Unable to retrieve share network details.'),
                              redirect=self.redirect_url)
        return share_net
Beispiel #9
0
    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
Beispiel #10
0
    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
Beispiel #11
0
    def get_data(self):
        try:
            share_net_id = self.kwargs['share_network_id']
            share_net = manila.share_network_get(self.request, share_net_id)
            if base.is_service_enabled(self.request, 'network'):
                try:
                    share_net.neutron_net = neutron.network_get(
                        self.request, share_net.neutron_net_id).name_or_id
                except (
                    neutron.neutron_client.exceptions.NeutronClientException):
                    share_net.neutron_net = _("Unknown")
                try:
                    share_net.neutron_subnet = neutron.subnet_get(
                        self.request, share_net.neutron_subnet_id).name_or_id
                except (
                    neutron.neutron_client.exceptions.NeutronClientException):
                    share_net.neutron_subnet = _("Unknown")
            else:
                try:
                    share_net.nova_net = network.network_get(
                        self.request, share_net.nova_net_id).name_or_id
                except Exception:
                    share_net.nova_net = _("Unknown")

            share_net.sec_services = \
                manila.share_network_security_service_list(self.request,
                                                           share_net_id)
            server_search_opts = {'share_network_id': share_net_id}
            share_servs = manila.share_server_list(
                self.request,
                search_opts=server_search_opts)
            share_net.share_servers = share_servs
        except Exception:
            redirect = reverse('horizon:project:shares:index')
            exceptions.handle(self.request,
                              _('Unable to retrieve share network details.'),
                              redirect=redirect)
        return share_net
Beispiel #12
0
    def get_data(self):
        try:
            share_net_id = self.kwargs['share_network_id']
            share_net = manila.share_network_get(self.request, share_net_id)
            if base.is_service_enabled(self.request, 'network'):
                try:
                    share_net.neutron_net = neutron.network_get(
                        self.request, share_net.neutron_net_id).name_or_id
                except (neutron.neutron_client.exceptions.
                        NeutronClientException):
                    share_net.neutron_net = _("Unknown")
                try:
                    share_net.neutron_subnet = neutron.subnet_get(
                        self.request, share_net.neutron_subnet_id).name_or_id
                except (neutron.neutron_client.exceptions.
                        NeutronClientException):
                    share_net.neutron_subnet = _("Unknown")
            else:
                try:
                    share_net.nova_net = network.network_get(
                        self.request, share_net.nova_net_id).name_or_id
                except Exception:
                    share_net.nova_net = _("Unknown")

            share_net.sec_services = \
                manila.share_network_security_service_list(self.request,
                                                           share_net_id)
            server_search_opts = {'share_network_id': share_net_id}
            share_servs = manila.share_server_list(
                self.request, search_opts=server_search_opts)
            share_net.share_servers = share_servs
        except Exception:
            redirect = reverse('horizon:project:shares:index')
            exceptions.handle(self.request,
                              _('Unable to retrieve share network details.'),
                              redirect=redirect)
        return share_net
Beispiel #13
0
def network_get(request, net_id):
    return neutron.network_get(request, net_id)