Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not load models from jamf #15

Open
flammable opened this issue May 15, 2017 · 9 comments
Open

Could not load models from jamf #15

flammable opened this issue May 15, 2017 · 9 comments

Comments

@flammable
Copy link

Thanks for this script! I'm finally getting around to running it via launchd. The Jamf Pro functionality looks perfect - it sure beats listing the model IDs manually in the script, which was my original plan. 😄

I'm running into a weird error, though - any idea?

I created a new JSS user, and gave them the ability to read Mobile Devices. Here's the command I'm running:

/usr/local/precache/precache.py --cache-server http://my.server.tld:49240 --jamfserver https://my.jss.tld:8443 --jamfuser myusername --jamfpassword mypassword

Here's the bash -x output:

+ /usr/local/precache/precache.py --cache-server http://my.server.tld:49240 --jamfserver https://my.jss.tld:8443 --jamfuser myusername --jamfpassword mypassword
precache version 1.1.2
Caching Server: http://my.server.tld:49240
Processing feeds. This may take a few moments.
Can not load models from jamf: <urlopen error [Errno 8] nodename nor servname provided, or not known>

The JSS URL is reachable from the server that's running this script - I was able to load the URL in Safari with no issues. Any idea what could be wrong?

Thanks!

Mike

@macinandy
Copy link

macinandy commented May 15, 2017

What happens If you change line 1012 from
"https://{}.jamfcloud.com/JSSResource/mobiledevices".format(args.jamfserver))
to read
"https://{}/JSSResource/mobiledevices".format(args.jamfserver))
and remove the https:// from your jamfserverurl this worked for me

@flammable
Copy link
Author

Thanks! I'll give this a try tomorrow!

@flammable
Copy link
Author

Ah, still the same error:

Can not load models from jamf: <urlopen error [Errno 8] nodename nor servname provided, or not known>

Anything else I can try?

Thanks!

Mike

@macinandy
Copy link

Hi Mike, this is the command I am using notice the "="
precache.py --jamfserver=jssaddress:8443 --jamfuser=jamfuser --jamfpassword=jamfpassword --debug

@flammable
Copy link
Author

Thanks, @macinandy. I made the changes, but they don't seem to have helped - here's the bash -x output. I added some variables, but nothing too fancy.

+ precache=/usr/local/precache/precache.py
+ caching_server_1=http://my.server.tld:49240
+ jamf_server=https://my.jss.tld:8443
+ jamf_user=myusername
+ jamf_password=mypassword
+ /usr/local/precache/precache.py --cache-server http://my.server.tld:49240 --jamfserver=https://my.jss.tld:8443 --jamfuser=myusername --jamfpassword=mypassword
precache version 1.1.2
Caching Server: http://my.server.tld:49240
Processing feeds. This may take a few moments.
Can not load models from jamf: <urlopen error [Errno 8] nodename nor servname provided, or not known>
+ exit 0

I also changed Caching Servers so that's why the ports are different. I also added --debug, but that just added more output to /tmp/precache.log. I don't see any hints that indicate what went wrong.

Also: I know the ReadMe says to put precache.py in /usr/local/bin, but do you think it's okay that I'm using /usr/local/precache instead? That way, I can do a git pull prior to running the script.

Thanks again for the help!

Mike

@macinandy
Copy link

macinandy commented May 16, 2017 via email

@flammable
Copy link
Author

Oops! I understand now. I had changed it from https:// to http://, not realizing that you meant to remove it entirely.

It's working! Thank you!

Do you think I can return line 1012 in precache.py back to normal?

Mike

@flammable
Copy link
Author

Hi @macinandy -

I updated my copy of precache.py, and the script returned these errors:

Traceback (most recent call last):
  File "/usr/local/precache/precache.py", line 1044, in <module>
    main()
  File "/usr/local/precache/precache.py", line 1016, in main
    jamf_response = urllib2.urlopen(jamf_request)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 431, in open
    response = self._open(req, data)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 449, in _open
    '_open', req)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1240, in https_open
    context=self._context)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1166, in do_open
    h = http_class(host, timeout=req.timeout, **http_conn_args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1254, in __init__
    source_address)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 751, in __init__
    (self.host, self.port) = self._get_hostport(host, port)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 793, in _get_hostport
    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
httplib.InvalidURL: nonnumeric port: '8443.jamfcloud.com'

I returned line 1012 to the code you mentioned in #15 (comment) and it's processing iOS device models properly again.

Would it be possible to merge this code change to the master branch, or would that break other things?

Thanks!

Mike

@carlashley
Copy link
Collaborator

carlashley commented Jun 30, 2017

@flammable @macinandy check out precache_dev here: https://github.com/carlashley/precache_dev to see if this resolves the issue. Note you will need to have the requests module installed. Definitely read through the README as there are some significant changes between this release, and v2.x.

Either of the below will work (may need to sudo):
pip install requests
easy_install_requests

If you prefer to manage python dependancies by using virtualenv, then use that.

You don't have to put precache.py in /usr/local/bin - it can be put anywhere. I'm lazy with my system config and don't like mucking about with PATH.

EDIT
I should point out that the precache_dev is still under testing, so keep it seperate from your current precache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants