Giter Club home page Giter Club logo

python-jss's Introduction

JSSImporter processor for AutoPkg

Deprecation Notice

This project is deprecated and is likely to stop functioning with upcoming versions of Jamf Pro. Please consider using JamfUploader instead.

Instructions for use

For details on how to use JSSImporter, please visit our Wiki.

Acknowledgements

Huge thanks to Shea Craig, who wrote the bulk of this work. Later versions were produced by Graham Pugh, who now maintains JamfUploader.

License

See the LICENSE file.

python-jss's People

Contributors

arubdesu avatar dependabot[bot] avatar eahrold avatar ftiff avatar fuzzylogiq avatar grahampugh avatar haircut avatar homebysix avatar jlrgraham avatar matthew-sec avatar moorereason avatar mosen avatar novaksam avatar sheagcraig avatar systemheld avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-jss's Issues

sslv3 alert handshake failure with JAMF Pro 10.6

We just updated our JAMF server to 10.6, and since then I haven't been able to get this library to run

Making the following call:
jamf_xml = j.MobileDevice().retrieve_all(subset="general&location&mobiledevicegroups")

And I get the resulting exception:
requests.exceptions.SSLError: HTTPSConnectionPool(host='ndh-jss-01.corp.contoso.com', port=8443): Max retries exceeded with url: /JSSResource/mobiledevices (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_read_bytes', 'sslv3 alert handshake failure')],)",),))

I have tried disabling ssl_verify in the JSS prefs, but the issue persists. Any ideas to further troubleshoot this?

SSL Verification Behaviour

According to what I've undertand , seems that default behaviour is that SSL verification is always enabled, isnt't it ?

In the jss_prefs.py file there is a line

self.verify = prefs.get("verify", True)

so if not specified, the SSL will be enabled, isn't it ?

I've fixed my issue ( at jssimporter/jss_helper#8) changing the value from True to False.
On my JSS test server I have an expired ssl certificates (problem that I will solve..) that without setting the SSL to False in the above file, doesn't allow me to use the toools (details of my error in the above link..)

I'm not a Python expert , so sorry if I've made some mistake :)

Support for Python3

This may come off as a bit of a noob question, but I'm still relatively new to Python..

I've been implementing AutoPkg (with the utilization of JSSImporter) for our JAMF instance at work, and I wanted to use the python-jss module specifically to take advantage of the JAMF API wrapper.. But I can't seem to get it to work with Python3.

In following the documentation, I'm able to import jss, but when I attempt to execute jss_prefs = jss.JSSPrefs(), and error is returned: module 'jss' has no attribute 'JSSPrefs'.

I've been wracking my brain over this and am wondering if this just doesn't work in python3. Any ideas?

UnboundLocalError: local variable 'prefs' referenced before assignment

Got this error with latest release:

[fti@gramont generate_report (master)]$ ./generate.sh 
Traceback (most recent call last):
  File "/root/generate_report.py", line 12, in <module>
    jss_prefs = jss.JSSPrefs()
  File "/usr/local/lib/python2.7/site-packages/jss/jss_prefs.py", line 125, in __init__
    self.parse_plist(self.preferences_file)
  File "/usr/local/lib/python2.7/site-packages/jss/jss_prefs.py", line 154, in parse_plist
    self.user = prefs.get("jss_user")
UnboundLocalError: local variable 'prefs' referenced before assignment

FYI I fixed this by converting the plist from binary to xml with plutil -convert xml1 ~/Library/Preferences/com.github.sheagcraig.python-jss.plist

Not able to use JSS_importer after logjam updates

