Esempio n. 1
0
class PoolsTable(tables.DataTable):
    name = tables.Column("name_or_id",
                         verbose_name=_("Name"),
                         link="horizon:network:loadbalancers:pooldetails")
    description = tables.Column('description', verbose_name=_("Description"))
    provider = tables.Column('provider', verbose_name=_("Provider"),
                             filters=(lambda v: filters.default(v, _('N/A')),))
    subnet_name = tables.Column('subnet_name', verbose_name=_("Subnet"))
    protocol = tables.Column('protocol', verbose_name=_("Protocol"))
    status = tables.Column('status',
                           verbose_name=_("Status"),
                           status=True,
                           status_choices=STATUS_CHOICES,
                           display_choices=STATUS_DISPLAY_CHOICES)
    vip_name = tables.Column('vip_name', verbose_name=_("VIP"),
                             link=get_vip_link)

    class Meta(object):
        name = "poolstable"
        verbose_name = _("Pools")
        status_columns = ["status"]
        row_class = UpdatePoolsRow
        table_actions = (AddPoolLink, DeletePoolLink)
        row_actions = (UpdatePoolLink, AddVipLink, UpdateVipLink,
                       DeleteVipLink, AddPMAssociationLink,
                       DeletePMAssociationLink, DeletePoolLink)
Esempio n. 2
0
class RulesTable(tables.DataTable):
    name = tables.Column("name",
                         verbose_name=_("Name"),
                         link="horizon:project:firewalls:ruledetails")
    protocol = tables.Column("protocol",
                             filters=(
                                 lambda v: filters.default(v, _("ANY")),
                                 filters.upper,
                             ),
                             verbose_name=_("Protocol"))
    source_ip_address = tables.Column("source_ip_address",
                                      verbose_name=_("Source IP"))
    source_port = tables.Column("source_port", verbose_name=_("Source Port"))
    destination_ip_address = tables.Column("destination_ip_address",
                                           verbose_name=_("Destination IP"))
    destination_port = tables.Column("destination_port",
                                     verbose_name=_("Destination Port"))
    action = tables.Column("action",
                           filters=(filters.upper, ),
                           verbose_name=_("Action"))
    enabled = tables.Column("enabled", verbose_name=_("Enabled"))
    firewall_policy_id = tables.Column(get_policy_name,
                                       link=get_policy_link,
                                       verbose_name=_("In Policy"))

    class Meta:
        name = "rulestable"
        verbose_name = _("Rules")
        table_actions = (AddRuleLink, DeleteRuleLink)
        row_actions = (UpdateRuleLink, DeleteRuleLink)
Esempio n. 3
0
class RulesTable(tables.DataTable):
    ACTION_DISPLAY_CHOICES = (
        ("Allow", pgettext_lazy("Action Name of a Firewall Rule", u"ALLOW")),
        ("Deny", pgettext_lazy("Action Name of a Firewall Rule", u"DENY")),
    )
    name = tables.Column("name_or_id",
                         verbose_name=_("Name"),
                         link="horizon:project:firewalls:ruledetails")
    protocol = tables.Column("protocol",
                             filters=(lambda v: filters.default(v, _("ANY")),
                                      filters.upper,),
                             verbose_name=_("Protocol"))
    source_ip_address = tables.Column("source_ip_address",
                                      verbose_name=_("Source IP"))
    source_port = tables.Column("source_port",
                                verbose_name=_("Source Port"))
    destination_ip_address = tables.Column("destination_ip_address",
                                           verbose_name=_("Destination IP"))
    destination_port = tables.Column("destination_port",
                                     verbose_name=_("Destination Port"))
    action = tables.Column("action",
                           display_choices=ACTION_DISPLAY_CHOICES,
                           verbose_name=_("Action"))
    enabled = tables.Column("enabled",
                            verbose_name=_("Enabled"),
                            filters=(filters.yesno, filters.capfirst))
    firewall_policy_id = tables.Column(get_policy_name,
                                       link=get_policy_link,
                                       verbose_name=_("In Policy"))

    class Meta(object):
        name = "rulestable"
        verbose_name = _("Rules")
        table_actions = (AddRuleLink, DeleteRuleLink)
        row_actions = (UpdateRuleLink, DeleteRuleLink)
Esempio n. 4
0
 def values(self):
     from django.template.defaultfilters import default
     return {
         'title':
         default(self.title, '').strip(),
         'ik_address':
         default(self.ik_address, '').strip(),
         'ik_lat':
         self.ik_lat,
         'ik_lon':
         self.ik_lon,
         'ik_phone':
         default(self.ik_phone, '').strip(),
         'fax':
         default(self.fax, '').strip(),
         'email':
         default(self.email, '').strip(),
         'expired_date':
         str(self.expired_date),
         'voteroom_address':
         default(self.voteroom_address, '').strip(),
         'voteroom_lat':
         self.voteroom_lat,
         'voteroom_lon':
         self.voteroom_lon,
         'voteroom_phone':
         default(self.voteroom_phone, '').strip(),
         'persons':
         sorted(list(
             self.ikperson_set.values('person_name', 'status',
                                      'recomend_by')),
                key=lambda x: x['person_name']),
         'info_url':
         self.info_url.strip(),
     }
