How to use the fmcapi.ProtocolPortObjects function in fmcapi

To help you get started, we’ve selected a few fmcapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github daxm / fmcapi / unit_tests / acprule.py View on Github external
vlantag1.post()
    # Build a Port object
    pport1 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_pport1", port="9090", protocol="UDP"
    )
    pport1.post()
    # Build a Port Group Object
    obj10 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_porttcp1", port="8443", protocol="TCP"
    )
    obj10.post()
    obj11 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_portudp1", port="161", protocol="UDP"
    )
    obj11.post()
    obj12 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_portrangetcp1", port="0-1023", protocol="TCP"
    )
    obj12.post()
    obj2 = fmcapi.PortObjectGroups(fmc=fmc, name="_fmcapi_test_portobjectgroup")
    obj2.named_ports(action="add", name=obj10.name)
    obj2.named_ports(action="add", name=obj11.name)
    obj2.named_ports(action="add", name=obj12.name)
    obj2.post()
    # Build a Security Zone object
    sz1 = fmcapi.SecurityZones(fmc=fmc, name="_sz1", interfaceMode="ROUTED")
    sz1.post()
    # Build an ACP Object
    acp1 = fmcapi.AccessPolicies(fmc=fmc, name=namer)
    acp1.post()
    # Get a file_policy
    # fp = fmcapi.FilePolicies(fmc=fmc1, name='daxm_test')
github daxm / fmcapi / unit_tests / protocol_port.py View on Github external
def test__protocol_port(fmc):
    logging.info("Test ProtocolPort.  Post, get, put, delete Port Objects.")

    starttime = str(int(time.time()))
    namer = f"_fmcapi_test_{starttime}"

    obj1 = fmcapi.ProtocolPortObjects(fmc=fmc)
    obj1.name = namer
    obj1.port = "1234"
    obj1.protocol = "TCP"
    obj1.post()
    time.sleep(1)
    del obj1
    obj1 = fmcapi.ProtocolPortObjects(fmc=fmc, name=namer)
    obj1.get()
    obj1.port = "5678"
    obj1.put()
    time.sleep(1)
    obj1.delete()
    logging.info("Test ProtocolPort done.\n")
github daxm / fmcapi / unit_tests / prefilter_rule.py View on Github external
)
    ip_range_1.post()
    fqdn_1 = FQDNS(fmc=fmc, name=f"test_fqdn_1_{namer}", value="www.cisco.com")
    fqdn_1.post()
    net_group_1 = NetworkGroups(fmc=fmc, name=f"net_group_1_{namer}")
    net_group_1.named_networks(action="add", name=f"test_net_1_{namer}")
    net_group_1.post()
    sec_zone_1 = SecurityZones(
        fmc=fmc, name=f"test_zone_1_{namer}", interfaceMode="ROUTED"
    )
    sec_zone_1.post()
    sec_zone_2 = SecurityZones(
        fmc=fmc, name=f"test_zone_2_{namer}", interfaceMode="ROUTED"
    )
    sec_zone_2.post()
    port_1 = ProtocolPortObjects(
        fmc=fmc, name=f"test_port_1_{namer}", port="8443", protocol="TCP"
    )
    port_1.post()
    port_2 = ProtocolPortObjects(
        fmc=fmc, name=f"test_port_2_{namer}", port="161", protocol="UDP"
    )
    port_2.post()
    port_3 = ProtocolPortObjects(
        fmc=fmc, name=f"test_port_3_{namer}", port="0-1023", protocol="TCP"
    )
    port_3.post()
    time.sleep(1)
    port_group_1 = PortObjectGroups(fmc=fmc, name=f"port_group_1_{namer}")
    port_group_1.named_ports(action="add", name=port_1.name)
    port_group_1.named_ports(action="add", name=port_2.name)
    port_group_1.named_ports(action="add", name=port_3.name)
