pyaoscx.pyaoscx_factory module

class pyaoscx.pyaoscx_factory.PyaoscxFactory(session)

Bases: object

Provide a Factory class to instantiate all pyaoscx Modules through specific
methods. This class is superseded by the Device class, use the Device class instead of this one. Using the API Version given by the Session.
acl(list_name, list_type)

Create an Acl object.

Parameters:
  • list_name – Alphanumeric name of ACL.
  • list_type – Alphanumeric type of ACL. Type should be one of “ipv4,” “ipv6,” or “mac”.
Returns:

Acl object.

acl_entry(list_name, list_type, sequence_num, action='permit', count=None, protocol=None, src_ip=None, dst_ip=None, dst_l4_port_min=None, dst_l4_port_max=None, src_mac=None, dst_mac=None, ethertype=None, **kwargs)

Create an AclEntry object.

Parameters:
  • list_name – Alphanumeric name of the ACL.
  • list_type – Type should be one of “ipv4,” “ipv6,” or “mac”.
  • sequence_num – Integer number of the sequence.
  • action – Action should be either “permit” or “deny”.
  • count – Optional boolean flag that when true, will make entry increment hit count for matched packets.
  • protocol – Optional integer IP protocol number.
  • src_ip – Optional source IP address. Both IPv4 and IPv6 are supported. Example: 10.10.12.11/255.255.255.255 2001:db8::11/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
  • dst_ip – Optional destination IP address. Both IPv4 and IPv6 are supported. Example: 10.10.12.11/255.255.255.255 2001:db8::11/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
  • dst_l4_port_min – Optional minimum L4 port number in range; used in conjunction with dst_l4_port_max.
  • dst_l4_port_max – Optional maximum L4 port number in range; used in conjunction with dst_l4_port_min.
  • src_mac – Optional source MAC address. Example: ‘01:02:03:04:05:06’
  • dst_mac – Optional destination MAC address. Example: ‘01:02:03:04:05:06’
  • ethertype – Optional integer EtherType number.
  • kwargs – Optional keyword arguments for more detailed configuration.
Returns:

A AclEntry object.

aggregate_address(vrf, bgp_router_asn, family_type, ip_prefix)

Create an AggregateAddress object.

Parameters:
  • vrf – Alphanumeric name of the VRF the BGP ASN belongs to. A Vrf object is also accepted.
  • bgp_router_asn – Integer that represents the Autonomous System Number.
  • family_type – Address Family type for the Aggregate Address. The options are: ‘ipv4-unicast’, ‘ipv6-unicast’.
  • ip_prefix – IP address and mask used to key Aggregate Address. Example: ‘1.1.1.1/24’.
Returns:

AggregateAddress object.

bgp_neighbor(vrf, bgp_router_asn, group_ip, family_type=None, reflector=None, send_community=None, local_interface='')
Create a BgpNeighbor object. If values differ from existing object,
incoming changes will be applied.
Parameters:
  • vrf – Alphanumeric name of the VRF the BGP ASN belongs to. A Vrf object is also accepted.
  • bgp_router_asn – Integer that represents the Autonomous System Number.
  • group_ip – IPv4 address or name of group of the neighbors that functions as the BGP Router link. Example: ‘1.1.1.1’
  • family_type – Alphanumeric to specify what type of neighbor settings to configure. The options are ‘l2vpn-evpn’, ‘ipv4-unicast’, or ‘ipv6-unicast’. When setting to l2vpn-evpn, the neighbor configurations also will add route-reflector-client and send-community settings.
  • reflector – Boolean value to determine whether this neighbor has route reflector enabled. Default is False.
  • send_community – Boolean value to determine whether this neighbor has send-community enabled. Default is False.
  • local_interface – Optional alphanumeric to specify which interface the neighbor will apply to.
Returns:

BgpNeighbor object.

bgp_router_asn(vrf, asn, router_id=None)
Create a BgpRouter object as Autonomous System Number. If values differ
from existing object, incoming changes will be applied.
Parameters:
  • vrf – Alphanumeric name of the VRF the BGP ASN belongs to. A Vrf object is also accepted.
  • asn – Integer that represents the Autonomous System Number.
  • router_id – Optional IPv4 address that functions as the BGP Router ID.
Returns:

BgpRouter object.

bgp_router_vrf(vrf, asn, redistribute)
Create a BgpRouter object with a BGP VRF settings for the associated
BGP ASN. If values differ from existing object, incoming changes will be applied.
Parameters:
  • vrf – Alphanumeric name of the VRF the BGP ASN belongs to. A Vrf object is also accepted.
  • asn – Integer that represents the Autonomous System Number.
  • redistribute – Alphanumeric to specify which types of routes that should be redistributed by BGP. The options are “ipv4-unicast” or “ipv6-unicast”.
