Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test__ftddevicehapairs(fmc):
logging.info(
'Test FTDDeviceHAPairs. After an HA Pair is created, all API calls to "devicerecords" objects should '
"be directed at the currently active device not the ha pair"
)
failover1 = fmcapi.PhysicalInterfaces(fmc=fmc)
failover1.get(device_name="PrimaryName", name="GigabitEthernet0/6")
stateful1 = fmcapi.PhysicalInterfaces(fmc=fmc)
stateful1.get(device_name="PrimaryName", name="GigabitEthernet0/7")
obj0 = fmcapi.DeviceHAPairs(fmc=fmc)
obj1 = fmcapi.FTDDeviceHAPairs(fmc=fmc)
obj1.primary(name="PrimaryName")
obj1.secondary(name="SecondaryName")
obj1.name = "HaName"
# failover interface subnetMask must be in x.x.x.x format"
obj1.ftdHABootstrap = {
"isEncryptionEnabled": "true",
"encKeyGenerationScheme": "CUSTOM",
"sharedKey": "cisco123",
"useSameLinkForFailovers": False,
"lanFailover": {
"useIPv6Address": False,
"subnetMask": "255.255.255.252",
"interfaceObject": {
def test__phys_interfaces(fmc):
logging.info(
"Test PhysicalInterface. get, put PhysicalInterface Objects. Requires registered device"
)
sz1 = fmcapi.SecurityZones(fmc=fmc)
sz1.name = "SZ-OUTSIDE1"
sz1.post()
time.sleep(1)
sz2 = fmcapi.SecurityZones(fmc=fmc)
sz2.name = "SZ-OUTSIDE2"
sz2.post()
time.sleep(1)
intf1 = fmcapi.PhysicalInterfaces(fmc=fmc, device_name="device_name")
intf1.get(name="GigabitEthernet0/0")
intf1.enabled = True
intf1.ifname = "OUTSIDE1"
intf1.activeMACAddress = "0050.5686.718f"
intf1.standbyMACAddress = "0050.5686.0c2e"
intf1.static(ipv4addr="10.254.0.3", ipv4mask=24)
intf1.sz(name=sz1.name)
intf2 = fmcapi.PhysicalInterfaces(fmc=fmc, device_name="device_name")
intf2.get(name="GigabitEthernet0/1")
intf2.enabled = True
intf2.ifname = "OUTSIDE2"
intf2.activeMACAddress = "0050.5686.821d"
intf2.standbyMACAddress = "0050.5686.11cb"
intf2.dhcp()
intf2.sz(name=sz2.name)
intf1.put()
hq_ftd.licensing(action="add", name="BASE")
hq_ftd.licensing(action="add", name="THREAT")
hq_ftd.licensing(action="add", name="URLFilter")
# Push to FMC to start device registration.
hq_ftd.post(post_wait_time=300)
# Once registration is complete configure the interfaces of hq-ftd.
hq_ftd_g00 = fmcapi.PhysicalInterfaces(fmc=fmc1, device_name=hq_ftd.name)
hq_ftd_g00.get(name="GigabitEthernet0/0")
hq_ftd_g00.enabled = True
hq_ftd_g00.ifname = "IN"
hq_ftd_g00.static(ipv4addr="10.0.0.1", ipv4mask=24)
hq_ftd_g00.sz(name="inside")
hq_ftd_g00.put()
hq_ftd_g01 = fmcapi.PhysicalInterfaces(fmc=fmc1, device_name=hq_ftd.name)
hq_ftd_g01.get(name="GigabitEthernet0/1")
hq_ftd_g01.enabled = True
hq_ftd_g01.ifname = "OUT"
hq_ftd_g01.static(ipv4addr="100.64.0.200", ipv4mask=24)
hq_ftd_g01.sz(name="outside")
hq_ftd_g01.put()
# Build static default route for HQ FTD
hq_default_route = fmcapi.IPv4StaticRoutes(fmc=fmc1, name="hq_default_route")
hq_default_route.device(device_name=hq_ftd.name)
hq_default_route.networks(action="add", networks=["any-ipv4"])
hq_default_route.gw(name=hq_dfgw_gateway.name)
hq_default_route.interfaceName = hq_ftd_g01.ifname
hq_default_route.metricValue = 1
hq_default_route.post()
ftd.regKey = dr["registration_key"]
if "access_policy" in dr:
ftd.acp(name=dr["access_policy"])
if "name" in dr:
ftd.name = dr["name"]
if "licenses" in dr:
for lice in dr["licenses"]:
ftd.licensing(action="add", name=lice["name"])
# Push to FMC to start device registration.
ftd.post(post_wait_time=dr["wait_for_post"])
# Time to configure interfaces.
if "interfaces" in dr:
if "physical" in dr["interfaces"]:
for interface in dr["interfaces"]["physical"]:
int1 = fmcapi.PhysicalInterfaces(fmc=fmc, device_name=dr["name"])
if "name" in interface:
int1.get(name=interface["name"])
if "enabled" in interface:
int1.enabled = interface["enabled"]
if "interface_name" in interface:
int1.ifname = interface["interface_name"]
if "security_zone" in interface:
int1.sz(name=interface["security_zone"])
if "addresses" in interface:
if "ipv4" in interface["addresses"]:
if "static" in interface["addresses"]["ipv4"]:
int1.static(
ipv4addr=interface["addresses"]["ipv4"]["static"][
"ip"
],
ipv4mask=interface["addresses"]["ipv4"]["static"][
# Minimum things set.
hq_ftd.hostName = "10.0.0.254"
hq_ftd.regKey = "cisco123"
hq_ftd.acp(name=acp.name)
# Other stuff I want set.
hq_ftd.name = "hq-ftd"
hq_ftd.licensing(action="add", name="MALWARE")
hq_ftd.licensing(action="add", name="VPN")
hq_ftd.licensing(action="add", name="BASE")
hq_ftd.licensing(action="add", name="THREAT")
hq_ftd.licensing(action="add", name="URLFilter")
# Push to FMC to start device registration.
hq_ftd.post(post_wait_time=300)
# Once registration is complete configure the interfaces of hq-ftd.
hq_ftd_g00 = fmcapi.PhysicalInterfaces(fmc=fmc1, device_name=hq_ftd.name)
hq_ftd_g00.get(name="GigabitEthernet0/0")
hq_ftd_g00.enabled = True
hq_ftd_g00.ifname = "IN"
hq_ftd_g00.static(ipv4addr="10.0.0.1", ipv4mask=24)
hq_ftd_g00.sz(name="inside")
hq_ftd_g00.put()
hq_ftd_g01 = fmcapi.PhysicalInterfaces(fmc=fmc1, device_name=hq_ftd.name)
hq_ftd_g01.get(name="GigabitEthernet0/1")
hq_ftd_g01.enabled = True
hq_ftd_g01.ifname = "OUT"
hq_ftd_g01.static(ipv4addr="100.64.0.200", ipv4mask=24)
hq_ftd_g01.sz(name="outside")
hq_ftd_g01.put()
# Build static default route for HQ FTD