I recently had a JAMF health checkup and we updated the ciphers for Tomcat to get around the Logjam problem (see https://jamfnation.jamfsoftware.com/article.html?id=384), but now I'm not able to push any JSS recipes!

Processing local.jss.AdobeAIR...
Traceback (most recent call last):
  File "/usr/local/bin/autopkg", line 1651, in <module>
    sys.exit(main(sys.argv))
  File "/usr/local/bin/autopkg", line 1645, in main
    exit(subcommands[verb]['function'](argv))
  File "/usr/local/bin/autopkg", line 1458, in run_recipes
    autopackager.process(recipe)
  File "/Library/AutoPkg/autopkglib/__init__.py", line 470, in process
    self.env = processor.process()
  File "/Library/AutoPkg/autopkglib/__init__.py", line 299, in process
    self.main()
  File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 866, in main
    suppress_warnings=suppress_warnings)
  File "/Library/Python/2.7/site-packages/python_jss-1.1.0-py2.7.egg/jss/jss.py", line 167, in __init__
    self.distribution_points = distribution_points.DistributionPoints(self)
  File "/Library/Python/2.7/site-packages/python_jss-1.1.0-py2.7.egg/jss/distribution_points.py", line 91, in __init__
    self.dp_info = self.jss.DistributionPoint().retrieve_all()
  File "/Library/Python/2.7/site-packages/python_jss-1.1.0-py2.7.egg/jss/jss.py", line 324, in DistributionPoint
    return self.factory.get_object(DistributionPoint, data)
  File "/Library/Python/2.7/site-packages/python_jss-1.1.0-py2.7.egg/jss/jss.py", line 475, in get_object
    result = self.jss.get(url)
  File "/Library/Python/2.7/site-packages/python_jss-1.1.0-py2.7.egg/jss/jss.py", line 197, in get
    response = self.session.get(url)
  File "/Library/Python/2.7/site-packages/python_jss-1.1.0-py2.7.egg/jss/contrib/requests/sessions.py", line 473, in get
    return self.request('GET', url, **kwargs)
  File "/Library/Python/2.7/site-packages/python_jss-1.1.0-py2.7.egg/jss/contrib/requests/sessions.py", line 461, in request
    resp = self.send(prep, **send_kwargs)
  File "/Library/Python/2.7/site-packages/python_jss-1.1.0-py2.7.egg/jss/contrib/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/Library/Python/2.7/site-packages/python_jss-1.1.0-py2.7.egg/jss/contrib/requests/adapters.py", line 431, in send
    raise SSLError(e, request=request)
jss.contrib.requests.exceptions.SSLError: [Errno 1] _ssl.c:507: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure

Using the builtin openssl to view the cert doesn't work, but using an updated one from Macports does.

{HOST}:~ {user}$ /usr/bin/openssl s_client -connect {JSS}:8443
CONNECTED(00000003)
94134:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:/SourceCache/OpenSSL098/OpenSSL098-52.30.1/src/ssl/s23_clnt.c:618:
{HOST}:~ {user}$ /usr/bin/openssl s_client -tls1 -connect {JSS}:8443
CONNECTED(00000003)
94136:error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure:/SourceCache/OpenSSL098/OpenSSL098-52.30.1/src/ssl/s3_pkt.c:1145:SSL alert number 40
94136:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:/SourceCache/OpenSSL098/OpenSSL098-52.30.1/src/ssl/s3_pkt.c:566:
{HOST}:~ {user}$ /opt/local/bin/openssl s_client -connect {JSS}:8443
[[ Lots of other, unimportant info ]]
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-GCM-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated

I've disabled SSL_VERIFY and otherwise done every suggestion I've been able to find. I also tried updating the openssl on my autopkg'ing machine but it didn't seem to work, even after a reboot.

kNAUIOptionNoUI Error on High Sierra macOS

https://github.com/sheagcraig/python-jss/blob/e1982466bd7e971f27525cbc31024590a456df66/jss/contrib/mount_shares_better.py#L54
https://github.com/sheagcraig/python-jss/blob/e1982466bd7e971f27525cbc31024590a456df66/jss/contrib/mount_shares_better.py#L80

These two lines are throwing an error in macOS High Sierra. My file system is APFS (encrypted).

I'm not sure how to proceed with troubleshooting (still learning), but my guess is that something has changed with the API calls that @pudquick discussed here: https://michaellynn.github.io/2015/08/08/learn-you-a-better-pyobjc-bridgesupport-signature/

Setting jss.verify_ssl does nothing.

SSL verification is only set upon JSS.__init__ which makes it obfuscated and confusing how to disable SSL verification through any means other than instantiating a new JSS object or reaching into the requests session (not recommended!)

Remove pyObjc and Foundation Dependecies

The project is great, but I'm curious how herculean the work would be to remove pyObjc/Foundation dependencies to allow python-jss to be used on other platforms (Linux mainly).

Way to create two policies?

We have a need to have two different policies get created for each new patch that comes out, one for creating a self-service policy scoped to our patch testers for initial QA, and another to alert them that the new self service policy is available to them.