Returns:

BgpRouter object.

configuration()
Create a Configuration class, to obtain device configuration and
perform other actions such as backup_config.
Returns:Configuration object.
dhcp_relay(vrf, port)

Create a DhcpRelay object.

Parameters:
  • vrf – Alphanumeric name of VRF.
  • port – Alphanumeric name of Port.
Returns:

DhcpRelay object.

dns(vrf=None, domain_name=None, domain_list=None, domain_servers=None, host_v4_address_mapping=None, host_v6_address_mapping=None)

Create a DNS class, to configure a DNS inside a given VRF.

Parameters:
  • domain_name – Domain name used for name resolution by the DNS client, if ‘dns_domain_list’ is not configured.
  • domain_list – dict of DNS Domain list names to be used for address resolution, keyed by the resolution priority order. Example: { 0: “hpe.com” 1: “arubanetworks.com” }
  • domain_servers – dict of DNS Name servers to be used for address resolution, keyed by the resolution priority order. Example: { 0: “4.4.4.10” 1: “4.4.4.12” }
  • host_v4_address_mapping – dict of static host address configurations and the IPv4 address associated with them. Example: { “host1”: “5.5.44.5” “host2”: “2.2.44.2” }
  • host_v6_address_mapping – dict of static host address configurations and the IPv6 address associated with them. Example: { “host1”: “2001:0db8:85a3:0000:0000:8a2e:0370:7334” }
Returns:

DNS object.

interface(name)

Create an Interface object.

Parameters:name – Alphanumeric name of Interface.
Returns:Interface object.
ipv6(address, interface_name, address_type=None)
Create a Ipv6 object. If values differ from existing object, incoming
changes will be applied.
Parameters:
  • address – Alphanumeric address of IPv6. Example: ‘2001:db8::11/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff’
  • interface_name – Alphanumeric name of the Interface parent of the IPv6 Address. A Interface object is also accepted.
  • address_type – Type of IPv6 address. Defaults to “global-unicast” if not specified..
Returns:

Ipv6 object.

mac(vlan, from_id, mac_address)

Create an Mac object.

Parameters:
  • vlan_id – Numeric ID for VLAN. A Vlan object is also accepted.
  • from_id – String source of the MAC address. Must be “dynamic”, “VSX”, “static”, “VRRP”, “port-access-security”, “evpn”, or “hsc”.
  • mac_address – String MAC address, or netaddr EUI object. Example: ‘01:02:03:04:05:06’.
Returns:

Mac object.

ospf_interface(vrf, ospf_id, area_id, interface_name, **kwargs)

Create a OspfInterface object.

Parameters:
  • vrf – Alphanumeric name of the VRF the OSPF ID belongs to. A Vrf object is also accepted.
  • ospf_id – OSPF process ID between numbers 1-63. A OSPF Router is accepted.
  • area_id – Unique identifier as a string in the form of x.x.x.x.
  • interface_name – Alphanumeric name of the interface that will be attached to the OSPF area.
Returns:

OspfInterface object.

ospf_router(vrf, ospf_id, **kwargs)
Create OspfRouter object. If values differ from existing object,
incoming changes will be applied.
Parameters:
  • vrf – Alphanumeric name of the VRF the OSPF ID belongs to A Vrf object is also accepted.
  • ospf_id – OSPF process ID between numbers 1-63.
  • redistribute – List of types of redistribution methods for the OSPF Process, with the options being “bgp”, “connected”, and “static”.
Returns:

OspfRouter object.

ospf_router_area(vrf, ospf_router, area_id, **kwargs)
Create an OspfArea object. If values differ from existing object,
incoming changes will be applied.
Parameters:
  • vrf – Alphanumeric name of the VRF the OSPF ID belongs to.
  • ospf_router – OSPF process ID in [1, 63], an OspfRouter, or Ospfv3Router object is also accepted.
  • area_id – Unique identifier as a string in the form of x.x.x.x.
  • area_type – Alphanumeric defining how the external routing and summary LSAs for this area will be handled. Options are “default”, “nssa”, “nssa_no_summary”, “stub”, “stub_no_summary”. If no value is passed, “default” is used.
Returns:

OspfArea object.

Create a OspfVlink object. Defaults to using OspfRouter, when providing
the OSPF process ID.
Parameters:
  • vrf – Alphanumeric name of the VRF the OSPF ID belongs to. A Vrf object is also accepted.
  • ospf_router – OSPF process ID number in [1,63]. An OSPF Router object is also accepted (both v2, and v3 versions).
  • area_id – Unique identifier as a string in the form of x.x.x.x.
  • peer_router – ID of the peer OSPF router as IP address in x.x.x.x form.
