From 6ecb208774860d061f7e10f45673b7a972835892 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 28 Oct 2024 10:06:43 -0700 Subject: [PATCH] api: add crypto.ManagerKmip.QueryCryptoKeyStatus --- crypto/manager_kmip.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/crypto/manager_kmip.go b/crypto/manager_kmip.go index 6fac35920..2523c0a2e 100644 --- a/crypto/manager_kmip.go +++ b/crypto/manager_kmip.go @@ -26,6 +26,13 @@ import ( "github.com/vmware/govmomi/vim25/types" ) +const ( + CheckKeyAvailable = int32(0x01) + CheckKeyUsedByVms = int32(0x02) + CheckKeyUsedByHosts = int32(0x04) + CheckKeyUsedByOther = int32(0x08) +) + type ManagerKmip struct { object.Common } @@ -313,6 +320,24 @@ func (m ManagerKmip) RemoveKmipServer( return nil } +func (m ManagerKmip) QueryCryptoKeyStatus( + ctx context.Context, + ids []types.CryptoKeyId, + check int32) ([]types.CryptoManagerKmipCryptoKeyStatus, error) { + + req := types.QueryCryptoKeyStatus{ + This: m.Reference(), + KeyIds: ids, + CheckKeyBitMap: check, + } + + res, err := methods.QueryCryptoKeyStatus(ctx, m.Client(), &req) + if err != nil { + return nil, err + } + return res.Returnval, nil +} + func (m ManagerKmip) ListKeys( ctx context.Context, limit *int32) ([]types.CryptoKeyId, error) { @@ -413,6 +438,21 @@ func (m ManagerKmip) GenerateKey( return res.Returnval.KeyId.KeyId, nil } +func (m ManagerKmip) RemoveKeys( + ctx context.Context, + ids []types.CryptoKeyId, + force bool) error { + + req := types.RemoveKeys{ + This: m.Reference(), + Keys: ids, + Force: force, + } + + _, err := methods.RemoveKeys(ctx, m.Client(), &req) + return err +} + type generateKeyError struct { types.LocalizedMethodFault reason string