Originally, we were simply using one policy and letting the JSS recipe's policy template include the needed strings to enable the JSS's ability to send Notifications to OS X's Notification Center, but we ran into to problems in that we want Alerts, not Banners. After significant attempts to find an operationalizable way of making the changes we needed, we have chosen to pursue using the JAMF Helper.app to send our alerts instead.

Our idea was that when a new patch comes out, it gets downloaded, packaged, uploaded to Casper, and two policies get created both scoped to the same smart group, with one being the one that triggers the JAMF Helper.app once per computer for any machines that fall into the associated Smart Group.

When executed all together, a client would get fall into the Smart Group, get hit once with an alert that the new patch was available, and then could run the other Self Service Policy at will.

I was able to get everything working properly manually, but when I try to do it with recipes I run into some issues and I think Python-JSS might be playing a part. (FYI I'm not a Python expert by any means).

I can write my JSS recipe so that it creates two policies no problem, and all the individual unique components get passed properly (e.g. one policies has a self service description, the other has different trigger settings, etc). The only problem is no matter what I do, the package getting created is added to both. I tried removing any references to the package configuration from the 2nd policy template but it still gets added. I also tried just running the arguments for the notification policy but its still adds the package.

I'm thinking that because a pkg recipe is listed as the parent, and because by default when the JSSImporter runs it normally adds the package info for you, that its just always putting it in by default. I tried purposely adding package configuration information to the policy xml for the notification template and specifying 0 but it still gets added.

I though maybe I could have two different JSS policies with one as the parent to the other, but I'm thinking the pkg info will still ultimately get passed because that would be the default behavior.

Any ideas how I can get that second policy created for the Notifications without having the package get added to it?

Thanks in advance.

"easy_install python-jss" installs 1.2.0, not current release

I was having a lot of trouble getting JSS_helper to work, but I think I've narrowed down the cause. The instructions on that project tell you to run "sudo easy_install python-jss" to get the required version of python-jss. Running that recommended command installs v1.2.0 of python-jss. The current version of jss_helper then refuses to run citing a need for version 1.3 of python-jss to be installed. Here's the output from that command:

Searching for python-jss
Best match: python-jss 1.2.0
Processing python_jss-1.2.0-py2.7.egg
python-jss 1.2.0 is already the active version in easy-install.pth

Using /Library/Python/2.7/site-packages/python_jss-1.2.0-py2.7.egg
Processing dependencies for python-jss
Finished processing dependencies for python-jss
titan:~ <username>$ jss_helper
Requires python-jss version: 1.3. Installed: 1.2

I'm guessing something didn't get updated quite right when the new version of python-jss was released. So it's downloading an older release rather than the current official one. That said, I haven't been able to locate the code that handles the easy_install, so I can't verify things on that.

Incorrect wrapper tags with add_object_to_path()

Using this code:

import jss
j = jss.JSS(jss.JSSPrefs())

foo_site = j.Site("Foo")
new_policy = jss.Policy(j, "New Policy TEST")
new_policy.add_object_to_path(foo_site, "general")

This is the result:

<policy>
    <general>
        <name>New Policy TEST</name>
        <enabled>true</enabled>
        ...
         <JSSContainerObject>
            <id>4</id>
            <name>Foo</name>
        </JSSContainerObject>
        ...
    </general>
    ...
</policy>

Expected:

<policy>
    <general>
        <name>New Policy TEST</name>
        <enabled>true</enabled>
        ...
         <site>
            <id>4</id>
            <name>Foo</name>
        </site>
        ...
    </general>
    ...
</policy>

403 Errors with JSS Recipes

Hi Shea, I've been working with @eahrold on an issue I'm having with AutoPkgr where I am getting 403 errors. Based on our troubleshooting so far, it appears the issue is related to something with the Python-JSS lib.

Can you take a look at the following thread and let us know your thoughts? Thanks in advance. - Jordan

lindegroup/autopkgr#187

Using own preferences file doesn't work if the file doesn't exist

Perhaps this is the intended behaviour, but if I call JSSPrefs() with my own (non-existent) plist file as preferences_file argument, I'd expect it to act the same way as it does in the default case, and ask me for the information needed to create the file.

Instead, it throws an exception if the file isn't found. Is this intended? It's these lines:

https://github.com/sheagcraig/python-jss/blob/e1982466bd7e971f27525cbc31024590a456df66/jss/jss_prefs.py#L110-L112

I also suspect that the call to self.init() at the bottom of init() should include self.preferences_file as the preferences_file argument:

https://github.com/sheagcraig/python-jss/blob/e1982466bd7e971f27525cbc31024590a456df66/jss/jss_prefs.py#L132

Otherwise it tries to read the default plist. Am I missing something?

add_criterion method returning errors

Thanks for all the hard work on this. It sure makes interacting with the JSS API easier! I have a problem that may be related to improper usage by me or a bug. I've created a variable:

jss_prefs = jss.JSSPrefs()
j = jss.JSS(jss_prefs, ssl_verify=False, suppress_warnings=True)
smartGroup = j.ComputerGroup(99)

When trying to add criteria to smartGroup (which is a smart group), I get the following error:

smartGroup.add_criterion(name="Username", priority=0, and_or="and", search_type="is", value="bobafett2")
self.criteria.append(criterion)
AttributeError: 'ComputerGroup' object has no attribute 'criteria'

I can see the contents of the group and criteria, also inspect.getargspec(smartGroup.add_criterion)
returns this:

ArgSpec(args=['self', 'name', 'priority', 'and_or', 'search_type', 'value'], varargs=None, keywords=None, defaults=None)

ImportError: No module named cryptography

JSSImporter 0.5.1 was installed by AutoPkgr

Since then I get this error when running autopkg:

$ autopkg 
Traceback (most recent call last):
  File "/usr/local/bin/autopkg", line 36, in <module>
    import autopkglib.github
  File "/Library/AutoPkg/autopkglib/__init__.py", line 629, in <module>
    import_processors()
  File "/Library/AutoPkg/autopkglib/__init__.py", line 532, in import_processors
    mydirname + '.' + name, fromlist=[name]), name)
  File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 28, in <module>
    import jss
  File "/Library/Python/2.7/site-packages/python_jss-1.5.0-py2.7.egg/jss/__init__.py", line 60, in <module>
    from .jamf_software_server import JSS
  File "/Library/Python/2.7/site-packages/python_jss-1.5.0-py2.7.egg/jss/jamf_software_server.py", line 37, in <module>
    from .tlsadapter import TLSAdapter
  File "/Library/Python/2.7/site-packages/python_jss-1.5.0-py2.7.egg/jss/tlsadapter.py", line 26, in <module>
    from requests.packages.urllib3.contrib import pyopenssl
  File "/Library/Python/2.7/site-packages/urllib3-1.22-py2.7.egg/urllib3/contrib/pyopenssl.py", line 47, in <module>
    from cryptography import x509
