jssimporter / python-jss

python-jss is deprecated. Please see the wiki for alternatives.
GNU General Public License v3.0
102 stars 41 forks source link

JDS._copy() introduces corruption to package and script uploads #5

Closed sheagcraig closed 9 years ago

sheagcraig commented 9 years ago

The multipart boundaries are included, as well as the "content disposition" line.

everetteallen commented 9 years ago

Ok trying to get to a point with the latest rc releases to see the corruption in the scripts so I can test. 2 questions: a) Is it correct that I can just comment out the blocked code (i.e. the exit) in the jss-plugin code to test? b) Does this defaults read com.github.autopkg look correct for JDS testing? I am guessing the 3 urls need to be identical and that I only need the api user in both sections (as opposed to the read/write user and password from the JDS configuration):

"API_PASSWORD" = xxxxxx; "API_URL" = "https://xxxx.jamfcloud.com:443/"; "API_USERNAME" = autopkgr; "CACHE_DIR" = "/Users/oitadmin/Library/AutoPkg/Cache"; "GIT_PATH" = "/usr/local/git/bin/git"; "JSS_REPOS" = ( { URL = "https://xxxx.jamfcloud.com:443/"; password = xxxxxx; type = JDS; username = autopkgr; } ); "JSS_URL" = "https://xxxx.jamfcloud.com:443/"; "JSS_VERIFY_SSL" = 0;

everetteallen commented 9 years ago

Follow up. I did comment out the exits in JSSImporter.py and get the FireFox.jss recipe to run against a cloud test server. The pkg did upload and sync but as expected is unusable. First lines are: --437c8503461b4bfb922d7be104014868 Content-Disposition: form-data; name="Firefox-33.1.1.pkg"; filename="Firefox-33.1.1.pkg"

beckf commented 9 years ago

Everette,

Yes, if you remove the first three lines the package will install. Shea and I talked about this a little on Friday. I am going to do another packet capture tonight and try to determine what is going on. I am wondering if these three lines need to be added to the request header.

Forrest

On Nov 26, 2014, at 5:24 PM, everetteallen notifications@github.com wrote:

Follow up. I did comment out the exits in JSSImporter.py and get the FireFox.jss recipe to run against a cloud test server. The pkg did upload and sync but as expected is unusable. First lines are: --437c8503461b4bfb922d7be104014868 Content-Disposition: form-data; name="Firefox-33.1.1.pkg"; filename="Firefox-33.1.1.pkg"

— Reply to this email directly or view it on GitHub.

everetteallen commented 9 years ago

I was just wondering that myself looking at _copy headers. Having not seen the captures I wonder if the file goes up without anything and the xml struct takes care of everything... just don't see how they get associated except by filename. Thanks for doing the captures. def copy(self, filename, id='-1', file_type=0): """Upload a file to the JDS.""" basefname = os.path.basename(filename) extension = os.path.splitext(basefname)[1].upper()

    resource = {basefname: open(filename, 'rb')}
    headers = {'Content-Type': 'text/xml', 'DESTINATION': '1',
               'OBJECT_ID': str(id_), 'FILE_TYPE': file_type,
               'FILE_NAME': basefname}
    response = requests.post(url=self.connection['upload_url'],
                             files=resource,
                             auth=(self.connection['username'],
                                   self.connection['password']),
                             headers=headers)
    print(response, response.text)
    return response
sheagcraig commented 9 years ago

@everetteallen I think we figured it out. Forrest worked out a successful curl and then we changed the python code to match it.

If you grab the latest testing branch, give uploading a script and a package to the JDS a try and make sure to check for any cruft in them. I don't expect there to be any-it just works now.

This will become the 0.4.3 release. I imagine that with all of the other stuff add in the latest jss-autopkg-addon that you could just test that as well. You would have to keep the exit() commented out for scripts and packages, but otherwise it should just go.

everetteallen commented 9 years ago

Shea, I hacked the changes from the last commit into my working test 0.42 distribution_points.py with a test jamfcloud.com server and SUCCESS!!! I got good deliverable AutoPkgr pkg files for Firefox.jss and GoogleEarth.jss recipes and AutoPkgr 1.1.2rc2/python_jss-0.4.3equiv/JSS_Importer.py 0.3.0noexit.

Whoo Hoo!!

I am running off to early meetings tonight so have not had time to test script uploads yet.

Great Job both of you!!

On 12/1/14 4:05 PM, Shea Craig wrote:

@everetteallen https://github.com/everetteallen I think we figured it out. Forrest worked out a successful curl and then we changed the python code to match it.

If you grab the latest testing branch, give uploading a script and a package to the JDS a try and make sure to check for any cruft in them. I don't expect there to be any-it just works now.

This will become the 0.4.3 release. I imagine that with all of the other stuff add in the latest jss-autopkg-addon that you could just test that as well. You would have to keep the |exit()| commented out for scripts and packages, but otherwise it should just go.

— Reply to this email directly or view it on GitHub https://github.com/sheagcraig/python-jss/issues/5#issuecomment-65134414.

Everette Gray Allen Systems Programmer II Office of Information Technology Macintosh Support Specialist 2620 Hillsborough St, Campus Box 7109 Raleigh, NC 27695-7109 AIM: EveretteAlln 919-515-4558 Everette_Allen@ncsu.edu

sheagcraig commented 9 years ago

Fixed in 0.4.3