def do_something(incoming_msg): """ Sample function to do some action. :param incoming_msg: The incoming message object from Teams :return: A text or markdown based reply """ guest_user = quick_guest(name) gu = guest_user.split(',') usr = gu[0].split(':') user = usr[1].replace('"', '') pswd = gu[1].split(':') passwd = pswd[1].replace('"', '') password = passwd.replace('}', '') fmc_policy = 0 fmc_authenticate() test_fmc = fmc_get('policy/accesspolicies') for item in test_fmc['items']: if item['name'] == config['FMC']['POLICY_NAME']: fmc_policy = 1 if fmc_policy == 0: os.system('python3 fmc_create_access_policy.py') os.system('rm *.log') return "I did what you said - {}".format( incoming_msg.text ) + "\n Username: "******"\nPassword: "******"I did what you said - {}".format( incoming_msg.text ) + "\n Username: "******"\nPassword: " + password
def dumptofile(f): # Authenticate with FMC access_token, domain_uuid = fmc_authenticate() output = fmc_get("devices/devicerecords") # So get the number of items in the list. I figure that this will be the number of sensors for i in range(len(output['items'])): # print(output['items'][i-1]['id']) containerUUID.append(output['items'][i - 1]['id']) for i in containerUUID: output = fmc_get("devices/devicerecords/" + i + "/routing/ipv4staticroutes") #print(output['items'][0]['id']) #print(len(output['items'])) for i in range(len(output['items'])): objectid.append(output['items'][i - 1]['id']) for i in range(len(containerUUID)): for j in range(len(objectid)): output = "ContainerUUID " + containerUUID[ i - 1] + " objectID " + objectid[j - 1] for i in containerUUID: for j in objectid: getRoutes(i, j, f)
def loadroutes(containerUUID): f = open('fmc-route-output.txt', 'r') access_token, domain_uuid = fmc_authenticate() for line in f: try: output = fmc_post( "devices/devicerecords/" + containerUUID + "/routing/ipv4staticroutes", json.loads(line)) except: print("Error: " + line) pass
# Temporarily add these directories to the system path so that we can import # local files. here = Path(__file__).parent.absolute() repository_root = (here / ".." / "..").resolve() sys.path.insert(0, str(repository_root)) sys.path.insert(0, str(here)) import os import configparser from fmc_requests import fmc_authenticate, fmc_get, fmc_delete # noqa config = configparser.ConfigParser() config.read(os.path.join(os.path.dirname(__file__), 'volume', 'config.cfg')) # Authenticate with FMC fmc_authenticate() # Get the configured access policies print(blue("\n==> Retrieving the configured access policies")) configured_policies = fmc_get("policy/accesspolicies") print( green("Successfully retrieved the list of configured access policies"), f"Retrieved {len(configured_policies['items'])} policies", sep="\n" ) # Look for a policy named "DNE Security Access Control Policy"