ImportError: No module named cryptography

SSL_VERIFY on JDS (question)

Hey @sheagcraig,
we go this report. He has SSL_VERIFY set to false.

It seems like it accessed the JSS server with a self-signed cert fine, but once it started trying to upload to the JDS side the certificate verify failed. From what I can tell it looks like same session so the SSL_VERIFY should stick. can you confirm/disconfirm this?

Here's the original post
And here's the relevant part...

12/4/14 1:18:35.462 PM AutoPkgr[7740]: (FULL AUTOPKG TRACEBACK) 
File "/usr/local/bin/autopkg", line 1334, in 
sys.exit(main(sys.argv))
File "/usr/local/bin/autopkg", line 1328, in main
exit(subcommands[verb]'function')
File "/usr/local/bin/autopkg", line 1152, in run_recipes
autopackager.process(recipe)
File "/Library/AutoPkg/autopkglib/init.py", line 466, in process
self.env = processor.process()
File "/Library/AutoPkg/autopkglib/init.py", line 295, in process
self.main()
File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 601, in main
self.package = self.handle_package()
File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 328, in handle_package
self.copy(self.env["pkg_path"], id=package.id)
File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 342, in copy
self.j.distribution_points.copy(source_item, id=id_)
File "/Library/Python/2.7/site-packages/python_jss-0.5.1-py2.7.egg/jss/distribution_points.py", line 196, in copy
repo.copy_pkg(filename, id_)
File "/Library/Python/2.7/site-packages/python_jss-0.5.1-py2.7.egg/jss/distribution_points.py", line 533, in copy_pkg
self.copy(filename, id=id_, file_type=PKG_FILE_TYPE)
File "/Library/Python/2.7/site-packages/python_jss-0.5.1-py2.7.egg/jss/distribution_points.py", line 560, in _copy
headers=headers)
File "/Library/Python/2.7/site-packages/python_jss-0.5.1-py2.7.egg/jss/contrib/requests/api.py", line 99, in post
return request('post', url, data=data, json=json, **kwargs)
File "/Library/Python/2.7/site-packages/python_jss-0.5.1-py2.7.egg/jss/contrib/requests/api.py", line 49, in request
response = session.request(method=method, url=url, **kwargs)
File "/Library/Python/2.7/site-packages/python_jss-0.5.1-py2.7.egg/jss/contrib/requests/sessions.py", line 461, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Python/2.7/site-packages/python_jss-0.5.1-py2.7.egg/jss/contrib/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/Library/Python/2.7/site-packages/python_jss-0.5.1-py2.7.egg/jss/contrib/requests/adapters.py", line 431, in send
raise SSLError(e, request=request)
jss.contrib.requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

