Skip to content

Commit

Permalink
hooks: add hooks api proto specification
Browse files Browse the repository at this point in the history
  • Loading branch information
phoracek committed Jul 2, 2018
1 parent bb5d086 commit d377288
Show file tree
Hide file tree
Showing 10 changed files with 333 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ _out
vendor/**/*_test.go
**/polarion.xml
tools/manifest-templator/manifest-templator
tools/vms-generator/vms-generator
.coverprofile
tools/vms-generator/vms-generator
4 changes: 2 additions & 2 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ import:
version: eabcf70a1bd73e9296fa0c5f57de604689200a1b
- package: kubevirt.io/qe-tools
version: v0.1.1
repo: https://github.com/kubevirt/qe-tools.git
repo: https://github.com/kubevirt/qe-tools.git
- package: github.com/golang/protobuf
subpackages:
- proto
testImport:
- package: github.com/elazarl/goproxy
version: 07b16b6e30fcac0ad8c0435548e743bcf2ca7e92
Expand Down
6 changes: 5 additions & 1 deletion hack/docker-builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM fedora:27

ENV LIBVIRT_VERSION 3.7.0

RUN dnf -y install libvirt-devel-${LIBVIRT_VERSION} make git mercurial sudo gcc findutils gradle rsync-daemon rsync qemu-img && \
RUN dnf -y install libvirt-devel-${LIBVIRT_VERSION} make git mercurial sudo gcc findutils gradle rsync-daemon rsync qemu-img protobuf-compiler && \
dnf -y clean all

ENV GIMME_GO_VERSION=1.10
Expand Down Expand Up @@ -38,6 +38,10 @@ RUN \
go install && \
cd /go/src/k8s.io/code-generator/cmd/openapi-gen && \
git checkout release-1.9 && \
go install && \
go get -u -d github.com/golang/protobuf/protoc-gen-go && \
cd /go/src/github.com/golang/protobuf/protoc-gen-go && \
git checkout 1643683e1b54a9e88ad26d98f81400c8c9d9f4f9 && \
go install

RUN pip install j2cli
Expand Down
2 changes: 2 additions & 0 deletions hack/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ ${KUBEVIRT_DIR}/tools/crd-generator/crd-generator --crd-type=vm >${KUBEVIRT_DIR}

(cd ${KUBEVIRT_DIR}/tools/vms-generator/ && go build)
${KUBEVIRT_DIR}/tools/vms-generator/vms-generator --generated-vms-dir=${KUBEVIRT_DIR}/cluster/examples

protoc --proto_path=pkg/hooks/v1alpha --go_out=plugins=grpc,import_path=v1alpha:pkg/hooks/v1alpha pkg/hooks/v1alpha/api.proto
File renamed without changes.
File renamed without changes.
276 changes: 276 additions & 0 deletions pkg/hooks/v1alpha/api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions pkg/hooks/v1alpha/api.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
syntax = "proto3";

package kubevirt.hooks.v1alpha;

service Hook {
rpc Info (InfoParams) returns (InfoResult);
rpc OnDefineDomain (OnDefineDomainParams) returns (OnDefineDomainResult);
}

message InfoParams {
// supportedVersions is a list of versions supported by client
repeated string supportedVersions = 1;
}

message InfoResult {
// name of the hook used by virt-launcher to compare it with requested hooks
string name = 1;
// priority is used to sort hooks prior to their execution (second key is the name)
uint32 priority = 2;
// hookPoints is a list of subscribed hook points
repeated string hookPoints = 3;
// version is choosen from passed supportedVersions, this version will be used for communication
string version = 4;
}

message OnDefineDomainParams {
// domainXML is original libvirt domain specification, it is XML passed as string
string domainXML = 1;
// vm is VirtualMachine is object of virtual machine currently processed by virt-launcher, it is encoded as JSON and passed as string
string vm = 2;
}

message OnDefineDomainResult {
// domainXML is processed libvirt domain specification, it is XML passed as string
string domainXML = 1;
}
7 changes: 7 additions & 0 deletions pkg/hooks/v1alpha/v1alpha.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package v1alpha

const Version = "v1alpha"

const (
OnDefineDomainHookPointName = "OnDefineDomain"
)

0 comments on commit d377288

Please sign in to comment.