I've battled with the packaging api as well, it does seem over complicated. I
think the key is upload and install are 2 separate steps. Here's a bash script
I use:
#!/usr/bin/env bash
set -e
# defaults
HOST="ml.local.springer.com"
AUTH="admin:admin"
PACKAGE_ZIP="package.zip"
function usage() {
printf '
usage: deploy.sh [options...]
Options:
-t <target host> Target hostname. Defaults to ml.local.springer.com
-c <user:password> Credentials. Defaults to admin:admin
-p <package zip path> Path to package zip. Defaults to package.zip
'
exit 1
}
while getopts 't:c:p:' OPTION
do
case $OPTION in
t) HOST="$OPTARG";;
c) AUTH="$OPTARG";;
p) PACKAGE_ZIP="$OPTARG";;
*) usage;;
esac
done
PACKAGE_NAME="mldeploy"
PACKAGE_LOG="/tmp/mldeploy.log"
CREDENTIALS="--digest -u ${AUTH}"
URL="http://${HOST}:8002/manage/v2/packages"
function errorcheck() {
if [ ${PIPESTATUS[0]} != 0 ]; then
exit 1
fi
grep -q error $PACKAGE_LOG && exit 1 || true
}
echo "" > $PACKAGE_LOG
echo Deploying ${PACKAGE_ZIP} as ${PACKAGE_NAME} to ${URL}
echo Deleting existing package..
curl --progress-bar -X DELETE ${CREDENTIALS} \
"${URL}/${PACKAGE_NAME}" \
2>&1 | tee -a "${PACKAGE_LOG}"
errorcheck
echo Uploading package..
curl --progress-bar -X POST ${CREDENTIALS} -H "Content-type: application/zip" \
--data-binary @"${PACKAGE_ZIP}" \
"${URL}?pkgname=${PACKAGE_NAME}" \
2>&1 | tee -a "${PACKAGE_LOG}"
errorcheck
echo Installing package..
curl --progress-bar -X POST ${CREDENTIALS} \
--data-binary @/dev/null \
"${URL}/${PACKAGE_NAME}/install" \
2>&1 | tee -a "${PACKAGE_LOG}"
errorcheck
echo Finished
________________________________________
From: [email protected]
[[email protected]] on behalf of Retter, Adam (RBI-UK)
[[email protected]]
Sent: 04 September 2014 10:51
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Migrating packages from ML6 to 7
Previously with ML6 we were HTTP POST’ing a package to configure a clean
install of an ML instance. The package API has changed in ML7 and we are having
a hard time understanding exactly how it works and which end-point to use.
We previously posted a single XML document in ML6 containing all of our config
to http://localhost:8002/manage/v1/package/install. Studying the documentation
here: https://docs.marklogic.com/guide/relnotes/chap4#id_89025
Implies that to migrate we now have to:
1) switch to a ZIP file format of multiple XML documents and update the
package config files to contain the extra stuff in ML7. We have done that no
problem.
2) Instead now HTTP POST our ZIP file to
http://localhost:8002/manage/v2/packages/{pkgname}/install<http://localhost:8002/manage/v2/packages/%7bpkgname%7d/install>
We are having problems understanding (2). We do not know what the value of
`pkgname` should be, so we have chosen an arbitrary name e.g. `devbox`. However
when we perform the HTTP POST with cURL, we get the following `
PKG-DOESNOTEXIST ` error:
[rettera@qhsw24691-ml7 ~]$ curl -v -X POST --digest -u admin:admin -H
"Content-Type: application/zip" --data-binary
@config/marklogic/devbox/devbox-package-v2.zip
http://localhost:8002/manage/v2/packages/devbox/install
Warning: Couldn't read data from file
Warning: "config/marklogic/devbox/devbox-package-v2.zip", this makes an empty
Warning: POST.
* About to connect() to localhost port 8002 (#0)
* Trying ::1... Connection refused
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 8002 (#0)
* Server auth using Digest with user 'admin'
> POST /manage/v2/packages/devbox/install HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3
> zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: localhost:8002
> Accept: */*
> Content-Type: application/zip
> Content-Length: 0
>
< HTTP/1.1 401 Unauthorized
< WWW-Authenticate: Digest realm="public", qop="auth",
nonce="f55af58e243a74202dc40b1240578d15", opaque="50c2c74c190fae6e"
< Content-type: application/xml
< Server: MarkLogic
< Content-Length: 173
< Connection: Keep-Alive
< Keep-Alive: timeout=5
<
* Ignoring the response-body
* Connection #0 to host localhost left intact
* Issue another request to this URL:
'http://localhost:8002/manage/v2/packages/devbox/install'
* Re-using existing connection! (#0) with host localhost
* Connected to localhost (127.0.0.1) port 8002 (#0)
* Server auth using Digest with user 'admin'
> POST /manage/v2/packages/devbox/install HTTP/1.1
> Authorization: Digest username="admin", realm="public",
> nonce="f55af58e243a74202dc40b1240578d15",
> uri="/manage/v2/packages/devbox/install", cnonce="MDAwMjQ3", nc=00000001,
> qop="auth", response="1faa715f863f4420d8bf654e33668c77",
> opaque="50c2c74c190fae6e"
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3
> zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: localhost:8002
> Accept: */*
> Content-Type: application/zip
> Content-Length: 0
>
< HTTP/1.1 404 Not Found
< Content-type: application/xml
< Server: MarkLogic
< Content-Length: 259
< Connection: Keep-Alive
< Keep-Alive: timeout=5
<
<error xmlns="http://marklogic.com/manage">
<status-code>404</status-code>
<status>Not Found</status>
<message-code>PKG-DOESNOTEXIST</message-code>
<message>PKG-DOESNOTEXIST: (pkg:ERR-DOESNOTEXIST) There is no package named:
devbox</message>
</error>
* Connection #0 to host localhost left intact
* Closing connection #0
So what are we missing? The documentation for the new packaging API and
migration to seems to be very vague, unless I am missing some pages somewhere?
Cheers Adam.
DISCLAIMER
This message is intended only for the use of the person(s) ("Intended
Recipient") to whom it is addressed. It may contain information, which is
privileged and confidential. Accordingly any dissemination, distribution,
copying or other use of this message or any of its content by any person other
than the Intended Recipient may constitute a breach of civil or criminal law
and is strictly prohibited. If you are not the Intended Recipient, please
contact the sender as soon as possible.
Reed Business Information Limited. Registered Office: Quadrant House, The
Quadrant, Sutton, Surrey, SM2 5AS, UK.
Registered in England under Company No. 151537
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general