Returns:

OspfVlink object.

ospfv3_interface(vrf, ospf_id, area_id, interface_name, **kwargs)

Create a OspfInterface object.

Parameters:
  • vrf – Alphanumeric name of the VRF the OSPF ID belongs to. A Vrf object is also accepted.
  • ospfv3_id – OSPFv3 process ID between numbers 1-63. An OSPFv3 Router is accepted.
  • area_id – Unique identifier as a string in the form of x.x.x.x.
  • interface_name – Alphanumeric name of the interface that will be attached to the OSPF area.
Returns:

OspfInterface object.

ospfv3_router(vrf, ospfv3_id, **kwargs)
Create Ospfv3Router object. If values differ from existing object,
incoming changes will be applied.
Parameters:
  • vrf – Alphanumeric name of the VRF the OSPF ID belongs to. A Vrf object is also accepted.
  • ospfv3_id – OSPF process ID between numbers 1-63.
  • redistribute – List of types of redistribution methods for the OSPF Process, with the options being “bgp”, “connected”, “local_loopback”, “rip”, and “static”.
Returns:

Ospfv3Router object.

ospfv3_router_area(vrf, ospfv3_id, area_id, **kwargs)
Create OspfArea object. If values differ from existing object, incoming
changes will be applied.
Parameters:
  • vrf – Alphanumeric name of the VRF the OSPF ID belongs to.
  • ospfv3_id – OSPFv3 process ID in [1,63], an Ospfv3Router object is also accepted.
  • area_id – Unique identifier as a string in the form of x.x.x.x.
  • area_type – Alphanumeric defining how the external routing and summary LSAs for this area will be handled. Options are “default”, “nssa”, “nssa_no_summary”, “stub”, “stub_no_summary” if no value is passed, “default” is used.
Returns:

OspfArea object.

Create a OspfVlink object.

Parameters:
  • vrf – Alphanumeric name of the VRF the OSPF ID belongs to. A Vrf object is also accepted.
  • ospf_router – OSPFv3 process ID number in [1, 63]. An Ospfv3Router object is also accepted.
  • area_id – Unique identifier as a string in the form of x.x.x.x.
  • peer_router – ID of the peer OSPFv3 router as IP address in x.x.x.x form.
Returns:

OspfVlink object.

poe_interface(interface)

Create a PoE Interface object with associated settings.

Parameters:Interface – Alphanumeric name of the Interface the PoE_Interface belongs to. An Interface object is also accepted.
Returns:PoE Interface object.
qos(name, **kwargs)

Create a Qos object.

Parameters:name – String representing a user-defined name for a Qos object.
Returns:Returns a Qos object.
qos_cos(code_point, **kwargs)

Gets a QoS COS trust mode object.

Parameters:code_point – Integer to identify an entry a QoS COS trust mode object.
Returns:Returns a QoS COS trust mode object.
qos_dscp(code_point, **kwargs)

Retrieves a QoS DSCP trust mode map entry as an object.

Parameters:code_point – Integer to identify an entry a QoS DSCP trust mode object.
Returns:Returns a QoS DSCP trust mode object.
queue(qos_name, queue_number, **kwargs)

Create a Queue object.

Parameters:
  • qos_name – String with a user-defined name for a QoS object.
  • queue_number – Integer representing a queue priority, with zero being the lowest priority. The maximum number of queues is hardware-dependent.
Returns:

Queue object.

queue_profile(name, **kwargs)

Create a Queue Profile object.

Parameters:name – name of the profile.
Returns:Queue Profile object.
queue_profile_entry(queue_number, queue_profile, **kwargs)

Create a Queue Profile Entry object.

Parameters:
  • queue_number – Number that identifies the entry.
  • queue_profile – A Queue Profile object.
Returns:

Queue Profile Entry object.

static_mac(vlan, port, mac_address)

Create an StaticMac object.

param vlan_id: Numeric ID for VLAN. A Vlan object is also accepted. :param port: String for the Port’s name. Example 1/1/1. :param mac_address: String MAC address, or netaddr EUI object. :return: StaticMac object.

