Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
clh: Add Generation tools for API client
Browse files Browse the repository at this point in the history
cloud-hypervisor provides an API server to send commands
in a qmp and Firecracker style over an Unix socket.

The API is defined via OpenAPI, this commit adds
scripts to help to generate a client using:

https://github.com/OpenAPITools/openapi-generator

This will make easy to update any change related with the API
in the future.

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
  • Loading branch information
jcvenegas committed Dec 5, 2019
1 parent 62cd080 commit dcac021
Show file tree
Hide file tree
Showing 4 changed files with 444 additions and 0 deletions.
4 changes: 4 additions & 0 deletions virtcontainers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ The `virtcontainers` package relies on hypervisors to start and stop virtual mac
sandboxes will be running. An hypervisor is defined by an Hypervisor interface implementation,
and the default implementation is the QEMU one.

### Update cloud-hypervisor client code

See [docs](pkg/cloud-hypervisor/README.md)

## Agents

During the lifecycle of a container, the runtime running on the host needs to interact with
Expand Down
21 changes: 21 additions & 0 deletions virtcontainers/pkg/cloud-hypervisor/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Copyright (c) 2019 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#

all: | update-yaml generate-client-code

generate-client-code: clean-generated-code
docker run --rm \
--user $$(id -u):$$(id -g) \
-v $${PWD}:/local openapitools/openapi-generator-cli generate \
-i /local/cloud-hypervisor.yaml \
-g go \
-o /local/client

update-yaml:
curl -OL https://raw.githubusercontent.com/cloud-hypervisor/cloud-hypervisor/master/vmm/src/api/openapi/cloud-hypervisor.yaml

clean-generated-code:
rm "./client" -rf
13 changes: 13 additions & 0 deletions virtcontainers/pkg/cloud-hypervisor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Cloud Hypervisor OpenAPI generated code

This directory provide tools to generate code client based
on `cloud-hypervisor` `OpenAPI` schema.

## Update client to match latest Cloud Hypervisor server API

Requirements:
- docker: `openapi-generator` is executed in a docker container

```
make all
```
Loading

0 comments on commit dcac021

Please sign in to comment.