Esempio n. 1
0
class FlowClassifier(mf.ModelBase, mixins.BasicEvents, mixins.Topic,
                     mixins.Name, mixins.UniqueKey):
    table_name = 'sfc_flowclassifier'

    ether_type = df_fields.EnumField([
        constants.IPv4,
        constants.IPv6,
    ], )
    protocol = df_fields.EnumField([
        constants.PROTO_NAME_TCP,
        constants.PROTO_NAME_UDP,
    ], )
    source_cidr = df_fields.IpNetworkField()
    dest_cidr = df_fields.IpNetworkField()
    source_transport_ports = df_fields.PortRangeField()
    dest_transport_ports = df_fields.PortRangeField()

    source_port = df_fields.ReferenceField(l2.LogicalPort)
    dest_port = df_fields.ReferenceField(l2.LogicalPort)
    # TODO(dimak) Add l7 parameters

    @property
    def is_classification_local(self):
        '''Should the flow classifier classification flows be installed locally

        For classification on source lport, we match using reg6, which is
        available only after classification app sets it, so there is no use
        installing it on other hosts.

        For classification on dest lport, we match using reg7. reg7 is set on
        all hosts during the time packet passes through L2 app. We can classify
        the packet right away on any of the hosts and forward it to the first
        SF, saving 2 hops of going to dest node then to the first SF.
    '''
        if self.source_port is not None:
            return self.source_port.is_local

        return True

    @property
    def is_dispatch_local(self):
        '''Should the flow classifier dispatch flows be installed locally.

        For classification on source lport, we match using reg6, so we can
        dispatch the packet anywhere, and it will be forwarded. No loop will be
        created because no app will set reg6 again.

        For classification on dest lport, we match using reg7, so we have to
        forward the packet all the way to the destination host, and mark it
        as 'already done SFC', so it won't get stuck in a loop. The has to be
        done on the destination host because the mark gets lost in transit.
        '''
        if self.dest_port is not None:
            return self.dest_port.is_local
        return True
Esempio n. 2
0
class RemoteLabeledRoute(mf.ModelBase, mixins.BasicEvents):
    table_name = 'rlroutes'

    destination = df_fields.IpNetworkField(required=True)
    nexthop = df_fields.IpAddressField(required=True)
    label = fields.IntField(required=True)
    helper_port = fields.StringField(required=True)
Esempio n. 3
0
class Subnet(mf.ModelBase, mixins.Name, mixins.Topic):
    enable_dhcp = fields.BoolField()
    dhcp_ip = df_fields.IpAddressField()
    cidr = df_fields.IpNetworkField()
    gateway_ip = df_fields.IpAddressField()
    dns_nameservers = df_fields.ListOfField(df_fields.IpAddressField())
    host_routes = fields.ListField(host_route.HostRoute)
Esempio n. 4
0
class LocalLabeledRoute(mf.ModelBase, mixins.BasicEvents):
    table_name = 'llroutes'

    dest_ip = df_fields.IpNetworkField(required=True)
    # dest_mac = df_fields.MacAddressField(required=True)
    port = fields.StringField(required=True)
    # host = df_fields.IpAddressField(required=True)
    label = fields.IntField(required=True)
Esempio n. 5
0
class SecurityGroupRule(mf.ModelBase, mixins.BasicEvents, mixins.Topic,
                        mixins.Version):

    direction = df_fields.EnumField(RULE_DIRECTION, required=True)
    ethertype = df_fields.EnumField(RULE_ETHERTYPE, required=True)
    port_range_max = fields.IntField()
    port_range_min = fields.IntField()
    protocol = df_fields.IpProto()
    remote_group_id = fields.StringField()
    remote_ip_prefix = df_fields.IpNetworkField()
    security_group_id = fields.StringField()
Esempio n. 6
0
class FieldTestModel(mf.ModelBase):
    enum = df_fields.EnumField(('a', 'b', 'c'))
    enum_list = df_fields.EnumListField(('a', 'b', 'c'))
    ipaddr = df_fields.IpAddressField()
    ipnetwork = df_fields.IpNetworkField()
    ref = df_fields.ReferenceField(ReffedTestModel)
    ref_list = df_fields.ReferenceListField(ReffedTestModel)
    ip_list = df_fields.ListOfField(df_fields.IpAddressField())

    def __init__(self, **kwargs):
        super(FieldTestModel, self).__init__(id='id1', **kwargs)
Esempio n. 7
0
class Subnet(mf.ModelBase, mixins.Name, mixins.Topic, mixins.Version,
             mixins.BasicEvents):

    table_name = "lsubnet"

    enable_dhcp = fields.BoolField()
    dhcp_ip = df_fields.IpAddressField()
    cidr = df_fields.IpNetworkField()
    gateway_ip = df_fields.IpAddressField()
    dns_nameservers = df_fields.ListOfField(df_fields.IpAddressField())
    host_routes = fields.ListField(host_route.HostRoute)
    lswitch = df_fields.ReferenceField(LogicalSwitch, required=True)
Esempio n. 8
0
class FieldTestModel(mf.ModelBase):
    enum = df_fields.EnumField(('a', 'b', 'c'))
    enum_list = df_fields.EnumListField(('a', 'b', 'c'))
    ipaddr = df_fields.IpAddressField()
    ipnetwork = df_fields.IpNetworkField()
    ref = df_fields.ReferenceField(ReffedTestModel)
    ref_list = df_fields.ReferenceListField(ReffedTestModel)
    ip_list = df_fields.ListOfField(df_fields.IpAddressField())
    port_range = df_fields.PortRangeField()
    dhcp_opts = df_fields.DhcpOptsDictField()

    def __init__(self, **kwargs):
        id = kwargs.pop("id", 'id1')
        super(FieldTestModel, self).__init__(id=id, **kwargs)
Esempio n. 9
0
class LogicalRouterPort(mf.ModelBase, mixins.Topic, mixins.UniqueKey):
    mac = fields.StringField()
    lswitch = df_fields.ReferenceField(l2.LogicalSwitch)
    network = df_fields.IpNetworkField()
Esempio n. 10
0
class HostRoute(models.Base):
    destination = df_fields.IpNetworkField(required=True)
    nexthop = df_fields.IpAddressField(required=True)