mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-30 09:56:21 -05:00
2ea695896f
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
|
|
"github.com/edgelesssys/constellation/v2/hack/qemu-metadata-api/server"
|
|
"github.com/edgelesssys/constellation/v2/hack/qemu-metadata-api/virtwrapper"
|
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
"go.uber.org/zap"
|
|
"go.uber.org/zap/zapcore"
|
|
"libvirt.org/go/libvirt"
|
|
)
|
|
|
|
func main() {
|
|
bindPort := flag.String("port", "8080", "Port to bind to")
|
|
targetNetwork := flag.String("network", "constellation-network", "Name of the network in QEMU to use")
|
|
libvirtURI := flag.String("libvirt-uri", "qemu:///system", "URI of the libvirt connection")
|
|
flag.Parse()
|
|
|
|
log := logger.New(logger.JSONLog, zapcore.InfoLevel)
|
|
|
|
conn, err := libvirt.NewConnect(*libvirtURI)
|
|
if err != nil {
|
|
log.With(zap.Error(err)).Fatalf("Failed to connect to libvirt")
|
|
}
|
|
defer conn.Close()
|
|
|
|
serv := server.New(log, *targetNetwork, &virtwrapper.Connect{Conn: conn})
|
|
if err := serv.ListenAndServe(*bindPort); err != nil {
|
|
log.With(zap.Error(err)).Fatalf("Failed to serve")
|
|
}
|
|
}
|