Beispiel #1
0
class RoutingNodeGateway(Routing):
    def __init__(self, element=None, level='gateway', **kwargs):
        self.destinations = kwargs.pop('destinations', [])
        self.data = ElementCache(kwargs)
        self.data.update(level=level, routing_node=[])

        if element:
            self.data.update(href=element.href, name=element.name)
            #related_element_type=element.typeof)

        for destination in self.destinations:
            self.data['routing_node'].append({
                'href': destination.href,
                'name': destination.name,
                'level': 'any'
            })
Beispiel #2
0
class RoutingNodeGateway(Routing):
    def __init__(self, element=None, level="gateway", **kwargs):
        self.destinations = kwargs.pop("destinations", [])
        self.data = ElementCache(kwargs)
        self.data.update(level=level, routing_node=[])

        if element:
            self.data.update(href=element.href, name=element.name)
            # related_element_type=element.typeof)

        for destination in self.destinations:
            self.data["routing_node"].append({
                "href": destination.href,
                "name": destination.name,
                "level": "any"
            })
Beispiel #3
0
class RoutingNodeGateway(Routing):
    def __init__(self, element=None, level='gateway', **kwargs):
        self.destinations = kwargs.pop('destinations', [])
        self.data = ElementCache(kwargs)
        self.data.update(
            level=level,
            routing_node=[])

        if element:
            self.data.update(
                href=element.href,
                name=element.name)
                #related_element_type=element.typeof)
        
        for destination in self.destinations:
            self.data['routing_node'].append(
                {'href': destination.href,
                 'name': destination.name,
                 'level': 'any'})
Beispiel #4
0
class MultilinkMember(object):
    """
    A multilink member represents an netlink member used on a multilink
    configuration. Multilink uses netlinks to specify settings specific
    to a connection, network, whether it should be active or standby and
    optionally QoS.
    Use this class to create mutlilink members that are required for
    creating a Multilink element.
    """
    def __init__(self, kwargs):
        self.data = ElementCache(kwargs)
    
    @property
    def ip_range(self):
        """
        Specifies the IP address range for dynamic source address
        translation (NAT) for the internal source IP addresses on the
        NetLink. Can also be set.

        :rtype: str
        """
        return self.data.get('ip_range')
    
    @ip_range.setter
    def ip_range(self, value):
        if '-' in value:
            self.data.update(ip_range=value)
    
    @property
    def netlink_role(self):
        """
        Shows whether the Netlink is active or standby.
        Active - traffic is routed through the NetLink according to the
        method you specify in the Outbound Multi-Link element properties.
        Standby - traffic is only routed through the netlink if all primary
        (active) netlinks are unavailable.
        
        :rtype: str
        """
        return self.data.get('netlink_role')
    
    @netlink_role.setter
    def netlink_role(self, value):
        if value in ('standby', 'active'):
            self.data.update(netlink_role=value)
    
    @property
    def network(self):
        """
        Specifies the Network element that represents the IP address
        space in the directly connected external network of the network
        link. Can also be set.
        
        :rtype: Network
        """
        return Element.from_href(self.data.get('network_ref'))
    
    @network.setter
    def network(self, value):
        self.data.update(network_ref=element_resolver(value))
    
    @property
    def netlink(self):
        """
        The static netlink referenced in this multilink member
        
        :rtype: StaticNetlink
        """
        return Element.from_href(self.data.get('netlink_ref'))

    @classmethod
    def create(cls, netlink, ip_range=None, netlink_role='active'):
        """
        Create a multilink member. Multilink members are added to an
        Outbound Multilink configuration and define the ip range, static
        netlink to use, and the role. This element can be passed to the
        Multilink constructor to simplify creation of the outbound multilink.
        
        :param StaticNetlink,DynamicNetlink netlink: static netlink element to
            use as member
        :param str ip_range: the IP range for source NAT for this member. The
            IP range should be part of the defined network range used by this
            netlink. Not required for dynamic netlink
        :param str netlink_role: role of this netlink, 'active' or 'standby'
        :raises ElementNotFound: Specified netlink could not be found
        :rtype: MultilinkMember
        """
        member_def = dict(
            netlink_ref=netlink.href,
            netlink_role=netlink_role,
            ip_range=ip_range if netlink.typeof == 'netlink' else '0.0.0.0')
        if netlink.typeof == 'netlink': # static netlink vs dynamic netlink
            member_def.update(network_ref=netlink.network[0].href)
            
        return cls(member_def)
    
    def __repr__(self):
        return 'MultilinkMember(netlink={},netlink_role={},ip_range={})'.format(
            self.netlink, self.netlink_role, self.ip_range)  
