コード例 #1
0
 def get_context_data(self, request):
     external_connectivity_id = \
         self.tab_group.kwargs['external_connectivity_id']
     try:
         external_connectivity = client.get_externalconnectivity(
             request, external_connectivity_id)
     except Exception:
         exceptions.handle(request,
                           _('Unable to retrieve service policy details.'),
                           redirect=self.failure_url)
     return {'external_connectivity': external_connectivity}
コード例 #2
0
 def get_context_data(self, request):
     external_connectivity_id = \
         self.tab_group.kwargs['external_connectivity_id']
     try:
         external_connectivity = client.get_externalconnectivity(request,
             external_connectivity_id)
     except Exception:
         exceptions.handle(
             request, _('Unable to retrieve service policy details.'),
             redirect=self.failure_url)
     return {'external_connectivity': external_connectivity}
コード例 #3
0
 def __init__(self, request, *args, **kwargs):
     super(UpdateExternalConnectivityForm, self).__init__(request, *args, **kwargs)
     try:
         external_connectivity_id = self.initial["external_connectivity_id"]
         external_connectivity = client.get_externalconnectivity(request, external_connectivity_id)
         self.fields["name"].initial = external_connectivity.name
         self.fields["description"].initial = external_connectivity.description
         self.fields["shared"].initial = external_connectivity.shared
     except Exception as e:
         msg = _("Failed to retrive external connectivity details. %s") % (str(e))
         LOG.debug(msg)
コード例 #4
0
def update_nat_pool_attributes(request, nat_pool):
    url = "horizon:project:network_policy:external_connectivity_details"
    id = nat_pool.external_segment_id
    value = ["<ul>"]
    li = \
        lambda x: "<li><a href='" + \
        reverse(url, kwargs={'external_connectivity_id': x.id}) + \
        "'>" + x.name + "</a>" + "</li>"
    external_connectivity = client.get_externalconnectivity(request, id)
    value.append(li(external_connectivity))
    value.append("</ul>")
    tag = mark_safe("".join(value))
    setattr(nat_pool, 'external_segment_id', tag)
    return nat_pool
コード例 #5
0
 def __init__(self, request, *args, **kwargs):
     super(UpdateExternalConnectivityForm,
           self).__init__(request, *args, **kwargs)
     try:
         external_connectivity_id = \
             self.initial['external_connectivity_id']
         external_connectivity = client.get_externalconnectivity(
             request, external_connectivity_id)
         self.fields['name'].initial = external_connectivity.name
         self.fields['description'].initial = \
             external_connectivity.description
         self.fields['shared'].initial = external_connectivity.shared
     except Exception as e:
         msg = _("Failed to retrive external connectivity details. %s") % \
             (str(e))
         LOG.debug(msg)
コード例 #6
0
def update_l3_policy_attributes(request, l3_policy):
    url = "horizon:project:network_policy:external_connectivity_details"
    if bool(l3_policy.external_segments):
        external_connectivity_id = l3_policy.external_segments.keys()[0]
        try:
            external_connectivity = client.get_externalconnectivity(request,
                external_connectivity_id)
            segment_name = external_connectivity.name
        except Exception:
            segment_name = external_connectivity_id
        u = reverse(url,
            kwargs={'external_connectivity_id': external_connectivity_id})
        tag = mark_safe("<a href='" + u + "'>" + segment_name + "</a>"
            + " : " + l3_policy.external_segments.values()[0][0])
    else:
        tag = '-'
    setattr(l3_policy, 'external_segments', tag)
    return l3_policy
コード例 #7
0
def update_l3_policy_attributes(request, l3_policy):
    url = "horizon:project:network_policy:external_connectivity_details"
    if bool(l3_policy.external_segments):
        value = ["<ul>"]
        li = \
            lambda x: "<li><a href='" + \
            reverse(url, kwargs={'external_connectivity_id': x.id}) + \
             "'>" + x.name + "</a>" + " : " + \
            l3_policy.external_segments[x.id][0] + "</li>"
        for ec in l3_policy.external_segments.keys():
            external_connectivity = client.get_externalconnectivity(
                request, ec)
            value.append(li(external_connectivity))
        value.append("</ul>")
        tag = mark_safe("".join(value))
    else:
        tag = '-'
    setattr(l3_policy, 'external_segments', tag)
    return l3_policy
