fmcapi
fmcapi copied to clipboard
Error running example script
Ran the example script and keep getting the following error:
INFO:root:Waiting 15 seconds to allow the FMC to update the list of deployable devices. INFO:root:Getting a list of deployable devices.
You will need to provide a lot more details if we are to offer you any advice. What debugging have you done? After which call is the problem occurring? etc
Make sure you include the argument debug=false to output additional debugging
So with debug enabled I see this:
DEBUG:root:In __init__() for APIClassTemplate class.
DEBUG:root:In __init__() for AccessPolicies class.
DEBUG:root:In parse_kwargs() for APIClassTemplate class.
DEBUG:root:In syntax_correcter() helper_function.
DEBUG:root:In parse_kwargs() for AccessPolicies class.
DEBUG:root:In the FMC __exit__() class method.
DEBUG:root:In __init__ for DeploymentRequests() class.
DEBUG:root:In post() method for DeploymentRequests() class.
DEBUG:root:In __init__ for DeployableDevices() class.
INFO:root:Waiting 15 seconds to allow the FMC to update the list of deployable devices.
DEBUG:root:GET method for API for DeployableDevices.
INFO:root:Getting a list of deployable devices.
DEBUG:root:In the FMC send_to_api() class method.
DEBUG:root:In the Token get_token() class method.
It tries to create an Access Policy and then it looks for Deployable Devices, but since I have not added an FTD yet, it does not find a deployable device. Then it fails due to an issue with connection establishment which is weird because I am already interacting with the FMC up to this point
DEBUG:root:Being sent to FMC's API:
HEADERS={'Content-Type': 'application/json', 'X-auth-access-token': '90019041-12b1-4a3c-89fa-590f425a6905'}
URL=https://192.168.1.150/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/deployment/deployabledevices?expanded=true
METHOD=get
MORE_ITEMS=None
JSON_DATA=None
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): 192.168.1.150:443
DEBUG:urllib3.connectionpool:https://192.168.1.150:443 "GET /api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/deployment/deployabledevices?expanded=true HTTP/1.1" 200 None
DEBUG:root:Response from FMC's API:
_content=b'{"links":{},"paging":{"offset":0,"limit":0,"count":0,"pages":0}}'
_content_consumed=True
_next=None
apparent_encoding=ascii
close=<bound method Response.close of <Response [200]>>
connection=<requests.adapters.HTTPAdapter object at 0x7f70db87d310>
content=b'{"links":{},"paging":{"offset":0,"limit":0,"count":0,"pages":0}}'
cookies=<RequestsCookieJar[]>
elapsed=0:00:00.620826
encoding=None
headers={'Date': 'Sat, 20 Apr 2024 04:29:44 GMT', 'Server': 'Apache', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'Cache-Control': 'no-store', 'Accept-Ranges': 'bytes', 'Vary': 'Accept-Charset,Accept-Encoding,Accept-Language,Accept', 'Content-Encoding': 'gzip', 'X-Frame-Options': 'SAMEORIGIN', 'X-UA-Compatible': 'IE=edge', 'X-Permitted-Cross-Domain-Policies': 'none', 'X-XSS-Protection': '1; mode=block', 'Referrer-Policy': 'same-origin', 'Content-Security-Policy': "base-uri 'self'", 'X-Content-Type-Options': 'nosniff', 'Keep-Alive': 'timeout=5, max=100', 'Connection': 'Keep-Alive', 'Transfer-Encoding': 'chunked', 'Content-Type': 'application/json'}
history=[]
is_permanent_redirect=False
is_redirect=False
iter_content=<bound method Response.iter_content of <Response [200]>>
iter_lines=<bound method Response.iter_lines of <Response [200]>>
json=<bound method Response.json of <Response [200]>>
links={}
next=None
ok=True
raise_for_status=<bound method Response.raise_for_status of <Response [200]>>
raw=<urllib3.response.HTTPResponse object at 0x7f70db83ebb0>
reason=200
request=<PreparedRequest [GET]>
status_code=200
text={"links":{},"paging":{"offset":0,"limit":0,"count":0,"pages":0}}
url=https://192.168.1.150/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/deployment/deployabledevices?expanded=true
INFO:root:No devices need deployed.
ERROR:root:Section 'fmc' does not have the right information (bad password?) to establish a connection to FMC:
ERROR:root: Error is ''str' object has no attribute 'get'
Do not attempt to deploy to the FTDs then, set autodeploy=True to autodeploy=False
Sounds good. Thanks
Still shows the following error. I guess this is unrelated to Auto Deploy:
INFO:root:Auto deploy changes set to False. Use the Deploy button in FMC to push changes to FTDs.
ERROR:root:Section 'fmc' does not have the right information (bad password?) to establish a connection to FMC:
ERROR:root: Error is ''str' object has no attribute 'get''
That error is only present in in the example code example/logic_separate_from_data/program_logic.py
It is a catch all for any errors in the example:
except Exception as e:
logging.error(
f"Section 'fmc' does not have the right information (bad password?)"
f" to establish a connection to FMC:"
)
logging.error(f"\tError is '{e}'")
Given the error is Error is ''str' object has no attribute 'get'' I am going to speculate there is a data issue. If I was troubleshooting this I would use my debugger to step through the example and find where the error is occurring. Then you will be able to determine what is going wrong.
Alternatively, give the mixed logic/data a go (example/mixed_logic_and_data/hq-ftd.py) and see if you hit the same issue.