Ejemplo n.º 1
0
 def get_context_data(self, request):
     service_profile_id = self.tab_group.kwargs['sp_id']
     try:
         service_profile = client.get_service_profile(
             request, service_profile_id)
     except Exception:
         exceptions.handle(request, _(
             'Unable to retrieve service profile details.'),
             redirect=self.failure_url)
     return {'service_profile': service_profile}
def update_sc_node_attributes(request, scnode):
    t = "<p style='margin-bottom:0px'>"
    val = [t]
    sp_url = "horizon:project:network_services:service_profile_details"
    url = reverse(sp_url, kwargs={'sp_id': scnode.service_profile_id})
    try:
        service_profile = client.get_service_profile(request,
                                                     scnode.service_profile_id)
        sp = "<a href='" + url + "'>" + service_profile.name + ' : ' + \
            service_profile.service_type + '</a></p>'
        val.append(sp)
    except Exception:
        return scnode
    setattr(scnode, 'service_profile', mark_safe("".join(val)))
    return scnode
def update_sc_node_attributes(request, scnode):
    t = "<p style='margin-bottom:0px'>"
    val = [t]
    sp_url = "horizon:project:network_services:service_profile_details"
    url = reverse(sp_url, kwargs={'sp_id': scnode.service_profile_id})
    try:
        service_profile = client.get_service_profile(request,
            scnode.service_profile_id)
        sp = "<a href='" + url + "'>" + service_profile.name + ' : ' + \
            service_profile.service_type + '</a></p>'
        val.append(sp)
    except Exception:
        return scnode
    setattr(scnode, 'service_profile', mark_safe("".join(val)))
    return scnode
def update_sc_spec_attributes(request, scspec):
    static_url = getattr(settings, 'STATIC_URL', "/static/")
    img_path = static_url + "dashboard/img/"
    provider = "default"
    nodes = scspec.nodes
    nodes = [client.get_servicechain_node(request, item) for item in nodes]
    t = "<table class='table table-condensed' \
        style='margin-bottom:0px'><tr><td>"

    val = [t + "<span class='glyphicon glyphicon-remove-circle'></span></td>"]
    ds_path = "/opt/stack/horizon/static/dashboard/img/"
    if os.path.exists(ds_path):
        local_img_path = ds_path
    else:
        local_img_path = "/usr/share/openstack-dashboard/" \
            + "openstack_dashboard/static/dashboard/img/"
    if os.path.exists(local_img_path):
        providers = os.listdir(local_img_path)
        for p in providers:
            if p in scspec.description:
                provider = p
                break

    img_src = img_path + provider + "/"
    scn_url = "horizon:project:network_services:sc_node_details"
    for n in nodes:
        url = reverse(scn_url, kwargs={'scnode_id': n.id})
        service_profile_id = n.service_profile_id
        try:
            service_profile = client.get_service_profile(
                request, service_profile_id)
            service_type = service_profile.service_type
        except Exception:
            pass
        val.append(
            "<td><span class='glyphicon glyphicon-arrow-right'></span></td>")
        scnode = "<td><a href='" + url + "' style='font-size: 9px;' >" \
            + "<img src='" + img_src + service_type + ".png'>" \
            + "<br>" + n.name + " (" + service_type + ")</a></td>"
        val.append(scnode)
    val.append("</tr></table>")
    setattr(scspec, 'nodes', mark_safe("".join(val)))
    return scspec
def update_sc_spec_attributes(request, scspec):
    img_path = "/static/dashboard/img/"
    provider = "default"
    nodes = scspec.nodes
    nodes = [client.get_servicechain_node(request, item) for item in nodes]
    t = "<table class='table table-condensed' \
        style='margin-bottom:0px'><tr><td>"
    val = [t + "<span class='glyphicon glyphicon-remove-circle'></span></td>"]
    ds_path = "/opt/stack/horizon/static/dashboard/img/"
    if os.path.exists(ds_path):
        local_img_path = ds_path
    else:
        local_img_path = "/usr/share/openstack-dashboard/openstack_dashboard/" \
            + "static/dashboard/img/"
    if os.path.exists(local_img_path):
        providers = os.listdir(local_img_path)
        for p in providers:
            if p in scspec.description:
                provider = p
                break

    img_src = img_path + provider + "/"
    scn_url = "horizon:project:network_services:sc_node_details"
    for n in nodes:
        url = reverse(scn_url, kwargs={'scnode_id': n.id})
        service_profile_id = n.service_profile_id
        try:
            service_profile = client.get_service_profile(request,
                service_profile_id)
            service_type = service_profile.service_type
        except Exception:
            pass
        val.append(
            "<td><span class='glyphicon glyphicon-arrow-right'></span></td>")
        scnode = "<td><a href='" + url + "' style='font-size: 9px;' >" \
            + "<img src='" + img_src + service_type + ".png'>" \
            + "<br>" + n.name + " (" + service_type + ")</a></td>"
        val.append(scnode)
    val.append("</tr></table>")
    setattr(scspec, 'nodes', mark_safe("".join(val)))
    return scspec
def update_scn_instance_attributes(request, scspec):
    static_url = getattr(settings, 'STATIC_URL', "/static/")
    img_path = static_url + "dashboard/img/"
    provider = "default"
    nodes = scspec.nodes
    nodes = [client.get_servicechain_node(request, item) for item in nodes]
    sc = ["<div>"]
    ds_path = "/opt/stack/horizon/static/dashboard/img/"
    if os.path.exists(ds_path):
        local_img_path = ds_path
    else:
        local_img_path = "/usr/share/openstack-dashboard/" \
            + "openstack_dashboard/static/dashboard/img/"
    if os.path.exists(local_img_path):
        providers = os.listdir(local_img_path)
        for p in providers:
            if p in scspec.description:
                provider = p
                break

    img_src = img_path + provider + "/"
    for n in nodes:
        service_profile_id = n.service_profile_id
        try:
            service_profile = client.get_service_profile(
                request, service_profile_id)
            service_type = service_profile.service_type
        except Exception:
            pass
        sc.append("<span class='glyphicon glyphicon-arrow-right' "
                  "style='margin: auto 10px'></span>")
        scnode = "<img src='" + img_src + service_type + ".png'>"
        sc.append(scnode)
    sc.append("</div>")
    setattr(scspec, 'chain', mark_safe("".join(sc)))
    return scspec