Environment Java 17 + Spring
<dependency>
<groupId>com.github.openstack4j.core</groupId>
<artifactId>openstack4j</artifactId>
<version>3.10</version>
</dependency>
Call
String imageId = <id that was used to create VM image metadata through osClientV3.imagesV2().create(image)>;
ImageUpdate imageUpdate = <patch data>;
OSClientV3 osClientV3 = <create client>;
Image image = osClientV3
.imagesV2()
.update(imageId, imageUpdate);
Created request
2023-03-01 19:44:38,113 DEBUG [http-nio-8104-exec-9] org.apache.http.impl.conn.DefaultHttpClientConnectionOperator : Connection established 10.16.104.31:62444<-><my_os_ip>:9292
2023-03-01 19:44:38,113 DEBUG [http-nio-8104-exec-9] org.apache.http.impl.execchain.MainClientExec : Executing request PATCH /v2/images/5b9acfbb-1e19-4127-8bac-fe1eae2ed1ad HTTP/1.1
2023-03-01 19:44:38,113 DEBUG [http-nio-8104-exec-9] org.apache.http.impl.execchain.MainClientExec : Target auth state: UNCHALLENGED
2023-03-01 19:44:38,113 DEBUG [http-nio-8104-exec-9] org.apache.http.impl.execchain.MainClientExec : Proxy auth state: UNCHALLENGED
2023-03-01 19:44:38,113 DEBUG [http-nio-8104-exec-9] org.apache.http.headers : http-outgoing-57 >> PATCH /v2/images/5b9acfbb-1e19-4127-8bac-fe1eae2ed1ad HTTP/1.1
2023-03-01 19:44:38,113 DEBUG [http-nio-8104-exec-9] org.apache.http.headers : http-outgoing-57 >> Content-Type: application/json
2023-03-01 19:44:38,113 DEBUG [http-nio-8104-exec-9] org.apache.http.headers : http-outgoing-57 >> User-Agent: OpenStack4j / OpenStack Client
2023-03-01 19:44:38,113 DEBUG [http-nio-8104-exec-9] org.apache.http.headers : http-outgoing-57 >> X-Auth-Token: my-auth-token
2023-03-01 19:44:38,113 DEBUG [http-nio-8104-exec-9] org.apache.http.headers : http-outgoing-57 >> X-OpenStack-Nova-API-Version: 2.90
2023-03-01 19:44:38,113 DEBUG [http-nio-8104-exec-9] org.apache.http.headers : http-outgoing-57 >> Content-Length: 246
2023-03-01 19:44:38,113 DEBUG [http-nio-8104-exec-9] org.apache.http.headers : http-outgoing-57 >> Host: my-correct-os-hostname:9292
2023-03-01 19:44:38,113 DEBUG [http-nio-8104-exec-9] org.apache.http.headers : http-outgoing-57 >> Connection: Keep-Alive
2023-03-01 19:44:38,113 DEBUG [http-nio-8104-exec-9] org.apache.http.headers : http-outgoing-57 >> Accept-Encoding: gzip,deflate
Mistake here:
Content-Type: application/json
Response log:
2023-03-01 19:44:38,123 DEBUG [http-nio-8104-exec-9] org.apache.http.wire : http-outgoing-57 << "HTTP/1.1 415 Unsupported Media Type[\r][\n]"
2023-03-01 19:44:38,123 DEBUG [http-nio-8104-exec-9] org.apache.http.wire : http-outgoing-57 << "accept-patch: application/openstack-images-v2.0-json-patch, application/openstack-images-v2.1-json-patch[\r][\n]"
2023-03-01 19:44:38,123 DEBUG [http-nio-8104-exec-9] org.apache.http.wire : http-outgoing-57 << "content-length: 104[\r][\n]"
2023-03-01 19:44:38,123 DEBUG [http-nio-8104-exec-9] org.apache.http.wire : http-outgoing-57 << "content-type: text/plain; charset=UTF-8[\r][\n]"
Expected behavior When i call it in Insomnia i use other headers (it works well)
> PATCH /v2/images/d55969b2-7e83-474e-84ff-29212e80efa4 HTTP/1.1
> Host: my-correct-os-hostname:9292
> User-Agent: insomnia/2022.7.5
> X-OpenStack-Nova-API-Version: 2.90
> X-Auth-Token: my-auth-token
> Content-Type: application/openstack-images-v2.1-json-patch
> Accept: */*
> Content-Length: 207
Proofs Official doc: https://specs.openstack.org/openstack/glance-specs/specs/api/v2/http-patch-image-api-v2.html User case: https://www.sebastien-han.fr/blog/2015/05/13/openstack-glance-use-multiple-location-for-an-image/
Is documentation correct?
Are there any ways to set custom headers to osClientV3
?
I tried to invoke PATCH method for precreated virtual machine image metadata.