コード例 #8
0
def update_policy_target_attributes(request, pt):
    url = "horizon:project:application_policy:policy_rule_set_details"
    provided = pt.provided_policy_rule_sets
    consumed = pt.consumed_policy_rule_sets
    provided = [client.policy_rule_set_get(request, item) for item in provided]
    consumed = [client.policy_rule_set_get(request, item) for item in consumed]
    p = ["<ul>"]
    li = lambda x: "<li><a href='" + \
        reverse(url, kwargs={'policy_rule_set_id': x.id}) + \
        "'>" + x.name + "</a></li>"
    for item in provided:
        p.append(li(item))
    p.append("</ul>")
    p = "".join(p)
    c = ["<ul>"]
    for item in consumed:
        c.append(li(item))
    c.append("</ul>")
    c = "".join(c)
    consumed = [item.name for item in consumed]
    setattr(pt, 'provided_policy_rule_sets', mark_safe(p))
    setattr(pt, 'consumed_policy_rule_sets', mark_safe(c))
    l2url = "horizon:project:network_policy:l2policy_details"
    if hasattr(pt, 'l2_policy_id') and pt.l2_policy_id is not None:
        policy = client.l2policy_get(request, pt.l2_policy_id)
        u = reverse(l2url, kwargs={'l2policy_id': policy.id})
        atag = mark_safe("<a href='" + u + "'>" + policy.name + "</a>")
        setattr(pt, 'l2_policy_id', atag)
    if hasattr(pt, 'external_segments'):
        exturl = "horizon:project:network_policy:external_connectivity_details"
        value = ["<ul>"]
        li = lambda x: "<li><a href='" + \
            reverse(exturl, kwargs={'external_connectivity_id': x.id}) + \
            "'>" + x.name + "</a></li>"
        for external_segment in pt.external_segments:
            ext_policy = client.get_externalconnectivity(
                request, external_segment)
            value.append(li(ext_policy))
        value.append("</ul>")
        value = "".join(value)
        setattr(pt, 'external_segments', mark_safe(value))
    return pt
コード例 #9
0
def update_policy_target_attributes(request, pt):
    url = "horizon:project:application_policy:policy_rule_set_details"
    provided = pt.provided_policy_rule_sets
    consumed = pt.consumed_policy_rule_sets
    provided = [client.policy_rule_set_get(request, item) for item in provided]
    consumed = [client.policy_rule_set_get(request, item) for item in consumed]
    p = ["<ul>"]
    li = lambda x: "<li><a href='" + \
        reverse(url, kwargs={'policy_rule_set_id': x.id}) + \
        "'>" + x.name + "</a></li>"
    for item in provided:
        p.append(li(item))
    p.append("</ul>")
    p = "".join(p)
    c = ["<ul>"]
    for item in consumed:
        c.append(li(item))
    c.append("</ul>")
    c = "".join(c)
    consumed = [item.name for item in consumed]
    setattr(pt, 'provided_policy_rule_sets', mark_safe(p))
    setattr(pt, 'consumed_policy_rule_sets', mark_safe(c))
    l2url = "horizon:project:network_policy:l2policy_details"
    if hasattr(pt, 'l2_policy_id') and pt.l2_policy_id is not None:
        policy = client.l2policy_get(request, pt.l2_policy_id)
        u = reverse(l2url, kwargs={'l2policy_id': policy.id})
        atag = mark_safe(
            "<a href='" + u + "'>" + policy.name + "</a>")
        setattr(pt, 'l2_policy_id', atag)
    if hasattr(pt, 'external_segments'):
        exturl = "horizon:project:network_policy:external_connectivity_details"
        ext_policy = client.get_externalconnectivity(request,
            pt.external_segments[0])
        u = reverse(exturl, kwargs={'external_connectivity_id': ext_policy.id})
        exttag = mark_safe(
            "<a href='" + u + "'>" + ext_policy.name + "</a>")
        setattr(pt, 'external_segments', exttag)
    return pt