Thanks,
Eldon

"errorMessage": "__str__ returned non-string (type bytes)" when printing ComputerGroup object

When trying to print a computer group object I got the error:
"errorMessage": "__str__ returned non-string (type bytes)"

As per this comment on https://stackoverflow.com/questions/15304229/convert-python-elementtree-to-string:

In Python 3, encoding='utf8' returns a bytestring instead of a string. I recommend using tostring(xml, encoding="unicode") instead. โ€“ Stevoisiak Feb 7 '18 at 19:18

So I believe you need to change line 159 in tools.py from:
return ElementTree.tostring(pretty_data, encoding='UTF-8')
to
return ElementTree.tostring(pretty_data, encoding='unicode')

I did this locally and it fixed the error for me.

File Uploads

I wanted to check to see if you or anyone you know of are working on the file upload to the JSS section?
We are interested in using the functionality in autopkg JSS and would consider working on a contribution but I wanted to make sure we would not overlap.
Thanks!


class FileUpload(JSSObject):
# Need to think about how to handle this.
def init(self):
raise NotImplementedError
# _url = '/fileuploads'
# can_put = False
# can_delete = False

# can_get = False

AFP mount no longer working in version 1.0.0

The new code throws an "Unsupported OS" error when it tries to mount my AFP share. It's being triggered at line 671 of distribution_points.py. I'm able to mount the AFP share by hand without any issues. Also, I'm running the 0.5.9 code on another system and it is able to mount the same share.

I should mention, python-jss is being called from the latest version of AutoPkgr.

saving new ComputerGroup object fails, b/c .jss is a str

When doing a .save() on a new ComputerGroup object, it throws an error that

str does not have a method called post()

It seems like something with the inheritance isn't working correctly. Doing a dir(new_group.jss), compared with a dir(existing_group.jss) yields very very different methods/properties.

new_group.jss is a str object, rather than what it should be.

Enhancement: add_object()

Can we get a wrapper method to add an object to an already selected object?

import jss
j = jss.JSS(jss.JSSPrefs())

foo_site = j.Site("Foo")
new_policy = jss.Policy(j, "New Policy TEST")
new_policy.add_object_to_path(foo_site, "general")

The idea is to make the above code rewritable as the following code.

import jss
j = jss.JSS(jss.JSSPrefs())

foo_site = j.Site("Foo")
new_policy = jss.Policy(j, "New Policy TEST")
new_policy.find("general").add_object(foo_site)

Often times there is a need to make multiple changes to a tag (in this case "general"), so a variable may be used new_policy_general = new_policy.find("general") to decrease the number of lookups.

[ERROR] UnboundLocalError: local variable 'updated_data' referenced before assignment

I'm receiving the following error when running Firefox.jss, or Evernote.jss and even tried Silveright.jss

"/Library/Python/2.7/site-packages/jss/jss.py", line 616 in save for child in updated_data.getchildren():
UnboundLocalError: local variable 'updated_data' referenced before assignment

I have posted the same issue in Autopkgr Git issues page which may have more details on current troubleshooting lindegroup/autopkgr#209

Policies fail to save with no category

Pulling an existing policy with no category, or creating a new one, and then trying to .save() results in a HTTP 409 error: "Conflict/Error: Problem with category name".

It seems that Jamf has changed it so, lacking a category, a policy now has a category id of -1 and a name of "No category assigned". However, it won't accept those values when you try to PUT/update.

I imagine that this also affects other things that have categories, like Packages.

