You are on page 1of 2

#!

/usr/bin/python
import json
import connect
import sys

host = "fmc.dcloud.local"
username = "restapiuser"
password = "C1sco12345"
name="NGFW"

#connect to the FMC API


headers,uuid,server = connect.connect (host, username, password)

user_input = str(raw_input("Would you like to register the managed device? [y/n]"))


if user_input == "y":
policy_name = str(raw_input("Enter name of new Access Control Policy to be
create:"))
access_policy = {
"type": "AccessPolicy",
"name": policy_name,
"defaultAction": { "action": "BLOCK" }
}
post_response = connect.accesspolicyPOST(headers,uuid,server,access_policy)
policy_id = post_response["id"]
print "\n\nAccess Control Policy\n" + policy_name + "\ncreated\n\n"
device_post = {
"name": name,
"hostName": "ngfw.dcloud.local",
"regKey": "C1sco12345",
"type": "Device",
"license_caps": [
"BASE",
"MALWARE",
"URLFilter",
"THREAT"
],
"accessPolicy": {
"id": policy_id,
"type": "AccessPolicy"
}
}
post_data = json.dumps(device_post)

output = connect.devicePOST (headers, uuid, server, post_data)


# print "\n\nPost request is: \n" + json.dumps(output,indent=4) + "\n\n"

# GET ALL THE DEVICES AND THEIR corresponding interfaces

user_input = str(raw_input("In the FMC UI, confirm that the device discovery has
completed and then press 'y' to continue or 'n' to exit. [y/n]"))
headers,uuid,server = connect.connect (host, username, password)
if user_input == "n":
quit()

devices = connect.deviceGET(headers,uuid,server)
for device in devices["items"]:
if device["name"] == name:

Type :quit<Enter> to exit Vim


1,1 Top

You might also like