Skip to content
Extend vCenter with OpenFaaS
Go Dockerfile Shell Makefile
Branch: master
Clone or download
embano1 and alexellis Switch to latest connector-SDK release
The connector now leverages the latest connector-sdk features such as
allowing multiple event topic subscriptions (delimited with ",") and
printing invokation responses via the `controller.Subscribe` interface
(implemented by `events.NewEventReceiver()`.

The controller uses a 10 second `RebuildInterval` (sync function
subscriptions) and 15 second `UpstreamTimeout` for invoking functions.
The controller uses asynchronous invocation mode to not block on
slow/long-running functions.

Function comments are line-wrapped.
Updates to Gopkg.toml to use the latest releases for imported packages:

- connector-sdk 0.5.3
- openfaas-cloud 0.11.10
- govmomi 0.21.0

Build successfully tested against VMware vCenter 6.7U3 and OpenFaaS faas-netes commit b14f727.
README updated covering the recent changes.

Signed-off-by: Michael Gasch <mgasch@vmware.com>
Latest commit 56e929e Nov 28, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
contrib
docs Code refactoring and more events supported Mar 15, 2019
pkg/events
vendor/github.com
yaml/kubernetes
.DEREK.yml
.gitignore
.travis.yml
Dockerfile
Dockerfile.armhf
Gopkg.lock
Gopkg.toml
LICENSE
Makefile
README.md
build.sh
main.go

README.md

OpenFaaS vcenter-connector

vcenter-connector is an OpenFaaS event-connector built to consume events from vCenter and to trigger functions.

Build Status

Overview

With this project your functions can subscribe to events generated by the changes (i.e. events) in your vCenter installation - for instance a VM being created, turned on or deleted. This allows you to extend vCenter's functionality by writing functions to execute each time an event is fired. An example may be tagging a VM with the date it was last turned on or applying a tag showing which user made a change to an object.

Status

This project uses the OpenFaaS Connector SDK. vCenter credentials are stored using Kubernetes secrets.

Supported Events

The following event types (incl. their subtypes) are supported and can be used to trigger functions:

  • Alarm Event, e.g. AlarmCreatedEvent
  • Datastore Event, e.g. DatastoreDestroyedEvent
  • Host Event, e.g. HostDisconnectedEvent
  • Resource Pool Event, e.g. ResourcePoolCreatedEvent
  • VM Event, e.g. VmPoweredOnEvent

For further details and naming see the vSphere Web Services API documentation.

A function can be subscribed to multiple events using a comma-delimited syntax in its stack configuration:

[...]
annotations:
    topic: "drs.vm.powered.on,vm.powered.off"

Note: Wildcards for event subscriptions, e.g. "vm.powered.*", are not supported.

Credentials

Credentials within Kubernetes

When using the connector in Kubernetes, you will need to create a secret for the connector in the openfaas namespace.

kubectl create secret generic vcenter-secrets \
  -n openfaas \
  --from-literal vcenter-username=user \
  --from-literal vcenter-password=pass

At runtime these secrets will be mounted at /var/openfaas/secrets/. See /yaml/kubernetes/connector-dep.yml for more.

Using credentials outside of Kubernetes

You can pass credentials via arguments (not recommended).

./vcenter-connector \
  -vc-user="admin" \
  -vc-pass="test1234" \

Or use a file and pass the name:

export secret_mount_path="/tmp/secrets/`

./vcenter-connector \
  -vc-user="" \
  -vc-pass="" \
  -vc-user-secret-name=vcenter-username \
  -vc-password-secret-name=vcenter-password

The default path is /var/openfaas/secrets/ which can be overridden by setting the secret_mount_path environment variable.

Examples / community

  • You can find a detailed example using vSphere tags for VmPoweredOnEvent here.

  • Robert Guske of VMware write up a detailed blog post on how he automated the integration between several VMware products with OpenFaaS and this vcenter-connector.

VEBA

VMware have released an appliance which packages OpenFaaS and the OpenFaaS vcenter-connector (this repository) and called it the "vCenter Event Broker Appliance". The appliance uses Photon OS.

Contributing

Please propose changes in an Issue before submitting a PR and sign-off commits.

See the contribution guide for OpenFaaS for more.

License

MIT

Acknowledgements

This project is hosted and maintained by OpenFaaS Ltd

It makes use of the following components:

  • govmomi project providing Golang bindings for vCenter by Doug MacEachern, VMware
  • vcsim simulator tool by Doug MacEachern, VMware

The contact for OpenFaaS Ltd is Alex Ellis

The contact for VMware is Michael Gasch (VMware)

You can’t perform that action at this time.