Either API perms or lack of JDS causing immediate failure

I'm not using distribution points(don't ask) even though there's one configured, but no JDS's. The API user only has rights to computers, 'cause that's all I want to operate on. Is that allowable? This is what my first try looks like:


jss_prefs = jss.JSSPrefs()

j = jss.JSS(jss_prefs)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/jss/jss.py", line 166, in **init**
    self.distribution_points = distribution_points.DistributionPoints(self)
  File "/Library/Python/2.7/site-packages/jss/distribution_points.py", line 85, in **init**
    self.dp_info = self.jss.DistributionPoint().retrieve_all()
  File "/Library/Python/2.7/site-packages/jss/jss.py", line 320, in DistributionPoint
    return self.factory.get_object(DistributionPoint, data)
  File "/Library/Python/2.7/site-packages/jss/jss.py", line 466, in get_object
    result = self.jss.get(url)
  File "/Library/Python/2.7/site-packages/jss/jss.py", line 199, in get
    self._error_handler(JSSGetError, response)
  File "/Library/Python/2.7/site-packages/jss/jss.py", line 186, in _error_handler
    raise exception
jss.jss.JSSGetError: JSS Error. Response Code: 401  Response" Unauthorized
The request requires user authentication```

CasperShare Stays Mounted

Noticed that when running AutoPkgr, if my CasperShare its configured to use isn't mounted, it will mount it as expected once the JSS-Importer process kicks off but then the DP stays mounted after everything runs.

It looks like the command does in fact get sent from Python-JSS to unmount but its not waiting for anything to complete so if the share is being accessed by anything else (say spotlight), it prevents it from un-mounting.

Not the end of the world but not a good practice to leave the CasperShare mounted because it can cause odd behavior when syncing the DPs via Admin.

Install via pip requires 'cryptography'

Installing via pip alongside the system python on 10.13.3 seems to be missing a dependency. After installing, I get the message

 File "/Library/Python/2.7/site-packages/urllib3/contrib/pyopenssl.py", line 47, in <module>
    from cryptography import x509
ImportError: No module named cryptography

So, it looks as if cryptography is actually an unresolved dependency of pyopenssl, which is included in urllib3.

Interestingly, I don't get this issue if I install into a virtualenv - pip installs cryptography along with all the other packages...

Python3 compatibility

I'm wondering if Python3 compatibility is planned for python-jss. I've been using 2to3 to try and get it running for the sake of testing, but that's not feasible for installation on other machines.

Missing Object types

It seems that there is a heap of new objects to add in. Expect them in 0.5.0.

  • BYOProfile
  • ComputerConfiguration
  • IBeacons
  • MacApplication
  • VPPAccount

Cloud URL with /instance_name

Hey Shea,
First off congrats on your baby girl. I just had my second, a baby boy just about 5 months ago.

I know It's going to be tough to find some free time to code, so I'll try and keep as much of the AutoPkgr related issues off your plate for a while.

I am finding one strange occurrence and If you could point me in the right direction I could probably put a PR together to sort it out.

When a user specifies a URL with a path component it's doing some weird assembly

for example if the cloud url is

https://mytest.jamfcloud.com/myinstance/
HTTP Status 404 - /mytest/myinstance//JSSResource/distributionpoints

So I'm not sure how, but it looks like it's stripping out the host, using the first part of that, and adding it to the resource path. Any Ideas on where to start.

(I've added this to L194 of jss.py)

print ("This is the response %s" % response.text.encode('utf-8'))

To help diagnose this issue

so here's the full response

10/29/14 9:38:49.209 AM AutoPkgr[26617]: This is the response <html>
<head><title>Apache Tomcat/7.0.26 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
 </head>
<body><h1>HTTP Status 404 - /mytest/myinstance//JSSResource/distributionpoints</h1>
<HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>/mytest/myinstance//JSSResource/distributionpoints</u></p><p><b>description</b> <u>The requested resource (/mytest/myinstance//JSSResource/distributionpoints) is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.26</h3>
</body>
</html>

Let me know if you want more info.

Thanks,
--Eldon

Error when installing using pip

When trying to install the package with pip, I am getting the following error:

$ pip install python-jss
Collecting python-jss
Could not find a version that satisfies the requirement python-jss (from versions: )
No matching distribution found for python-jss

Cant seem to figure out why. Also, is this package supported by python3?

SSL related issue...

So looks like this could be related to other issues but since I am seeing it in autopkg, autopkgr, and spruce all showing from python_jss-0.5.9-py2.7.egg/jss/jss.py. Just started after the Casper 9.72 update.
Getting:
back:~ serveradmin$ defaults write com.github.autopkg JSS_VERIFY_SSL -bool True
back:~ serveradmin$ /Users/serveradmin/Desktop/Spruce-1.0.1/Spruce.py --report
Traceback (most recent call last):
File "/Users/serveradmin/Desktop/Spruce-1.0.1/Spruce.py", line 367, in
main()
File "/Users/serveradmin/Desktop/Spruce-1.0.1/Spruce.py", line 358, in main
report(j, args.verbose)
File "/Users/serveradmin/Desktop/Spruce-1.0.1/Spruce.py", line 230, in report
all_policies = j.Policy().retrieve_all()
File "/Library/Python/2.7/site-packages/python_jss-0.5.9-py2.7.egg/jss/jss.py", line 394, in Policy
return self.factory.get_object(Policy, data)
File "/Library/Python/2.7/site-packages/python_jss-0.5.9-py2.7.egg/jss/jss.py", line 467, in get_object
result = self.jss.get(url)
File "/Library/Python/2.7/site-packages/python_jss-0.5.9-py2.7.egg/jss/jss.py", line 195, in get
self._error_handler(JSSGetError, response)
File "/Library/Python/2.7/site-packages/python_jss-0.5.9-py2.7.egg/jss/jss.py", line 179, in _error_handler
raise exception
jss.exceptions.JSSGetError: Response Code: 401 Response: Unauthorized. The request requires user authentication

also:
back:~ serveradmin$ defaults read com.github.autopkg
{
"API_PASSWORD" = uwish;
"API_USERNAME" = autopkgapi;
"CACHE_DIR" = "/Users/serveradmin/Library/AutoPkg/Cache";
"GIT_PATH" = "/usr/local/git/bin/git";
"JSS_REPOS" = (
{
type = JDS;
}
);
"JSS_URL" = "https://nc.jamfcloud.com:443";
"JSS_VERIFY_SSL" = 1;

NOTE: switching to "JSS_VERIFY_SSL" = 0 gives
hundreds of these:
/Library/Python/2.7/site-packages/python_jss-0.5.9-py2.7.egg/jss/contrib/requests/packages/urllib3/connectionpool.py:769: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
InsecureRequestWarning)

Am I just missing some thing? These smell like earlier reports but nothing I see there fixes or works around the issue.

Failing to upload non-flat packages to JSS

Using the silverlight.jss.recipe found at sheagcraig/jss-recipes, I receive the following error.

Traceback (most recent call last):
  File "/usr/local/bin/autopkg", line 1334, in <module>
    sys.exit(main(sys.argv))
  File "/usr/local/bin/autopkg", line 1328, in main
    exit(subcommands[verb]['function'](argv))
  File "/usr/local/bin/autopkg", line 1152, in run_recipes
    autopackager.process(recipe)
  File "/Library/AutoPkg/autopkglib/__init__.py", line 466, in process
    self.env = processor.process()
  File "/Library/AutoPkg/autopkglib/__init__.py", line 295, in process
    self.main()
  File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 601, in main
    self.package = self.handle_package()
  File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 328, in handle_package
    self._copy(self.env["pkg_path"], id_=package.id)
  File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 342, in _copy
    self.j.distribution_points.copy(source_item, id_=id_)
  File "/Library/Python/2.7/site-packages/python_jss-0.5.2-py2.7.egg/jss/distribution_points.py", line 196, in copy
    repo.copy_pkg(filename, id_)
  File "/Library/Python/2.7/site-packages/python_jss-0.5.2-py2.7.egg/jss/distribution_points.py", line 533, in copy_pkg
    self._copy(filename, id_=id_, file_type=PKG_FILE_TYPE)
  File "/Library/Python/2.7/site-packages/python_jss-0.5.2-py2.7.egg/jss/distribution_points.py", line 554, in _copy
    resource = open(filename, 'rb')
IOError: [Errno 21] Is a directory: u'/Users/msblake/Library/AutoPkg/Cache/com.github.autopkg.jss.Silverlight/Silverlight-5.1.30514.0.pkg'

If you add this pkg to Casper Admin manually, the pkg file is zipped before upload. I believe that is what will need to happen for non-flat packages.

URL and Protocol confusion with custom DP

Hey Shea,
I'm not sure exactly what to do with this here.
https://github.com/sheagcraig/python-jss/blob/master/jss/distribution_points.py#L432-L434

When building the mount_url it's prefixed with protocol, then adds auth, then adds the url.
It's slightly misleading since the url would arguably be something like afp://my.jssdp.com rather than simply my.jssdp.com

So if you actually set the url as an actual url you end up with this for the mount_url

afp://me:mypass@afp://my.jssdb.com

I'm not sure if this is a method fix, or a documentation fix. Just something I noticed.

It could be something as simple as checking the self.connection['URL'] for :// and if found splitting, and taking list[1]

Thanks,
-- Eldon

UnboundLocalError: local variable 'dp' referenced before assignment

It doesn't look like the dp variable is being set properly on https://github.com/sheagcraig/python-jss/blob/7c8e0cceb24bb4d1a03f157f9c24975e16872d1d/jss/distribution_points.py#L169

I am running the following command through Autopkg in an environment with only JDS distribution points and my plist has the updated type=JDS only structure.

$ autopkg run firefox.jss -v
Processing firefox.jss...
MozillaURLProvider
MozillaURLProvider: Found URL http://ftp.mozilla.org/pub/mozilla.org//firefox/releases/latest/mac/en-US/Firefox%2034.0.5.dmg
URLDownloader
URLDownloader: Item at URL is unchanged.
URLDownloader: Using existing /Users/msblake/Library/AutoPkg/Cache/com.github.autopkg.jss.Firefox_EN/downloads/Firefox.dmg
EndOfCheckPhase
AppDmgVersioner
AppDmgVersioner: Mounted disk image /Users/msblake/Library/AutoPkg/Cache/com.github.autopkg.jss.Firefox_EN/downloads/Firefox.dmg
AppDmgVersioner: BundleID: org.mozilla.firefox
AppDmgVersioner: Version: 34.0.5
PkgRootCreator
PkgRootCreator: Created /Users/msblake/Library/AutoPkg/Cache/com.github.autopkg.jss.Firefox_EN/Firefox
PkgRootCreator: Created /Users/msblake/Library/AutoPkg/Cache/com.github.autopkg.jss.Firefox_EN/Firefox/Applications
Copier
Copier: Mounted disk image /Users/msblake/Library/AutoPkg/Cache/com.github.autopkg.jss.Firefox_EN/downloads/Firefox.dmg
Copier: Copied /private/tmp/dmg.k2l2Nm/Firefox.app to /Users/msblake/Library/AutoPkg/Cache/com.github.autopkg.jss.Firefox_EN/Firefox/Applications/Firefox.app
PkgCreator
PkgCreator: Package already exists at path /Users/msblake/Library/AutoPkg/Cache/com.github.autopkg.jss.Firefox_EN/Firefox-34.0.5.pkg.
PkgCreator: Existing package matches version and identifier, not building.
JSSImporter
/Library/Python/2.7/site-packages/python_jss-0.5.1-py2.7.egg/jss/contrib/requests/packages/urllib3/connectionpool.py:734: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
  InsecureRequestWarning)
Traceback (most recent call last):
  File "/usr/local/bin/autopkg", line 1334, in <module>
    sys.exit(main(sys.argv))
  File "/usr/local/bin/autopkg", line 1328, in main
    exit(subcommands[verb]['function'](argv))
  File "/usr/local/bin/autopkg", line 1152, in run_recipes
    autopackager.process(recipe)
  File "/Library/AutoPkg/autopkglib/__init__.py", line 466, in process
    self.env = processor.process()
  File "/Library/AutoPkg/autopkglib/__init__.py", line 295, in process
    self.main()
  File "/Library/AutoPkg/autopkglib/JSSImporter.py", line 577, in main
    ssl_verify=sslVerify, repo_prefs=repos)
  File "/Library/Python/2.7/site-packages/python_jss-0.5.1-py2.7.egg/jss/jss.py", line 166, in __init__
    self.distribution_points = distribution_points.DistributionPoints(self)
  File "/Library/Python/2.7/site-packages/python_jss-0.5.1-py2.7.egg/jss/distribution_points.py", line 174, in __init__
    self._children.append(dp)
UnboundLocalError: local variable 'dp' referenced before assignment

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.