def __init__(self, request, *args, **kwargs): super(AttachInterface, self).__init__(request, *args, **kwargs) networks = instance_utils.network_field_data(request, include_empty_option=True, with_cidr=True) self.fields['network'].choices = networks choices = [('network', _("by Network (and IP address)"))] ports = instance_utils.port_field_data(request, with_network=True) if ports: self.fields['port'].choices = ports choices.append(('port', _("by Port"))) self.fields['specification_method'].choices = choices
def __init__(self, request, *args, **kwargs): super(AttachInterface, self).__init__(request, *args, **kwargs) networks = instance_utils.network_field_data(request, include_empty_option=True, with_cidr=True) self.fields['network'].choices = networks choices = [('network', _("by Network (and IP address)"))] ports = instance_utils.port_field_data(request, with_network=True) if len(ports) > 0: self.fields['port'].choices = ports choices.append(('port', _("by Port"))) self.fields['specification_method'].choices = choices
def populate_ports_choices(self, request, context): ports = instance_utils.port_field_data(request) if not ports: self.fields['ports'].label = _("No ports available") self.fields['ports'].help_text = _("No ports available") return ports