github daxm / fmcapi / unit_tests / prefilter_rule.py View on Github external
net_group_1 = NetworkGroups(fmc=fmc, name=f"net_group_1_{namer}")
    net_group_1.named_networks(action="add", name=f"test_net_1_{namer}")
    net_group_1.post()
    sec_zone_1 = SecurityZones(
        fmc=fmc, name=f"test_zone_1_{namer}", interfaceMode="ROUTED"
    )
    sec_zone_1.post()
    sec_zone_2 = SecurityZones(
        fmc=fmc, name=f"test_zone_2_{namer}", interfaceMode="ROUTED"
    )
    sec_zone_2.post()
    port_1 = ProtocolPortObjects(
        fmc=fmc, name=f"test_port_1_{namer}", port="8443", protocol="TCP"
    )
    port_1.post()
    port_2 = ProtocolPortObjects(
        fmc=fmc, name=f"test_port_2_{namer}", port="161", protocol="UDP"
    )
    port_2.post()
    port_3 = ProtocolPortObjects(
        fmc=fmc, name=f"test_port_3_{namer}", port="0-1023", protocol="TCP"
    )
    port_3.post()
    time.sleep(1)
    port_group_1 = PortObjectGroups(fmc=fmc, name=f"port_group_1_{namer}")
    port_group_1.named_ports(action="add", name=port_1.name)
    port_group_1.named_ports(action="add", name=port_2.name)
    port_group_1.named_ports(action="add", name=port_3.name)
    port_group_1.post()

    vlan_tag_1 = VlanTags(fmc=fmc, name=f"vlan_tag_1_{namer}")
    vlan_tag_1.vlans(start_vlan="1", end_vlan="9")
github daxm / fmcapi / unit_tests / port_object_group.py View on Github external
def test__port_object_group(fmc):
    logging.info("Testing PortObjectGroup class.")

    starttime = str(int(time.time()))
    namer = f"_fmcapi_test_{starttime}"

    obj10 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_porttcp1", port="8443", protocol="TCP"
    )
    obj10.post()
    obj11 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_portudp1", port="161", protocol="UDP"
    )
    obj11.post()
    obj12 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_portrangetcp1", port="0-1023", protocol="TCP"
    )
    obj12.post()
    time.sleep(1)
    obj1 = fmcapi.PortObjectGroups(fmc=fmc, name=namer)
    obj1.named_ports(action="add", name=obj10.name)
    obj1.named_ports(action="add", name=obj10.name)
    obj1.named_ports(action="remove", name=obj10.name)
github daxm / fmcapi / unit_tests / port_object_group.py View on Github external
def test__port_object_group(fmc):
    logging.info("Testing PortObjectGroup class.")

    starttime = str(int(time.time()))
    namer = f"_fmcapi_test_{starttime}"

    obj10 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_porttcp1", port="8443", protocol="TCP"
    )
    obj10.post()
    obj11 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_portudp1", port="161", protocol="UDP"
    )
    obj11.post()
    obj12 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_portrangetcp1", port="0-1023", protocol="TCP"
    )
    obj12.post()
    time.sleep(1)
    obj1 = fmcapi.PortObjectGroups(fmc=fmc, name=namer)
    obj1.named_ports(action="add", name=obj10.name)
    obj1.named_ports(action="add", name=obj10.name)
    obj1.named_ports(action="remove", name=obj10.name)
    obj1.named_ports(action="clear")
    obj1.named_ports(action="add", name=obj11.name)
    obj1.named_ports(action="add", name=obj12.name)
    obj1.named_ports(action="remove", name=obj11.name)