Esempio n. 5
0
def display_pair(field, name, autoescape=None):
    if autoescape is not True:
        raise ValueError('Auto escaping must be turned on for this filter '
                         'to work')

    if field is True or field is False:
        field = nicebool(field, autoescape=True)
    else:
        field = escape(default(field, '-'))
    markup = "<li><b>{}:</b> {}</li>".format(name, field)

    return mark_safe(markup)
Esempio n. 6
0
def display_pair(field, name, autoescape = None):
	if autoescape is not True:
		raise ValueError("Auto escaping must be turned on for this filter to work")

	if field is True or field is False:
		field = nicebool(field, autoescape = True)
	else:
		field = escape(default(field, "-"))
	markup = """
	<div class="form-group">
		<label class="col-sm-2 control-label">%s</label>
		<div class="col-sm-10">
			<p class="form-control-static">%s</p>
		</div>
	</div> """ % (name, field)

	return mark_safe(markup)
Esempio n. 7
0
class PoolsTable(tables.DataTable):
    METHOD_DISPLAY_CHOICES = (
        ("round_robin", pgettext_lazy("load balancing method",
                                      u"Round Robin")),
        ("least_connections",
         pgettext_lazy("load balancing method", u"Least Connections")),
        ("source_ip", pgettext_lazy("load balancing method", u"Source IP")),
    )

    name = tables.Column("name_or_id",
                         verbose_name=_("Name"),
                         link="horizon:project:loadbalancers:pooldetails")
    description = tables.Column('description', verbose_name=_("Description"))
    provider = tables.Column(
        'provider',
        verbose_name=_("Provider"),
        filters=(lambda v: filters.default(v, _('N/A')), ))
    subnet_name = tables.Column('subnet_name', verbose_name=_("Subnet"))
    protocol = tables.Column('protocol', verbose_name=_("Protocol"))
    method = tables.Column('lb_method',
                           verbose_name=_("LB Method"),
                           display_choices=METHOD_DISPLAY_CHOICES)
    status = tables.Column('status',
                           verbose_name=_("Status"),
                           status=True,
                           status_choices=STATUS_CHOICES,
                           display_choices=STATUS_DISPLAY_CHOICES)
    vip_name = tables.Column(get_vip_name, verbose_name=_("VIP"))
    admin_state = tables.Column("admin_state",
                                verbose_name=_("Admin State"),
                                display_choices=ADMIN_STATE_DISPLAY_CHOICES)

    class Meta(object):
        name = "poolstable"
        verbose_name = _("Pools")
        status_columns = ["status"]
        row_class = UpdatePoolsRow
        table_actions = (AddPoolLink, DeletePoolLink)
        row_actions = (UpdatePoolLink, AddVipLink, UpdateVipLink,
                       DeleteVipLink, AddPMAssociationLink,
                       DeletePMAssociationLink, DeletePoolLink,
                       AddVIPFloatingIP, RemoveVIPFloatingIP)
Esempio n. 8
0
class PoolsTable(tables.DataTable):
    name = tables.Column("name",
                         verbose_name=_("Name"),
                         link="horizon:project:loadbalancers:pooldetails")
    description = tables.Column('description', verbose_name=_("Description"))
    provider = tables.Column('provider', verbose_name=_("Provider"),
                             filters=(lambda v: filters.default(v, _('N/A')),))
    subnet_name = tables.Column('subnet_name', verbose_name=_("Subnet"))
    protocol = tables.Column('protocol', verbose_name=_("Protocol"))
    status = tables.Column('status', verbose_name=_("Status"))
    vip_name = tables.Column('vip_name', verbose_name=_("VIP"),
                             link=get_vip_link)

    class Meta:
        name = "poolstable"
        verbose_name = _("Pools")
        table_actions = (AddPoolLink, DeletePoolLink)
        row_actions = (UpdatePoolLink, AddVipLink, UpdateVipLink,
                       DeleteVipLink, AddPMAssociationLink,
                       DeletePMAssociationLink, DeletePoolLink)
Esempio n. 9
0
 def test_default(self):
     self.assertEqual(default("val", "default"), 'val')
     self.assertEqual(default(None, "default"), 'default')
     self.assertEqual(default('', "default"), 'default')
Esempio n. 10
0
 def test_default(self):
     self.assertEqual(default("val", "default"), 'val')
     self.assertEqual(default(None, "default"), 'default')
     self.assertEqual(default('', "default"), 'default')
Esempio n. 11
0
 def test_empty_string(self):
     self.assertEqual(default('', 'default'), 'default')
Esempio n. 12
0
 def test_none(self):
     self.assertEqual(default(None, 'default'), 'default')
Esempio n. 13
0
 def test_value(self):
     self.assertEqual(default('val', 'default'), 'val')
Esempio n. 14
0
 def test_empty_string(self):
     self.assertEqual(default("", "default"), "default")
Esempio n. 15
0
 def test_none(self):
     self.assertEqual(default(None, "default"), "default")
Esempio n. 16
0
 def test_value(self):
     self.assertEqual(default("val", "default"), "val")