static_nexthop(vrf, destination_address_prefix, next_hop_ip_address=None, nexthop_type=None, distance=None, next_hop_interface=None, bfd_enable=None)
Create a Static Nexthop, with a VRF and a Destination Address related
to a Static Route.
Parameters:
  • vrf – Name of the VRF on which the static route is to be configured. Defaults to “default”. A Vrf object is also accepted.
  • destination_address_prefix – String IPv4 or IPv6 destination prefix and mask in the address/mask format. A StaticRoute object is also accepted. Example: ‘1.1.1.1’ or ‘2001:db8::11/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff’
  • next_hop_ip_address – The IPv4 address or the IPv6 address of next hop. Example: ‘1.1.1.1’ or ‘2001:db8::11/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff’
  • nexthop_type – Specifies whether the static route is a forward, blackhole or reject route.
  • distance – Administrative distance to be used for the next hop in the static route instead of default value.
  • next_hop_interface – The interface through which the next hop can be reached.
  • bfd_enable – Boolean to enable BFD.
Returns:

StaticNexthop object.

static_route(vrf, destination_address_prefix)

Create a StaticRoute object with a VRF.

Parameters:
  • vrf – Name of the VRF on which the static route is to be configured. Defaults to default vrf. A Vrf object is also accepted.
  • destination_address_prefix – String IPv4 or IPv6 destination prefix and mask in the address/mask format. Example: ‘1.1.1.1’ or ‘2001:db8::11/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff’
Returns:

StaticRoute object.

tunnel_endpoint(interface, network_id, destination, origin='static', vrf=None, **kwargs)

Create a Tunnel Endpoint

Parameters:
  • interface – Attached interface for tunnel
  • network_id – Network identifier
  • destination – Destination IP
  • origin – Type of tunneling ‘static’ for user configuration (default) ‘evpn’ for dynamically learnt via EVPN ‘hsc’ for dynamically learnt from a remote controller
  • vrf – Mapped VRF of tunnel
vlan(vlan_id, name=None, description=None, vlan_type=None, admin_conf_state='up')

Create a Vlan object.

Parameters:
  • vlan_id – Numeric ID for VLAN.
  • name – Alphanumeric name of VLAN, Defaults to “VLAN <ID>”.
  • description – Optional description to add to VLAN.
  • vlan_type – VLAN type. Defaults to “static” if not specified.
  • admin_conf_state – Optional administratively-configured state of VLAN. Only configurable for static VLANs. Defaults to “up” for static VLANs.
Returns:

Vlan object.

vlan_and_svi(vlan_id, vlan_name, vlan_int_name, vlan_desc=None, ipv4=None, vrf_name='default', vlan_port_desc=None)
Create VLAN and Interface objects to represent VLAN and SVI,
respectively.
Parameters:
  • vlan_id – Numeric ID of VLAN.
  • vlan_name – Alphanumeric name of VLAN.
  • vlan_int_name – Alphanumeric name for the VLAN interface.
  • vlan_desc – Optional description to add to VLAN.
  • ipv4 – Optional IPv4 address to assign to the interface. Defaults to nothing if not specified. Example: ‘1.1.1.1’
  • vrf_name – VRF to attach the SVI to. Defaults to “default”.
  • vlan_port_desc – Optional description for the interface. Defaults to nothing if not specified.
Returns:

A tuple with a Vlan object and a Interface SVI object.

vni(vni_id, interface, vni_type='vxlan_vni', routing=None, vlan=None, vrf=None, **kwargs)

Create a Virtual Network ID (VNI).

Parameters:
  • vni_id – VNI identifier.
  • interface – Attached interface to the VNI.
  • vni_type – Type of the VNI (for now just vxlan_vni).
  • vlan – Mapped VLAN to the VNI.
  • vrf – Mapped VRF to the VNI (if L3 is supported).
  • routing – Flag that indicates if VNI is L2 or L3.
Returns:

VNI object.

vrf(name, route_distinguisher=None, vrf_type=None)
Create a Vrf object. If values differ from existing object, incoming
changes will be applied.
Parameters:
  • name – VRF name.
  • route_distinguisher – Optional route distinguisher to add. Defaults to nothing if not specified.
  • vrf_type – Optional VRF type. Defaults to “user” if not specified.
Returns:

Vrf object.

vrf_address_family(vrf, address_family='ipv4_unicast')

Create a VrfAddressFamily object with a VRF.

Parameters:
  • vrf – Alphanumeric name of the VRF the Family Address belongs to. A Vrf object is also accepted.
  • address_family – Alphanumeric type of the Address Family. The options are ‘ipv4_unicast’ and ‘ipv6_unicast’. Defaults to ‘ipv4_unicast’.
Returns:

VRF_Address_Family object.

vsx(**kwargs)
Create a Vsx object. If values differ from existing object, incoming
changes will be applied.
Returns:A Vsx object.
class pyaoscx.pyaoscx_factory.Singleton

Bases: type

Metaclass to turn classes into a Singleton.