github daxm / fmcapi / unit_tests / manualnat.py View on Github external
time.sleep(1)

    obj10 = fmcapi.Hosts(fmc=fmc)
    obj10.name = "_net_xlate_portbased"
    obj10.value = "192.0.2.254"
    obj10.post()
    time.sleep(1)

    obj11 = fmcapi.ProtocolPortObjects(fmc=fmc)
    obj11.name = "_port_original"
    obj11.protocol = "TCP"
    obj11.port = "443"
    obj11.post()
    time.sleep(1)

    obj12 = fmcapi.ProtocolPortObjects(fmc=fmc)
    obj12.name = "_port_xlate"
    obj12.protocol = "TCP"
    obj12.port = "8443"
    obj12.post()
    time.sleep(1)

    # Create Security Zones
    sz1 = fmcapi.SecurityZones(fmc=fmc, name="IG-INSIDE")
    sz1.post()
    sz2 = fmcapi.SecurityZones(fmc=fmc, name="SZ-OUTSIDE1")
    sz2.post()

    # Manualnat a network object to a host
    manualnat1 = fmcapi.ManualNatRules(fmc=fmc)
    manualnat1.original_source(name="_net_original")
    manualnat1.translated_source(name="_net_xlate")
github daxm / fmcapi / unit_tests / acprule.py View on Github external
obj1 = fmcapi.NetworkGroups(fmc=fmc, name="_fmcapi_test_networkgroup")
    obj1.named_networks(action="add", name=ipnet2.name)
    obj1.unnamed_networks(action="add", value="4.4.4.4/32")
    obj1.post()
    # Build a URL object
    url1 = fmcapi.URLs(fmc=fmc, name="_url1", url="asdf.org")
    url1.post()
    url1.get()
    # lists = [{"type": url1.type, "id": url1.id, "name": url1.name}]
    # Build a VLAN Tag object
    vlantag1 = fmcapi.VlanTags(
        fmc=fmc, name="_vlantag1", data={"startTag": "888", "endTag": "999"}
    )
    vlantag1.post()
    # Build a Port object
    pport1 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_pport1", port="9090", protocol="UDP"
    )
    pport1.post()
    # Build a Port Group Object
    obj10 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_porttcp1", port="8443", protocol="TCP"
    )
    obj10.post()
    obj11 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_portudp1", port="161", protocol="UDP"
    )
    obj11.post()
    obj12 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_portrangetcp1", port="0-1023", protocol="TCP"
    )
    obj12.post()
github daxm / fmcapi / unit_tests / protocol_port.py View on Github external
def test__protocol_port(fmc):
    logging.info("Test ProtocolPort.  Post, get, put, delete Port Objects.")

    starttime = str(int(time.time()))
    namer = f"_fmcapi_test_{starttime}"

    obj1 = fmcapi.ProtocolPortObjects(fmc=fmc)
    obj1.name = namer
    obj1.port = "1234"
    obj1.protocol = "TCP"
    obj1.post()
    time.sleep(1)
    del obj1
    obj1 = fmcapi.ProtocolPortObjects(fmc=fmc, name=namer)
    obj1.get()
    obj1.port = "5678"
    obj1.put()
    time.sleep(1)
    obj1.delete()
    logging.info("Test ProtocolPort done.\n")
github daxm / fmcapi / unit_tests / port_object_group.py View on Github external
def test__port_object_group(fmc):
    logging.info("Testing PortObjectGroup class.")

    starttime = str(int(time.time()))
    namer = f"_fmcapi_test_{starttime}"

    obj10 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_porttcp1", port="8443", protocol="TCP"
    )
    obj10.post()
    obj11 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_portudp1", port="161", protocol="UDP"
    )
    obj11.post()
    obj12 = fmcapi.ProtocolPortObjects(
        fmc=fmc, name="_portrangetcp1", port="0-1023", protocol="TCP"
    )
    obj12.post()
    time.sleep(1)
    obj1 = fmcapi.PortObjectGroups(fmc=fmc, name=namer)
    obj1.named_ports(action="add", name=obj10.name)
    obj1.named_ports(action="add", name=obj10.name)
    obj1.named_ports(action="remove", name=obj10.name)
    obj1.named_ports(action="clear")
    obj1.named_ports(action="add", name=obj11.name)
    obj1.named_ports(action="add", name=obj12.name)
    obj1.named_ports(action="remove", name=obj11.name)
    obj1.post()
    time.sleep(1)
    del obj1