Beispiel #5
0
class MultilinkMember(object):
    """
    A multilink member represents an netlink member used on a multilink
    configuration. Multilink uses netlinks to specify settings specific
    to a connection, network, whether it should be active or standby and
    optionally QoS.
    Use this class to create mutlilink members that are required for
    creating a Multilink element.
    
    :ivar Network network: network element reference specifying netlink subnet
    :ivar StaticNetlink,DynamicNetlink netlink: netlink element reference
    """
    network = ElementRef('network_ref')
    netlink = ElementRef('netlink_ref')
    
    def __init__(self, kwargs):
        self.data = ElementCache(kwargs)
    
    def __eq__(self, other):
        return all([
            self.ip_range == other.ip_range,
            self.netlink_role == other.netlink_role,
            self.data.get('network_ref') == other.data.get('network_ref'),
            self.data.get('netlink_ref') == other.data.get('netlink_ref')
            ])
    
    def __ne__(self, other):
        return not self == other

    def __hash__(self):
        return hash((self.ip_range, self.netlink_role,
            self.data.get('network_ref'), self.data.get('netlink_ref')))
    
    @property
    def ip_range(self):
        """
        Specifies the IP address range for dynamic source address
        translation (NAT) for the internal source IP addresses on the
        NetLink. Can also be set.

        :rtype: str
        """
        return self.data.get('ip_range')
    
    @ip_range.setter
    def ip_range(self, value):
        if '-' in value:
            self.data.update(ip_range=value)
    
    @property
    def netlink_role(self):
        """
        Shows whether the Netlink is active or standby.
        Active - traffic is routed through the NetLink according to the
        method you specify in the Outbound Multi-Link element properties.
        Standby - traffic is only routed through the netlink if all primary
        (active) netlinks are unavailable.
        
        :rtype: str
        """
        return self.data.get('netlink_role')
    
    @netlink_role.setter
    def netlink_role(self, value):
        if value in ('standby', 'active'):
            self.data.update(netlink_role=value)

    @classmethod
    def create(cls, netlink, ip_range=None, netlink_role='active'):
        """
        Create a multilink member. Multilink members are added to an
        Outbound Multilink configuration and define the ip range, static
        netlink to use, and the role. This element can be passed to the
        Multilink constructor to simplify creation of the outbound multilink.
        
        :param StaticNetlink,DynamicNetlink netlink: static netlink element to
            use as member
        :param str ip_range: the IP range for source NAT for this member. The
            IP range should be part of the defined network range used by this
            netlink. Not required for dynamic netlink
        :param str netlink_role: role of this netlink, 'active' or 'standby'
        :raises ElementNotFound: Specified netlink could not be found
        :rtype: MultilinkMember
        """
        member_def = dict(
            netlink_ref=netlink.href,
            netlink_role=netlink_role,
            ip_range=ip_range if netlink.typeof == 'netlink' else '0.0.0.0')
        if netlink.typeof == 'netlink': # static netlink vs dynamic netlink
            member_def.update(network_ref=netlink.network[0].href)
            
        return cls(member_def)
    
    def __repr__(self):
        return 'MultilinkMember(netlink={},netlink_role={},ip_range={})'.format(
            self.netlink, self.netlink_role, self.ip_range)  
Beispiel #6
0
class MultilinkMember(object):
    """
    A multilink member represents an netlink member used on a multilink
    configuration. Multilink uses netlinks to specify settings specific
    to a connection, network, whether it should be active or standby and
    optionally QoS.
    Use this class to create mutlilink members that are required for
    creating a Multilink element.

    :ivar Network network: network element reference specifying netlink subnet
    :ivar StaticNetlink,DynamicNetlink netlink: netlink element reference
    """

    network = ElementRef("network_ref")
    netlink = ElementRef("netlink_ref")

    def __init__(self, kwargs):
        self.data = ElementCache(kwargs)

    def __eq__(self, other):
        return all([
            self.ip_range == other.ip_range,
            self.netlink_role == other.netlink_role,
            self.data.get("network_ref") == other.data.get("network_ref"),
            self.data.get("netlink_ref") == other.data.get("netlink_ref"),
        ])

    def __ne__(self, other):
        return not self == other

    def __hash__(self):
        return hash((
            self.ip_range,
            self.netlink_role,
            self.data.get("network_ref"),
            self.data.get("netlink_ref"),
        ))

    @property
    def ip_range(self):
        """
        Specifies the IP address range for dynamic source address
        translation (NAT) for the internal source IP addresses on the
        NetLink. Can also be set.

        :rtype: str
        """
        return self.data.get("ip_range")

    @ip_range.setter
    def ip_range(self, value):
        if "-" in value:
            self.data.update(ip_range=value)

    @property
    def netlink_role(self):
        """
        Shows whether the Netlink is active or standby.
        Active - traffic is routed through the NetLink according to the
        method you specify in the Outbound Multi-Link element properties.
        Standby - traffic is only routed through the netlink if all primary
        (active) netlinks are unavailable.

        :rtype: str
        """
        return self.data.get("netlink_role")

    @netlink_role.setter
    def netlink_role(self, value):
        if value in ("standby", "active"):
            self.data.update(netlink_role=value)

    @classmethod
    def create(cls, netlink, ip_range=None, netlink_role="active"):
        """
        Create a multilink member. Multilink members are added to an
        Outbound Multilink configuration and define the ip range, static
        netlink to use, and the role. This element can be passed to the
        Multilink constructor to simplify creation of the outbound multilink.

        :param StaticNetlink,DynamicNetlink netlink: static netlink element to
            use as member
        :param str ip_range: the IP range for source NAT for this member. The
            IP range should be part of the defined network range used by this
            netlink. Not required for dynamic netlink
        :param str netlink_role: role of this netlink, 'active' or 'standby'
        :raises ElementNotFound: Specified netlink could not be found
        :rtype: MultilinkMember
        """
        member_def = dict(
            netlink_ref=netlink.href,
            netlink_role=netlink_role,
            ip_range=ip_range if netlink.typeof == "netlink" else "0.0.0.0",
        )
        if netlink.typeof == "netlink":  # static netlink vs dynamic netlink
            member_def.update(network_ref=netlink.network[0].href)

        return cls(member_def)

    def __repr__(self):
        return "MultilinkMember(netlink={},netlink_role={},ip_range={})".format(
            self.netlink, self.netlink_role, self.ip_range)