diff --git a/go.mod b/go.mod index 9307587cc2..1b7e983493 100644 --- a/go.mod +++ b/go.mod @@ -12,14 +12,14 @@ require ( github.com/Azure/go-autorest/autorest v0.11.29 github.com/Azure/go-autorest/autorest/azure/auth v0.5.12 github.com/BurntSushi/toml v1.3.2 - github.com/aws/aws-sdk-go v1.45.15 + github.com/aws/aws-sdk-go v1.45.16 github.com/containers/common v0.56.0 github.com/containers/image/v5 v5.28.0 github.com/gobwas/glob v0.2.3 github.com/golang-jwt/jwt/v4 v4.5.0 github.com/google/go-cmp v0.5.9 github.com/google/uuid v1.3.1 - github.com/gophercloud/gophercloud v1.6.0 + github.com/gophercloud/gophercloud v1.7.0 github.com/hashicorp/go-retryablehttp v0.7.4 github.com/kolo/xmlrpc v0.0.0-20201022064351-38db28db192b github.com/opencontainers/go-digest v1.0.0 @@ -29,16 +29,16 @@ require ( github.com/spf13/cobra v1.7.0 github.com/stretchr/testify v1.8.4 github.com/ubccr/kerby v0.0.0-20170626144437-201a958fc453 - github.com/vmware/govmomi v0.30.7 + github.com/vmware/govmomi v0.31.0 golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 golang.org/x/oauth2 v0.12.0 golang.org/x/sys v0.12.0 - google.golang.org/api v0.142.0 + google.golang.org/api v0.143.0 gopkg.in/ini.v1 v1.67.0 ) require ( - cloud.google.com/go v0.110.6 // indirect + cloud.google.com/go v0.110.7 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/iam v1.1.1 // indirect github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 // indirect @@ -81,7 +81,7 @@ require ( github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-containerregistry v0.16.1 // indirect github.com/google/s2a-go v0.1.7 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.3.1 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect github.com/gorilla/mux v1.8.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -135,9 +135,9 @@ require ( golang.org/x/text v0.13.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb // indirect + google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect google.golang.org/grpc v1.57.0 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/go-jose/go-jose.v2 v2.6.1 // indirect diff --git a/go.sum b/go.sum index c4549a91e2..c025ea9437 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.110.6 h1:8uYAkj3YHTP/1iwReuHPxLSbdcyc+dSBbzFMrVwDR6Q= -cloud.google.com/go v0.110.6/go.mod h1:+EYjdK8e5RME/VY/qLCAtuyALQ9q67dvuum8i+H5xsI= +cloud.google.com/go v0.110.7 h1:rJyC7nWRg2jWGZ4wSJ5nY65GTdYJkg0cd/uXb+ACI6o= +cloud.google.com/go v0.110.7/go.mod h1:+EYjdK8e5RME/VY/qLCAtuyALQ9q67dvuum8i+H5xsI= cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= @@ -59,8 +59,8 @@ github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat6 github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= -github.com/aws/aws-sdk-go v1.45.15 h1:gYBTVSYuhXdatrLbsPaRgVcc637zzdgThWmsDRwXLOo= -github.com/aws/aws-sdk-go v1.45.15/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.45.16 h1:spca2z7UJgoQ5V2fX6XiHDCj2E65kOJAfbUPozSkE24= +github.com/aws/aws-sdk-go v1.45.16/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= @@ -216,12 +216,12 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.2.5 h1:UR4rDjcgpgEnqpIEvkiqTYKBCKLNmlge2eVjoZfySzM= -github.com/googleapis/enterprise-certificate-proxy v0.2.5/go.mod h1:RxW0N9901Cko1VOCW3SXCpWP+mlIEkk2tP7jnHy9a3w= +github.com/googleapis/enterprise-certificate-proxy v0.3.1 h1:SBWmZhjUDRorQxrN0nwzf+AHBxnbFjViHQS4P0yVpmQ= +github.com/googleapis/enterprise-certificate-proxy v0.3.1/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas= github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qKpsEkdD5+I6QGU= -github.com/gophercloud/gophercloud v1.6.0 h1:JwJN1bauRnWPba5ueWs9IluONHteXPWjjK+MvfM4krY= -github.com/gophercloud/gophercloud v1.6.0/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM= +github.com/gophercloud/gophercloud v1.7.0 h1:fyJGKh0LBvIZKLvBWvQdIgkaV5yTM3Jh9EYUh+UNCAs= +github.com/gophercloud/gophercloud v1.7.0/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -393,8 +393,8 @@ github.com/vbauerster/mpb/v8 v8.6.1 h1:XbBpIbJxJOO9yMcKPpI4oEFPW6tLAptefNQJNcGWr github.com/vbauerster/mpb/v8 v8.6.1/go.mod h1:S0tuIjikxlLxCeNijNhwAuD/BB3UE/d2nygG8SOldk0= github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= -github.com/vmware/govmomi v0.30.7 h1:YO8CcDpLJzmq6PK5/CBQbXyV21iCMh8SbdXt+xNkXp8= -github.com/vmware/govmomi v0.30.7/go.mod h1:epgoslm97rLECMV4D+08ORzUBEU7boFSepKjt7AYVGg= +github.com/vmware/govmomi v0.31.0 h1:+NC7le8yeXj7f4YUC841jgdWsehN7A3ivqLxm79eKyo= +github.com/vmware/govmomi v0.31.0/go.mod h1:JA63Pg0SgQcSjk+LuPzjh3rJdcWBo/ZNCIwbb1qf2/0= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= @@ -515,8 +515,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -google.golang.org/api v0.142.0 h1:mf+7EJ94fi5ZcnpPy+m0Yv2dkz8bKm+UL0snTCuwXlY= -google.golang.org/api v0.142.0/go.mod h1:zJAN5o6HRqR7O+9qJUFOWrZkYE66RH+efPBdTLA4xBA= +google.golang.org/api v0.143.0 h1:o8cekTkqhywkbZT6p1UHJPZ9+9uuCAJs/KYomxZB8fA= +google.golang.org/api v0.143.0/go.mod h1:FoX9DO9hT7DLNn97OuoZAGSDuNAXdJRuGK98rSUgurk= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= @@ -524,12 +524,12 @@ google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCID google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 h1:L6iMMGrtzgHsWofoFcihmDEMYeDR9KN/ThbPWGrh++g= -google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5/go.mod h1:oH/ZOT02u4kWEp7oYBGYFFkCdKS/uYR9Z7+0/xuuFp8= -google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5 h1:nIgk/EEq3/YlnmVVXVnm14rC2oxgs1o0ong4sD/rd44= -google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5/go.mod h1:5DZzOUPCLYL3mNkQ0ms0F3EuUNZ7py1Bqeq6sxzI7/Q= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb h1:Isk1sSH7bovx8Rti2wZK0UZF6oraBDK74uoyLEEVFN0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= +google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb h1:XFBgcDwm7irdHTbz4Zk2h7Mh+eis4nfJEFQFYzJzuIA= +google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4= +google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb h1:lK0oleSc7IQsUxO3U5TjL9DWlsxpEBemh+zpB7IqhWI= +google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 h1:N3bU/SQDCDyD6R528GJ/PwW9KjYcJA3dgyH+MovAkIM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:KSqppvjFjtoCI+KGd4PELB0qLNxdJHRGqRI09mB6pQA= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= diff --git a/vendor/cloud.google.com/go/internal/.repo-metadata-full.json b/vendor/cloud.google.com/go/internal/.repo-metadata-full.json index d953f44e9c..95b54b1378 100644 --- a/vendor/cloud.google.com/go/internal/.repo-metadata-full.json +++ b/vendor/cloud.google.com/go/internal/.repo-metadata-full.json @@ -26,7 +26,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/advisorynotifications/latest/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/ai/generativelanguage/apiv1beta2": { @@ -89,6 +89,16 @@ "release_level": "preview", "library_type": "GAPIC_AUTO" }, + "cloud.google.com/go/alloydb/connectors/apiv1alpha": { + "api_shortname": "connectors", + "distribution_name": "cloud.google.com/go/alloydb/connectors/apiv1alpha", + "description": "AlloyDB connectors", + "language": "go", + "client_library_type": "generated", + "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/alloydb/latest/connectors/apiv1alpha", + "release_level": "preview", + "library_type": "GAPIC_AUTO" + }, "cloud.google.com/go/analytics/admin/apiv1alpha": { "api_shortname": "analyticsadmin", "distribution_name": "cloud.google.com/go/analytics/admin/apiv1alpha", @@ -276,7 +286,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/beyondcorp/latest/appconnections/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/beyondcorp/appconnectors/apiv1": { @@ -286,7 +296,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/beyondcorp/latest/appconnectors/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/beyondcorp/appgateways/apiv1": { @@ -296,7 +306,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/beyondcorp/latest/appgateways/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/beyondcorp/clientconnectorservices/apiv1": { @@ -306,7 +316,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/beyondcorp/latest/clientconnectorservices/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/beyondcorp/clientgateways/apiv1": { @@ -316,7 +326,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/beyondcorp/latest/clientgateways/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/bigquery": { @@ -336,7 +346,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/bigquery/latest/analyticshub/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/bigquery/connection/apiv1": { @@ -376,7 +386,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/bigquery/latest/datapolicies/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/bigquery/datapolicies/apiv1beta1": { @@ -545,7 +555,7 @@ "description": "Cloud Build API", "language": "go", "client_library_type": "generated", - "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/latest/cloudbuild/apiv1/v2", + "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/cloudbuild/latest/apiv1/v2", "release_level": "stable", "library_type": "GAPIC_AUTO" }, @@ -599,6 +609,16 @@ "release_level": "preview", "library_type": "GAPIC_AUTO" }, + "cloud.google.com/go/commerce/consumer/procurement/apiv1": { + "api_shortname": "cloudcommerceconsumerprocurement", + "distribution_name": "cloud.google.com/go/commerce/consumer/procurement/apiv1", + "description": "Cloud Commerce Consumer Procurement API", + "language": "go", + "client_library_type": "generated", + "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/commerce/latest/consumer/procurement/apiv1", + "release_level": "preview", + "library_type": "GAPIC_AUTO" + }, "cloud.google.com/go/compute/apiv1": { "api_shortname": "compute", "distribution_name": "cloud.google.com/go/compute/apiv1", @@ -626,7 +646,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/confidentialcomputing/latest/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/confidentialcomputing/apiv1alpha1": { @@ -696,7 +716,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/datacatalog/latest/lineage/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/dataflow/apiv1beta3": { @@ -826,13 +846,13 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/latest/debugger/apiv2", - "release_level": "stable", + "release_level": "preview", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/deploy/apiv1": { "api_shortname": "clouddeploy", "distribution_name": "cloud.google.com/go/deploy/apiv1", - "description": "Google Cloud Deploy API", + "description": "Cloud Deploy API", "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/deploy/latest/apiv1", @@ -886,7 +906,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/discoveryengine/latest/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/discoveryengine/apiv1beta": { @@ -996,7 +1016,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/eventarc/latest/publishing/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/filestore/apiv1": { @@ -1106,7 +1126,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/gkemulticloud/latest/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/gsuiteaddons/apiv1": { @@ -1306,7 +1326,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/maps/latest/places/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/maps/routing/apiv2": { @@ -1419,6 +1439,16 @@ "release_level": "stable", "library_type": "GAPIC_AUTO" }, + "cloud.google.com/go/netapp/apiv1": { + "api_shortname": "netapp", + "distribution_name": "cloud.google.com/go/netapp/apiv1", + "description": "NetApp API", + "language": "go", + "client_library_type": "generated", + "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/netapp/latest/apiv1", + "release_level": "preview", + "library_type": "GAPIC_AUTO" + }, "cloud.google.com/go/networkconnectivity/apiv1": { "api_shortname": "networkconnectivity", "distribution_name": "cloud.google.com/go/networkconnectivity/apiv1", @@ -1589,6 +1619,16 @@ "release_level": "preview", "library_type": "GAPIC_AUTO" }, + "cloud.google.com/go/policysimulator/apiv1": { + "api_shortname": "policysimulator", + "distribution_name": "cloud.google.com/go/policysimulator/apiv1", + "description": "Policy Simulator API", + "language": "go", + "client_library_type": "generated", + "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/policysimulator/latest/apiv1", + "release_level": "preview", + "library_type": "GAPIC_AUTO" + }, "cloud.google.com/go/policytroubleshooter/apiv1": { "api_shortname": "policytroubleshooter", "distribution_name": "cloud.google.com/go/policytroubleshooter/apiv1", @@ -1666,7 +1706,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/rapidmigrationassessment/latest/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/recaptchaenterprise/v2/apiv1": { @@ -2036,7 +2076,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/speech/latest/apiv2", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/storage": { @@ -2086,7 +2126,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/support/latest/apiv2", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/talent/apiv4": { @@ -2176,7 +2216,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/latest/video/stitcher/apiv1", - "release_level": "stable", + "release_level": "preview", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/video/transcoder/apiv1": { @@ -2256,7 +2296,7 @@ "language": "go", "client_library_type": "generated", "client_documentation": "https://cloud.google.com/go/docs/reference/cloud.google.com/go/vmwareengine/latest/apiv1", - "release_level": "preview", + "release_level": "stable", "library_type": "GAPIC_AUTO" }, "cloud.google.com/go/vpcaccess/apiv1": { diff --git a/vendor/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go b/vendor/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go index 5d3516cb4b..c0faf837ec 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go @@ -38529,6 +38529,16 @@ var awsusgovPartition = partition{ }: endpoint{}, }, }, + "rolesanywhere": service{ + Endpoints: serviceEndpoints{ + endpointKey{ + Region: "us-gov-east-1", + }: endpoint{}, + endpointKey{ + Region: "us-gov-west-1", + }: endpoint{}, + }, + }, "route53": service{ PartitionEndpoint: "aws-us-gov-global", IsRegionalized: boxedFalse, diff --git a/vendor/github.com/aws/aws-sdk-go/aws/version.go b/vendor/github.com/aws/aws-sdk-go/aws/version.go index 8fe3a6efea..f9673717cf 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/version.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/version.go @@ -5,4 +5,4 @@ package aws const SDKName = "aws-sdk-go" // SDKVersion is the version of this SDK -const SDKVersion = "1.45.15" +const SDKVersion = "1.45.16" diff --git a/vendor/github.com/googleapis/enterprise-certificate-proxy/client/client.go b/vendor/github.com/googleapis/enterprise-certificate-proxy/client/client.go index b3283b8158..ea5beb5aa7 100644 --- a/vendor/github.com/googleapis/enterprise-certificate-proxy/client/client.go +++ b/vendor/github.com/googleapis/enterprise-certificate-proxy/client/client.go @@ -35,6 +35,8 @@ import ( const signAPI = "EnterpriseCertSigner.Sign" const certificateChainAPI = "EnterpriseCertSigner.CertificateChain" const publicKeyAPI = "EnterpriseCertSigner.Public" +const encryptAPI = "EnterpriseCertSigner.Encrypt" +const decryptAPI = "EnterpriseCertSigner.Decrypt" // A Connection wraps a pair of unidirectional streams as an io.ReadWriteCloser. type Connection struct { @@ -54,13 +56,28 @@ func (c *Connection) Close() error { func init() { gob.Register(crypto.SHA256) + gob.Register(crypto.SHA384) + gob.Register(crypto.SHA512) gob.Register(&rsa.PSSOptions{}) + gob.Register(&rsa.OAEPOptions{}) } -// SignArgs contains arguments to a crypto Signer.Sign method. +// SignArgs contains arguments for a Sign API call. type SignArgs struct { Digest []byte // The content to sign. - Opts crypto.SignerOpts // Options for signing, such as Hash identifier. + Opts crypto.SignerOpts // Options for signing. Must implement HashFunc(). +} + +// EncryptArgs contains arguments for an Encrypt API call. +type EncryptArgs struct { + Plaintext []byte // The plaintext to encrypt. + Opts any // Options for encryption. Ex: an instance of crypto.Hash. +} + +// DecryptArgs contains arguments to for a Decrypt API call. +type DecryptArgs struct { + Ciphertext []byte // The ciphertext to decrypt. + Opts crypto.DecrypterOpts // Options for decryption. Ex: an instance of *rsa.OAEPOptions. } // Key implements credential.Credential by holding the executed signer subprocess. @@ -98,7 +115,7 @@ func (k *Key) Public() crypto.PublicKey { return k.publicKey } -// Sign signs a message digest, using the specified signer options. +// Sign signs a message digest, using the specified signer opts. Implements crypto.Signer interface. func (k *Key) Sign(_ io.Reader, digest []byte, opts crypto.SignerOpts) (signed []byte, err error) { if opts != nil && opts.HashFunc() != 0 && len(digest) != opts.HashFunc().Size() { return nil, fmt.Errorf("Digest length of %v bytes does not match Hash function size of %v bytes", len(digest), opts.HashFunc().Size()) @@ -107,6 +124,18 @@ func (k *Key) Sign(_ io.Reader, digest []byte, opts crypto.SignerOpts) (signed [ return } +// Encrypt encrypts a plaintext msg into ciphertext, using the specified encrypt opts. +func (k *Key) Encrypt(_ io.Reader, msg []byte, opts any) (ciphertext []byte, err error) { + err = k.client.Call(encryptAPI, EncryptArgs{Plaintext: msg, Opts: opts}, &ciphertext) + return +} + +// Decrypt decrypts a ciphertext msg into plaintext, using the specified decrypter opts. Implements crypto.Decrypter interface. +func (k *Key) Decrypt(_ io.Reader, msg []byte, opts crypto.DecrypterOpts) (plaintext []byte, err error) { + err = k.client.Call(decryptAPI, DecryptArgs{Ciphertext: msg, Opts: opts}, &plaintext) + return +} + // ErrCredUnavailable is a sentinel error that indicates ECP Cred is unavailable, // possibly due to missing config or missing binary path. var ErrCredUnavailable = errors.New("Cred is unavailable") @@ -120,7 +149,12 @@ var ErrCredUnavailable = errors.New("Cred is unavailable") // The config file also specifies which certificate the signer should use. func Cred(configFilePath string) (*Key, error) { if configFilePath == "" { - configFilePath = util.GetDefaultConfigFilePath() + envFilePath := util.GetConfigFilePathFromEnv() + if envFilePath != "" { + configFilePath = envFilePath + } else { + configFilePath = util.GetDefaultConfigFilePath() + } } enterpriseCertSignerPath, err := util.LoadSignerBinaryPath(configFilePath) if err != nil { diff --git a/vendor/github.com/googleapis/enterprise-certificate-proxy/client/util/util.go b/vendor/github.com/googleapis/enterprise-certificate-proxy/client/util/util.go index 1640ec1c9e..f374a7f55f 100644 --- a/vendor/github.com/googleapis/enterprise-certificate-proxy/client/util/util.go +++ b/vendor/github.com/googleapis/enterprise-certificate-proxy/client/util/util.go @@ -22,6 +22,7 @@ import ( "os/user" "path/filepath" "runtime" + "strings" ) const configFileName = "certificate_config.json" @@ -63,6 +64,9 @@ func LoadSignerBinaryPath(configFilePath string) (path string, err error) { if signerBinaryPath == "" { return "", ErrConfigUnavailable } + + signerBinaryPath = strings.ReplaceAll(signerBinaryPath, "~", guessHomeDir()) + signerBinaryPath = strings.ReplaceAll(signerBinaryPath, "$HOME", guessHomeDir()) return signerBinaryPath, nil } @@ -89,3 +93,8 @@ func getDefaultConfigFileDirectory() (directory string) { func GetDefaultConfigFilePath() (path string) { return filepath.Join(getDefaultConfigFileDirectory(), configFileName) } + +// GetConfigFilePathFromEnv returns the path associated with environment variable GOOGLE_API_CERTIFICATE_CONFIG +func GetConfigFilePathFromEnv() (path string) { + return os.Getenv("GOOGLE_API_CERTIFICATE_CONFIG") +} diff --git a/vendor/github.com/gophercloud/gophercloud/CHANGELOG.md b/vendor/github.com/gophercloud/gophercloud/CHANGELOG.md index fb9d4172a8..b470df398b 100644 --- a/vendor/github.com/gophercloud/gophercloud/CHANGELOG.md +++ b/vendor/github.com/gophercloud/gophercloud/CHANGELOG.md @@ -1,3 +1,19 @@ +## v1.7.0 (2023-09-22) + +New features and improvements: + +* [GH-2782](https://github.com/gophercloud/gophercloud/pull/2782) [v1] (manual clean backport) Add tag field to compute block_device_v2 + +CI changes: + +* [GH-2760](https://github.com/gophercloud/gophercloud/pull/2760) [v1 backports] semver auto labels +* [GH-2775](https://github.com/gophercloud/gophercloud/pull/2775) [v1] Fix typos in comments +* [GH-2783](https://github.com/gophercloud/gophercloud/pull/2783) [v1] (clean manual backport) ci/functional: fix ubuntu version & add antelope +* [GH-2785](https://github.com/gophercloud/gophercloud/pull/2785) [v1] Acceptance: Handle numerical version names in version comparison helpers +* [GH-2787](https://github.com/gophercloud/gophercloud/pull/2787) backport-v1: fixes to semver label +* [GH-2788](https://github.com/gophercloud/gophercloud/pull/2788) [v1] Make acceptance tests internal + + ## v1.6.0 (2023-08-30) New features and improvements: diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/results.go b/vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/results.go index 1b27a15495..96fd91a2ca 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/results.go +++ b/vendor/github.com/gophercloud/gophercloud/openstack/imageservice/v2/images/results.go @@ -76,7 +76,7 @@ type Image struct { CreatedAt time.Time `json:"created_at"` // UpdatedAt is the date when the last change has been made to the image or - // it's properties. + // its properties. UpdatedAt time.Time `json:"updated_at"` // File is the trailing path after the glance endpoint that represent the diff --git a/vendor/github.com/gophercloud/gophercloud/provider_client.go b/vendor/github.com/gophercloud/gophercloud/provider_client.go index d1955b65ab..e53b713cd4 100644 --- a/vendor/github.com/gophercloud/gophercloud/provider_client.go +++ b/vendor/github.com/gophercloud/gophercloud/provider_client.go @@ -14,7 +14,7 @@ import ( // DefaultUserAgent is the default User-Agent string set in the request header. const ( - DefaultUserAgent = "gophercloud/v1.6.0" + DefaultUserAgent = "gophercloud/v1.7.0" DefaultMaxBackoffRetries = 60 ) diff --git a/vendor/github.com/vmware/govmomi/CONTRIBUTORS b/vendor/github.com/vmware/govmomi/CONTRIBUTORS index ef8c56de8b..406173b84c 100644 --- a/vendor/github.com/vmware/govmomi/CONTRIBUTORS +++ b/vendor/github.com/vmware/govmomi/CONTRIBUTORS @@ -9,6 +9,7 @@ Adam Chalkley Adam Fowler Adam Shannon Akanksha Panse +akutz Al Biheiri Alessandro Cortiana Alex @@ -52,7 +53,6 @@ Brian Rak brian57860 Bruce Downs Bryan Venteicher -Cédric Blomart Cheng Cheng Chethan Venkatesh Choudhury Sarada Prasanna Nanda @@ -61,6 +61,7 @@ Christian Höltje Clint Greenwood cpiment CuiHaozhi +Cédric Blomart Dan Ilan Dan Norris Daniel Frederick Crisman @@ -104,6 +105,7 @@ Gavrie Philipson George Hicken Gerrit Renker gthombare +Hakan Halil HakanSunay Hasan Mahmood Haydon Ryan @@ -123,9 +125,9 @@ Jeremy Canady jeremy-clerc Jiatong Wang jingyizPensando -João Pereira Jonas Ausevicius Jorge Sevilla +João Pereira Julien PILLON Justin J. Novack kayrus @@ -140,6 +142,7 @@ Louie Jiang Luther Monson Madanagopal Arunachalam makelarisjr <8687447+makelarisjr@users.noreply.github.com> +Manuel Grandeit maplain Marc Carmier Marcus Tan @@ -164,6 +167,7 @@ Mike Schinkel Mincho Tonev mingwei Nicolas Lamirault +nikhaild <84156354+nikhaild@users.noreply.github.com> Nikhil Kathare Nikhil R Deshpande Nikolas Grottendieck @@ -226,6 +230,7 @@ Tjeu Kayim <15987676+TjeuKayim@users.noreply.github.com> Toomas Pelberg Trevor Dawe tshihad +Ueli Banholzer Uwe Bessle Vadim Egorov Vikram Krishnamurthy @@ -245,6 +250,7 @@ Yi Jiang yiyingy ykakarap Yogesh Sobale <6104071+ysobale@users.noreply.github.com> +Your Name Yue Yin Yun Zhou Yuya Kusakabe diff --git a/vendor/github.com/vmware/govmomi/cns/client.go b/vendor/github.com/vmware/govmomi/cns/client.go index 037ac2e929..a526ff46f9 100644 --- a/vendor/github.com/vmware/govmomi/cns/client.go +++ b/vendor/github.com/vmware/govmomi/cns/client.go @@ -44,6 +44,10 @@ var ( Type: "CnsVolumeManager", Value: "cns-volume-manager", } + CnsDebugManagerInstance = vimtypes.ManagedObjectReference{ + Type: "CnsDebugManager", + Value: "cns-debug-manager", + } ) type Client struct { @@ -282,3 +286,20 @@ func (c *Client) ReconfigVolumePolicy(ctx context.Context, PolicyReconfigSpecs [ } return object.NewTask(c.vim25Client, res.Returnval), nil } + +// SyncDatastore calls the CnsSyncDatastore API +// Note: To be used only by VMware's internal support tools. +// This API triggers a manual sync of internal CNS and FCD DBs which otherwise happens periodially, +// with fullsync it forces synchronization of complete tables. +func (c *Client) SyncDatastore(ctx context.Context, dsURL string, fullSync bool) (*object.Task, error) { + req := cnstypes.CnsSyncDatastore{ + This: CnsDebugManagerInstance, + DatastoreUrl: dsURL, + FullSync: &fullSync, + } + res, err := methods.CnsSyncDatastore(ctx, c, &req) + if err != nil { + return nil, err + } + return object.NewTask(c.vim25Client, res.Returnval), nil +} diff --git a/vendor/github.com/vmware/govmomi/cns/methods/methods.go b/vendor/github.com/vmware/govmomi/cns/methods/methods.go index 43f41f3aa5..da9318cac0 100644 --- a/vendor/github.com/vmware/govmomi/cns/methods/methods.go +++ b/vendor/github.com/vmware/govmomi/cns/methods/methods.go @@ -346,3 +346,24 @@ func CnsReconfigVolumePolicy(ctx context.Context, r soap.RoundTripper, req *type return resBody.Res, nil } + +type CnsSyncDatastoreBody struct { + Req *types.CnsSyncDatastore `xml:"urn:vsan CnsSyncDatastore,omitempty"` + Res *types.CnsSyncDatastoreResponse `xml:"urn:vsan CnsSyncDatastoreResponse,omitempty"` + Fault_ *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"` +} + +func (b *CnsSyncDatastoreBody) Fault() *soap.Fault { return b.Fault_ } + +// Note: To be used only by VMware's internal support tools. +func CnsSyncDatastore(ctx context.Context, r soap.RoundTripper, req *types.CnsSyncDatastore) (*types.CnsSyncDatastoreResponse, error) { + var reqBody, resBody CnsSyncDatastoreBody + + reqBody.Req = req + + if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil { + return nil, err + } + + return resBody.Res, nil +} diff --git a/vendor/github.com/vmware/govmomi/cns/types/types.go b/vendor/github.com/vmware/govmomi/cns/types/types.go index 452b9ed387..d493e99c59 100644 --- a/vendor/github.com/vmware/govmomi/cns/types/types.go +++ b/vendor/github.com/vmware/govmomi/cns/types/types.go @@ -909,3 +909,23 @@ type CnsVolumePolicyReconfigSpec struct { func init() { types.Add("vsan:CnsVolumePolicyReconfigSpec", reflect.TypeOf((*CnsVolumePolicyReconfigSpec)(nil)).Elem()) } + +type CnsSyncDatastore CnsSyncDatastoreRequestType + +func init() { + types.Add("vsan:CnsSyncDatastore", reflect.TypeOf((*CnsSyncDatastore)(nil)).Elem()) +} + +type CnsSyncDatastoreRequestType struct { + This types.ManagedObjectReference `xml:"_this"` + DatastoreUrl string `xml:"datastoreUrl,omitempty"` + FullSync *bool `xml:"fullSync"` +} + +func init() { + types.Add("vsan:CnsSyncDatastoreRequestType", reflect.TypeOf((*CnsSyncDatastoreRequestType)(nil)).Elem()) +} + +type CnsSyncDatastoreResponse struct { + Returnval types.ManagedObjectReference `xml:"returnval"` +} diff --git a/vendor/github.com/vmware/govmomi/find/doc.go b/vendor/github.com/vmware/govmomi/find/doc.go index 0c8acee016..d22e883534 100644 --- a/vendor/github.com/vmware/govmomi/find/doc.go +++ b/vendor/github.com/vmware/govmomi/find/doc.go @@ -32,6 +32,6 @@ otherwise "find" mode is used. The exception is to use a "..." wildcard with a path to find all objects recursively underneath any root object. For example: VirtualMachineList("/DC1/...") -See also: https://github.com/vmware/govmomi/blob/master/govc/README.md#usage +See also: https://github.com/vmware/govmomi/blob/main/govc/README.md#usage */ package find diff --git a/vendor/github.com/vmware/govmomi/govc/cli/command.go b/vendor/github.com/vmware/govmomi/govc/cli/command.go index e42533fc33..fb1a255d4f 100644 --- a/vendor/github.com/vmware/govmomi/govc/cli/command.go +++ b/vendor/github.com/vmware/govmomi/govc/cli/command.go @@ -23,6 +23,7 @@ import ( "io" "io/ioutil" "os" + "path/filepath" "sort" "strings" "text/tabwriter" @@ -55,7 +56,56 @@ func generalHelp(w io.Writer, filter string) { } if len(matches) == 0 { - fmt.Fprintf(w, "Usage of %s:\n", os.Args[0]) + fmt.Fprintf(w, `Usage: %[1]s [COMMON OPTIONS] [PATH]... + +govmomi is a Go library for interacting with VMware vSphere APIs (ESXi and/or +vCenter Server). +It is licensed under the Apache License, Version 2.0 + +%[1]s is the CLI for govmomi. + +The available commands are listed below. A detailed description of each +command can be displayed with "govc -h". The description of all +commands can be also found at https://via.vmw.com/GJ98hk . + +Examples: + show usage of a command: govc -h + show toplevel structure: govc ls + show datacenter summary: govc datacenter.info + show all VMs: govc find -type m + upload a ISO file: govc datastore.upload -ds datastore1 ./config.iso vm-name/config.iso + +Common options: + -h Show this message + -cert= Certificate [GOVC_CERTIFICATE] + -debug=false Store debug logs [GOVC_DEBUG] + -trace=false Write SOAP/REST traffic to stderr + -verbose=false Write request/response data to stderr + -dump=false Enable output dump + -json=false Enable JSON output + -xml=false Enable XML output + -k=false Skip verification of server certificate [GOVC_INSECURE] + -key= Private key [GOVC_PRIVATE_KEY] + -persist-session=true Persist session to disk [GOVC_PERSIST_SESSION] + -tls-ca-certs= TLS CA certificates file [GOVC_TLS_CA_CERTS] + -tls-known-hosts= TLS known hosts file [GOVC_TLS_KNOWN_HOSTS] + -u= ESX or vCenter URL [GOVC_URL] + -vim-namespace=urn:vim25 Vim namespace [GOVC_VIM_NAMESPACE] + -vim-version=6.0 Vim version [GOVC_VIM_VERSION] + -dc= Datacenter [GOVC_DATACENTER] + -host.dns= Find host by FQDN + -host.ip= Find host by IP address + -host.ipath= Find host by inventory path + -host.uuid= Find host by UUID + -vm.dns= Find VM by FQDN + -vm.ip= Find VM by IP address + -vm.ipath= Find VM by inventory path + -vm.path= Find VM by path to .vmx file + -vm.uuid= Find VM by UUID + +Available commands: +`, filepath.Base(os.Args[0])) + } else { fmt.Fprintf(w, "%s: command '%s' not found, did you mean:\n", os.Args[0], filter) cmds = matches @@ -117,7 +167,8 @@ func Run(args []string) int { hw := os.Stderr rc := 1 hwrc := func(arg string) { - if arg == "-h" { + arg = strings.TrimLeft(arg, "-") + if arg == "h" || arg == "help" { hw = os.Stdout rc = 0 } diff --git a/vendor/github.com/vmware/govmomi/govc/flags/client.go b/vendor/github.com/vmware/govmomi/govc/flags/client.go index d410e6d197..9b04882ca2 100644 --- a/vendor/github.com/vmware/govmomi/govc/flags/client.go +++ b/vendor/github.com/vmware/govmomi/govc/flags/client.go @@ -1,11 +1,11 @@ /* -Copyright (c) 2014-2018 VMware, Inc. All Rights Reserved. +Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -298,6 +298,8 @@ func (flag *ClientFlag) ConfigureTLS(sc *soap.Client) error { } } + sc.UseJSON(os.Getenv("GOVC_VI_JSON") != "") + return nil } diff --git a/vendor/github.com/vmware/govmomi/govc/flags/common.go b/vendor/github.com/vmware/govmomi/govc/flags/common.go index 2b133b885e..002c239b9e 100644 --- a/vendor/github.com/vmware/govmomi/govc/flags/common.go +++ b/vendor/github.com/vmware/govmomi/govc/flags/common.go @@ -1,11 +1,11 @@ /* -Copyright (c) 2015-2016 VMware, Inc. All Rights Reserved. +Copyright (c) 2015-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/vendor/github.com/vmware/govmomi/govc/flags/optional_string.go b/vendor/github.com/vmware/govmomi/govc/flags/optional_string.go new file mode 100644 index 0000000000..0460785d03 --- /dev/null +++ b/vendor/github.com/vmware/govmomi/govc/flags/optional_string.go @@ -0,0 +1,50 @@ +/* +Copyright (c) 2023-2023 VMware, Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package flags + +import ( + "flag" +) + +type optionalString struct { + val **string +} + +func (s *optionalString) Set(input string) error { + *s.val = &input + return nil +} + +func (s *optionalString) Get() interface{} { + if *s.val == nil { + return nil + } + return **s.val +} + +func (s *optionalString) String() string { + if s.val == nil || *s.val == nil { + return "" + } + return **s.val +} + +// NewOptionalString returns a flag.Value implementation where there is no default value. +// This avoids sending a default value over the wire as using flag.StringVar() would. +func NewOptionalString(v **string) flag.Value { + return &optionalString{v} +} diff --git a/vendor/github.com/vmware/govmomi/govc/host/esxcli/esxcli.go b/vendor/github.com/vmware/govmomi/govc/host/esxcli/esxcli.go index 6ca0cd39b4..3ddd143004 100644 --- a/vendor/github.com/vmware/govmomi/govc/host/esxcli/esxcli.go +++ b/vendor/github.com/vmware/govmomi/govc/host/esxcli/esxcli.go @@ -1,11 +1,11 @@ /* -Copyright (c) 2014-2015 VMware, Inc. All Rights Reserved. +Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -18,6 +18,7 @@ package esxcli import ( "context" + "errors" "flag" "fmt" "io" @@ -92,6 +93,9 @@ func (cmd *esxcli) Run(ctx context.Context, f *flag.FlagSet) error { res, err := e.Run(f.Args()) if err != nil { + if f, ok := err.(*Fault); ok { + return errors.New(f.messageDetail()) + } return err } diff --git a/vendor/github.com/vmware/govmomi/govc/host/esxcli/executor.go b/vendor/github.com/vmware/govmomi/govc/host/esxcli/executor.go index af5e9ff9cc..792809eac2 100644 --- a/vendor/github.com/vmware/govmomi/govc/host/esxcli/executor.go +++ b/vendor/github.com/vmware/govmomi/govc/host/esxcli/executor.go @@ -1,11 +1,11 @@ /* -Copyright (c) 2014-2015 VMware, Inc. All Rights Reserved. +Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -18,7 +18,6 @@ package esxcli import ( "context" - "errors" "fmt" "github.com/vmware/govmomi/internal" @@ -27,6 +26,23 @@ import ( "github.com/vmware/govmomi/vim25/xml" ) +type Fault struct { + Message string + Detail string +} + +func (f Fault) Error() string { + return f.Message +} + +func (f Fault) messageDetail() string { + if f.Detail != "" { + return fmt.Sprintf("%s %s", f.Message, f.Detail) + } + + return f.Message +} + type Executor struct { c *vim25.Client host *object.HostSystem @@ -138,7 +154,10 @@ func (e *Executor) Execute(req *internal.ExecuteSoapRequest, res interface{}) er if x.Returnval != nil { if x.Returnval.Fault != nil { - return errors.New(x.Returnval.Fault.FaultMsg) + return &Fault{ + x.Returnval.Fault.FaultMsg, + x.Returnval.Fault.FaultDetail, + } } if err := xml.Unmarshal([]byte(x.Returnval.Response), res); err != nil { diff --git a/vendor/github.com/vmware/govmomi/govc/host/esxcli/response.go b/vendor/github.com/vmware/govmomi/govc/host/esxcli/response.go index e1c70b76d8..25de902df1 100644 --- a/vendor/github.com/vmware/govmomi/govc/host/esxcli/response.go +++ b/vendor/github.com/vmware/govmomi/govc/host/esxcli/response.go @@ -1,11 +1,11 @@ /* -Copyright (c) 2014-2015 VMware, Inc. All Rights Reserved. +Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/vendor/github.com/vmware/govmomi/govc/importx/archive.go b/vendor/github.com/vmware/govmomi/govc/importx/archive.go index f8d256d453..bd7c380549 100644 --- a/vendor/github.com/vmware/govmomi/govc/importx/archive.go +++ b/vendor/github.com/vmware/govmomi/govc/importx/archive.go @@ -32,6 +32,7 @@ import ( "strings" "github.com/vmware/govmomi/ovf" + "github.com/vmware/govmomi/vapi/library" "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/soap" ) @@ -40,6 +41,8 @@ import ( // only encapsulates some common archive related functionality. type ArchiveFlag struct { Archive + + manifest map[string]*library.Checksum } func newArchiveFlag(ctx context.Context) (*ArchiveFlag, context.Context) { @@ -72,6 +75,22 @@ func (f *ArchiveFlag) ReadEnvelope(data []byte) (*ovf.Envelope, error) { return e, nil } +func (f *ArchiveFlag) readManifest(fpath string) error { + base := filepath.Base(fpath) + ext := filepath.Ext(base) + mfName := strings.Replace(base, ext, ".mf", 1) + + mf, _, err := f.Open(mfName) + if err != nil { + msg := fmt.Sprintf("manifest %q: %s", mf, err) + fmt.Fprintln(os.Stderr, msg) + return errors.New(msg) + } + f.manifest, err = library.ReadManifest(mf) + _ = mf.Close() + return err +} + type Archive interface { Open(string) (io.ReadCloser, int64, error) } diff --git a/vendor/github.com/vmware/govmomi/govc/importx/ovf.go b/vendor/github.com/vmware/govmomi/govc/importx/ovf.go index bdb18ba9c4..a982722c21 100644 --- a/vendor/github.com/vmware/govmomi/govc/importx/ovf.go +++ b/vendor/github.com/vmware/govmomi/govc/importx/ovf.go @@ -22,6 +22,7 @@ import ( "flag" "fmt" "path" + "strings" "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/govc/cli" @@ -44,7 +45,8 @@ type ovfx struct { *ArchiveFlag *OptionsFlag - Name string + Name string + VerifyManifest bool Client *vim25.Client Datacenter *object.Datacenter @@ -74,6 +76,7 @@ func (cmd *ovfx) Register(ctx context.Context, f *flag.FlagSet) { cmd.OptionsFlag.Register(ctx, f) f.StringVar(&cmd.Name, "name", "", "Name to use for new entity") + f.BoolVar(&cmd.VerifyManifest, "m", false, "Verify checksum of uploaded files against manifest (.mf)") } func (cmd *ovfx) Process(ctx context.Context) error { @@ -315,6 +318,13 @@ func (cmd *ovfx) Import(fpath string) (*types.ManagedObjectReference, error) { } } + if cmd.VerifyManifest { + err = cmd.readManifest(fpath) + if err != nil { + return nil, err + } + } + lease, err := cmd.ResourcePool.ImportVApp(ctx, spec.ImportSpec, folder, host) if err != nil { return nil, err @@ -355,5 +365,74 @@ func (cmd *ovfx) Upload(ctx context.Context, lease *nfc.Lease, item nfc.FileItem Progress: logger, } - return lease.Upload(ctx, item, f, opts) + err = lease.Upload(ctx, item, f, opts) + if err != nil { + return err + } + + if cmd.VerifyManifest { + mapImportKeyToKey := func(urls []types.HttpNfcLeaseDeviceUrl, importKey string) string { + for _, url := range urls { + if url.ImportKey == importKey { + return url.Key + } + } + return "" + } + leaseInfo, err := lease.Wait(ctx, nil) + if err != nil { + return err + } + return cmd.validateChecksum(ctx, lease, file, mapImportKeyToKey(leaseInfo.DeviceUrl, item.DeviceId)) + } + return nil +} + +func (cmd *ovfx) validateChecksum(ctx context.Context, lease *nfc.Lease, file string, key string) error { + sum, found := cmd.manifest[file] + if !found { + msg := fmt.Sprintf("missing checksum for %v in manifest file", file) + return errors.New(msg) + } + // Perform the checksum match eagerly, after each file upload, instead + // of after uploading all the files, to provide fail-fast behavior. + // (Trade-off here is multiple GetManifest() API calls to the server.) + manifests, err := lease.GetManifest(ctx) + if err != nil { + return err + } + for _, m := range manifests { + if m.Key == key { + // Compare server-side computed checksum of uploaded file + // against the client's manifest entry (assuming client's + // manifest has correct checksums - client doesn't compute + // checksum of the file before uploading). + + // Try matching sha1 first (newer versions have moved to sha256). + if strings.ToUpper(sum.Algorithm) == "SHA1" { + if sum.Checksum != m.Sha1 { + msg := fmt.Sprintf("manifest checksum %v mismatch with uploaded checksum %v for file %v", + sum.Checksum, m.Sha1, file) + return errors.New(msg) + } + // Uploaded file checksum computed by server matches with local manifest entry. + return nil + } + // If not sha1, check for other types (in a separate field). + if !strings.EqualFold(sum.Algorithm, m.ChecksumType) { + msg := fmt.Sprintf("manifest checksum type %v mismatch with uploaded checksum type %v for file %v", + sum.Algorithm, m.ChecksumType, file) + return errors.New(msg) + } + if !strings.EqualFold(sum.Checksum, m.Checksum) { + msg := fmt.Sprintf("manifest checksum %v mismatch with uploaded checksum %v for file %v", + sum.Checksum, m.Checksum, file) + return errors.New(msg) + } + // Uploaded file checksum computed by server matches with local manifest entry. + return nil + } + } + msg := fmt.Sprintf("missing manifest entry on server for uploaded file %v (key %v), manifests=%#v", file, key, manifests) + return errors.New(msg) } diff --git a/vendor/github.com/vmware/govmomi/govc/vm/clone.go b/vendor/github.com/vmware/govmomi/govc/vm/clone.go index b8217e79ce..d9ef49a2b2 100644 --- a/vendor/github.com/vmware/govmomi/govc/vm/clone.go +++ b/vendor/github.com/vmware/govmomi/govc/vm/clone.go @@ -220,6 +220,10 @@ func (cmd *clone) Run(ctx context.Context, f *flag.FlagSet) error { if cmd.ResourcePool, err = cmd.ResourcePoolFlag.ResourcePool(); err != nil { return err } + } else { + if cmd.ResourcePool, err = cmd.Cluster.ResourcePool(ctx); err != nil { + return err + } } } diff --git a/vendor/github.com/vmware/govmomi/govc/vm/power.go b/vendor/github.com/vmware/govmomi/govc/vm/power.go index 0f604e8ad4..d3c8c8e5f4 100644 --- a/vendor/github.com/vmware/govmomi/govc/vm/power.go +++ b/vendor/github.com/vmware/govmomi/govc/vm/power.go @@ -1,11 +1,11 @@ /* -Copyright (c) 2014-2016 VMware, Inc. All Rights Reserved. +Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -37,6 +37,7 @@ type power struct { Reset bool Reboot bool Shutdown bool + Standby bool Suspend bool Force bool Multi bool @@ -60,6 +61,7 @@ func (cmd *power) Register(ctx context.Context, f *flag.FlagSet) { f.BoolVar(&cmd.Suspend, "suspend", false, "Power suspend") f.BoolVar(&cmd.Reboot, "r", false, "Reboot guest") f.BoolVar(&cmd.Shutdown, "s", false, "Shutdown guest") + f.BoolVar(&cmd.Standby, "standby", false, "Standby guest") f.BoolVar(&cmd.Force, "force", false, "Force (ignore state error and hard shutdown/reboot if tools unavailable)") f.BoolVar(&cmd.Multi, "M", false, "Use Datacenter.PowerOnMultiVM method instead of VirtualMachine.PowerOnVM") f.BoolVar(&cmd.Wait, "wait", true, "Wait for the operation to complete") @@ -85,7 +87,7 @@ func (cmd *power) Process(ctx context.Context) error { if err := cmd.SearchFlag.Process(ctx); err != nil { return err } - opts := []bool{cmd.On, cmd.Off, cmd.Reset, cmd.Suspend, cmd.Reboot, cmd.Shutdown} + opts := []bool{cmd.On, cmd.Off, cmd.Reset, cmd.Suspend, cmd.Reboot, cmd.Shutdown, cmd.Standby} selected := false for _, opt := range opts { @@ -188,6 +190,13 @@ func (cmd *power) Run(ctx context.Context, f *flag.FlagSet) error { if err != nil && cmd.Force && isToolsUnavailable(err) { task, err = vm.PowerOff(ctx) } + case cmd.Standby: + fmt.Fprintf(cmd, "Standby guest %s... ", vm.Reference()) + err = vm.StandbyGuest(ctx) + + if err != nil && cmd.Force && isToolsUnavailable(err) { + task, err = vm.Suspend(ctx) + } } if err != nil { diff --git a/vendor/github.com/vmware/govmomi/guest/file_manager.go b/vendor/github.com/vmware/govmomi/guest/file_manager.go index 9dc0c194b2..1141f54cc3 100644 --- a/vendor/github.com/vmware/govmomi/guest/file_manager.go +++ b/vendor/github.com/vmware/govmomi/guest/file_manager.go @@ -168,6 +168,15 @@ func (m FileManager) TransferURL(ctx context.Context, u string) (*url.URL, error return turl, nil // won't matter if the VM was powered off since the call to InitiateFileTransfer will fail } + // VC supports the use of a Unix domain socket for guest file transfers. + if internal.UsingEnvoySidecar(m.c) { + // Rewrite the URL in the format unix:// + // Reciever must use a custom dialer. + // Nil check performed above, so Host is safe to access. + return internal.HostGatewayTransferURL(turl, *vm.Runtime.Host), nil + } + + // Determine host thumbprint, address etc. to be able to trust host. props := []string{ "name", "runtime.connectionState", diff --git a/vendor/github.com/vmware/govmomi/guest/toolbox/client.go b/vendor/github.com/vmware/govmomi/guest/toolbox/client.go index 9d492296ce..38cc5946d5 100644 --- a/vendor/github.com/vmware/govmomi/guest/toolbox/client.go +++ b/vendor/github.com/vmware/govmomi/guest/toolbox/client.go @@ -29,6 +29,7 @@ import ( "time" "github.com/vmware/govmomi/guest" + "github.com/vmware/govmomi/internal" "github.com/vmware/govmomi/property" "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/mo" @@ -284,6 +285,10 @@ func (c *Client) Download(ctx context.Context, src string) (io.ReadCloser, int64 p := soap.DefaultDownload + if internal.UsingEnvoySidecar(c.ProcessManager.Client()) { + vc = internal.ClientWithEnvoyHostGateway(vc) + } + f, n, err := vc.Download(ctx, u, &p) if err != nil { return nil, n, err @@ -341,5 +346,9 @@ func (c *Client) Upload(ctx context.Context, src io.Reader, dst string, p soap.U return err } + if internal.UsingEnvoySidecar(c.ProcessManager.Client()) { + vc = internal.ClientWithEnvoyHostGateway(vc) + } + return vc.Client.Upload(ctx, src, u, &p) } diff --git a/vendor/github.com/vmware/govmomi/internal/helpers.go b/vendor/github.com/vmware/govmomi/internal/helpers.go index b3eafeadfd..41e533fd75 100644 --- a/vendor/github.com/vmware/govmomi/internal/helpers.go +++ b/vendor/github.com/vmware/govmomi/internal/helpers.go @@ -1,5 +1,5 @@ /* -Copyright (c) 2020 VMware, Inc. All Rights Reserved. +Copyright (c) 2020-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,13 +17,25 @@ limitations under the License. package internal import ( + "context" + "fmt" "net" + "net/http" + "net/url" + "os" "path" + "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/mo" + "github.com/vmware/govmomi/vim25/soap" "github.com/vmware/govmomi/vim25/types" ) +const ( + vCenterHostGatewaySocket = "/var/run/envoy-hgw/hgw-pipe" + vCenterHostGatewaySocketEnv = "VCENTER_ENVOY_HOST_GATEWAY" +) + // InventoryPath composed of entities by Name func InventoryPath(entities []mo.ManagedEntity) string { val := "/" @@ -61,3 +73,69 @@ func HostSystemManagementIPs(config []types.VirtualNicManagerNetConfig) []net.IP return ips } + +// UsingEnvoySidecar determines if the given *vim25.Client is using vCenter's +// local Envoy sidecar (as opposed to using the HTTPS port.) +// Returns a boolean indicating whether to use the sidecar or not. +func UsingEnvoySidecar(c *vim25.Client) bool { + envoySidecarPort := os.Getenv("GOVMOMI_ENVOY_SIDECAR_PORT") + if envoySidecarPort == "" { + envoySidecarPort = "1080" + } + envoySidecarHost := os.Getenv("GOVMOMI_ENVOY_SIDECAR_HOST") + if envoySidecarHost == "" { + envoySidecarHost = "localhost" + } + return c.URL().Hostname() == envoySidecarHost && c.URL().Scheme == "http" && c.URL().Port() == envoySidecarPort +} + +// ClientWithEnvoyHostGateway clones the provided soap.Client and returns a new +// one that uses a Unix socket to leverage vCenter's local Envoy host +// gateway. +// This should be used to construct clients that talk to ESX. +// This method returns a new *vim25.Client and does not modify the original input. +// This client disables HTTP keep alives and is intended for a single round +// trip. (eg. guest file transfer, datastore file transfer) +func ClientWithEnvoyHostGateway(vc *vim25.Client) *vim25.Client { + // Override the vim client with a new one that wraps a Unix socket transport. + // Using HTTP here so secure means nothing. + sc := soap.NewClient(vc.URL(), true) + // Clone the underlying HTTP transport, only replacing the dialer logic. + transport := sc.DefaultTransport().Clone() + hostGatewaySocketPath := os.Getenv(vCenterHostGatewaySocketEnv) + if hostGatewaySocketPath == "" { + hostGatewaySocketPath = vCenterHostGatewaySocket + } + transport.DialContext = func(_ context.Context, _, _ string) (net.Conn, error) { + return net.Dial("unix", hostGatewaySocketPath) + } + // We use this client for a single request, so we don't require keepalives. + transport.DisableKeepAlives = true + sc.Client = http.Client{ + Transport: transport, + } + newVC := &vim25.Client{ + Client: sc, + } + return newVC +} + +// HostGatewayTransferURL rewrites the provided URL to be suitable for use +// with the Envoy host gateway on vCenter. +// It returns a copy of the provided URL with the host, scheme rewritten as needed. +// Receivers of such URLs must typically also use ClientWithEnvoyHostGateway to +// use the appropriate http.Transport to be able to make use of the host +// gateway. +// nil input yields an uninitialized struct. +func HostGatewayTransferURL(u *url.URL, hostMoref types.ManagedObjectReference) *url.URL { + if u == nil { + return &url.URL{} + } + // Make a copy of the provided URL. + turl := *u + turl.Host = "localhost" + turl.Scheme = "http" + oldPath := turl.Path + turl.Path = fmt.Sprintf("/hgw/%s%s", hostMoref.Value, oldPath) + return &turl +} diff --git a/vendor/github.com/vmware/govmomi/internal/version/version.go b/vendor/github.com/vmware/govmomi/internal/version/version.go index 0ab896cf29..15e56e4de1 100644 --- a/vendor/github.com/vmware/govmomi/internal/version/version.go +++ b/vendor/github.com/vmware/govmomi/internal/version/version.go @@ -21,5 +21,5 @@ const ( ClientName = "govmomi" // ClientVersion is the version of this SDK - ClientVersion = "0.30.7" + ClientVersion = "0.31.0" ) diff --git a/vendor/github.com/vmware/govmomi/nfc/lease.go b/vendor/github.com/vmware/govmomi/nfc/lease.go index 4575680336..eb3ef9fcaf 100644 --- a/vendor/github.com/vmware/govmomi/nfc/lease.go +++ b/vendor/github.com/vmware/govmomi/nfc/lease.go @@ -71,17 +71,17 @@ func (l *Lease) Complete(ctx context.Context) error { } // GetManifest wraps methods.GetManifest -func (l *Lease) GetManifest(ctx context.Context) error { +func (l *Lease) GetManifest(ctx context.Context) ([]types.HttpNfcLeaseManifestEntry, error) { req := types.HttpNfcLeaseGetManifest{ This: l.Reference(), } - _, err := methods.HttpNfcLeaseGetManifest(ctx, l.c, &req) + res, err := methods.HttpNfcLeaseGetManifest(ctx, l.c, &req) if err != nil { - return err + return nil, err } - return nil + return res.Returnval, nil } // Progress wraps methods.Progress diff --git a/vendor/github.com/vmware/govmomi/object/datastore.go b/vendor/github.com/vmware/govmomi/object/datastore.go index 65264ae152..77d51262a9 100644 --- a/vendor/github.com/vmware/govmomi/object/datastore.go +++ b/vendor/github.com/vmware/govmomi/object/datastore.go @@ -27,6 +27,7 @@ import ( "path" "strings" + "github.com/vmware/govmomi/internal" "github.com/vmware/govmomi/property" "github.com/vmware/govmomi/session" "github.com/vmware/govmomi/vim25" @@ -83,8 +84,14 @@ func (d Datastore) Path(path string) string { func (d Datastore) NewURL(path string) *url.URL { u := d.c.URL() + scheme := u.Scheme + // In rare cases where vCenter and ESX are accessed using different schemes. + if overrideScheme := os.Getenv("GOVMOMI_DATASTORE_ACCESS_SCHEME"); overrideScheme != "" { + scheme = overrideScheme + } + return &url.URL{ - Scheme: u.Scheme, + Scheme: scheme, Host: u.Host, Path: fmt.Sprintf("/folder/%s", path), RawQuery: url.Values{ @@ -223,8 +230,18 @@ func (d Datastore) ServiceTicket(ctx context.Context, path string, method string delete(q, "dcPath") u.RawQuery = q.Encode() + // Now that we have a host selected, take a copy of the URL. + transferURL := *u + + if internal.UsingEnvoySidecar(d.Client()) { + // Rewrite the host URL to go through the Envoy sidecar on VC. + // Reciever must use a custom dialer. + u = internal.HostGatewayTransferURL(u, host.Reference()) + } + spec := types.SessionManagerHttpServiceRequestSpec{ - Url: u.String(), + // Use the original URL (without rewrites) for the session ticket. + Url: transferURL.String(), // See SessionManagerHttpServiceRequestSpecMethod enum Method: fmt.Sprintf("http%s%s", method[0:1], strings.ToLower(method[1:])), } @@ -297,7 +314,13 @@ func (d Datastore) UploadFile(ctx context.Context, file string, path string, par if err != nil { return err } - return d.Client().UploadFile(ctx, file, u, p) + vc := d.Client() + if internal.UsingEnvoySidecar(vc) { + // Override the vim client with a new one that wraps a Unix socket transport. + // Using HTTP here so secure means nothing. + vc = internal.ClientWithEnvoyHostGateway(vc) + } + return vc.UploadFile(ctx, file, u, p) } // Download via soap.Download with an http service ticket @@ -315,7 +338,13 @@ func (d Datastore) DownloadFile(ctx context.Context, path string, file string, p if err != nil { return err } - return d.Client().DownloadFile(ctx, file, u, p) + vc := d.Client() + if internal.UsingEnvoySidecar(vc) { + // Override the vim client with a new one that wraps a Unix socket transport. + // Using HTTP here so secure means nothing. + vc = internal.ClientWithEnvoyHostGateway(vc) + } + return vc.DownloadFile(ctx, file, u, p) } // AttachedHosts returns hosts that have this Datastore attached, accessible and writable. diff --git a/vendor/github.com/vmware/govmomi/object/virtual_device_list.go b/vendor/github.com/vmware/govmomi/object/virtual_device_list.go index 3765506532..92797dcdab 100644 --- a/vendor/github.com/vmware/govmomi/object/virtual_device_list.go +++ b/vendor/github.com/vmware/govmomi/object/virtual_device_list.go @@ -404,9 +404,13 @@ func (l VirtualDeviceList) PickController(kind types.BaseVirtualController) type } // newUnitNumber returns the unit number to use for attaching a new device to the given controller. -func (l VirtualDeviceList) newUnitNumber(c types.BaseVirtualController) int32 { +func (l VirtualDeviceList) newUnitNumber(c types.BaseVirtualController, offset int) int32 { units := make([]bool, 30) + for i := 0; i < offset; i++ { + units[i] = true + } + switch sc := c.(type) { case types.BaseVirtualSCSIController: // The SCSI controller sits on its own bus @@ -455,7 +459,14 @@ func (l VirtualDeviceList) AssignController(device types.BaseVirtualDevice, c ty d := device.GetVirtualDevice() d.ControllerKey = c.GetVirtualController().Key d.UnitNumber = new(int32) - *d.UnitNumber = l.newUnitNumber(c) + + offset := 0 + switch device.(type) { + case types.BaseVirtualEthernetCard: + offset = 7 + } + *d.UnitNumber = l.newUnitNumber(c, offset) + if d.Key == 0 { d.Key = l.newRandomKey() } diff --git a/vendor/github.com/vmware/govmomi/object/virtual_machine.go b/vendor/github.com/vmware/govmomi/object/virtual_machine.go index eeffc19fd3..e6a4c5f64d 100644 --- a/vendor/github.com/vmware/govmomi/object/virtual_machine.go +++ b/vendor/github.com/vmware/govmomi/object/virtual_machine.go @@ -1,11 +1,11 @@ /* -Copyright (c) 2015-2021 VMware, Inc. All Rights Reserved. +Copyright (c) 2015-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -172,6 +172,15 @@ func (v VirtualMachine) ShutdownGuest(ctx context.Context) error { return err } +func (v VirtualMachine) StandbyGuest(ctx context.Context) error { + req := types.StandbyGuest{ + This: v.Reference(), + } + + _, err := methods.StandbyGuest(ctx, v.c, &req) + return err +} + func (v VirtualMachine) RebootGuest(ctx context.Context) error { req := types.RebootGuest{ This: v.Reference(), diff --git a/vendor/github.com/vmware/govmomi/pbm/methods/methods.go b/vendor/github.com/vmware/govmomi/pbm/methods/methods.go index fa7f2b200f..032c15c54c 100644 --- a/vendor/github.com/vmware/govmomi/pbm/methods/methods.go +++ b/vendor/github.com/vmware/govmomi/pbm/methods/methods.go @@ -1,5 +1,5 @@ /* -Copyright (c) 2014-2022 VMware, Inc. All Rights Reserved. +Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/vendor/github.com/vmware/govmomi/pbm/types/enum.go b/vendor/github.com/vmware/govmomi/pbm/types/enum.go index 66751bb1f4..be05cfd2a0 100644 --- a/vendor/github.com/vmware/govmomi/pbm/types/enum.go +++ b/vendor/github.com/vmware/govmomi/pbm/types/enum.go @@ -1,5 +1,5 @@ /* -Copyright (c) 2014-2022 VMware, Inc. All Rights Reserved. +Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -25,8 +25,11 @@ import ( type PbmAssociateAndApplyPolicyStatusPolicyStatus string const ( + // Policy applied successfully. PbmAssociateAndApplyPolicyStatusPolicyStatusSuccess = PbmAssociateAndApplyPolicyStatusPolicyStatus("success") - PbmAssociateAndApplyPolicyStatusPolicyStatusFailed = PbmAssociateAndApplyPolicyStatusPolicyStatus("failed") + // Policy cannot be applied + PbmAssociateAndApplyPolicyStatusPolicyStatusFailed = PbmAssociateAndApplyPolicyStatusPolicyStatus("failed") + // Policy cannot be applied PbmAssociateAndApplyPolicyStatusPolicyStatusInvalid = PbmAssociateAndApplyPolicyStatusPolicyStatus("invalid") ) @@ -34,28 +37,90 @@ func init() { types.Add("pbm:PbmAssociateAndApplyPolicyStatusPolicyStatus", reflect.TypeOf((*PbmAssociateAndApplyPolicyStatusPolicyStatus)(nil)).Elem()) } +// The `PbmBuiltinGenericType_enum` enumerated type defines the list +// of builtin generic datatypes. +// +// See +// `PbmCapabilityGenericTypeInfo*.*PbmCapabilityGenericTypeInfo.genericTypeName`. +// +// A generic datatype indicates how to interpret a collection of values +// of a specific datatype (`PbmCapabilityTypeInfo.typeName`). type PbmBuiltinGenericType string const ( + // Indicates a full or partial range of values (`PbmCapabilityRange`). + // + // A full range specifies both min and max values. + // A partial range specifies one or the other, min or max. PbmBuiltinGenericTypeVMW_RANGE = PbmBuiltinGenericType("VMW_RANGE") - PbmBuiltinGenericTypeVMW_SET = PbmBuiltinGenericType("VMW_SET") + // Indicates a single value or a discrete set of values + // (`PbmCapabilityDiscreteSet`). + PbmBuiltinGenericTypeVMW_SET = PbmBuiltinGenericType("VMW_SET") ) func init() { types.Add("pbm:PbmBuiltinGenericType", reflect.TypeOf((*PbmBuiltinGenericType)(nil)).Elem()) } +// The `PbmBuiltinType_enum` enumerated type defines datatypes +// for storage profiles. +// +// Property metadata +// (`PbmCapabilityPropertyMetadata`) uses the builtin types +// to define data types for storage capabilities and requirements. +// It may also specify the semantics that are applied to a collection +// of builtin type values. See `PbmCapabilityTypeInfo`. +// These semantics are specified as a generic builtin type. +// See `PbmCapabilityGenericTypeInfo`. +// The type information determines how capability constraints are interpreted +// `PbmCapabilityPropertyInstance.value`). type PbmBuiltinType string const ( - PbmBuiltinTypeXSD_LONG = PbmBuiltinType("XSD_LONG") - PbmBuiltinTypeXSD_SHORT = PbmBuiltinType("XSD_SHORT") - PbmBuiltinTypeXSD_INTEGER = PbmBuiltinType("XSD_INTEGER") - PbmBuiltinTypeXSD_INT = PbmBuiltinType("XSD_INT") - PbmBuiltinTypeXSD_STRING = PbmBuiltinType("XSD_STRING") - PbmBuiltinTypeXSD_BOOLEAN = PbmBuiltinType("XSD_BOOLEAN") - PbmBuiltinTypeXSD_DOUBLE = PbmBuiltinType("XSD_DOUBLE") + // Unsigned long value. + // + // This datatype supports the following constraint values. + // - Single value + // - Full or partial range of values (`PbmCapabilityRange`) + // - Discrete set of values (`PbmCapabilityDiscreteSet`) + PbmBuiltinTypeXSD_LONG = PbmBuiltinType("XSD_LONG") + // Datatype not supported. + PbmBuiltinTypeXSD_SHORT = PbmBuiltinType("XSD_SHORT") + // Datatype not supported. + // + // Use XSD\_INT instead. + PbmBuiltinTypeXSD_INTEGER = PbmBuiltinType("XSD_INTEGER") + // Integer value. + // + // This datatype supports the following constraint values. + // - Single value + // - Full or partial range of values (`PbmCapabilityRange`) + // - Discrete set of values (`PbmCapabilityDiscreteSet`) + PbmBuiltinTypeXSD_INT = PbmBuiltinType("XSD_INT") + // String value. + // + // This datatype supports a single value + // or a discrete set of values (`PbmCapabilityDiscreteSet`). + PbmBuiltinTypeXSD_STRING = PbmBuiltinType("XSD_STRING") + // Boolean value. + PbmBuiltinTypeXSD_BOOLEAN = PbmBuiltinType("XSD_BOOLEAN") + // Double precision floating point value. + // + // This datatype supports the following + // constraint values. + // - Single value + // - Full or partial range of values (`PbmCapabilityRange`) + // - Discrete set of values (`PbmCapabilityDiscreteSet`) + PbmBuiltinTypeXSD_DOUBLE = PbmBuiltinType("XSD_DOUBLE") + // Date and time value. PbmBuiltinTypeXSD_DATETIME = PbmBuiltinType("XSD_DATETIME") + // Timespan value (`PbmCapabilityTimeSpan`). + // + // This datatype supports + // the following constraint values. + // - Single value + // - Full or partial range of values (`PbmCapabilityRange`) + // - Discrete set of values (`PbmCapabilityDiscreteSet`) PbmBuiltinTypeVMW_TIMESPAN = PbmBuiltinType("VMW_TIMESPAN") PbmBuiltinTypeVMW_POLICY = PbmBuiltinType("VMW_POLICY") ) @@ -64,6 +129,10 @@ func init() { types.Add("pbm:PbmBuiltinType", reflect.TypeOf((*PbmBuiltinType)(nil)).Elem()) } +// List of operators that are supported for constructing policy. +// +// Currently only tag based properties can use this operator. +// Other operators can be added as required. type PbmCapabilityOperator string const ( @@ -74,52 +143,96 @@ func init() { types.Add("pbm:PbmCapabilityOperator", reflect.TypeOf((*PbmCapabilityOperator)(nil)).Elem()) } +// The `PbmCapabilityTimeUnitType_enum` enumeration type +// defines the supported list of time units for profiles that specify +// time span capabilities and constraints. +// +// See `PbmCapabilityTimeSpan`. type PbmCapabilityTimeUnitType string const ( + // Constraints and capabilities expressed in units of seconds. PbmCapabilityTimeUnitTypeSECONDS = PbmCapabilityTimeUnitType("SECONDS") + // Constraints and capabilities expressed in units of minutes. PbmCapabilityTimeUnitTypeMINUTES = PbmCapabilityTimeUnitType("MINUTES") - PbmCapabilityTimeUnitTypeHOURS = PbmCapabilityTimeUnitType("HOURS") - PbmCapabilityTimeUnitTypeDAYS = PbmCapabilityTimeUnitType("DAYS") - PbmCapabilityTimeUnitTypeWEEKS = PbmCapabilityTimeUnitType("WEEKS") - PbmCapabilityTimeUnitTypeMONTHS = PbmCapabilityTimeUnitType("MONTHS") - PbmCapabilityTimeUnitTypeYEARS = PbmCapabilityTimeUnitType("YEARS") + // Constraints and capabilities expressed in units of hours. + PbmCapabilityTimeUnitTypeHOURS = PbmCapabilityTimeUnitType("HOURS") + // Constraints and capabilities expressed in units of days. + PbmCapabilityTimeUnitTypeDAYS = PbmCapabilityTimeUnitType("DAYS") + // Constraints and capabilities expressed in units of weeks. + PbmCapabilityTimeUnitTypeWEEKS = PbmCapabilityTimeUnitType("WEEKS") + // Constraints and capabilities expressed in units of months. + PbmCapabilityTimeUnitTypeMONTHS = PbmCapabilityTimeUnitType("MONTHS") + // Constraints and capabilities expressed in units of years. + PbmCapabilityTimeUnitTypeYEARS = PbmCapabilityTimeUnitType("YEARS") ) func init() { types.Add("pbm:PbmCapabilityTimeUnitType", reflect.TypeOf((*PbmCapabilityTimeUnitType)(nil)).Elem()) } +// The `PbmComplianceResultComplianceTaskStatus_enum` +// enumeration type defines the set of task status for compliance +// operations. +// +// See `PbmComplianceResult` and +// `PbmRollupComplianceResult`. type PbmComplianceResultComplianceTaskStatus string const ( + // Compliance calculation is in progress. PbmComplianceResultComplianceTaskStatusInProgress = PbmComplianceResultComplianceTaskStatus("inProgress") - PbmComplianceResultComplianceTaskStatusSuccess = PbmComplianceResultComplianceTaskStatus("success") - PbmComplianceResultComplianceTaskStatusFailed = PbmComplianceResultComplianceTaskStatus("failed") + // Compliance calculation has succeeded. + PbmComplianceResultComplianceTaskStatusSuccess = PbmComplianceResultComplianceTaskStatus("success") + // Compliance calculation failed due to some exception. + PbmComplianceResultComplianceTaskStatusFailed = PbmComplianceResultComplianceTaskStatus("failed") ) func init() { types.Add("pbm:PbmComplianceResultComplianceTaskStatus", reflect.TypeOf((*PbmComplianceResultComplianceTaskStatus)(nil)).Elem()) } +// The `PbmComplianceStatus_enum` +// enumeration type defines the set of status values +// for compliance operations. +// +// See `PbmComplianceResult` and +// `PbmRollupComplianceResult`. type PbmComplianceStatus string const ( - PbmComplianceStatusCompliant = PbmComplianceStatus("compliant") - PbmComplianceStatusNonCompliant = PbmComplianceStatus("nonCompliant") - PbmComplianceStatusUnknown = PbmComplianceStatus("unknown") + // Entity is in compliance. + PbmComplianceStatusCompliant = PbmComplianceStatus("compliant") + // Entity is out of compliance. + PbmComplianceStatusNonCompliant = PbmComplianceStatus("nonCompliant") + // Compliance status of the entity is not known. + PbmComplianceStatusUnknown = PbmComplianceStatus("unknown") + // Compliance computation is not applicable for this entity, + // because it does not have any storage requirements that + // apply to the object-based datastore on which this entity is placed. PbmComplianceStatusNotApplicable = PbmComplianceStatus("notApplicable") - PbmComplianceStatusOutOfDate = PbmComplianceStatus("outOfDate") + // This is the same as `PbmComplianceResult.mismatch` + // variable. + // + // Compliance status becomes out-of-date when the profile + // associated with the entity is edited and not applied. The compliance + // status will remain in out-of-date compliance status until the latest + // policy is applied to the entity. + PbmComplianceStatusOutOfDate = PbmComplianceStatus("outOfDate") ) func init() { types.Add("pbm:PbmComplianceStatus", reflect.TypeOf((*PbmComplianceStatus)(nil)).Elem()) } +// This enum corresponds to the keystores used by +// sps. type PbmDebugManagerKeystoreName string const ( - PbmDebugManagerKeystoreNameSMS = PbmDebugManagerKeystoreName("SMS") + // Refers to SMS keystore + PbmDebugManagerKeystoreNameSMS = PbmDebugManagerKeystoreName("SMS") + // Refers to TRUSTED\_ROOTS keystore. PbmDebugManagerKeystoreNameTRUSTED_ROOTS = PbmDebugManagerKeystoreName("TRUSTED_ROOTS") ) @@ -127,12 +240,30 @@ func init() { types.Add("pbm:PbmDebugManagerKeystoreName", reflect.TypeOf((*PbmDebugManagerKeystoreName)(nil)).Elem()) } +// The enumeration type defines the set of health status values for an entity +// that is part of entity health operation. type PbmHealthStatusForEntity string const ( - PbmHealthStatusForEntityRed = PbmHealthStatusForEntity("red") - PbmHealthStatusForEntityYellow = PbmHealthStatusForEntity("yellow") - PbmHealthStatusForEntityGreen = PbmHealthStatusForEntity("green") + // For file share: 'red' if the file server for this file share is in error + // state or any of its backing vSAN objects are degraded. + // + // For FCD: 'red' if the datastore on which the FCD resides is not + // accessible from any of the hosts it is mounted. + PbmHealthStatusForEntityRed = PbmHealthStatusForEntity("red") + // For file share: 'yellow' if some backing objects are repairing, i.e. + // + // warning state. + // For FCD: 'yellow' if the datastore on which the entity resides is + // accessible only from some of the hosts it is mounted but not all. + PbmHealthStatusForEntityYellow = PbmHealthStatusForEntity("yellow") + // For file share: 'green' if the file server for this file share is + // running properly and all its backing vSAN objects are healthy. + // + // For FCD: 'green' if the datastore on which the entity resides + // is accessible from all the hosts it is mounted. + PbmHealthStatusForEntityGreen = PbmHealthStatusForEntity("green") + // If the health status of a file share is unknown, not valid for FCD. PbmHealthStatusForEntityUnknown = PbmHealthStatusForEntity("unknown") ) @@ -140,6 +271,11 @@ func init() { types.Add("pbm:PbmHealthStatusForEntity", reflect.TypeOf((*PbmHealthStatusForEntity)(nil)).Elem()) } +// Recognized types of an IO Filter. +// +// String constant used in `IofilterInfo#filterType`. +// These should match(upper case) the IO Filter classes as defined by IO Filter framework. +// See https://opengrok.eng.vmware.com/source/xref/vmcore-main.perforce.1666/bora/scons/apps/esx/iofilterApps.sc#33 type PbmIofilterInfoFilterType string const ( @@ -156,6 +292,7 @@ func init() { types.Add("pbm:PbmIofilterInfoFilterType", reflect.TypeOf((*PbmIofilterInfoFilterType)(nil)).Elem()) } +// Denotes the line of service of a schema. type PbmLineOfServiceInfoLineOfServiceEnum string const ( @@ -174,28 +311,43 @@ func init() { types.Add("pbm:PbmLineOfServiceInfoLineOfServiceEnum", reflect.TypeOf((*PbmLineOfServiceInfoLineOfServiceEnum)(nil)).Elem()) } +// This enum corresponds to the different packages whose logging +// is configured independently by sps service. type PbmLoggingConfigurationComponent string const ( - PbmLoggingConfigurationComponentPbm = PbmLoggingConfigurationComponent("pbm") - PbmLoggingConfigurationComponentVslm = PbmLoggingConfigurationComponent("vslm") - PbmLoggingConfigurationComponentSms = PbmLoggingConfigurationComponent("sms") - PbmLoggingConfigurationComponentSpbm = PbmLoggingConfigurationComponent("spbm") - PbmLoggingConfigurationComponentSps = PbmLoggingConfigurationComponent("sps") - PbmLoggingConfigurationComponentHttpclient_header = PbmLoggingConfigurationComponent("httpclient_header") + // Modifies logging level of com.vmware.pbm package. + PbmLoggingConfigurationComponentPbm = PbmLoggingConfigurationComponent("pbm") + // Modifies logging level of com.vmware.vslm package. + PbmLoggingConfigurationComponentVslm = PbmLoggingConfigurationComponent("vslm") + // Modifies logging level of com.vmware.vim.sms package. + PbmLoggingConfigurationComponentSms = PbmLoggingConfigurationComponent("sms") + // Modifies logging level of com.vmware.spbm package. + PbmLoggingConfigurationComponentSpbm = PbmLoggingConfigurationComponent("spbm") + // Modifies logging level of com.vmware.sps package. + PbmLoggingConfigurationComponentSps = PbmLoggingConfigurationComponent("sps") + // Modifies logging level of httpclient wire header. + PbmLoggingConfigurationComponentHttpclient_header = PbmLoggingConfigurationComponent("httpclient_header") + // Modifies logging level of httpclient wire content. PbmLoggingConfigurationComponentHttpclient_content = PbmLoggingConfigurationComponent("httpclient_content") - PbmLoggingConfigurationComponentVmomi = PbmLoggingConfigurationComponent("vmomi") + // Modifies logging level of com.vmware.vim.vmomi package. + PbmLoggingConfigurationComponentVmomi = PbmLoggingConfigurationComponent("vmomi") ) func init() { types.Add("pbm:PbmLoggingConfigurationComponent", reflect.TypeOf((*PbmLoggingConfigurationComponent)(nil)).Elem()) } +// This enum corresponds to the different log levels supported +// by sps service. type PbmLoggingConfigurationLogLevel string const ( - PbmLoggingConfigurationLogLevelINFO = PbmLoggingConfigurationLogLevel("INFO") + // Refers to INFO level logging + PbmLoggingConfigurationLogLevelINFO = PbmLoggingConfigurationLogLevel("INFO") + // Refers to DEBUG level logging. PbmLoggingConfigurationLogLevelDEBUG = PbmLoggingConfigurationLogLevel("DEBUG") + // Refers to TRACE level logging. PbmLoggingConfigurationLogLevelTRACE = PbmLoggingConfigurationLogLevel("TRACE") ) @@ -203,42 +355,76 @@ func init() { types.Add("pbm:PbmLoggingConfigurationLogLevel", reflect.TypeOf((*PbmLoggingConfigurationLogLevel)(nil)).Elem()) } +// The `PbmObjectType_enum` enumerated type +// defines vSphere Server object types that are known +// to the Storage Policy Server. +// +// See `PbmServerObjectRef*.*PbmServerObjectRef.objectType`. type PbmObjectType string const ( - PbmObjectTypeVirtualMachine = PbmObjectType("virtualMachine") + // Indicates a virtual machine, not including the disks, identified by the virtual machine + // identifier _virtual-machine-mor_. + PbmObjectTypeVirtualMachine = PbmObjectType("virtualMachine") + // Indicates the virtual machine and all its disks, identified by the virtual machine + // identifier _virtual-machine-mor_. PbmObjectTypeVirtualMachineAndDisks = PbmObjectType("virtualMachineAndDisks") - PbmObjectTypeVirtualDiskId = PbmObjectType("virtualDiskId") - PbmObjectTypeVirtualDiskUUID = PbmObjectType("virtualDiskUUID") - PbmObjectTypeDatastore = PbmObjectType("datastore") - PbmObjectTypeVsanObjectId = PbmObjectType("vsanObjectId") - PbmObjectTypeFileShareId = PbmObjectType("fileShareId") - PbmObjectTypeUnknown = PbmObjectType("unknown") + // Indicates a virtual disk, identified by disk key + // (_virtual-machine-mor_:_disk-key_). + PbmObjectTypeVirtualDiskId = PbmObjectType("virtualDiskId") + // Indicates a virtual disk, identified by UUID - for First Class Storage Object support. + PbmObjectTypeVirtualDiskUUID = PbmObjectType("virtualDiskUUID") + // Indicates a datastore. + PbmObjectTypeDatastore = PbmObjectType("datastore") + // Indicates a VSAN object + PbmObjectTypeVsanObjectId = PbmObjectType("vsanObjectId") + // Indicates a file service + PbmObjectTypeFileShareId = PbmObjectType("fileShareId") + // Unknown object type. + PbmObjectTypeUnknown = PbmObjectType("unknown") ) func init() { types.Add("pbm:PbmObjectType", reflect.TypeOf((*PbmObjectType)(nil)).Elem()) } +// The `PbmOperation_enum` enumerated type +// defines the provisioning operation being performed on the entity like FCD, virtual machine. type PbmOperation string const ( - PbmOperationCREATE = PbmOperation("CREATE") - PbmOperationREGISTER = PbmOperation("REGISTER") + // Indicates create operation of an entity. + PbmOperationCREATE = PbmOperation("CREATE") + // Indicates register operation of an entity. + PbmOperationREGISTER = PbmOperation("REGISTER") + // Indicates reconfigure operation of an entity. PbmOperationRECONFIGURE = PbmOperation("RECONFIGURE") - PbmOperationMIGRATE = PbmOperation("MIGRATE") - PbmOperationCLONE = PbmOperation("CLONE") + // Indicates migrate operation of an entity. + PbmOperationMIGRATE = PbmOperation("MIGRATE") + // Indicates clone operation of an entity. + PbmOperationCLONE = PbmOperation("CLONE") ) func init() { types.Add("pbm:PbmOperation", reflect.TypeOf((*PbmOperation)(nil)).Elem()) } +// Volume allocation type constants. type PbmPolicyAssociationVolumeAllocationType string const ( - PbmPolicyAssociationVolumeAllocationTypeFullyInitialized = PbmPolicyAssociationVolumeAllocationType("FullyInitialized") - PbmPolicyAssociationVolumeAllocationTypeReserveSpace = PbmPolicyAssociationVolumeAllocationType("ReserveSpace") + // Space required is fully allocated and initialized. + // + // It is wiped clean of any previous content on the + // physical media. Gives faster runtime IO performance. + PbmPolicyAssociationVolumeAllocationTypeFullyInitialized = PbmPolicyAssociationVolumeAllocationType("FullyInitialized") + // Space required is fully allocated. + // + // It may contain + // stale data on the physical media. + PbmPolicyAssociationVolumeAllocationTypeReserveSpace = PbmPolicyAssociationVolumeAllocationType("ReserveSpace") + // Space required is allocated and zeroed on demand + // as the space is used. PbmPolicyAssociationVolumeAllocationTypeConserveSpaceWhenPossible = PbmPolicyAssociationVolumeAllocationType("ConserveSpaceWhenPossible") ) @@ -246,11 +432,30 @@ func init() { types.Add("pbm:PbmPolicyAssociationVolumeAllocationType", reflect.TypeOf((*PbmPolicyAssociationVolumeAllocationType)(nil)).Elem()) } +// The `PbmProfileCategoryEnum_enum` +// enumerated type defines the profile categories for a capability-based +// storage profile. +// +// See +// `PbmCapabilityProfile`. type PbmProfileCategoryEnum string const ( - PbmProfileCategoryEnumREQUIREMENT = PbmProfileCategoryEnum("REQUIREMENT") - PbmProfileCategoryEnumRESOURCE = PbmProfileCategoryEnum("RESOURCE") + // Indicates a storage requirement. + // + // Requirements are based on + // storage capabilities. + PbmProfileCategoryEnumREQUIREMENT = PbmProfileCategoryEnum("REQUIREMENT") + // Indicates a storage capability. + // + // Storage capabilities + // are defined by storage providers. + PbmProfileCategoryEnumRESOURCE = PbmProfileCategoryEnum("RESOURCE") + // Indicates a data service policy that can be embedded into + // another storage policy. + // + // Policies of this type can't be assigned to + // Virtual Machines or Virtual Disks. PbmProfileCategoryEnumDATA_SERVICE_POLICY = PbmProfileCategoryEnum("DATA_SERVICE_POLICY") ) @@ -258,9 +463,14 @@ func init() { types.Add("pbm:PbmProfileCategoryEnum", reflect.TypeOf((*PbmProfileCategoryEnum)(nil)).Elem()) } +// The `PbmProfileResourceTypeEnum_enum` enumerated type defines the set of resource +// types that are supported for profile management. +// +// See `PbmProfileResourceType`. type PbmProfileResourceTypeEnum string const ( + // Indicates resources that support storage profiles. PbmProfileResourceTypeEnumSTORAGE = PbmProfileResourceTypeEnum("STORAGE") ) @@ -268,12 +478,21 @@ func init() { types.Add("pbm:PbmProfileResourceTypeEnum", reflect.TypeOf((*PbmProfileResourceTypeEnum)(nil)).Elem()) } +// System pre-created profile types. type PbmSystemCreatedProfileType string const ( - PbmSystemCreatedProfileTypeVsanDefaultProfile = PbmSystemCreatedProfileType("VsanDefaultProfile") - PbmSystemCreatedProfileTypeVVolDefaultProfile = PbmSystemCreatedProfileType("VVolDefaultProfile") - PbmSystemCreatedProfileTypePmemDefaultProfile = PbmSystemCreatedProfileType("PmemDefaultProfile") + // Indicates the system pre-created editable VSAN default profile. + PbmSystemCreatedProfileTypeVsanDefaultProfile = PbmSystemCreatedProfileType("VsanDefaultProfile") + // Indicates the system pre-created non-editable default profile + // for VVOL datastores. + PbmSystemCreatedProfileTypeVVolDefaultProfile = PbmSystemCreatedProfileType("VVolDefaultProfile") + // Indicates the system pre-created non-editable default profile + // for PMem datastores + PbmSystemCreatedProfileTypePmemDefaultProfile = PbmSystemCreatedProfileType("PmemDefaultProfile") + // Indicates the system pre-created non-editable VMC default profile. + PbmSystemCreatedProfileTypeVmcManagementProfile = PbmSystemCreatedProfileType("VmcManagementProfile") + // Indicates the system pre-created non-editable VSANMAX default profile. PbmSystemCreatedProfileTypeVsanMaxDefaultProfile = PbmSystemCreatedProfileType("VsanMaxDefaultProfile") ) @@ -281,25 +500,39 @@ func init() { types.Add("pbm:PbmSystemCreatedProfileType", reflect.TypeOf((*PbmSystemCreatedProfileType)(nil)).Elem()) } +// The `PbmVmOperation_enum` enumerated type +// defines the provisioning operation being performed on the virtual machine. type PbmVmOperation string const ( - PbmVmOperationCREATE = PbmVmOperation("CREATE") + // Indicates create operation of a virtual machine. + PbmVmOperationCREATE = PbmVmOperation("CREATE") + // Indicates reconfigure operation of a virtual machine. PbmVmOperationRECONFIGURE = PbmVmOperation("RECONFIGURE") - PbmVmOperationMIGRATE = PbmVmOperation("MIGRATE") - PbmVmOperationCLONE = PbmVmOperation("CLONE") + // Indicates migrate operation of a virtual machine. + PbmVmOperationMIGRATE = PbmVmOperation("MIGRATE") + // Indicates clone operation of a virtual machine. + PbmVmOperationCLONE = PbmVmOperation("CLONE") ) func init() { types.Add("pbm:PbmVmOperation", reflect.TypeOf((*PbmVmOperation)(nil)).Elem()) } +// The `PbmVvolType_enum` enumeration type +// defines VVOL types. +// +// VvolType's are referenced to specify which objectType +// to fetch for default capability. type PbmVvolType string const ( + // meta-data volume PbmVvolTypeConfig = PbmVvolType("Config") - PbmVvolTypeData = PbmVvolType("Data") - PbmVvolTypeSwap = PbmVvolType("Swap") + // vmdk volume + PbmVvolTypeData = PbmVvolType("Data") + // swap volume + PbmVvolTypeSwap = PbmVvolType("Swap") ) func init() { diff --git a/vendor/github.com/vmware/govmomi/pbm/types/if.go b/vendor/github.com/vmware/govmomi/pbm/types/if.go index a740a25dab..4008dffff7 100644 --- a/vendor/github.com/vmware/govmomi/pbm/types/if.go +++ b/vendor/github.com/vmware/govmomi/pbm/types/if.go @@ -1,5 +1,5 @@ /* -Copyright (c) 2014-2022 VMware, Inc. All Rights Reserved. +Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/vendor/github.com/vmware/govmomi/pbm/types/types.go b/vendor/github.com/vmware/govmomi/pbm/types/types.go index 1687df447d..4c6f72caec 100644 --- a/vendor/github.com/vmware/govmomi/pbm/types/types.go +++ b/vendor/github.com/vmware/govmomi/pbm/types/types.go @@ -1,5 +1,5 @@ /* -Copyright (c) 2014-2022 VMware, Inc. All Rights Reserved. +Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,246 +23,304 @@ import ( "github.com/vmware/govmomi/vim25/types" ) +// A boxed array of `PbmCapabilityConstraintInstance`. To be used in `Any` placeholders. type ArrayOfPbmCapabilityConstraintInstance struct { - PbmCapabilityConstraintInstance []PbmCapabilityConstraintInstance `xml:"PbmCapabilityConstraintInstance,omitempty"` + PbmCapabilityConstraintInstance []PbmCapabilityConstraintInstance `xml:"PbmCapabilityConstraintInstance,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmCapabilityConstraintInstance", reflect.TypeOf((*ArrayOfPbmCapabilityConstraintInstance)(nil)).Elem()) } +// A boxed array of `PbmCapabilityInstance`. To be used in `Any` placeholders. type ArrayOfPbmCapabilityInstance struct { - PbmCapabilityInstance []PbmCapabilityInstance `xml:"PbmCapabilityInstance,omitempty"` + PbmCapabilityInstance []PbmCapabilityInstance `xml:"PbmCapabilityInstance,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmCapabilityInstance", reflect.TypeOf((*ArrayOfPbmCapabilityInstance)(nil)).Elem()) } +// A boxed array of `PbmCapabilityMetadata`. To be used in `Any` placeholders. type ArrayOfPbmCapabilityMetadata struct { - PbmCapabilityMetadata []PbmCapabilityMetadata `xml:"PbmCapabilityMetadata,omitempty"` + PbmCapabilityMetadata []PbmCapabilityMetadata `xml:"PbmCapabilityMetadata,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmCapabilityMetadata", reflect.TypeOf((*ArrayOfPbmCapabilityMetadata)(nil)).Elem()) } +// A boxed array of `PbmCapabilityMetadataPerCategory`. To be used in `Any` placeholders. type ArrayOfPbmCapabilityMetadataPerCategory struct { - PbmCapabilityMetadataPerCategory []PbmCapabilityMetadataPerCategory `xml:"PbmCapabilityMetadataPerCategory,omitempty"` + PbmCapabilityMetadataPerCategory []PbmCapabilityMetadataPerCategory `xml:"PbmCapabilityMetadataPerCategory,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmCapabilityMetadataPerCategory", reflect.TypeOf((*ArrayOfPbmCapabilityMetadataPerCategory)(nil)).Elem()) } +// A boxed array of `PbmCapabilityPropertyInstance`. To be used in `Any` placeholders. type ArrayOfPbmCapabilityPropertyInstance struct { - PbmCapabilityPropertyInstance []PbmCapabilityPropertyInstance `xml:"PbmCapabilityPropertyInstance,omitempty"` + PbmCapabilityPropertyInstance []PbmCapabilityPropertyInstance `xml:"PbmCapabilityPropertyInstance,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmCapabilityPropertyInstance", reflect.TypeOf((*ArrayOfPbmCapabilityPropertyInstance)(nil)).Elem()) } +// A boxed array of `PbmCapabilityPropertyMetadata`. To be used in `Any` placeholders. type ArrayOfPbmCapabilityPropertyMetadata struct { - PbmCapabilityPropertyMetadata []PbmCapabilityPropertyMetadata `xml:"PbmCapabilityPropertyMetadata,omitempty"` + PbmCapabilityPropertyMetadata []PbmCapabilityPropertyMetadata `xml:"PbmCapabilityPropertyMetadata,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmCapabilityPropertyMetadata", reflect.TypeOf((*ArrayOfPbmCapabilityPropertyMetadata)(nil)).Elem()) } +// A boxed array of `PbmCapabilitySchema`. To be used in `Any` placeholders. type ArrayOfPbmCapabilitySchema struct { - PbmCapabilitySchema []PbmCapabilitySchema `xml:"PbmCapabilitySchema,omitempty"` + PbmCapabilitySchema []PbmCapabilitySchema `xml:"PbmCapabilitySchema,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmCapabilitySchema", reflect.TypeOf((*ArrayOfPbmCapabilitySchema)(nil)).Elem()) } +// A boxed array of `PbmCapabilitySubProfile`. To be used in `Any` placeholders. type ArrayOfPbmCapabilitySubProfile struct { - PbmCapabilitySubProfile []PbmCapabilitySubProfile `xml:"PbmCapabilitySubProfile,omitempty"` + PbmCapabilitySubProfile []PbmCapabilitySubProfile `xml:"PbmCapabilitySubProfile,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmCapabilitySubProfile", reflect.TypeOf((*ArrayOfPbmCapabilitySubProfile)(nil)).Elem()) } +// A boxed array of `PbmCapabilityVendorNamespaceInfo`. To be used in `Any` placeholders. type ArrayOfPbmCapabilityVendorNamespaceInfo struct { - PbmCapabilityVendorNamespaceInfo []PbmCapabilityVendorNamespaceInfo `xml:"PbmCapabilityVendorNamespaceInfo,omitempty"` + PbmCapabilityVendorNamespaceInfo []PbmCapabilityVendorNamespaceInfo `xml:"PbmCapabilityVendorNamespaceInfo,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmCapabilityVendorNamespaceInfo", reflect.TypeOf((*ArrayOfPbmCapabilityVendorNamespaceInfo)(nil)).Elem()) } +// A boxed array of `PbmCapabilityVendorResourceTypeInfo`. To be used in `Any` placeholders. type ArrayOfPbmCapabilityVendorResourceTypeInfo struct { - PbmCapabilityVendorResourceTypeInfo []PbmCapabilityVendorResourceTypeInfo `xml:"PbmCapabilityVendorResourceTypeInfo,omitempty"` + PbmCapabilityVendorResourceTypeInfo []PbmCapabilityVendorResourceTypeInfo `xml:"PbmCapabilityVendorResourceTypeInfo,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmCapabilityVendorResourceTypeInfo", reflect.TypeOf((*ArrayOfPbmCapabilityVendorResourceTypeInfo)(nil)).Elem()) } +// A boxed array of `PbmCompliancePolicyStatus`. To be used in `Any` placeholders. type ArrayOfPbmCompliancePolicyStatus struct { - PbmCompliancePolicyStatus []PbmCompliancePolicyStatus `xml:"PbmCompliancePolicyStatus,omitempty"` + PbmCompliancePolicyStatus []PbmCompliancePolicyStatus `xml:"PbmCompliancePolicyStatus,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmCompliancePolicyStatus", reflect.TypeOf((*ArrayOfPbmCompliancePolicyStatus)(nil)).Elem()) } +// A boxed array of `PbmComplianceResult`. To be used in `Any` placeholders. type ArrayOfPbmComplianceResult struct { - PbmComplianceResult []PbmComplianceResult `xml:"PbmComplianceResult,omitempty"` + PbmComplianceResult []PbmComplianceResult `xml:"PbmComplianceResult,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmComplianceResult", reflect.TypeOf((*ArrayOfPbmComplianceResult)(nil)).Elem()) } +// A boxed array of `PbmDatastoreSpaceStatistics`. To be used in `Any` placeholders. type ArrayOfPbmDatastoreSpaceStatistics struct { - PbmDatastoreSpaceStatistics []PbmDatastoreSpaceStatistics `xml:"PbmDatastoreSpaceStatistics,omitempty"` + PbmDatastoreSpaceStatistics []PbmDatastoreSpaceStatistics `xml:"PbmDatastoreSpaceStatistics,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmDatastoreSpaceStatistics", reflect.TypeOf((*ArrayOfPbmDatastoreSpaceStatistics)(nil)).Elem()) } +// A boxed array of `PbmDefaultProfileInfo`. To be used in `Any` placeholders. type ArrayOfPbmDefaultProfileInfo struct { - PbmDefaultProfileInfo []PbmDefaultProfileInfo `xml:"PbmDefaultProfileInfo,omitempty"` + PbmDefaultProfileInfo []PbmDefaultProfileInfo `xml:"PbmDefaultProfileInfo,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmDefaultProfileInfo", reflect.TypeOf((*ArrayOfPbmDefaultProfileInfo)(nil)).Elem()) } +// A boxed array of `PbmFaultNoPermissionEntityPrivileges`. To be used in `Any` placeholders. +type ArrayOfPbmFaultNoPermissionEntityPrivileges struct { + PbmFaultNoPermissionEntityPrivileges []PbmFaultNoPermissionEntityPrivileges `xml:"PbmFaultNoPermissionEntityPrivileges,omitempty" json:"_value"` +} + +func init() { + types.Add("pbm:ArrayOfPbmFaultNoPermissionEntityPrivileges", reflect.TypeOf((*ArrayOfPbmFaultNoPermissionEntityPrivileges)(nil)).Elem()) +} + +// A boxed array of `PbmLoggingConfiguration`. To be used in `Any` placeholders. +type ArrayOfPbmLoggingConfiguration struct { + PbmLoggingConfiguration []PbmLoggingConfiguration `xml:"PbmLoggingConfiguration,omitempty" json:"_value"` +} + +func init() { + types.Add("pbm:ArrayOfPbmLoggingConfiguration", reflect.TypeOf((*ArrayOfPbmLoggingConfiguration)(nil)).Elem()) +} + +// A boxed array of `PbmPlacementCompatibilityResult`. To be used in `Any` placeholders. type ArrayOfPbmPlacementCompatibilityResult struct { - PbmPlacementCompatibilityResult []PbmPlacementCompatibilityResult `xml:"PbmPlacementCompatibilityResult,omitempty"` + PbmPlacementCompatibilityResult []PbmPlacementCompatibilityResult `xml:"PbmPlacementCompatibilityResult,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmPlacementCompatibilityResult", reflect.TypeOf((*ArrayOfPbmPlacementCompatibilityResult)(nil)).Elem()) } +// A boxed array of `PbmPlacementHub`. To be used in `Any` placeholders. type ArrayOfPbmPlacementHub struct { - PbmPlacementHub []PbmPlacementHub `xml:"PbmPlacementHub,omitempty"` + PbmPlacementHub []PbmPlacementHub `xml:"PbmPlacementHub,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmPlacementHub", reflect.TypeOf((*ArrayOfPbmPlacementHub)(nil)).Elem()) } +// A boxed array of `PbmPlacementMatchingResources`. To be used in `Any` placeholders. type ArrayOfPbmPlacementMatchingResources struct { - PbmPlacementMatchingResources []BasePbmPlacementMatchingResources `xml:"PbmPlacementMatchingResources,omitempty,typeattr"` + PbmPlacementMatchingResources []BasePbmPlacementMatchingResources `xml:"PbmPlacementMatchingResources,omitempty,typeattr" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmPlacementMatchingResources", reflect.TypeOf((*ArrayOfPbmPlacementMatchingResources)(nil)).Elem()) } +// A boxed array of `PbmPlacementRequirement`. To be used in `Any` placeholders. type ArrayOfPbmPlacementRequirement struct { - PbmPlacementRequirement []BasePbmPlacementRequirement `xml:"PbmPlacementRequirement,omitempty,typeattr"` + PbmPlacementRequirement []BasePbmPlacementRequirement `xml:"PbmPlacementRequirement,omitempty,typeattr" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmPlacementRequirement", reflect.TypeOf((*ArrayOfPbmPlacementRequirement)(nil)).Elem()) } +// A boxed array of `PbmPlacementResourceUtilization`. To be used in `Any` placeholders. type ArrayOfPbmPlacementResourceUtilization struct { - PbmPlacementResourceUtilization []PbmPlacementResourceUtilization `xml:"PbmPlacementResourceUtilization,omitempty"` + PbmPlacementResourceUtilization []PbmPlacementResourceUtilization `xml:"PbmPlacementResourceUtilization,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmPlacementResourceUtilization", reflect.TypeOf((*ArrayOfPbmPlacementResourceUtilization)(nil)).Elem()) } +// A boxed array of `PbmProfile`. To be used in `Any` placeholders. type ArrayOfPbmProfile struct { - PbmProfile []BasePbmProfile `xml:"PbmProfile,omitempty,typeattr"` + PbmProfile []BasePbmProfile `xml:"PbmProfile,omitempty,typeattr" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmProfile", reflect.TypeOf((*ArrayOfPbmProfile)(nil)).Elem()) } +// A boxed array of `PbmProfileId`. To be used in `Any` placeholders. type ArrayOfPbmProfileId struct { - PbmProfileId []PbmProfileId `xml:"PbmProfileId,omitempty"` + PbmProfileId []PbmProfileId `xml:"PbmProfileId,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmProfileId", reflect.TypeOf((*ArrayOfPbmProfileId)(nil)).Elem()) } +// A boxed array of `PbmProfileOperationOutcome`. To be used in `Any` placeholders. type ArrayOfPbmProfileOperationOutcome struct { - PbmProfileOperationOutcome []PbmProfileOperationOutcome `xml:"PbmProfileOperationOutcome,omitempty"` + PbmProfileOperationOutcome []PbmProfileOperationOutcome `xml:"PbmProfileOperationOutcome,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmProfileOperationOutcome", reflect.TypeOf((*ArrayOfPbmProfileOperationOutcome)(nil)).Elem()) } +// A boxed array of `PbmProfileResourceType`. To be used in `Any` placeholders. type ArrayOfPbmProfileResourceType struct { - PbmProfileResourceType []PbmProfileResourceType `xml:"PbmProfileResourceType,omitempty"` + PbmProfileResourceType []PbmProfileResourceType `xml:"PbmProfileResourceType,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmProfileResourceType", reflect.TypeOf((*ArrayOfPbmProfileResourceType)(nil)).Elem()) } +// A boxed array of `PbmProfileType`. To be used in `Any` placeholders. type ArrayOfPbmProfileType struct { - PbmProfileType []PbmProfileType `xml:"PbmProfileType,omitempty"` + PbmProfileType []PbmProfileType `xml:"PbmProfileType,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmProfileType", reflect.TypeOf((*ArrayOfPbmProfileType)(nil)).Elem()) } +// A boxed array of `PbmQueryProfileResult`. To be used in `Any` placeholders. type ArrayOfPbmQueryProfileResult struct { - PbmQueryProfileResult []PbmQueryProfileResult `xml:"PbmQueryProfileResult,omitempty"` + PbmQueryProfileResult []PbmQueryProfileResult `xml:"PbmQueryProfileResult,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmQueryProfileResult", reflect.TypeOf((*ArrayOfPbmQueryProfileResult)(nil)).Elem()) } +// A boxed array of `PbmQueryReplicationGroupResult`. To be used in `Any` placeholders. type ArrayOfPbmQueryReplicationGroupResult struct { - PbmQueryReplicationGroupResult []PbmQueryReplicationGroupResult `xml:"PbmQueryReplicationGroupResult,omitempty"` + PbmQueryReplicationGroupResult []PbmQueryReplicationGroupResult `xml:"PbmQueryReplicationGroupResult,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmQueryReplicationGroupResult", reflect.TypeOf((*ArrayOfPbmQueryReplicationGroupResult)(nil)).Elem()) } +// A boxed array of `PbmRollupComplianceResult`. To be used in `Any` placeholders. type ArrayOfPbmRollupComplianceResult struct { - PbmRollupComplianceResult []PbmRollupComplianceResult `xml:"PbmRollupComplianceResult,omitempty"` + PbmRollupComplianceResult []PbmRollupComplianceResult `xml:"PbmRollupComplianceResult,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmRollupComplianceResult", reflect.TypeOf((*ArrayOfPbmRollupComplianceResult)(nil)).Elem()) } +// A boxed array of `PbmServerObjectRef`. To be used in `Any` placeholders. type ArrayOfPbmServerObjectRef struct { - PbmServerObjectRef []PbmServerObjectRef `xml:"PbmServerObjectRef,omitempty"` + PbmServerObjectRef []PbmServerObjectRef `xml:"PbmServerObjectRef,omitempty" json:"_value"` } func init() { types.Add("pbm:ArrayOfPbmServerObjectRef", reflect.TypeOf((*ArrayOfPbmServerObjectRef)(nil)).Elem()) } +// The `PbmAboutInfo` data object stores identifying data +// about the Storage Policy Server. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmAboutInfo struct { types.DynamicData - Name string `xml:"name"` - Version string `xml:"version"` - InstanceUuid string `xml:"instanceUuid"` + // Name of the server. + Name string `xml:"name" json:"name"` + // Version number. + Version string `xml:"version" json:"version"` + // Globally unique identifier associated with this server instance. + InstanceUuid string `xml:"instanceUuid" json:"instanceUuid"` } func init() { types.Add("pbm:PbmAboutInfo", reflect.TypeOf((*PbmAboutInfo)(nil)).Elem()) } +// An AlreadyExists fault is thrown when an attempt is made to add an element to +// a collection, if the element's key, name, or identifier already exists in +// that collection. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmAlreadyExists struct { PbmFault - Name string `xml:"name,omitempty"` + Name string `xml:"name,omitempty" json:"name,omitempty"` } func init() { @@ -281,10 +339,13 @@ func init() { types.Add("pbm:PbmAssignDefaultRequirementProfile", reflect.TypeOf((*PbmAssignDefaultRequirementProfile)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmAssignDefaultRequirementProfile`. type PbmAssignDefaultRequirementProfileRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Profile PbmProfileId `xml:"profile"` - Datastores []PbmPlacementHub `xml:"datastores"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // The profile that needs to be made default profile. + Profile PbmProfileId `xml:"profile" json:"profile"` + // The datastores for which the profile needs to be made as default profile. + Datastores []PbmPlacementHub `xml:"datastores" json:"datastores"` } func init() { @@ -294,16 +355,26 @@ func init() { type PbmAssignDefaultRequirementProfileResponse struct { } +// Constraints on the properties for a single occurrence of a capability. +// +// All properties must satisfy their respective constraints to be compliant. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityConstraintInstance struct { types.DynamicData - PropertyInstance []PbmCapabilityPropertyInstance `xml:"propertyInstance"` + // Property instance array for this constraint + PropertyInstance []PbmCapabilityPropertyInstance `xml:"propertyInstance" json:"propertyInstance"` } func init() { types.Add("pbm:PbmCapabilityConstraintInstance", reflect.TypeOf((*PbmCapabilityConstraintInstance)(nil)).Elem()) } +// The `PbmCapabilityConstraints` data object is the base +// object for capability subprofile constraints. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityConstraints struct { types.DynamicData } @@ -312,69 +383,161 @@ func init() { types.Add("pbm:PbmCapabilityConstraints", reflect.TypeOf((*PbmCapabilityConstraints)(nil)).Elem()) } +// A property value with description. +// +// It can be repeated under DiscreteSet. +// E.g., set of tags, each with description and tag name. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityDescription struct { types.DynamicData - Description PbmExtendedElementDescription `xml:"description"` - Value types.AnyType `xml:"value,typeattr"` + // Description of the property value + Description PbmExtendedElementDescription `xml:"description" json:"description"` + // Values for the set. + // + // must be one of the supported datatypes as + // defined in `PbmBuiltinType_enum` + // Must only contain unique values to comply with the Set semantics + Value types.AnyType `xml:"value,typeattr" json:"value"` } func init() { types.Add("pbm:PbmCapabilityDescription", reflect.TypeOf((*PbmCapabilityDescription)(nil)).Elem()) } +// The `PbmCapabilityDiscreteSet` data object defines a set of values +// for storage profile property instances (`PbmCapabilityPropertyInstance`). +// +// Use the discrete set type to define a set of values of a supported builtin type +// (`PbmBuiltinType_enum`), for example a set of integers +// (XSD\_INT) or a set of unsigned long values (XSD\_LONG). +// See `PbmBuiltinGenericType_enum*.*VMW_SET`. +// +// A discrete set of values is declared as an array of xsd:anyType values. +// - When you define a property instance for a storage profile requirement +// and pass an array of values to the Server, you must set the array elements +// to values of the appropriate datatype. +// - When you read a discrete set from a property instance for a storage profile +// capability, you must cast the xsd:anyType array element values +// to the appropriate datatype. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityDiscreteSet struct { types.DynamicData - Values []types.AnyType `xml:"values,typeattr"` + // Array of values for the set. + // + // The values must be one of the supported datatypes + // as defined in `PbmBuiltinType_enum` or `PbmBuiltinGenericType_enum`. + Values []types.AnyType `xml:"values,typeattr" json:"values"` } func init() { types.Add("pbm:PbmCapabilityDiscreteSet", reflect.TypeOf((*PbmCapabilityDiscreteSet)(nil)).Elem()) } +// Generic type definition for capabilities. +// +// Indicates how a collection of values of a specific datatype +// (`PbmCapabilityTypeInfo.typeName`) +// will be interpreted. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityGenericTypeInfo struct { PbmCapabilityTypeInfo - GenericTypeName string `xml:"genericTypeName"` + // Name of the generic type. + // + // Must correspond to one of the values defined in + // `PbmBuiltinGenericType_enum`. + GenericTypeName string `xml:"genericTypeName" json:"genericTypeName"` } func init() { types.Add("pbm:PbmCapabilityGenericTypeInfo", reflect.TypeOf((*PbmCapabilityGenericTypeInfo)(nil)).Elem()) } +// The `PbmCapabilityInstance` data object defines a storage capability instance. +// +// Metadata for the capability is described in `PbmCapabilityMetadata`. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityInstance struct { types.DynamicData - Id PbmCapabilityMetadataUniqueId `xml:"id"` - Constraint []PbmCapabilityConstraintInstance `xml:"constraint"` + // Identifier for the capability. + // + // The identifier value corresponds to + // `PbmCapabilityMetadata*.*PbmCapabilityMetadata.id`. + Id PbmCapabilityMetadataUniqueId `xml:"id" json:"id"` + // Constraints on the properties that comprise this capability. + // + // Each entry represents a constraint on one or more of the properties that + // constitute this capability. A datum must meet one of the + // constraints to be compliant. + Constraint []PbmCapabilityConstraintInstance `xml:"constraint" json:"constraint"` } func init() { types.Add("pbm:PbmCapabilityInstance", reflect.TypeOf((*PbmCapabilityInstance)(nil)).Elem()) } +// Metadata for a single unique setting defined by a provider. +// +// A simple setting is a setting with one property. +// A complex setting contains more than one property. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityMetadata struct { types.DynamicData - Id PbmCapabilityMetadataUniqueId `xml:"id"` - Summary PbmExtendedElementDescription `xml:"summary"` - Mandatory *bool `xml:"mandatory"` - Hint *bool `xml:"hint"` - KeyId string `xml:"keyId,omitempty"` - AllowMultipleConstraints *bool `xml:"allowMultipleConstraints"` - PropertyMetadata []PbmCapabilityPropertyMetadata `xml:"propertyMetadata"` + // Unique identifier for the capability. + Id PbmCapabilityMetadataUniqueId `xml:"id" json:"id"` + // Capability name and description + Summary PbmExtendedElementDescription `xml:"summary" json:"summary"` + // Indicates whether incorporating given capability is mandatory during creation of + // profile. + Mandatory *bool `xml:"mandatory" json:"mandatory,omitempty"` + // The flag hint dictates the interpretation of constraints specified for this capability + // in a storage policy profile. + // + // If hint is false, then constraints will affect placement. + // If hint is true, constraints will not affect placement, + // but will still be passed to provisioning operations if the provider understands the + // relevant namespace. Optional property, false if not set. + Hint *bool `xml:"hint" json:"hint,omitempty"` + // Property Id of the key property, if this capability represents a key + // value pair. + // + // Value is empty string if not set. + KeyId string `xml:"keyId,omitempty" json:"keyId,omitempty"` + // Flag to indicate if multiple constraints are allowed in the capability + // instance. + // + // False if not set. + AllowMultipleConstraints *bool `xml:"allowMultipleConstraints" json:"allowMultipleConstraints,omitempty"` + // Metadata for the properties that comprise this capability. + PropertyMetadata []PbmCapabilityPropertyMetadata `xml:"propertyMetadata" json:"propertyMetadata"` } func init() { types.Add("pbm:PbmCapabilityMetadata", reflect.TypeOf((*PbmCapabilityMetadata)(nil)).Elem()) } +// The `PbmCapabilityMetadataPerCategory` +// data object defines capability metadata for a profile subcategory. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityMetadataPerCategory struct { types.DynamicData - SubCategory string `xml:"subCategory"` - CapabilityMetadata []PbmCapabilityMetadata `xml:"capabilityMetadata"` + // Profile subcategory to which the capability metadata belongs. + // + // The subcategory is specified by the storage provider. + SubCategory string `xml:"subCategory" json:"subCategory"` + // Capability metadata for this category + CapabilityMetadata []PbmCapabilityMetadata `xml:"capabilityMetadata" json:"capabilityMetadata"` } func init() { @@ -384,60 +547,162 @@ func init() { type PbmCapabilityMetadataUniqueId struct { types.DynamicData - Namespace string `xml:"namespace"` - Id string `xml:"id"` + // Namespace to which this capability belongs. + // + // Must be the same as + // { @link CapabilityObjectSchema#namespace } defined for this + // capability + Namespace string `xml:"namespace" json:"namespace"` + // unique identifier for this capability within given namespace + Id string `xml:"id" json:"id"` } func init() { types.Add("pbm:PbmCapabilityMetadataUniqueId", reflect.TypeOf((*PbmCapabilityMetadataUniqueId)(nil)).Elem()) } +// Name space information for the capability metadata schema. +// +// NOTE: Name spaces are required to be globally unique across resource types. +// A same vendor can register multiple name spaces for same resource type or +// for different resource type, but the schema namespace URL must be unique +// for each of these cases. +// A CapabilityMetadata object is uniquely identified based on the namespace +// it belongs to and it's unique identifier within that namespace. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityNamespaceInfo struct { types.DynamicData - Version string `xml:"version"` - Namespace string `xml:"namespace"` - Info *PbmExtendedElementDescription `xml:"info,omitempty"` + // Schema version + Version string `xml:"version" json:"version"` + // Schema namespace. + Namespace string `xml:"namespace" json:"namespace"` + Info *PbmExtendedElementDescription `xml:"info,omitempty" json:"info,omitempty"` } func init() { types.Add("pbm:PbmCapabilityNamespaceInfo", reflect.TypeOf((*PbmCapabilityNamespaceInfo)(nil)).Elem()) } +// The `PbmCapabilityProfile` data object defines +// capability-based profiles. +// +// A capability-based profile is derived +// from tag-based storage capabilities or from vSAN storage capabilities. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityProfile struct { PbmProfile - ProfileCategory string `xml:"profileCategory"` - ResourceType PbmProfileResourceType `xml:"resourceType"` - Constraints BasePbmCapabilityConstraints `xml:"constraints,typeattr"` - GenerationId int64 `xml:"generationId,omitempty"` - IsDefault bool `xml:"isDefault"` - SystemCreatedProfileType string `xml:"systemCreatedProfileType,omitempty"` - LineOfService string `xml:"lineOfService,omitempty"` + // Indicates whether the profile is requirement + // profile, a resource profile or a data service profile. + // + // The profileCategory + // is a string value that corresponds to one of the + // `PbmProfileCategoryEnum_enum` values. + // - REQUIREMENT profile - Defines the storage constraints applied + // to virtual machine placement. Requirements are defined by + // the user and can be associated with virtual machines and virtual + // disks. During provisioning, you can use a requirements profile + // for compliance and placement checking to support + // selection and configuration of resources. + // - RESOURCE profile - Specifies system-defined storage capabilities. + // You cannot modify a resource profile. You cannot associate a resource + // profile with vSphere entities, use it during provisioning, or target + // entities for resource selection or configuration. + // This type of profile gives the user visibility into the capabilities + // supported by the storage provider. + // + // DATA\_SERVICE\_POLICY - Indicates a data service policy that can + // be embedded into another storage policy. Policies of this type can't + // be assigned to Virtual Machines or Virtual Disks. This policy cannot + // be used for compliance checking. + ProfileCategory string `xml:"profileCategory" json:"profileCategory"` + // Type of the target resource to which the capability information applies. + // + // A fixed enum that defines resource types for which capabilities can be defined + // see `PbmProfileResourceType`, `PbmProfileResourceTypeEnum_enum` + ResourceType PbmProfileResourceType `xml:"resourceType" json:"resourceType"` + // Subprofiles that describe storage requirements or storage provider capabilities, + // depending on the profile category (REQUIREMENT or RESOURCE). + Constraints BasePbmCapabilityConstraints `xml:"constraints,typeattr" json:"constraints"` + // Generation ID is used to communicate the current version of the profile to VASA + // providers. + // + // It is only applicable to REQUIREMENT profile types. Every time a + // requirement profile is edited, the Server will increment the generationId. You + // do not need to set the generationID. When an object is created (or + // reconfigured), the Server will send the requirement profile content, profile ID and + // the generationID to VASA provider. + GenerationId int64 `xml:"generationId,omitempty" json:"generationId,omitempty"` + // Deprecated since it is not supported. + // + // Not supported in this release. + IsDefault bool `xml:"isDefault" json:"isDefault"` + // Indicates the type of system pre-created default profile. + // + // This will be set only for system pre-created default profiles. And + // this is not set for RESOURCE profiles. + SystemCreatedProfileType string `xml:"systemCreatedProfileType,omitempty" json:"systemCreatedProfileType,omitempty"` + // This property is set only for data service policy. + // + // Indicates the line of service + // `PbmLineOfServiceInfoLineOfServiceEnum_enum` of the data service policy. + LineOfService string `xml:"lineOfService,omitempty" json:"lineOfService,omitempty"` } func init() { types.Add("pbm:PbmCapabilityProfile", reflect.TypeOf((*PbmCapabilityProfile)(nil)).Elem()) } +// The `PbmCapabilityProfileCreateSpec` describes storage requirements. +// +// Use this data object to create a `PbmCapabilityProfile`. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityProfileCreateSpec struct { types.DynamicData - Name string `xml:"name"` - Description string `xml:"description,omitempty"` - Category string `xml:"category,omitempty"` - ResourceType PbmProfileResourceType `xml:"resourceType"` - Constraints BasePbmCapabilityConstraints `xml:"constraints,typeattr"` + // Name of the capability based profile to be created. + // + // The maximum length of the name is 80 characters. + Name string `xml:"name" json:"name"` + // Text description associated with the profile. + Description string `xml:"description,omitempty" json:"description,omitempty"` + // Category specifies the type of policy to be created. + // + // This can be REQUIREMENT from + // `PbmProfileCategoryEnum_enum` + // or null when creating a storage policy. And it can be DATA\_SERVICE\_POLICY from + // `PbmProfileCategoryEnum_enum` + // when creating a data service policy. RESOURCE from `PbmProfileCategoryEnum_enum` + // is not allowed as resource profile is created by the system. + Category string `xml:"category,omitempty" json:"category,omitempty"` + // Deprecated as of vSphere API 6.5. + // + // Specifies the type of resource to which the profile applies. + // + // The only legal value is STORAGE - deprecated. + ResourceType PbmProfileResourceType `xml:"resourceType" json:"resourceType"` + // Set of subprofiles that define the storage requirements. + // + // A subprofile corresponds to a rule set in the vSphere Web Client. + Constraints BasePbmCapabilityConstraints `xml:"constraints,typeattr" json:"constraints"` } func init() { types.Add("pbm:PbmCapabilityProfileCreateSpec", reflect.TypeOf((*PbmCapabilityProfileCreateSpec)(nil)).Elem()) } +// Fault used when a datastore doesnt match the capability profile property instance in requirements profile. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityProfilePropertyMismatchFault struct { PbmPropertyMismatchFault - ResourcePropertyInstance PbmCapabilityPropertyInstance `xml:"resourcePropertyInstance"` + // The property instance in the resource profile that does not match. + ResourcePropertyInstance PbmCapabilityPropertyInstance `xml:"resourcePropertyInstance" json:"resourcePropertyInstance"` } func init() { @@ -450,118 +715,347 @@ func init() { types.Add("pbm:PbmCapabilityProfilePropertyMismatchFaultFault", reflect.TypeOf((*PbmCapabilityProfilePropertyMismatchFaultFault)(nil)).Elem()) } +// The `PbmCapabilityProfileUpdateSpec` data object +// contains data that you use to update a storage profile. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityProfileUpdateSpec struct { types.DynamicData - Name string `xml:"name,omitempty"` - Description string `xml:"description,omitempty"` - Constraints BasePbmCapabilityConstraints `xml:"constraints,omitempty,typeattr"` + // Specifies a new profile name. + Name string `xml:"name,omitempty" json:"name,omitempty"` + // Specifies a new profile description. + Description string `xml:"description,omitempty" json:"description,omitempty"` + // Specifies one or more subprofiles. + // + // A subprofile defines one or more + // storage requirements. + Constraints BasePbmCapabilityConstraints `xml:"constraints,omitempty,typeattr" json:"constraints,omitempty"` } func init() { types.Add("pbm:PbmCapabilityProfileUpdateSpec", reflect.TypeOf((*PbmCapabilityProfileUpdateSpec)(nil)).Elem()) } +// The `PbmCapabilityPropertyInstance` data object describes a virtual machine +// storage requirement. +// +// A storage requirement is based on the storage capability +// described in the `PbmCapabilityPropertyMetadata` and in the +// datastore profile property instance. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityPropertyInstance struct { types.DynamicData - Id string `xml:"id"` - Operator string `xml:"operator,omitempty"` - Value types.AnyType `xml:"value,typeattr"` + // Requirement property identifier. + // + // This identifier corresponds to the + // storage capability metadata identifier + // (`PbmCapabilityPropertyMetadata*.*PbmCapabilityPropertyMetadata.id`). + Id string `xml:"id" json:"id"` + // Operator for the values. + // + // Currently only support NOT operator for + // tag namespace + // See operator definition in (`PbmCapabilityOperator_enum`). + Operator string `xml:"operator,omitempty" json:"operator,omitempty"` + // Property value. + // + // You must specify the value. + // A property value is one value or a collection of values. + // - A single property value is expressed as a scalar value. + // - A collection of values is expressed as a `PbmCapabilityDiscreteSet` + // or a `PbmCapabilityRange` of values. + // + // The datatype of each value must be one of the + // `PbmBuiltinType_enum` datatypes. + // If the property consists of a collection of values, + // the interpretation of those values is determined by the + // `PbmCapabilityGenericTypeInfo`. + // + // Type information for a property instance is described in the property metadata + // (`PbmCapabilityPropertyMetadata*.*PbmCapabilityPropertyMetadata.type`). + Value types.AnyType `xml:"value,typeattr" json:"value"` } func init() { types.Add("pbm:PbmCapabilityPropertyInstance", reflect.TypeOf((*PbmCapabilityPropertyInstance)(nil)).Elem()) } +// The `PbmCapabilityPropertyMetadata` data object describes storage capability. +// +// An instance of property metadata may apply to many property instances +// (`PbmCapabilityPropertyInstance`). +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityPropertyMetadata struct { types.DynamicData - Id string `xml:"id"` - Summary PbmExtendedElementDescription `xml:"summary"` - Mandatory bool `xml:"mandatory"` - Type BasePbmCapabilityTypeInfo `xml:"type,omitempty,typeattr"` - DefaultValue types.AnyType `xml:"defaultValue,omitempty,typeattr"` - AllowedValue types.AnyType `xml:"allowedValue,omitempty,typeattr"` - RequirementsTypeHint string `xml:"requirementsTypeHint,omitempty"` + // Property identifier. + // + // Should be unique within the definition of the + // capability. Property instances refer to this identifier + // (`PbmCapabilityPropertyInstance*.*PbmCapabilityPropertyInstance.id`). + Id string `xml:"id" json:"id"` + // Property name and description. + // - The summary.label property + // (`PbmExtendedElementDescription.label`) + // contains property 'name' in server locale. + // - The summary.summary property + // (`PbmExtendedElementDescription.summary`) + // contains property 'description' in server locale. + // - The summary.messageCatalogKeyPrefix property + // (`PbmExtendedElementDescription.messageCatalogKeyPrefix`) + // contains unique prefix for this property within given message catalog. + // Prefix format: <capability\_unique\_identifier.<property\_id + // capability\_unique\_identifier -- string representation of + // `PbmCapabilityMetadataUniqueId` which globally identifies given + // capability metadata definition uniquely. + // property\_id -- 'id' of this property `PbmCapabilityPropertyMetadata.id` + // Eg www.emc.com.storage.Recovery.Recovery\_site + // www.emc.com.storage.Recovery.RPO + // www.emc.com.storage.Recovery.RTO + Summary PbmExtendedElementDescription `xml:"summary" json:"summary"` + // Indicates whether incorporating given capability is mandatory during creation of + // profile. + Mandatory bool `xml:"mandatory" json:"mandatory"` + // Type information for the capability. + // + // The type of a property value + // (`PbmCapabilityPropertyInstance*.*PbmCapabilityPropertyInstance.value`) + // is specified as a builtin datatype and may also specify the interpretation of a + // collection of values of that datatype. + // - `PbmCapabilityPropertyMetadata.type*.*PbmCapabilityTypeInfo.typeName` + // specifies the `PbmBuiltinType_enum`. + // - `PbmCapabilityPropertyMetadata.type*.*PbmCapabilityGenericTypeInfo.genericTypeName` + // indicates how a collection of values of the specified datatype will be interpreted + // (`PbmBuiltinGenericType_enum`). + Type BasePbmCapabilityTypeInfo `xml:"type,omitempty,typeattr" json:"type,omitempty"` + // Default value, if any, that the property will assume when not + // constrained by requirements. + // + // This object must be of the + // `PbmCapabilityPropertyMetadata.type` + // defined for the property. + DefaultValue types.AnyType `xml:"defaultValue,omitempty,typeattr" json:"defaultValue,omitempty"` + // All legal values that the property may take on, across all + // implementations of the property. + // + // This definition of legal values is not + // determined by any particular resource configuration; rather it is + // inherent to the definition of the property. If undefined, then any value + // of the correct type is legal. This object must be a generic container for + // the `PbmCapabilityPropertyMetadata.type` + // defined for the property; + // see `PbmBuiltinGenericType_enum` + // for the supported generic container types. + AllowedValue types.AnyType `xml:"allowedValue,omitempty,typeattr" json:"allowedValue,omitempty"` + // A hint for data-driven systems that assist in authoring requirements + // constraints. + // + // Acceptable values defined by + // `PbmBuiltinGenericType_enum`. + // A property will typically only have constraints of a given type in + // requirement profiles, even if it is likely to use constraints of + // different types across capability profiles. This value, if specified, + // specifies the expected kind of constraint used in requirement profiles. + // Considerations for using this information: + // - This is only a hint; any properly formed constraint + // (see `PbmCapabilityPropertyInstance.value`) + // is still valid for a requirement profile. + // - If VMW\_SET is hinted, then a single value matching the property metadata type is + // also an expected form of constraint, as the latter is an allowed convenience + // for expressing a single-member set. + // - If this hint is not specified, then the authoring system may default to a form of + // constraint determined by its own criteria. + RequirementsTypeHint string `xml:"requirementsTypeHint,omitempty" json:"requirementsTypeHint,omitempty"` } func init() { types.Add("pbm:PbmCapabilityPropertyMetadata", reflect.TypeOf((*PbmCapabilityPropertyMetadata)(nil)).Elem()) } +// The `PbmCapabilityRange` data object defines a range of values for storage property +// instances (`PbmCapabilityPropertyInstance`). +// +// Use the range type to define a range of values of a supported builtin type, +// for example range<int>, range<long>, or range<timespan>. +// You can specify a partial range by omitting one of the properties, min or max. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityRange struct { types.DynamicData - Min types.AnyType `xml:"min,typeattr"` - Max types.AnyType `xml:"max,typeattr"` + // Minimum value of range. + // + // Must be one of the supported + // datatypes as defined in `PbmBuiltinType_enum`. + // Must be the same datatype as min. + Min types.AnyType `xml:"min,typeattr" json:"min"` + // Maximum value of range. + // + // Must be one of the supported + // datatypes as defined in `PbmBuiltinType_enum`. + // Must be the same datatype as max. + Max types.AnyType `xml:"max,typeattr" json:"max"` } func init() { types.Add("pbm:PbmCapabilityRange", reflect.TypeOf((*PbmCapabilityRange)(nil)).Elem()) } +// Capability Schema information +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilitySchema struct { types.DynamicData - VendorInfo PbmCapabilitySchemaVendorInfo `xml:"vendorInfo"` - NamespaceInfo PbmCapabilityNamespaceInfo `xml:"namespaceInfo"` - LineOfService BasePbmLineOfServiceInfo `xml:"lineOfService,omitempty,typeattr"` - CapabilityMetadataPerCategory []PbmCapabilityMetadataPerCategory `xml:"capabilityMetadataPerCategory"` + VendorInfo PbmCapabilitySchemaVendorInfo `xml:"vendorInfo" json:"vendorInfo"` + NamespaceInfo PbmCapabilityNamespaceInfo `xml:"namespaceInfo" json:"namespaceInfo"` + // Service type for the schema. + // + // Do not use Category as each service needs to have its own schema version. + // + // If omitted, this schema specifies persistence capabilities. + LineOfService BasePbmLineOfServiceInfo `xml:"lineOfService,omitempty,typeattr" json:"lineOfService,omitempty"` + // Capability metadata organized by category + CapabilityMetadataPerCategory []PbmCapabilityMetadataPerCategory `xml:"capabilityMetadataPerCategory" json:"capabilityMetadataPerCategory"` } func init() { types.Add("pbm:PbmCapabilitySchema", reflect.TypeOf((*PbmCapabilitySchema)(nil)).Elem()) } +// Information about vendor/owner of the capability metadata schema +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilitySchemaVendorInfo struct { types.DynamicData - VendorUuid string `xml:"vendorUuid"` - Info PbmExtendedElementDescription `xml:"info"` + // Unique identifier for the vendor who owns the given capability + // schema definition + VendorUuid string `xml:"vendorUuid" json:"vendorUuid"` + // Captures name and description information about the vendor/owner of + // the schema. + // - The summary.label property + // (`PbmExtendedElementDescription.label`) + // contains vendor name information in server locale. + // - The summary.summary property + // (`PbmExtendedElementDescription.summary`) + // contains vendor description string in server locale. + // - The summary.messageCatalogKeyPrefix property + // (`PbmExtendedElementDescription.messageCatalogKeyPrefix`) + // contains unique prefix for the vendor information within given message + // catalog. + Info PbmExtendedElementDescription `xml:"info" json:"info"` } func init() { types.Add("pbm:PbmCapabilitySchemaVendorInfo", reflect.TypeOf((*PbmCapabilitySchemaVendorInfo)(nil)).Elem()) } +// A `PbmCapabilitySubProfile` +// is a section within a profile that aggregates one or more capability +// instances. +// +// Capability instances define storage constraints. +// +// All constraints within a subprofile are ANDed by default. +// When you perform compliance checking on a virtual machine or virtual +// disk, all of the constraints must be satisfied by the storage capabilities. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilitySubProfile struct { types.DynamicData - Name string `xml:"name"` - Capability []PbmCapabilityInstance `xml:"capability"` - ForceProvision *bool `xml:"forceProvision"` + // Subprofile name. + Name string `xml:"name" json:"name"` + // List of capability instances. + Capability []PbmCapabilityInstance `xml:"capability" json:"capability"` + // Indicates whether the source policy profile allows creating a virtual machine + // or virtual disk that may be non-compliant. + ForceProvision *bool `xml:"forceProvision" json:"forceProvision,omitempty"` } func init() { types.Add("pbm:PbmCapabilitySubProfile", reflect.TypeOf((*PbmCapabilitySubProfile)(nil)).Elem()) } +// The `PbmCapabilitySubProfileConstraints` data object defines a group +// of storage subprofiles. +// +// Subprofile usage depends on the type of profile +// (`PbmCapabilityProfile*.*PbmCapabilityProfile.profileCategory`). +// - For a REQUIREMENTS profile, each subprofile defines storage requirements. +// A Storage Policy API requirements subprofile corresponds to a vSphere Web Client +// rule set. +// - For a RESOURCE profile, each subprofile defines storage capabilities. +// Storage capabilities are read-only. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilitySubProfileConstraints struct { PbmCapabilityConstraints - SubProfiles []PbmCapabilitySubProfile `xml:"subProfiles"` + // Aggregation of one or more subprofiles. + // + // The relationship among all subprofiles is "OR". When you perform + // compliance checking on a profile that contains more than one subprofile, + // a non-compliant result for any one of the subprofiles will produce a + // non-compliant result for the operation. + SubProfiles []PbmCapabilitySubProfile `xml:"subProfiles" json:"subProfiles"` } func init() { types.Add("pbm:PbmCapabilitySubProfileConstraints", reflect.TypeOf((*PbmCapabilitySubProfileConstraints)(nil)).Elem()) } +// The `PbmCapabilityTimeSpan` data object defines a time value and time unit, +// for example 10 hours or 5 minutes. +// +// See +// `PbmBuiltinType_enum*.*VMW_TIMESPAN`. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityTimeSpan struct { types.DynamicData - Value int32 `xml:"value"` - Unit string `xml:"unit"` + // Time value. + // + // Must be a positive integer. + Value int32 `xml:"value" json:"value"` + // Unit value for time. + // + // The string value must correspond + // to one of the `PbmCapabilityTimeUnitType_enum` values. + Unit string `xml:"unit" json:"unit"` } func init() { types.Add("pbm:PbmCapabilityTimeSpan", reflect.TypeOf((*PbmCapabilityTimeSpan)(nil)).Elem()) } +// The `PbmCapabilityTypeInfo` data object defines the datatype for a requirement +// or capability property. +// +// See `PbmCapabilityPropertyMetadata`. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCapabilityTypeInfo struct { types.DynamicData - TypeName string `xml:"typeName"` + // Datatype for a property. + // + // Must be one of the types defined + // in `PbmBuiltinType_enum`. + // + // A property value might consist of a collection of values of the specified + // datatype. The interpretation of the collection is determined by the + // generic type (`PbmCapabilityGenericTypeInfo.genericTypeName`). + // The generic type indicates how a collection of values + // of the specified datatype will be interpreted. See the descriptions of the + // `PbmBuiltinType_enum` definitions. + TypeName string `xml:"typeName" json:"typeName"` } func init() { @@ -571,8 +1065,8 @@ func init() { type PbmCapabilityVendorNamespaceInfo struct { types.DynamicData - VendorInfo PbmCapabilitySchemaVendorInfo `xml:"vendorInfo"` - NamespaceInfo PbmCapabilityNamespaceInfo `xml:"namespaceInfo"` + VendorInfo PbmCapabilitySchemaVendorInfo `xml:"vendorInfo" json:"vendorInfo"` + NamespaceInfo PbmCapabilityNamespaceInfo `xml:"namespaceInfo" json:"namespaceInfo"` } func init() { @@ -582,8 +1076,14 @@ func init() { type PbmCapabilityVendorResourceTypeInfo struct { types.DynamicData - ResourceType string `xml:"resourceType"` - VendorNamespaceInfo []PbmCapabilityVendorNamespaceInfo `xml:"vendorNamespaceInfo"` + // Resource type for which given vendor has registered given namespace + // along with capability metadata that belongs to the namespace. + // + // Must match one of the values for enum `PbmProfileResourceTypeEnum_enum` + ResourceType string `xml:"resourceType" json:"resourceType"` + // List of all vendorInfo -- namespaceInfo tuples that are registered for + // given resource type + VendorNamespaceInfo []PbmCapabilityVendorNamespaceInfo `xml:"vendorNamespaceInfo" json:"vendorNamespaceInfo"` } func init() { @@ -596,10 +1096,16 @@ func init() { types.Add("pbm:PbmCheckCompatibility", reflect.TypeOf((*PbmCheckCompatibility)(nil)).Elem()) } +// The parameters of `PbmPlacementSolver.PbmCheckCompatibility`. type PbmCheckCompatibilityRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - HubsToSearch []PbmPlacementHub `xml:"hubsToSearch,omitempty"` - Profile PbmProfileId `xml:"profile"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Candidate list of hubs, either datastores or storage pods or a + // mix. If this parameter is not specified, the Server uses all + // of the datastores and storage pods for placement compatibility + // checking. + HubsToSearch []PbmPlacementHub `xml:"hubsToSearch,omitempty" json:"hubsToSearch,omitempty"` + // Storage requirement profile. + Profile PbmProfileId `xml:"profile" json:"profile"` } func init() { @@ -607,7 +1113,7 @@ func init() { } type PbmCheckCompatibilityResponse struct { - Returnval []PbmPlacementCompatibilityResult `xml:"returnval,omitempty"` + Returnval []PbmPlacementCompatibilityResult `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmCheckCompatibilityWithSpec PbmCheckCompatibilityWithSpecRequestType @@ -616,10 +1122,15 @@ func init() { types.Add("pbm:PbmCheckCompatibilityWithSpec", reflect.TypeOf((*PbmCheckCompatibilityWithSpec)(nil)).Elem()) } +// The parameters of `PbmPlacementSolver.PbmCheckCompatibilityWithSpec`. type PbmCheckCompatibilityWithSpecRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - HubsToSearch []PbmPlacementHub `xml:"hubsToSearch,omitempty"` - ProfileSpec PbmCapabilityProfileCreateSpec `xml:"profileSpec"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Candidate list of hubs, either datastores or storage pods + // or a mix. If this parameter is not specified, the Server uses all of the + // datastores and storage pods for placement compatibility checking. + HubsToSearch []PbmPlacementHub `xml:"hubsToSearch,omitempty" json:"hubsToSearch,omitempty"` + // Specification for a capability based profile. + ProfileSpec PbmCapabilityProfileCreateSpec `xml:"profileSpec" json:"profileSpec"` } func init() { @@ -627,7 +1138,7 @@ func init() { } type PbmCheckCompatibilityWithSpecResponse struct { - Returnval []PbmPlacementCompatibilityResult `xml:"returnval,omitempty"` + Returnval []PbmPlacementCompatibilityResult `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmCheckCompliance PbmCheckComplianceRequestType @@ -636,10 +1147,31 @@ func init() { types.Add("pbm:PbmCheckCompliance", reflect.TypeOf((*PbmCheckCompliance)(nil)).Elem()) } +// The parameters of `PbmComplianceManager.PbmCheckCompliance`. type PbmCheckComplianceRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Entities []PbmServerObjectRef `xml:"entities"` - Profile *PbmProfileId `xml:"profile,omitempty"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // One or more references to storage entities. + // You can specify virtual machines and virtual disks + // A maximum of 1000 virtual machines and/or virtual disks can be specified + // in a call. The results of calling the checkCompliance API with + // more than a 1000 entities is undefined. + // - If the list of entities also contains datastores, the Server + // will ignore the datastores. + // - If the list contains valid and invalid entities, the Server ignores + // the invalid entities and returns results for the valid entities. + // Invalid entities are entities that are not in the vCenter inventory. + // - If the list contains only datastores, the method throws + // an InvalidArgument fault. + // - If the list contains virtual machines and disks and the entities + // are invalid or have been deleted by the time of the request, the method + // throws an InvalidArgument fault. + // + // If an entity does not have an associated storage profile, the entity + // is removed from the list. + Entities []PbmServerObjectRef `xml:"entities" json:"entities"` + // Not used. If specified, the Server ignores the value. + // The Server uses the profiles associated with the specified entities. + Profile *PbmProfileId `xml:"profile,omitempty" json:"profile,omitempty"` } func init() { @@ -647,7 +1179,7 @@ func init() { } type PbmCheckComplianceResponse struct { - Returnval []PbmComplianceResult `xml:"returnval,omitempty"` + Returnval []PbmComplianceResult `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmCheckRequirements PbmCheckRequirementsRequestType @@ -656,11 +1188,27 @@ func init() { types.Add("pbm:PbmCheckRequirements", reflect.TypeOf((*PbmCheckRequirements)(nil)).Elem()) } +// The parameters of `PbmPlacementSolver.PbmCheckRequirements`. type PbmCheckRequirementsRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - HubsToSearch []PbmPlacementHub `xml:"hubsToSearch,omitempty"` - PlacementSubjectRef *PbmServerObjectRef `xml:"placementSubjectRef,omitempty"` - PlacementSubjectRequirement []BasePbmPlacementRequirement `xml:"placementSubjectRequirement,omitempty,typeattr"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Candidate list of hubs, either datastores or storage pods + // or a mix. If this parameter is not specified, the Server uses all of the + // datastores and storage pods for placement compatibility checking. + HubsToSearch []PbmPlacementHub `xml:"hubsToSearch,omitempty" json:"hubsToSearch,omitempty"` + // reference to the object being placed. Should be null when a new + // object is being provisioned. Should be specified when placement compatibility is being checked + // for an existing object. Supported objects are + // `virtualMachine`, + // `virtualMachineAndDisks`, + // `virtualDiskId`, + // `virtualDiskUUID` + PlacementSubjectRef *PbmServerObjectRef `xml:"placementSubjectRef,omitempty" json:"placementSubjectRef,omitempty"` + // Requirements including the policy requirements, compute + // requirements and capacity requirements. It is invalid to specify no requirements. It is also + // invalid to specify duplicate requirements or multiple conflicting requirements such as + // specifying both `PbmPlacementCapabilityConstraintsRequirement` and + // `PbmPlacementCapabilityProfileRequirement`. + PlacementSubjectRequirement []BasePbmPlacementRequirement `xml:"placementSubjectRequirement,omitempty,typeattr" json:"placementSubjectRequirement,omitempty"` } func init() { @@ -668,7 +1216,7 @@ func init() { } type PbmCheckRequirementsResponse struct { - Returnval []PbmPlacementCompatibilityResult `xml:"returnval,omitempty"` + Returnval []PbmPlacementCompatibilityResult `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmCheckRollupCompliance PbmCheckRollupComplianceRequestType @@ -677,9 +1225,14 @@ func init() { types.Add("pbm:PbmCheckRollupCompliance", reflect.TypeOf((*PbmCheckRollupCompliance)(nil)).Elem()) } +// The parameters of `PbmComplianceManager.PbmCheckRollupCompliance`. type PbmCheckRollupComplianceRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Entity []PbmServerObjectRef `xml:"entity"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // One or more references to virtual machines. + // A maximum of 1000 virtual machines can be specified + // in a call. The results of calling the checkRollupCompliance API with + // more than a 1000 entities is undefined. + Entity []PbmServerObjectRef `xml:"entity" json:"entity"` } func init() { @@ -687,13 +1240,17 @@ func init() { } type PbmCheckRollupComplianceResponse struct { - Returnval []PbmRollupComplianceResult `xml:"returnval,omitempty"` + Returnval []PbmRollupComplianceResult `xml:"returnval,omitempty" json:"returnval,omitempty"` } +// Super class for all compatibility check faults. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCompatibilityCheckFault struct { PbmFault - Hub PbmPlacementHub `xml:"hub"` + // Placement Hub + Hub PbmPlacementHub `xml:"hub" json:"hub"` } func init() { @@ -706,43 +1263,124 @@ func init() { types.Add("pbm:PbmCompatibilityCheckFaultFault", reflect.TypeOf((*PbmCompatibilityCheckFaultFault)(nil)).Elem()) } +// Additional information on the effects of backend resources and +// operations on the storage object. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmComplianceOperationalStatus struct { types.DynamicData - Healthy *bool `xml:"healthy"` - OperationETA *time.Time `xml:"operationETA"` - OperationProgress int64 `xml:"operationProgress,omitempty"` - Transitional *bool `xml:"transitional"` + // Whether the object is currently affected by the failure of backend + // storage resources. + // + // Optional property. + Healthy *bool `xml:"healthy" json:"healthy,omitempty"` + // Estimated completion time of a backend operation affecting the object. + // + // If set, then "transitional" will be true. + // Optional property. + OperationETA *time.Time `xml:"operationETA" json:"operationETA,omitempty"` + // Percent progress of a backend operation affecting the object. + // + // If set, then "transitional" will be true. + // Optional property. + OperationProgress int64 `xml:"operationProgress,omitempty" json:"operationProgress,omitempty"` + // Whether an object is undergoing a backend operation that may affect + // its performance. + // + // This may be a rebalancing the resources of a healthy + // object or recovery tasks for an unhealthy object. + // Optional property. + Transitional *bool `xml:"transitional" json:"transitional,omitempty"` } func init() { types.Add("pbm:PbmComplianceOperationalStatus", reflect.TypeOf((*PbmComplianceOperationalStatus)(nil)).Elem()) } +// The `PbmCompliancePolicyStatus` data object provides information +// when compliance checking produces non-compliant results. +// +// See +// `PbmComplianceResult*.*PbmComplianceResult.violatedPolicies`. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmCompliancePolicyStatus struct { types.DynamicData - ExpectedValue PbmCapabilityInstance `xml:"expectedValue"` - CurrentValue *PbmCapabilityInstance `xml:"currentValue,omitempty"` + // Expected storage capability values of profile policies defined + // by a storage provider. + ExpectedValue PbmCapabilityInstance `xml:"expectedValue" json:"expectedValue"` + // Current storage requirement values of the profile policies + // specified for the virtual machine or virtual disk. + CurrentValue *PbmCapabilityInstance `xml:"currentValue,omitempty" json:"currentValue,omitempty"` } func init() { types.Add("pbm:PbmCompliancePolicyStatus", reflect.TypeOf((*PbmCompliancePolicyStatus)(nil)).Elem()) } +// The `PbmComplianceResult` data object describes the results of profile compliance +// checking for a virtual machine or virtual disk. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmComplianceResult struct { types.DynamicData - CheckTime time.Time `xml:"checkTime"` - Entity PbmServerObjectRef `xml:"entity"` - Profile *PbmProfileId `xml:"profile,omitempty"` - ComplianceTaskStatus string `xml:"complianceTaskStatus,omitempty"` - ComplianceStatus string `xml:"complianceStatus"` - Mismatch bool `xml:"mismatch"` - ViolatedPolicies []PbmCompliancePolicyStatus `xml:"violatedPolicies,omitempty"` - ErrorCause []types.LocalizedMethodFault `xml:"errorCause,omitempty"` - OperationalStatus *PbmComplianceOperationalStatus `xml:"operationalStatus,omitempty"` - Info *PbmExtendedElementDescription `xml:"info,omitempty"` + // Time when the compliance was checked. + CheckTime time.Time `xml:"checkTime" json:"checkTime"` + // Virtual machine or virtual disk for which compliance was checked. + Entity PbmServerObjectRef `xml:"entity" json:"entity"` + // Requirement profile with which the compliance was checked. + Profile *PbmProfileId `xml:"profile,omitempty" json:"profile,omitempty"` + // Status of the current running compliance operation. + // + // If there is no + // compliance check operation triggered, this indicates the last compliance + // task status. complianceTaskStatus is a string value that + // corresponds to one of the + // `PbmComplianceResultComplianceTaskStatus_enum` values. + ComplianceTaskStatus string `xml:"complianceTaskStatus,omitempty" json:"complianceTaskStatus,omitempty"` + // Status of the compliance operation. + // + // complianceStatus is a + // string value that corresponds to one of the + // `PbmComplianceStatus_enum` values. + // + // When you perform compliance checking on an entity whose associated profile + // contains more than one subprofile ( + // `PbmCapabilityProfile` . + // `PbmCapabilityProfile.constraints`), a compliant + // result for any one of the subprofiles will produce a compliant result + // for the operation. + ComplianceStatus string `xml:"complianceStatus" json:"complianceStatus"` + // Deprecated as of vSphere 2016, use + // `PbmComplianceStatus_enum` to + // know if a mismatch has occurred. If + // `PbmComplianceResult.complianceStatus` value + // is outOfDate, mismatch has occurred. + // + // Set to true if there is a profile version mismatch between the Storage + // Profile Server and the storage provider. + // + // If you receive a result that + // indicates a mismatch, you must use the vSphere API to update the profile + // associated with the virtual machine or virtual disk. + Mismatch bool `xml:"mismatch" json:"mismatch"` + // Values for capabilities that are known to be non-compliant with the specified constraints. + ViolatedPolicies []PbmCompliancePolicyStatus `xml:"violatedPolicies,omitempty" json:"violatedPolicies,omitempty"` + // This property is set if the compliance task fails with errors. + // + // There can be + // more than one error since a policy containing multiple blobs can return + // multiple failures, one for each blob. + ErrorCause []types.LocalizedMethodFault `xml:"errorCause,omitempty" json:"errorCause,omitempty"` + // Additional information on the effects of backend resources and + // operations on the storage object. + OperationalStatus *PbmComplianceOperationalStatus `xml:"operationalStatus,omitempty" json:"operationalStatus,omitempty"` + // Informational localized messages provided by the VASA provider in + // addition to the violatedPolicy. + Info *PbmExtendedElementDescription `xml:"info,omitempty" json:"info,omitempty"` } func init() { @@ -755,9 +1393,11 @@ func init() { types.Add("pbm:PbmCreate", reflect.TypeOf((*PbmCreate)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmCreate`. type PbmCreateRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - CreateSpec PbmCapabilityProfileCreateSpec `xml:"createSpec"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Capability-based profile specification. + CreateSpec PbmCapabilityProfileCreateSpec `xml:"createSpec" json:"createSpec"` } func init() { @@ -765,48 +1405,87 @@ func init() { } type PbmCreateResponse struct { - Returnval PbmProfileId `xml:"returnval"` + Returnval PbmProfileId `xml:"returnval" json:"returnval"` } +// DataServiceToProfilesMap maps the data service policy to the parent storage policies +// if referred. +// +// This is returned from the API call +// `ProfileManager#queryParentStoragePolicies(ProfileId[])` +// +// This structure may be used only with operations rendered under `/pbm`. type PbmDataServiceToPoliciesMap struct { types.DynamicData - DataServicePolicy PbmProfileId `xml:"dataServicePolicy"` - ParentStoragePolicies []PbmProfileId `xml:"parentStoragePolicies,omitempty"` - Fault *types.LocalizedMethodFault `xml:"fault,omitempty"` + // Denotes a Data Service Policy Id. + DataServicePolicy PbmProfileId `xml:"dataServicePolicy" json:"dataServicePolicy"` + // Storage Policies that refer to the Data Service Policy given by + // `PbmDataServiceToPoliciesMap.dataServicePolicy`. + ParentStoragePolicies []PbmProfileId `xml:"parentStoragePolicies,omitempty" json:"parentStoragePolicies,omitempty"` + // The fault is set in case of error conditions and this property will + // have the reason. + Fault *types.LocalizedMethodFault `xml:"fault,omitempty" json:"fault,omitempty"` } func init() { types.Add("pbm:PbmDataServiceToPoliciesMap", reflect.TypeOf((*PbmDataServiceToPoliciesMap)(nil)).Elem()) } +// Space stats for datastore +// +// This structure may be used only with operations rendered under `/pbm`. type PbmDatastoreSpaceStatistics struct { types.DynamicData - ProfileId string `xml:"profileId,omitempty"` - PhysicalTotalInMB int64 `xml:"physicalTotalInMB"` - PhysicalFreeInMB int64 `xml:"physicalFreeInMB"` - PhysicalUsedInMB int64 `xml:"physicalUsedInMB"` - LogicalLimitInMB int64 `xml:"logicalLimitInMB,omitempty"` - LogicalFreeInMB int64 `xml:"logicalFreeInMB"` - LogicalUsedInMB int64 `xml:"logicalUsedInMB"` + // Capability profile id. + // + // It is null when the statistics are for the entire + // datastore. + ProfileId string `xml:"profileId,omitempty" json:"profileId,omitempty"` + // Total physical space in MB. + PhysicalTotalInMB int64 `xml:"physicalTotalInMB" json:"physicalTotalInMB"` + // Total physical free space in MB. + PhysicalFreeInMB int64 `xml:"physicalFreeInMB" json:"physicalFreeInMB"` + // Used physical storage space in MB. + PhysicalUsedInMB int64 `xml:"physicalUsedInMB" json:"physicalUsedInMB"` + // Logical space limit set by the storage admin in MB. + // + // Omitted if there is no Logical space limit. + LogicalLimitInMB int64 `xml:"logicalLimitInMB,omitempty" json:"logicalLimitInMB,omitempty"` + // Free logical storage space in MB. + LogicalFreeInMB int64 `xml:"logicalFreeInMB" json:"logicalFreeInMB"` + // Used logical storage space in MB. + LogicalUsedInMB int64 `xml:"logicalUsedInMB" json:"logicalUsedInMB"` } func init() { types.Add("pbm:PbmDatastoreSpaceStatistics", reflect.TypeOf((*PbmDatastoreSpaceStatistics)(nil)).Elem()) } +// Not supported in this release. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmDefaultCapabilityProfile struct { PbmCapabilityProfile - VvolType []string `xml:"vvolType"` - ContainerId string `xml:"containerId"` + // Not supported in this release. + VvolType []string `xml:"vvolType" json:"vvolType"` + // Not supported in this release. + ContainerId string `xml:"containerId" json:"containerId"` } func init() { types.Add("pbm:PbmDefaultCapabilityProfile", reflect.TypeOf((*PbmDefaultCapabilityProfile)(nil)).Elem()) } +// Warning fault used to indicate that the vendor specific datastore matches the tag in the +// requirements profile that does not have a vendor specific rule set. +// +// In such case, +// an empty blob is sent to the vendor specific datastore and the default profile would apply. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmDefaultProfileAppliesFault struct { PbmCompatibilityCheckFault } @@ -821,11 +1500,20 @@ func init() { types.Add("pbm:PbmDefaultProfileAppliesFaultFault", reflect.TypeOf((*PbmDefaultProfileAppliesFaultFault)(nil)).Elem()) } +// Data structure that stores the default profile for datastores. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmDefaultProfileInfo struct { types.DynamicData - Datastores []PbmPlacementHub `xml:"datastores"` - DefaultProfile BasePbmProfile `xml:"defaultProfile,omitempty,typeattr"` + // Datastores + Datastores []PbmPlacementHub `xml:"datastores" json:"datastores"` + // Default requirements profile. + // + // It is set to null if the datastores are not associated with any default profile. + DefaultProfile BasePbmProfile `xml:"defaultProfile,omitempty,typeattr" json:"defaultProfile,omitempty"` + // NoPermission fault if default profile is not permitted. + MethodFault *types.LocalizedMethodFault `xml:"methodFault,omitempty" json:"methodFault,omitempty"` } func init() { @@ -838,9 +1526,11 @@ func init() { types.Add("pbm:PbmDelete", reflect.TypeOf((*PbmDelete)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmDelete`. type PbmDeleteRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - ProfileId []PbmProfileId `xml:"profileId"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Array of profile identifiers. + ProfileId []PbmProfileId `xml:"profileId" json:"profileId"` } func init() { @@ -848,13 +1538,18 @@ func init() { } type PbmDeleteResponse struct { - Returnval []PbmProfileOperationOutcome `xml:"returnval,omitempty"` + Returnval []PbmProfileOperationOutcome `xml:"returnval,omitempty" json:"returnval,omitempty"` } +// A DuplicateName exception is thrown because a name already exists +// in the same name space. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmDuplicateName struct { PbmFault - Name string `xml:"name"` + // The name that is already bound in the name space. + Name string `xml:"name" json:"name"` } func init() { @@ -870,17 +1565,38 @@ func init() { type PbmExtendedElementDescription struct { types.DynamicData - Label string `xml:"label"` - Summary string `xml:"summary"` - Key string `xml:"key"` - MessageCatalogKeyPrefix string `xml:"messageCatalogKeyPrefix"` - MessageArg []types.KeyAnyValue `xml:"messageArg,omitempty"` + // Display label. + Label string `xml:"label" json:"label"` + // Summary description. + Summary string `xml:"summary" json:"summary"` + // Enumeration or literal ID being described. + Key string `xml:"key" json:"key"` + // Key to the localized message string in the catalog. + // + // If the localized string contains parameters, values to the + // parameters will be provided in #messageArg. + // E.g: If the message in the catalog is + // "IP address is {address}", value for "address" + // will be provided by #messageArg. + // Both summary and label in ElementDescription will have a corresponding + // entry in the message catalog with the keys + // .summary and .label + // respectively. + // ElementDescription.summary and ElementDescription.label will contain + // the strings in server locale. + MessageCatalogKeyPrefix string `xml:"messageCatalogKeyPrefix" json:"messageCatalogKeyPrefix"` + // Provides named arguments that can be used to localize the + // message in the catalog. + MessageArg []types.KeyAnyValue `xml:"messageArg,omitempty" json:"messageArg,omitempty"` } func init() { types.Add("pbm:PbmExtendedElementDescription", reflect.TypeOf((*PbmExtendedElementDescription)(nil)).Elem()) } +// The super class for all pbm faults. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmFault struct { types.MethodFault } @@ -895,6 +1611,10 @@ func init() { types.Add("pbm:PbmFaultFault", reflect.TypeOf((*PbmFaultFault)(nil)).Elem()) } +// Thrown when login fails due to token not provided or token could not be +// validated. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmFaultInvalidLogin struct { PbmFault } @@ -909,17 +1629,51 @@ func init() { types.Add("pbm:PbmFaultInvalidLoginFault", reflect.TypeOf((*PbmFaultInvalidLoginFault)(nil)).Elem()) } +// Thrown when an operation is denied because of a privilege +// not held on a storage profile. +// +// This structure may be used only with operations rendered under `/pbm`. +type PbmFaultNoPermission struct { + types.SecurityError + + // List of profile ids and missing privileges for each profile + MissingPrivileges []PbmFaultNoPermissionEntityPrivileges `xml:"missingPrivileges,omitempty" json:"missingPrivileges,omitempty"` +} + +func init() { + types.Add("pbm:PbmFaultNoPermission", reflect.TypeOf((*PbmFaultNoPermission)(nil)).Elem()) +} + type PbmFaultNoPermissionEntityPrivileges struct { types.DynamicData - ProfileId *PbmProfileId `xml:"profileId,omitempty"` - PrivilegeIds []string `xml:"privilegeIds,omitempty"` + ProfileId *PbmProfileId `xml:"profileId,omitempty" json:"profileId,omitempty"` + PrivilegeIds []string `xml:"privilegeIds,omitempty" json:"privilegeIds,omitempty"` } func init() { types.Add("pbm:PbmFaultNoPermissionEntityPrivileges", reflect.TypeOf((*PbmFaultNoPermissionEntityPrivileges)(nil)).Elem()) } +type PbmFaultNoPermissionFault PbmFaultNoPermission + +func init() { + types.Add("pbm:PbmFaultNoPermissionFault", reflect.TypeOf((*PbmFaultNoPermissionFault)(nil)).Elem()) +} + +// A NotFound error occurs when a referenced component of a managed +// object cannot be found. +// +// The referenced component can be a data +// object type (such as a role or permission) or a primitive +// (such as a string). +// +// For example, if the missing referenced component is a data object, such as +// VirtualSwitch, the NotFound error is +// thrown. The NotFound error is also thrown if the data object is found, but the referenced name +// (for example, "vswitch0") is not. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmFaultNotFound struct { PbmFault } @@ -954,10 +1708,19 @@ func init() { types.Add("pbm:PbmFetchCapabilityMetadata", reflect.TypeOf((*PbmFetchCapabilityMetadata)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmFetchCapabilityMetadata`. type PbmFetchCapabilityMetadataRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - ResourceType *PbmProfileResourceType `xml:"resourceType,omitempty"` - VendorUuid string `xml:"vendorUuid,omitempty"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Type of profile resource. The Server supports the "STORAGE" resource + // type only. If not specified, this method will return capability metadata for the storage + // resources. Any other resourceType is considered invalid. + ResourceType *PbmProfileResourceType `xml:"resourceType,omitempty" json:"resourceType,omitempty"` + // Unique identifier for the vendor/owner of capability + // metadata. The specified vendor ID must match + // `PbmCapabilitySchemaVendorInfo*.*PbmCapabilitySchemaVendorInfo.vendorUuid`. + // If omitted, the Server searchs all capability metadata registered with the system. If a + // vendorUuid unknown to the Server is specified, empty results will be returned. + VendorUuid string `xml:"vendorUuid,omitempty" json:"vendorUuid,omitempty"` } func init() { @@ -965,7 +1728,7 @@ func init() { } type PbmFetchCapabilityMetadataResponse struct { - Returnval []PbmCapabilityMetadataPerCategory `xml:"returnval,omitempty"` + Returnval []PbmCapabilityMetadataPerCategory `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmFetchCapabilitySchema PbmFetchCapabilitySchemaRequestType @@ -974,10 +1737,20 @@ func init() { types.Add("pbm:PbmFetchCapabilitySchema", reflect.TypeOf((*PbmFetchCapabilitySchema)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmFetchCapabilitySchema`. type PbmFetchCapabilitySchemaRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - VendorUuid string `xml:"vendorUuid,omitempty"` - LineOfService []string `xml:"lineOfService,omitempty"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Unique identifier for the vendor/owner of capability metadata. + // If omitted, the server searchs all capability metadata registered + // with the system. The specified vendor ID must match + // `PbmCapabilitySchemaVendorInfo*.*PbmCapabilitySchemaVendorInfo.vendorUuid`. + VendorUuid string `xml:"vendorUuid,omitempty" json:"vendorUuid,omitempty"` + // Optional line of service that must match `PbmLineOfServiceInfoLineOfServiceEnum_enum`. + // If specified, the capability schema objects + // are returned for the given lineOfServices. If null, then all + // capability schema objects that may or may not have data service capabilities + // are returned. + LineOfService []string `xml:"lineOfService,omitempty" json:"lineOfService,omitempty"` } func init() { @@ -985,7 +1758,7 @@ func init() { } type PbmFetchCapabilitySchemaResponse struct { - Returnval []PbmCapabilitySchema `xml:"returnval,omitempty"` + Returnval []PbmCapabilitySchema `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmFetchComplianceResult PbmFetchComplianceResultRequestType @@ -994,10 +1767,24 @@ func init() { types.Add("pbm:PbmFetchComplianceResult", reflect.TypeOf((*PbmFetchComplianceResult)(nil)).Elem()) } +// The parameters of `PbmComplianceManager.PbmFetchComplianceResult`. type PbmFetchComplianceResultRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Entities []PbmServerObjectRef `xml:"entities"` - Profile *PbmProfileId `xml:"profile,omitempty"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // One or more references to storage entities. + // A maximum of 1000 virtual machines and/or virtual disks can be specified + // in a call. The results of calling the fetchComplianceResult API with + // more than a 1000 entities is undefined. + // - If the list of entities also contains datastores, the Server + // will ignore the datastores. + // - If the list contains valid and invalid entities, the Server ignores + // the invalid entities and returns results for the valid entities. + // Invalid entities are entities that are not in the vCenter inventory. + // - If the list contains only datastores, the method throws + // an InvalidArgument fault. + Entities []PbmServerObjectRef `xml:"entities" json:"entities"` + // Not used. if specified, the Server ignores the value. + // The Server uses the profiles associated with the specified entities. + Profile *PbmProfileId `xml:"profile,omitempty" json:"profile,omitempty"` } func init() { @@ -1005,14 +1792,22 @@ func init() { } type PbmFetchComplianceResultResponse struct { - Returnval []PbmComplianceResult `xml:"returnval,omitempty"` + Returnval []PbmComplianceResult `xml:"returnval,omitempty" json:"returnval,omitempty"` } +// The `PbmFetchEntityHealthStatusSpec` data object contains +// the arguments required for +// `PbmComplianceManager.PbmFetchEntityHealthStatusExt`. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmFetchEntityHealthStatusSpec struct { types.DynamicData - ObjectRef PbmServerObjectRef `xml:"objectRef"` - BackingId string `xml:"backingId,omitempty"` + // `PbmServerObjectRef` for which the healthStatus is required + ObjectRef PbmServerObjectRef `xml:"objectRef" json:"objectRef"` + // BackingId for the ServerObjectRef + // BackingId is mandatory for FCD on vSAN + BackingId string `xml:"backingId,omitempty" json:"backingId,omitempty"` } func init() { @@ -1026,7 +1821,7 @@ func init() { } type PbmFetchResourceTypeRequestType struct { - This types.ManagedObjectReference `xml:"_this"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` } func init() { @@ -1034,7 +1829,7 @@ func init() { } type PbmFetchResourceTypeResponse struct { - Returnval []PbmProfileResourceType `xml:"returnval,omitempty"` + Returnval []PbmProfileResourceType `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmFetchRollupComplianceResult PbmFetchRollupComplianceResultRequestType @@ -1043,9 +1838,14 @@ func init() { types.Add("pbm:PbmFetchRollupComplianceResult", reflect.TypeOf((*PbmFetchRollupComplianceResult)(nil)).Elem()) } +// The parameters of `PbmComplianceManager.PbmFetchRollupComplianceResult`. type PbmFetchRollupComplianceResultRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Entity []PbmServerObjectRef `xml:"entity"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // One or more virtual machines. + // A maximum of 1000 virtual machines can be specified + // in a call. The results of calling the fetchRollupComplianceResult API with + // more than a 1000 entity objects is undefined. + Entity []PbmServerObjectRef `xml:"entity" json:"entity"` } func init() { @@ -1053,7 +1853,7 @@ func init() { } type PbmFetchRollupComplianceResultResponse struct { - Returnval []PbmRollupComplianceResult `xml:"returnval,omitempty"` + Returnval []PbmRollupComplianceResult `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmFetchVendorInfo PbmFetchVendorInfoRequestType @@ -1062,9 +1862,13 @@ func init() { types.Add("pbm:PbmFetchVendorInfo", reflect.TypeOf((*PbmFetchVendorInfo)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmFetchVendorInfo`. type PbmFetchVendorInfoRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - ResourceType *PbmProfileResourceType `xml:"resourceType,omitempty"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Specifies the resource type. The Server supports the STORAGE resource + // type only. If not specified, server defaults to STORAGE resource type. Any other + // resourceType is considered invalid. + ResourceType *PbmProfileResourceType `xml:"resourceType,omitempty" json:"resourceType,omitempty"` } func init() { @@ -1072,7 +1876,7 @@ func init() { } type PbmFetchVendorInfoResponse struct { - Returnval []PbmCapabilityVendorResourceTypeInfo `xml:"returnval,omitempty"` + Returnval []PbmCapabilityVendorResourceTypeInfo `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmFindApplicableDefaultProfile PbmFindApplicableDefaultProfileRequestType @@ -1081,9 +1885,12 @@ func init() { types.Add("pbm:PbmFindApplicableDefaultProfile", reflect.TypeOf((*PbmFindApplicableDefaultProfile)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmFindApplicableDefaultProfile`. type PbmFindApplicableDefaultProfileRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Datastores []PbmPlacementHub `xml:"datastores"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Datastores for which the default profile is found out. Note that + // the datastore pods/clusters are not supported. + Datastores []PbmPlacementHub `xml:"datastores" json:"datastores"` } func init() { @@ -1091,9 +1898,13 @@ func init() { } type PbmFindApplicableDefaultProfileResponse struct { - Returnval []BasePbmProfile `xml:"returnval,omitempty,typeattr"` + Returnval []BasePbmProfile `xml:"returnval,omitempty,typeattr" json:"returnval,omitempty"` } +// Warning fault used to indicate that the vendor specific datastore matches the tag in the +// requirements profile but doesnt match the vendor specific rule set in the requirements profile. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmIncompatibleVendorSpecificRuleSet struct { PbmCapabilityProfilePropertyMismatchFault } @@ -1108,10 +1919,19 @@ func init() { types.Add("pbm:PbmIncompatibleVendorSpecificRuleSetFault", reflect.TypeOf((*PbmIncompatibleVendorSpecificRuleSetFault)(nil)).Elem()) } +// LegacyHubsNotSupported fault is thrown to indicate the legacy hubs that are not supported. +// +// For storage, legacy hubs or datastores are VMFS and NFS datastores. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmLegacyHubsNotSupported struct { PbmFault - Hubs []PbmPlacementHub `xml:"hubs"` + // Legacy hubs that are not supported. + // + // Only datastores will be populated in this fault. Datastore clusters + // are not allowed. + Hubs []PbmPlacementHub `xml:"hubs" json:"hubs"` } func init() { @@ -1124,12 +1944,21 @@ func init() { types.Add("pbm:PbmLegacyHubsNotSupportedFault", reflect.TypeOf((*PbmLegacyHubsNotSupportedFault)(nil)).Elem()) } +// Describes Line of Service of a capability provider. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmLineOfServiceInfo struct { types.DynamicData - LineOfService string `xml:"lineOfService"` - Name PbmExtendedElementDescription `xml:"name"` - Description *PbmExtendedElementDescription `xml:"description,omitempty"` + // `PbmLineOfServiceInfoLineOfServiceEnum_enum` - must be one of the values + // for enum `PbmLineOfServiceInfoLineOfServiceEnum_enum`. + LineOfService string `xml:"lineOfService" json:"lineOfService"` + // Name of the service - for informational + // purposes only. + Name PbmExtendedElementDescription `xml:"name" json:"name"` + // Description of the service - for informational + // purposes only. + Description *PbmExtendedElementDescription `xml:"description,omitempty" json:"description,omitempty"` } func init() { @@ -1139,18 +1968,22 @@ func init() { type PbmLoggingConfiguration struct { types.DynamicData - Component string `xml:"component"` - LogLevel string `xml:"logLevel"` + Component string `xml:"component" json:"component"` + LogLevel string `xml:"logLevel" json:"logLevel"` } func init() { types.Add("pbm:PbmLoggingConfiguration", reflect.TypeOf((*PbmLoggingConfiguration)(nil)).Elem()) } +// NonExistentHubs is thrown to indicate that some non existent datastores are used. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmNonExistentHubs struct { PbmFault - Hubs []PbmPlacementHub `xml:"hubs"` + // Legacy hubs that do not exist. + Hubs []PbmPlacementHub `xml:"hubs" json:"hubs"` } func init() { @@ -1163,72 +1996,140 @@ func init() { types.Add("pbm:PbmNonExistentHubsFault", reflect.TypeOf((*PbmNonExistentHubsFault)(nil)).Elem()) } +// Describes the data services provided by the storage arrays. +// +// In addition to storing bits, some VASA providers may also want to separate +// their capabilities into lines of service to let vSphere manage finer grain +// policies. For example an array may support replication natively, and may +// want vSphere policies to be defined for the replication aspect separately +// and compose them with persistence related policies. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmPersistenceBasedDataServiceInfo struct { PbmLineOfServiceInfo - CompatiblePersistenceSchemaNamespace []string `xml:"compatiblePersistenceSchemaNamespace,omitempty"` + // This property should be set with compatible schema namespaces exposed by + // the vendor provider. + // + // If not specified, vSphere assumes all Data Service + // provider schemas are compatible with all persistence provider namespaces + // advertised by the VASA provider. + CompatiblePersistenceSchemaNamespace []string `xml:"compatiblePersistenceSchemaNamespace,omitempty" json:"compatiblePersistenceSchemaNamespace,omitempty"` } func init() { types.Add("pbm:PbmPersistenceBasedDataServiceInfo", reflect.TypeOf((*PbmPersistenceBasedDataServiceInfo)(nil)).Elem()) } +// Requirement type containing capability constraints +// +// This structure may be used only with operations rendered under `/pbm`. type PbmPlacementCapabilityConstraintsRequirement struct { PbmPlacementRequirement - Constraints BasePbmCapabilityConstraints `xml:"constraints,typeattr"` + // Capability constraints + Constraints BasePbmCapabilityConstraints `xml:"constraints,typeattr" json:"constraints"` } func init() { types.Add("pbm:PbmPlacementCapabilityConstraintsRequirement", reflect.TypeOf((*PbmPlacementCapabilityConstraintsRequirement)(nil)).Elem()) } +// A Requirement for a particular `PbmCapabilityProfile`. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmPlacementCapabilityProfileRequirement struct { PbmPlacementRequirement - ProfileId PbmProfileId `xml:"profileId"` + // Reference to the capability profile being used as a requirement + ProfileId PbmProfileId `xml:"profileId" json:"profileId"` } func init() { types.Add("pbm:PbmPlacementCapabilityProfileRequirement", reflect.TypeOf((*PbmPlacementCapabilityProfileRequirement)(nil)).Elem()) } +// The `PbmPlacementCompatibilityResult` data object +// contains the compatibility result of a placement request. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmPlacementCompatibilityResult struct { types.DynamicData - Hub PbmPlacementHub `xml:"hub"` - MatchingResources []BasePbmPlacementMatchingResources `xml:"matchingResources,omitempty,typeattr"` - HowMany int64 `xml:"howMany,omitempty"` - Utilization []PbmPlacementResourceUtilization `xml:"utilization,omitempty"` - Warning []types.LocalizedMethodFault `xml:"warning,omitempty"` - Error []types.LocalizedMethodFault `xml:"error,omitempty"` + // The Datastore or StoragePod under consideration + // as a location for virtual machine files. + Hub PbmPlacementHub `xml:"hub" json:"hub"` + // Resources that match the policy. + // + // If populated, signifies that there are + // specific resources that match the policy for `PbmPlacementCompatibilityResult.hub`. If null, + // signifies that all resources (for example, hosts connected to the + // datastore or storage pod) are compatible. + MatchingResources []BasePbmPlacementMatchingResources `xml:"matchingResources,omitempty,typeattr" json:"matchingResources,omitempty"` + // How many objects of the kind requested can be provisioned on this + // `PbmPlacementCompatibilityResult.hub`. + HowMany int64 `xml:"howMany,omitempty" json:"howMany,omitempty"` + // This field is not populated if there is no size in the query, i.e. + // + // if the request carries only policy and no size requirements, this + // will not be populated. + Utilization []PbmPlacementResourceUtilization `xml:"utilization,omitempty" json:"utilization,omitempty"` + // Array of faults that describe issues that may affect profile compatibility. + // + // Users should consider these issues before using this Datastore + // or StoragePod and a connected Hosts. + Warning []types.LocalizedMethodFault `xml:"warning,omitempty" json:"warning,omitempty"` + // Array of faults that prevent this datastore or storage pod from being compatible with the + // specified profile, including if no host connected to this `PbmPlacementCompatibilityResult.hub` is compatible. + Error []types.LocalizedMethodFault `xml:"error,omitempty" json:"error,omitempty"` } func init() { types.Add("pbm:PbmPlacementCompatibilityResult", reflect.TypeOf((*PbmPlacementCompatibilityResult)(nil)).Elem()) } +// A `PbmPlacementHub` data object identifies a storage location +// where virtual machine files can be placed. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmPlacementHub struct { types.DynamicData - HubType string `xml:"hubType"` - HubId string `xml:"hubId"` + // Type of the hub. + // + // Currently ManagedObject is the only supported type. + HubType string `xml:"hubType" json:"hubType"` + // Hub identifier; a ManagedObjectReference to a datastore or a storage pod. + HubId string `xml:"hubId" json:"hubId"` } func init() { types.Add("pbm:PbmPlacementHub", reflect.TypeOf((*PbmPlacementHub)(nil)).Elem()) } +// Describes the collection of replication related resources that satisfy a +// policy, for a specific datastore. +// +// This class is returned only when the policy contains replication capabilities. +// For a storage pod, only those replication groups that are common across +// all datastores in the storage pod are considered compatible. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmPlacementMatchingReplicationResources struct { PbmPlacementMatchingResources - ReplicationGroup []types.ReplicationGroupId `xml:"replicationGroup,omitempty"` + // Replication groups that match the policy. + ReplicationGroup []types.ReplicationGroupId `xml:"replicationGroup,omitempty" json:"replicationGroup,omitempty"` } func init() { types.Add("pbm:PbmPlacementMatchingReplicationResources", reflect.TypeOf((*PbmPlacementMatchingReplicationResources)(nil)).Elem()) } +// Describes the collection of resources (for example, hosts) that satisfy a +// policy, for a specific datastore. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmPlacementMatchingResources struct { types.DynamicData } @@ -1237,6 +2138,9 @@ func init() { types.Add("pbm:PbmPlacementMatchingResources", reflect.TypeOf((*PbmPlacementMatchingResources)(nil)).Elem()) } +// Defines a constraint for placing objects onto `PbmPlacementHub`s. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmPlacementRequirement struct { types.DynamicData } @@ -1245,82 +2149,156 @@ func init() { types.Add("pbm:PbmPlacementRequirement", reflect.TypeOf((*PbmPlacementRequirement)(nil)).Elem()) } +// Describes the resource utilization metrics of a datastore. +// +// These results are not to be treated as a guaranteed availability, +// they are useful to estimate the effects of a change of policy +// or the effects of a provisioning action. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmPlacementResourceUtilization struct { types.DynamicData - Name PbmExtendedElementDescription `xml:"name"` - Description PbmExtendedElementDescription `xml:"description"` - AvailableBefore int64 `xml:"availableBefore,omitempty"` - AvailableAfter int64 `xml:"availableAfter,omitempty"` - Total int64 `xml:"total,omitempty"` + // Name of the resource. + Name PbmExtendedElementDescription `xml:"name" json:"name"` + // Description of the resource. + Description PbmExtendedElementDescription `xml:"description" json:"description"` + // Currently available (i.e. + // + // before the provisioning step). + AvailableBefore int64 `xml:"availableBefore,omitempty" json:"availableBefore,omitempty"` + // Available after the provisioning step. + AvailableAfter int64 `xml:"availableAfter,omitempty" json:"availableAfter,omitempty"` + // Total resource availability + Total int64 `xml:"total,omitempty" json:"total,omitempty"` } func init() { types.Add("pbm:PbmPlacementResourceUtilization", reflect.TypeOf((*PbmPlacementResourceUtilization)(nil)).Elem()) } +// The `PbmProfile` data object is the base object +// for storage capability profiles. +// +// This object defines metadata +// for the profile. The derived capability profile represents the +// user's intent for selection and configuration of storage resources +// and/or services that support deployment of virtual machines +// and virtual disks. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmProfile struct { types.DynamicData - ProfileId PbmProfileId `xml:"profileId"` - Name string `xml:"name"` - Description string `xml:"description,omitempty"` - CreationTime time.Time `xml:"creationTime"` - CreatedBy string `xml:"createdBy"` - LastUpdatedTime time.Time `xml:"lastUpdatedTime"` - LastUpdatedBy string `xml:"lastUpdatedBy"` + // Unique identifier for the profile. + ProfileId PbmProfileId `xml:"profileId" json:"profileId"` + Name string `xml:"name" json:"name"` + // Profile description. + Description string `xml:"description,omitempty" json:"description,omitempty"` + // Time stamp of profile creation. + CreationTime time.Time `xml:"creationTime" json:"creationTime"` + // User name of the profile creator. + // + // Set during creation time. + CreatedBy string `xml:"createdBy" json:"createdBy"` + // Time stamp of latest modification to the profile. + LastUpdatedTime time.Time `xml:"lastUpdatedTime" json:"lastUpdatedTime"` + // Name of the user performing the latest modification of the profile. + LastUpdatedBy string `xml:"lastUpdatedBy" json:"lastUpdatedBy"` } func init() { types.Add("pbm:PbmProfile", reflect.TypeOf((*PbmProfile)(nil)).Elem()) } +// Profile unique identifier. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmProfileId struct { types.DynamicData - UniqueId string `xml:"uniqueId"` + // Unique identifier of the profile. + UniqueId string `xml:"uniqueId" json:"uniqueId"` } func init() { types.Add("pbm:PbmProfileId", reflect.TypeOf((*PbmProfileId)(nil)).Elem()) } +// The `PbmProfileOperationOutcome` data object describes the result +// of a `PbmProfileProfileManager` operation. +// +// If there was an +// error during the operation, the object identifies the fault. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmProfileOperationOutcome struct { types.DynamicData - ProfileId PbmProfileId `xml:"profileId"` - Fault *types.LocalizedMethodFault `xml:"fault,omitempty"` + // Identifies the profile specified for the operation. + ProfileId PbmProfileId `xml:"profileId" json:"profileId"` + // One of the `PbmFault` objects. + Fault *types.LocalizedMethodFault `xml:"fault,omitempty" json:"fault,omitempty"` } func init() { types.Add("pbm:PbmProfileOperationOutcome", reflect.TypeOf((*PbmProfileOperationOutcome)(nil)).Elem()) } +// The `PbmProfileResourceType` data object defines the vSphere resource type +// that is supported for profile management. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmProfileResourceType struct { types.DynamicData - ResourceType string `xml:"resourceType"` + // Type of resource to which capability information applies. + // + // resourceType is a string value that corresponds to + // a `PbmProfileResourceTypeEnum_enum` enumeration value. + // Only the STORAGE resource type is supported. + ResourceType string `xml:"resourceType" json:"resourceType"` } func init() { types.Add("pbm:PbmProfileResourceType", reflect.TypeOf((*PbmProfileResourceType)(nil)).Elem()) } +// The `PbmProfileType` identifier is defined by storage providers +// to distinguish between different types of profiles plugged into the system. +// +// An example of a system supported profile type is "CapabilityBasedProfileType" +// which will be the type used for all capability-based profiles created by +// the system using capability metadata information published to the system. +// +// For internal use only. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmProfileType struct { types.DynamicData - UniqueId string `xml:"uniqueId"` + // Unique type identifier for this profile type. + // + // eg "CapabilityBased", or other. + UniqueId string `xml:"uniqueId" json:"uniqueId"` } func init() { types.Add("pbm:PbmProfileType", reflect.TypeOf((*PbmProfileType)(nil)).Elem()) } +// Fault used to indicate which property instance in requirements profile that does not +// match. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmPropertyMismatchFault struct { PbmCompatibilityCheckFault - CapabilityInstanceId PbmCapabilityMetadataUniqueId `xml:"capabilityInstanceId"` - RequirementPropertyInstance PbmCapabilityPropertyInstance `xml:"requirementPropertyInstance"` + // Id of the CapabilityInstance in requirements profile that + // does not match. + CapabilityInstanceId PbmCapabilityMetadataUniqueId `xml:"capabilityInstanceId" json:"capabilityInstanceId"` + // The property instance in requirement profile that does not match. + RequirementPropertyInstance PbmCapabilityPropertyInstance `xml:"requirementPropertyInstance" json:"requirementPropertyInstance"` } func init() { @@ -1339,9 +2317,11 @@ func init() { types.Add("pbm:PbmQueryAssociatedEntities", reflect.TypeOf((*PbmQueryAssociatedEntities)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmQueryAssociatedEntities`. type PbmQueryAssociatedEntitiesRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Profiles []PbmProfileId `xml:"profiles,omitempty"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Storage policy array. + Profiles []PbmProfileId `xml:"profiles,omitempty" json:"profiles,omitempty"` } func init() { @@ -1349,7 +2329,7 @@ func init() { } type PbmQueryAssociatedEntitiesResponse struct { - Returnval []PbmQueryProfileResult `xml:"returnval,omitempty"` + Returnval []PbmQueryProfileResult `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmQueryAssociatedEntity PbmQueryAssociatedEntityRequestType @@ -1358,10 +2338,16 @@ func init() { types.Add("pbm:PbmQueryAssociatedEntity", reflect.TypeOf((*PbmQueryAssociatedEntity)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmQueryAssociatedEntity`. type PbmQueryAssociatedEntityRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Profile PbmProfileId `xml:"profile"` - EntityType string `xml:"entityType,omitempty"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Profile identifier. + Profile PbmProfileId `xml:"profile" json:"profile"` + // If specified, the method returns only those entities + // which match the type. The entityType string value must match + // one of the `PbmObjectType_enum` values. + // If not specified, the method returns all entities associated with the profile. + EntityType string `xml:"entityType,omitempty" json:"entityType,omitempty"` } func init() { @@ -1369,7 +2355,7 @@ func init() { } type PbmQueryAssociatedEntityResponse struct { - Returnval []PbmServerObjectRef `xml:"returnval,omitempty"` + Returnval []PbmServerObjectRef `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmQueryAssociatedProfile PbmQueryAssociatedProfileRequestType @@ -1378,9 +2364,11 @@ func init() { types.Add("pbm:PbmQueryAssociatedProfile", reflect.TypeOf((*PbmQueryAssociatedProfile)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmQueryAssociatedProfile`. type PbmQueryAssociatedProfileRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Entity PbmServerObjectRef `xml:"entity"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Reference to a virtual machine, virtual disk, or datastore. + Entity PbmServerObjectRef `xml:"entity" json:"entity"` } func init() { @@ -1388,7 +2376,7 @@ func init() { } type PbmQueryAssociatedProfileResponse struct { - Returnval []PbmProfileId `xml:"returnval,omitempty"` + Returnval []PbmProfileId `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmQueryAssociatedProfiles PbmQueryAssociatedProfilesRequestType @@ -1397,9 +2385,11 @@ func init() { types.Add("pbm:PbmQueryAssociatedProfiles", reflect.TypeOf((*PbmQueryAssociatedProfiles)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmQueryAssociatedProfiles`. type PbmQueryAssociatedProfilesRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Entities []PbmServerObjectRef `xml:"entities"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Array of server object references. + Entities []PbmServerObjectRef `xml:"entities" json:"entities"` } func init() { @@ -1407,7 +2397,7 @@ func init() { } type PbmQueryAssociatedProfilesResponse struct { - Returnval []PbmQueryProfileResult `xml:"returnval,omitempty"` + Returnval []PbmQueryProfileResult `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmQueryByRollupComplianceStatus PbmQueryByRollupComplianceStatusRequestType @@ -1416,9 +2406,11 @@ func init() { types.Add("pbm:PbmQueryByRollupComplianceStatus", reflect.TypeOf((*PbmQueryByRollupComplianceStatus)(nil)).Elem()) } +// The parameters of `PbmComplianceManager.PbmQueryByRollupComplianceStatus`. type PbmQueryByRollupComplianceStatusRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Status string `xml:"status"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // `PbmComplianceStatus_enum` + Status string `xml:"status" json:"status"` } func init() { @@ -1426,7 +2418,7 @@ func init() { } type PbmQueryByRollupComplianceStatusResponse struct { - Returnval []PbmServerObjectRef `xml:"returnval,omitempty"` + Returnval []PbmServerObjectRef `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmQueryDefaultRequirementProfile PbmQueryDefaultRequirementProfileRequestType @@ -1435,9 +2427,11 @@ func init() { types.Add("pbm:PbmQueryDefaultRequirementProfile", reflect.TypeOf((*PbmQueryDefaultRequirementProfile)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmQueryDefaultRequirementProfile`. type PbmQueryDefaultRequirementProfileRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Hub PbmPlacementHub `xml:"hub"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Placement hub (i.e. datastore). + Hub PbmPlacementHub `xml:"hub" json:"hub"` } func init() { @@ -1445,7 +2439,7 @@ func init() { } type PbmQueryDefaultRequirementProfileResponse struct { - Returnval *PbmProfileId `xml:"returnval,omitempty"` + Returnval *PbmProfileId `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmQueryDefaultRequirementProfiles PbmQueryDefaultRequirementProfilesRequestType @@ -1454,9 +2448,13 @@ func init() { types.Add("pbm:PbmQueryDefaultRequirementProfiles", reflect.TypeOf((*PbmQueryDefaultRequirementProfiles)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmQueryDefaultRequirementProfiles`. type PbmQueryDefaultRequirementProfilesRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Datastores []PbmPlacementHub `xml:"datastores"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // The datastores for which the default profiles are requested. For + // legacy datastores we set + // `DefaultProfileInfo.defaultProfile` to `null`. + Datastores []PbmPlacementHub `xml:"datastores" json:"datastores"` } func init() { @@ -1464,7 +2462,7 @@ func init() { } type PbmQueryDefaultRequirementProfilesResponse struct { - Returnval []PbmDefaultProfileInfo `xml:"returnval"` + Returnval []PbmDefaultProfileInfo `xml:"returnval" json:"returnval"` } type PbmQueryMatchingHub PbmQueryMatchingHubRequestType @@ -1473,10 +2471,15 @@ func init() { types.Add("pbm:PbmQueryMatchingHub", reflect.TypeOf((*PbmQueryMatchingHub)(nil)).Elem()) } +// The parameters of `PbmPlacementSolver.PbmQueryMatchingHub`. type PbmQueryMatchingHubRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - HubsToSearch []PbmPlacementHub `xml:"hubsToSearch,omitempty"` - Profile PbmProfileId `xml:"profile"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Candidate list of hubs, either datastores or storage pods or a + // mix. If this parameter is not specified, the Server uses all + // of the datastores and storage pods. + HubsToSearch []PbmPlacementHub `xml:"hubsToSearch,omitempty" json:"hubsToSearch,omitempty"` + // Storage requirement profile. + Profile PbmProfileId `xml:"profile" json:"profile"` } func init() { @@ -1484,7 +2487,7 @@ func init() { } type PbmQueryMatchingHubResponse struct { - Returnval []PbmPlacementHub `xml:"returnval,omitempty"` + Returnval []PbmPlacementHub `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmQueryMatchingHubWithSpec PbmQueryMatchingHubWithSpecRequestType @@ -1493,10 +2496,15 @@ func init() { types.Add("pbm:PbmQueryMatchingHubWithSpec", reflect.TypeOf((*PbmQueryMatchingHubWithSpec)(nil)).Elem()) } +// The parameters of `PbmPlacementSolver.PbmQueryMatchingHubWithSpec`. type PbmQueryMatchingHubWithSpecRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - HubsToSearch []PbmPlacementHub `xml:"hubsToSearch,omitempty"` - CreateSpec PbmCapabilityProfileCreateSpec `xml:"createSpec"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Candidate list of hubs, either datastores or storage + // pods or a mix. If this parameter is not specified, the Server uses + // all of the datastores and storage pods for placement compatibility checking. + HubsToSearch []PbmPlacementHub `xml:"hubsToSearch,omitempty" json:"hubsToSearch,omitempty"` + // Storage profile creation specification. + CreateSpec PbmCapabilityProfileCreateSpec `xml:"createSpec" json:"createSpec"` } func init() { @@ -1504,7 +2512,7 @@ func init() { } type PbmQueryMatchingHubWithSpecResponse struct { - Returnval []PbmPlacementHub `xml:"returnval,omitempty"` + Returnval []PbmPlacementHub `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmQueryProfile PbmQueryProfileRequestType @@ -1513,10 +2521,16 @@ func init() { types.Add("pbm:PbmQueryProfile", reflect.TypeOf((*PbmQueryProfile)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmQueryProfile`. type PbmQueryProfileRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - ResourceType PbmProfileResourceType `xml:"resourceType"` - ProfileCategory string `xml:"profileCategory,omitempty"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Type of resource. You can specify only STORAGE. + ResourceType PbmProfileResourceType `xml:"resourceType" json:"resourceType"` + // Profile category. The string value must correspond + // to one of the `PbmProfileCategoryEnum_enum` values. + // If you do not specify a profile category, the method returns profiles in all + // categories. + ProfileCategory string `xml:"profileCategory,omitempty" json:"profileCategory,omitempty"` } func init() { @@ -1524,27 +2538,48 @@ func init() { } type PbmQueryProfileResponse struct { - Returnval []PbmProfileId `xml:"returnval,omitempty"` + Returnval []PbmProfileId `xml:"returnval,omitempty" json:"returnval,omitempty"` } +// The `PbmQueryProfileResult` data object +// identifies a virtual machine, virtual disk, or datastore +// and it lists the identifier(s) for the associated profile(s). +// +// This structure may be used only with operations rendered under `/pbm`. type PbmQueryProfileResult struct { types.DynamicData - Object PbmServerObjectRef `xml:"object"` - ProfileId []PbmProfileId `xml:"profileId,omitempty"` - Fault *types.LocalizedMethodFault `xml:"fault,omitempty"` + // Reference to the virtual machine, virtual disk, or + // datastore on which the query was performed. + Object PbmServerObjectRef `xml:"object" json:"object"` + // Array of identifiers for profiles which are associated with object. + ProfileId []PbmProfileId `xml:"profileId,omitempty" json:"profileId,omitempty"` + // Fault associated with the query, if there is one. + Fault *types.LocalizedMethodFault `xml:"fault,omitempty" json:"fault,omitempty"` } func init() { types.Add("pbm:PbmQueryProfileResult", reflect.TypeOf((*PbmQueryProfileResult)(nil)).Elem()) } +// The `PbmQueryReplicationGroupResult` data object +// identifies a virtual machine, or a virtual disk and lists the identifier(s) for the associated +// replication group. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmQueryReplicationGroupResult struct { types.DynamicData - Object PbmServerObjectRef `xml:"object"` - ReplicationGroupId *types.ReplicationGroupId `xml:"replicationGroupId,omitempty"` - Fault *types.LocalizedMethodFault `xml:"fault,omitempty"` + // Reference to the virtual machine or virtual disk on which the query was performed. + // + // If the + // query was performed for a virtual machine and all it's disks, this will reference each disk + // and the virtual machine config individually. + Object PbmServerObjectRef `xml:"object" json:"object"` + // Replication group identifier which is associated with object. + ReplicationGroupId *types.ReplicationGroupId `xml:"replicationGroupId,omitempty" json:"replicationGroupId,omitempty"` + // Fault associated with the query, if there is one. + Fault *types.LocalizedMethodFault `xml:"fault,omitempty" json:"fault,omitempty"` } func init() { @@ -1557,9 +2592,15 @@ func init() { types.Add("pbm:PbmQueryReplicationGroups", reflect.TypeOf((*PbmQueryReplicationGroups)(nil)).Elem()) } +// The parameters of `PbmReplicationManager.PbmQueryReplicationGroups`. type PbmQueryReplicationGroupsRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Entities []PbmServerObjectRef `xml:"entities,omitempty"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Array of server object references. Valid types are + // `virtualMachine`, + // `virtualMachineAndDisks`, + // `virtualDiskId`, + // `virtualDiskUUID` + Entities []PbmServerObjectRef `xml:"entities,omitempty" json:"entities,omitempty"` } func init() { @@ -1567,7 +2608,7 @@ func init() { } type PbmQueryReplicationGroupsResponse struct { - Returnval []PbmQueryReplicationGroupResult `xml:"returnval,omitempty"` + Returnval []PbmQueryReplicationGroupResult `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmQuerySpaceStatsForStorageContainer PbmQuerySpaceStatsForStorageContainerRequestType @@ -1576,10 +2617,15 @@ func init() { types.Add("pbm:PbmQuerySpaceStatsForStorageContainer", reflect.TypeOf((*PbmQuerySpaceStatsForStorageContainer)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmQuerySpaceStatsForStorageContainer`. type PbmQuerySpaceStatsForStorageContainerRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Datastore PbmServerObjectRef `xml:"datastore"` - CapabilityProfileId []PbmProfileId `xml:"capabilityProfileId,omitempty"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Entity for which space statistics are being requested i.e datastore. + Datastore PbmServerObjectRef `xml:"datastore" json:"datastore"` + // \- capability profile Ids. + // If omitted, the statistics for the container + // as a whole would be returned. + CapabilityProfileId []PbmProfileId `xml:"capabilityProfileId,omitempty" json:"capabilityProfileId,omitempty"` } func init() { @@ -1587,7 +2633,7 @@ func init() { } type PbmQuerySpaceStatsForStorageContainerResponse struct { - Returnval []PbmDatastoreSpaceStatistics `xml:"returnval,omitempty"` + Returnval []PbmDatastoreSpaceStatistics `xml:"returnval,omitempty" json:"returnval,omitempty"` } type PbmResetDefaultRequirementProfile PbmResetDefaultRequirementProfileRequestType @@ -1596,9 +2642,11 @@ func init() { types.Add("pbm:PbmResetDefaultRequirementProfile", reflect.TypeOf((*PbmResetDefaultRequirementProfile)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmResetDefaultRequirementProfile`. type PbmResetDefaultRequirementProfileRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - Profile *PbmProfileId `xml:"profile,omitempty"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Profile to reset. + Profile *PbmProfileId `xml:"profile,omitempty" json:"profile,omitempty"` } func init() { @@ -1615,7 +2663,7 @@ func init() { } type PbmResetVSanDefaultProfileRequestType struct { - This types.ManagedObjectReference `xml:"_this"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` } func init() { @@ -1625,11 +2673,20 @@ func init() { type PbmResetVSanDefaultProfileResponse struct { } +// A ResourceInUse fault indicating that some error has occurred because a +// resource was in use. +// +// Information about the resource that is in use may +// be supplied. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmResourceInUse struct { PbmFault - Type string `xml:"type,omitempty"` - Name string `xml:"name,omitempty"` + // Type of resource that is in use. + Type string `xml:"type,omitempty" json:"type,omitempty"` + // Name of the instance of the resource that is in use. + Name string `xml:"name,omitempty" json:"name,omitempty"` } func init() { @@ -1648,9 +2705,11 @@ func init() { types.Add("pbm:PbmRetrieveContent", reflect.TypeOf((*PbmRetrieveContent)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmRetrieveContent`. type PbmRetrieveContentRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - ProfileIds []PbmProfileId `xml:"profileIds"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Array of storage profile identifiers. + ProfileIds []PbmProfileId `xml:"profileIds" json:"profileIds"` } func init() { @@ -1658,7 +2717,7 @@ func init() { } type PbmRetrieveContentResponse struct { - Returnval []BasePbmProfile `xml:"returnval,typeattr"` + Returnval []BasePbmProfile `xml:"returnval,typeattr" json:"returnval"` } type PbmRetrieveServiceContent PbmRetrieveServiceContentRequestType @@ -1668,7 +2727,7 @@ func init() { } type PbmRetrieveServiceContentRequestType struct { - This types.ManagedObjectReference `xml:"_this"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` } func init() { @@ -1676,47 +2735,154 @@ func init() { } type PbmRetrieveServiceContentResponse struct { - Returnval PbmServiceInstanceContent `xml:"returnval"` + Returnval PbmServiceInstanceContent `xml:"returnval" json:"returnval"` } +// The `PbmRollupComplianceResult` data object identifies the virtual machine +// for which rollup compliance was checked, and it contains the overall status +// and a list of compliance result objects. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmRollupComplianceResult struct { types.DynamicData - OldestCheckTime time.Time `xml:"oldestCheckTime"` - Entity PbmServerObjectRef `xml:"entity"` - OverallComplianceStatus string `xml:"overallComplianceStatus"` - OverallComplianceTaskStatus string `xml:"overallComplianceTaskStatus,omitempty"` - Result []PbmComplianceResult `xml:"result,omitempty"` - ErrorCause []types.LocalizedMethodFault `xml:"errorCause,omitempty"` - ProfileMismatch bool `xml:"profileMismatch"` + // Indicates the earliest time that compliance was checked for any + // of the entities in the rollup compliance check. + // + // The compliance + // check time for a single entity is represented in the + // `PbmComplianceResult*.*PbmComplianceResult.checkTime` + // property. If the `PbmComplianceResult.checkTime` + // property is unset for any of the objects in the results + // array, the oldestCheckTime property will be unset. + OldestCheckTime time.Time `xml:"oldestCheckTime" json:"oldestCheckTime"` + // Virtual machine for which the rollup compliance was checked. + Entity PbmServerObjectRef `xml:"entity" json:"entity"` + // Overall compliance status of the virtual machine and its virtual disks. + // + // overallComplianceStatus is a string value that + // corresponds to one of the + // `PbmComplianceResult*.*PbmComplianceResult.complianceStatus` + // values. + // + // The overall compliance status is determined by the following rules, applied in the order + // listed: + // - If all the entities are compliant, the overall status is + // compliant. + // - Else if any entity's status is outOfDate, the overall status is + // outOfDate. + // - Else if any entity's status is nonCompliant, the overall status is + // nonCompliant. + // - Else if any entity's status is unknown, the overall status is + // unknown. + // - Else if any entity's status is notApplicable, the overall status is + // notApplicable. + OverallComplianceStatus string `xml:"overallComplianceStatus" json:"overallComplianceStatus"` + // Overall compliance task status of the virtual machine and its virtual + // disks. + // + // overallComplianceTaskStatus is a string value that + // corresponds to one of the `PbmComplianceResult`. + // `PbmComplianceResult.complianceTaskStatus` values. + OverallComplianceTaskStatus string `xml:"overallComplianceTaskStatus,omitempty" json:"overallComplianceTaskStatus,omitempty"` + // Individual compliance results that make up the rollup. + Result []PbmComplianceResult `xml:"result,omitempty" json:"result,omitempty"` + // This property is set if the overall compliance task fails with some error. + // + // This + // property indicates the causes of error. If there are multiple failures, it stores + // these failure in this array. + ErrorCause []types.LocalizedMethodFault `xml:"errorCause,omitempty" json:"errorCause,omitempty"` + // Deprecated as of vSphere 2016, use + // `PbmRollupComplianceResult.overallComplianceStatus` + // to know if profile mismatch has occurred. If + // overallComplianceStatus value is outOfDate, it means + // profileMismatch has occurred. + // + // True if and only if `PbmComplianceResult`. + // + // `PbmComplianceResult.mismatch` is true for at least one + // entity in the rollup compliance check. + ProfileMismatch bool `xml:"profileMismatch" json:"profileMismatch"` } func init() { types.Add("pbm:PbmRollupComplianceResult", reflect.TypeOf((*PbmRollupComplianceResult)(nil)).Elem()) } +// The `PbmServerObjectRef` data object identifies +// a virtual machine, +// virtual disk attached to a virtual machine, +// a first class storage object +// or a datastore. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmServerObjectRef struct { types.DynamicData - ObjectType string `xml:"objectType"` - Key string `xml:"key"` - ServerUuid string `xml:"serverUuid,omitempty"` + // Type of vSphere Server object. + // + // The value of the objectType string + // corresponds to one of the `PbmObjectType_enum` + // enumerated type values. + ObjectType string `xml:"objectType" json:"objectType"` + // Unique identifier for the object. + // + // The value of key depends + // on the objectType. + // + // + // + // + // + // + // + // + // + //
`*PbmObjectType***`key value**
virtualMachine_virtual-machine-MOR_
virtualDiskId_virtual-disk-MOR_:_VirtualDisk.key_
datastore_datastore-MOR_
MOR = ManagedObjectReference
+ Key string `xml:"key" json:"key"` + // vCenter Server UUID; the ServiceContent.about.instanceUuid + // property in the vSphere API. + ServerUuid string `xml:"serverUuid,omitempty" json:"serverUuid,omitempty"` } func init() { types.Add("pbm:PbmServerObjectRef", reflect.TypeOf((*PbmServerObjectRef)(nil)).Elem()) } +// The `PbmServiceInstanceContent` data object defines properties for the +// `PbmServiceInstance` managed object. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmServiceInstanceContent struct { types.DynamicData - AboutInfo PbmAboutInfo `xml:"aboutInfo"` - SessionManager types.ManagedObjectReference `xml:"sessionManager"` - CapabilityMetadataManager types.ManagedObjectReference `xml:"capabilityMetadataManager"` - ProfileManager types.ManagedObjectReference `xml:"profileManager"` - ComplianceManager types.ManagedObjectReference `xml:"complianceManager"` - PlacementSolver types.ManagedObjectReference `xml:"placementSolver"` - ReplicationManager *types.ManagedObjectReference `xml:"replicationManager,omitempty"` + // Contains information that identifies the Storage Policy service. + AboutInfo PbmAboutInfo `xml:"aboutInfo" json:"aboutInfo"` + // For internal use. + // + // Refers instance of `PbmSessionManager`. + SessionManager types.ManagedObjectReference `xml:"sessionManager" json:"sessionManager"` + // For internal use. + // + // Refers instance of `PbmCapabilityMetadataManager`. + CapabilityMetadataManager types.ManagedObjectReference `xml:"capabilityMetadataManager" json:"capabilityMetadataManager"` + // Provides access to the Storage Policy ProfileManager. + // + // Refers instance of `PbmProfileProfileManager`. + ProfileManager types.ManagedObjectReference `xml:"profileManager" json:"profileManager"` + // Provides access to the Storage Policy ComplianceManager. + // + // Refers instance of `PbmComplianceManager`. + ComplianceManager types.ManagedObjectReference `xml:"complianceManager" json:"complianceManager"` + // Provides access to the Storage Policy PlacementSolver. + // + // Refers instance of `PbmPlacementSolver`. + PlacementSolver types.ManagedObjectReference `xml:"placementSolver" json:"placementSolver"` + // Provides access to the Storage Policy ReplicationManager. + // + // Refers instance of `PbmReplicationManager`. + ReplicationManager *types.ManagedObjectReference `xml:"replicationManager,omitempty" json:"replicationManager,omitempty"` } func init() { @@ -1729,10 +2895,13 @@ func init() { types.Add("pbm:PbmUpdate", reflect.TypeOf((*PbmUpdate)(nil)).Elem()) } +// The parameters of `PbmProfileProfileManager.PbmUpdate`. type PbmUpdateRequestType struct { - This types.ManagedObjectReference `xml:"_this"` - ProfileId PbmProfileId `xml:"profileId"` - UpdateSpec PbmCapabilityProfileUpdateSpec `xml:"updateSpec"` + This types.ManagedObjectReference `xml:"_this" json:"_this"` + // Profile identifier. + ProfileId PbmProfileId `xml:"profileId" json:"profileId"` + // Capability-based update specification. + UpdateSpec PbmCapabilityProfileUpdateSpec `xml:"updateSpec" json:"updateSpec"` } func init() { @@ -1742,6 +2911,10 @@ func init() { type PbmUpdateResponse struct { } +// Information about a supported data service provided using +// vSphere APIs for IO Filtering (VAIO) data service provider. +// +// This structure may be used only with operations rendered under `/pbm`. type PbmVaioDataServiceInfo struct { PbmLineOfServiceInfo } diff --git a/vendor/github.com/vmware/govmomi/property/collector.go b/vendor/github.com/vmware/govmomi/property/collector.go index 8798ceacbf..16bf222669 100644 --- a/vendor/github.com/vmware/govmomi/property/collector.go +++ b/vendor/github.com/vmware/govmomi/property/collector.go @@ -1,11 +1,11 @@ /* -Copyright (c) 2015 VMware, Inc. All Rights Reserved. +Copyright (c) 2015-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -31,7 +31,6 @@ import ( // // For more information, see: // http://pubs.vmware.com/vsphere-60/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc%2Fvmodl.query.PropertyCollector.html -// type Collector struct { roundTripper soap.RoundTripper reference types.ManagedObjectReference diff --git a/vendor/github.com/vmware/govmomi/task/wait.go b/vendor/github.com/vmware/govmomi/task/wait.go index b78f5110d9..d52458e667 100644 --- a/vendor/github.com/vmware/govmomi/task/wait.go +++ b/vendor/github.com/vmware/govmomi/task/wait.go @@ -1,11 +1,11 @@ /* -Copyright (c) 2015 VMware, Inc. All Rights Reserved. +Copyright (c) 2015-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -113,7 +113,6 @@ func (t *taskCallback) fn(pc []types.PropertyChange) bool { // The detail for the progress update is set to an empty string. If the task // finishes in the error state, the error instance is passed through as well. // Note that this error is the same error that is returned by this function. -// func Wait(ctx context.Context, ref types.ManagedObjectReference, pc *property.Collector, s progress.Sinker) (*types.TaskInfo, error) { cb := &taskCallback{} diff --git a/vendor/github.com/vmware/govmomi/vapi/internal/internal.go b/vendor/github.com/vmware/govmomi/vapi/internal/internal.go index f6584c569b..2872f38030 100644 --- a/vendor/github.com/vmware/govmomi/vapi/internal/internal.go +++ b/vendor/github.com/vmware/govmomi/vapi/internal/internal.go @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2022 VMware, Inc. All Rights Reserved. +Copyright (c) 2018-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -43,7 +43,6 @@ const ( TrustedCertificatesPath = "/api/content/trusted-certificates" VCenterOVFLibraryItem = "/com/vmware/vcenter/ovf/library-item" VCenterVMTXLibraryItem = "/vcenter/vm-template/library-items" - VCenterVM = "/vcenter/vm" SessionCookieName = "vmware-api-session-id" UseHeaderAuthn = "vmware-use-header-authn" DebugEcho = "/vc-sim/debug/echo" @@ -59,7 +58,10 @@ type AssociatedObject struct { // Reference implements mo.Reference func (o AssociatedObject) Reference() types.ManagedObjectReference { - return types.ManagedObjectReference(o) + return types.ManagedObjectReference{ + Type: o.Type, + Value: o.Value, + } } // Association for tag-association requests. @@ -69,9 +71,11 @@ type Association struct { // NewAssociation returns an Association, converting ref to an AssociatedObject. func NewAssociation(ref mo.Reference) Association { - obj := AssociatedObject(ref.Reference()) return Association{ - ObjectID: &obj, + ObjectID: &AssociatedObject{ + Type: ref.Reference().Type, + Value: ref.Reference().Value, + }, } } diff --git a/vendor/github.com/vmware/govmomi/vapi/library/finder/README.md b/vendor/github.com/vmware/govmomi/vapi/library/finder/README.md index 1e2b90030a..62331f2673 100644 --- a/vendor/github.com/vmware/govmomi/vapi/library/finder/README.md +++ b/vendor/github.com/vmware/govmomi/vapi/library/finder/README.md @@ -1,5 +1,5 @@ # The content library finder -The govmomi package now includes a finder for the content library, [`github.com/vmware/govmomi/vapi/library.Finder`](https://github.com/akutz/govmomi/blob/feature/content-library/vapi/library/finder/finder.go). This finder supports searching for objects in the content library using an inventory path design similar to the [standard govmomi finder](https://github.com/vmware/govmomi/blob/master/find/finder.go) and includes support for wildcard matching courtesy of golang's [`path.Match`](https://golang.org/pkg/path/#Match). For example: +The govmomi package now includes a finder for the content library, [`github.com/vmware/govmomi/vapi/library.Finder`](https://github.com/akutz/govmomi/blob/feature/content-library/vapi/library/finder/finder.go). This finder supports searching for objects in the content library using an inventory path design similar to the [standard govmomi finder](https://github.com/vmware/govmomi/blob/main/find/finder.go) and includes support for wildcard matching courtesy of golang's [`path.Match`](https://golang.org/pkg/path/#Match). For example: | Pattern | Result | |---------|--------| diff --git a/vendor/github.com/vmware/govmomi/vapi/library/library.go b/vendor/github.com/vmware/govmomi/vapi/library/library.go index e5e5d0896f..62ad873bc5 100644 --- a/vendor/github.com/vmware/govmomi/vapi/library/library.go +++ b/vendor/github.com/vmware/govmomi/vapi/library/library.go @@ -1,5 +1,5 @@ /* -Copyright (c) 2018 VMware, Inc. All Rights Reserved. +Copyright (c) 2018-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ type StorageBackings struct { // Library provides methods to create, read, update, delete, and enumerate libraries. type Library struct { CreationTime *time.Time `json:"creation_time,omitempty"` - Description string `json:"description,omitempty"` + Description *string `json:"description,omitempty"` ID string `json:"id,omitempty"` LastModifiedTime *time.Time `json:"last_modified_time,omitempty"` LastSyncTime *time.Time `json:"last_sync_time,omitempty"` @@ -120,7 +120,7 @@ func (l *Library) Patch(src *Library) { if src.Name != "" { l.Name = src.Name } - if src.Description != "" { + if src.Description != nil { l.Description = src.Description } if src.Version != "" { diff --git a/vendor/github.com/vmware/govmomi/vapi/library/library_item.go b/vendor/github.com/vmware/govmomi/vapi/library/library_item.go index adc2101ab1..e143da5d96 100644 --- a/vendor/github.com/vmware/govmomi/vapi/library/library_item.go +++ b/vendor/github.com/vmware/govmomi/vapi/library/library_item.go @@ -36,7 +36,7 @@ type Item struct { Cached bool `json:"cached,omitempty"` ContentVersion string `json:"content_version,omitempty"` CreationTime *time.Time `json:"creation_time,omitempty"` - Description string `json:"description,omitempty"` + Description *string `json:"description,omitempty"` ID string `json:"id,omitempty"` LastModifiedTime *time.Time `json:"last_modified_time,omitempty"` LastSyncTime *time.Time `json:"last_sync_time,omitempty"` @@ -63,7 +63,7 @@ func (i *Item) Patch(src *Item) { if src.Name != "" { i.Name = src.Name } - if src.Description != "" { + if src.Description != nil { i.Description = src.Description } if src.Type != "" { @@ -82,12 +82,17 @@ func (c *Manager) CreateLibraryItem(ctx context.Context, item Item) (string, err LibraryID string `json:"library_id,omitempty"` Type string `json:"type"` } + + description := "" + if item.Description != nil { + description = *item.Description + } spec := struct { Item createItemSpec `json:"create_spec"` }{ Item: createItemSpec{ Name: item.Name, - Description: item.Description, + Description: description, LibraryID: item.LibraryID, Type: item.Type, }, diff --git a/vendor/github.com/vmware/govmomi/vim25/client.go b/vendor/github.com/vmware/govmomi/vim25/client.go index b14cea8520..6101330953 100644 --- a/vendor/github.com/vmware/govmomi/vim25/client.go +++ b/vendor/github.com/vmware/govmomi/vim25/client.go @@ -1,11 +1,11 @@ /* -Copyright (c) 2015-2016 VMware, Inc. All Rights Reserved. +Copyright (c) 2015-2023 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -32,7 +32,7 @@ import ( const ( Namespace = "vim25" - Version = "7.0" + Version = "8.0.2.0" Path = "/sdk" ) diff --git a/vendor/github.com/vmware/govmomi/vim25/json/LICENSE b/vendor/github.com/vmware/govmomi/vim25/json/LICENSE new file mode 100644 index 0000000000..6a66aea5ea --- /dev/null +++ b/vendor/github.com/vmware/govmomi/vim25/json/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/vmware/govmomi/vim25/json/README.md b/vendor/github.com/vmware/govmomi/vim25/json/README.md new file mode 100644 index 0000000000..6cbe80349a --- /dev/null +++ b/vendor/github.com/vmware/govmomi/vim25/json/README.md @@ -0,0 +1,9 @@ +# JSON with Discriminators + +The source code in this directory was copied from Go 1.17.13's `encoding/json` package in order to add support for JSON discriminators. Please use the following command to review the diff: + +```shell +C1="$(git log --pretty=format:'%h' --no-patch --grep='Vendor Go 1.17.13 encoding/json')" && \ +C2="$(git log --pretty=format:'%h' --no-patch --grep='JSON Encoding w Discriminator Support')" && \ +git diff "${C1}".."${C2}" +``` diff --git a/vendor/github.com/vmware/govmomi/vim25/json/decode.go b/vendor/github.com/vmware/govmomi/vim25/json/decode.go new file mode 100644 index 0000000000..6a92a2410b --- /dev/null +++ b/vendor/github.com/vmware/govmomi/vim25/json/decode.go @@ -0,0 +1,1319 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Represents JSON data structure using native Go types: booleans, floats, +// strings, arrays, and maps. + +package json + +import ( + "encoding" + "encoding/base64" + "fmt" + "reflect" + "strconv" + "strings" + "unicode" + "unicode/utf16" + "unicode/utf8" +) + +// Unmarshal parses the JSON-encoded data and stores the result +// in the value pointed to by v. If v is nil or not a pointer, +// Unmarshal returns an InvalidUnmarshalError. +// +// Unmarshal uses the inverse of the encodings that +// Marshal uses, allocating maps, slices, and pointers as necessary, +// with the following additional rules: +// +// To unmarshal JSON into a pointer, Unmarshal first handles the case of +// the JSON being the JSON literal null. In that case, Unmarshal sets +// the pointer to nil. Otherwise, Unmarshal unmarshals the JSON into +// the value pointed at by the pointer. If the pointer is nil, Unmarshal +// allocates a new value for it to point to. +// +// To unmarshal JSON into a value implementing the Unmarshaler interface, +// Unmarshal calls that value's UnmarshalJSON method, including +// when the input is a JSON null. +// Otherwise, if the value implements encoding.TextUnmarshaler +// and the input is a JSON quoted string, Unmarshal calls that value's +// UnmarshalText method with the unquoted form of the string. +// +// To unmarshal JSON into a struct, Unmarshal matches incoming object +// keys to the keys used by Marshal (either the struct field name or its tag), +// preferring an exact match but also accepting a case-insensitive match. By +// default, object keys which don't have a corresponding struct field are +// ignored (see Decoder.DisallowUnknownFields for an alternative). +// +// To unmarshal JSON into an interface value, +// Unmarshal stores one of these in the interface value: +// +// bool, for JSON booleans +// float64, for JSON numbers +// string, for JSON strings +// []interface{}, for JSON arrays +// map[string]interface{}, for JSON objects +// nil for JSON null +// +// To unmarshal a JSON array into a slice, Unmarshal resets the slice length +// to zero and then appends each element to the slice. +// As a special case, to unmarshal an empty JSON array into a slice, +// Unmarshal replaces the slice with a new empty slice. +// +// To unmarshal a JSON array into a Go array, Unmarshal decodes +// JSON array elements into corresponding Go array elements. +// If the Go array is smaller than the JSON array, +// the additional JSON array elements are discarded. +// If the JSON array is smaller than the Go array, +// the additional Go array elements are set to zero values. +// +// To unmarshal a JSON object into a map, Unmarshal first establishes a map to +// use. If the map is nil, Unmarshal allocates a new map. Otherwise Unmarshal +// reuses the existing map, keeping existing entries. Unmarshal then stores +// key-value pairs from the JSON object into the map. The map's key type must +// either be any string type, an integer, implement json.Unmarshaler, or +// implement encoding.TextUnmarshaler. +// +// If a JSON value is not appropriate for a given target type, +// or if a JSON number overflows the target type, Unmarshal +// skips that field and completes the unmarshaling as best it can. +// If no more serious errors are encountered, Unmarshal returns +// an UnmarshalTypeError describing the earliest such error. In any +// case, it's not guaranteed that all the remaining fields following +// the problematic one will be unmarshaled into the target object. +// +// The JSON null value unmarshals into an interface, map, pointer, or slice +// by setting that Go value to nil. Because null is often used in JSON to mean +// ``not present,'' unmarshaling a JSON null into any other Go type has no effect +// on the value and produces no error. +// +// When unmarshaling quoted strings, invalid UTF-8 or +// invalid UTF-16 surrogate pairs are not treated as an error. +// Instead, they are replaced by the Unicode replacement +// character U+FFFD. +// +func Unmarshal(data []byte, v interface{}) error { + // Check for well-formedness. + // Avoids filling out half a data structure + // before discovering a JSON syntax error. + var d decodeState + err := checkValid(data, &d.scan) + if err != nil { + return err + } + + d.init(data) + return d.unmarshal(v) +} + +// Unmarshaler is the interface implemented by types +// that can unmarshal a JSON description of themselves. +// The input can be assumed to be a valid encoding of +// a JSON value. UnmarshalJSON must copy the JSON data +// if it wishes to retain the data after returning. +// +// By convention, to approximate the behavior of Unmarshal itself, +// Unmarshalers implement UnmarshalJSON([]byte("null")) as a no-op. +type Unmarshaler interface { + UnmarshalJSON([]byte) error +} + +// An UnmarshalTypeError describes a JSON value that was +// not appropriate for a value of a specific Go type. +type UnmarshalTypeError struct { + Value string // description of JSON value - "bool", "array", "number -5" + Type reflect.Type // type of Go value it could not be assigned to + Offset int64 // error occurred after reading Offset bytes + Struct string // name of the struct type containing the field + Field string // the full path from root node to the field +} + +func (e *UnmarshalTypeError) Error() string { + if e.Struct != "" || e.Field != "" { + return "json: cannot unmarshal " + e.Value + " into Go struct field " + e.Struct + "." + e.Field + " of type " + e.Type.String() + } + return "json: cannot unmarshal " + e.Value + " into Go value of type " + e.Type.String() +} + +// An UnmarshalFieldError describes a JSON object key that +// led to an unexported (and therefore unwritable) struct field. +// +// Deprecated: No longer used; kept for compatibility. +type UnmarshalFieldError struct { + Key string + Type reflect.Type + Field reflect.StructField +} + +func (e *UnmarshalFieldError) Error() string { + return "json: cannot unmarshal object key " + strconv.Quote(e.Key) + " into unexported field " + e.Field.Name + " of type " + e.Type.String() +} + +// An InvalidUnmarshalError describes an invalid argument passed to Unmarshal. +// (The argument to Unmarshal must be a non-nil pointer.) +type InvalidUnmarshalError struct { + Type reflect.Type +} + +func (e *InvalidUnmarshalError) Error() string { + if e.Type == nil { + return "json: Unmarshal(nil)" + } + + if e.Type.Kind() != reflect.Ptr { + return "json: Unmarshal(non-pointer " + e.Type.String() + ")" + } + return "json: Unmarshal(nil " + e.Type.String() + ")" +} + +func (d *decodeState) unmarshal(v interface{}) error { + rv := reflect.ValueOf(v) + if rv.Kind() != reflect.Ptr || rv.IsNil() { + return &InvalidUnmarshalError{reflect.TypeOf(v)} + } + + d.scan.reset() + d.scanWhile(scanSkipSpace) + // We decode rv not rv.Elem because the Unmarshaler interface + // test must be applied at the top level of the value. + err := d.value(rv) + if err != nil { + return d.addErrorContext(err) + } + return d.savedError +} + +// A Number represents a JSON number literal. +type Number string + +// String returns the literal text of the number. +func (n Number) String() string { return string(n) } + +// Float64 returns the number as a float64. +func (n Number) Float64() (float64, error) { + return strconv.ParseFloat(string(n), 64) +} + +// Int64 returns the number as an int64. +func (n Number) Int64() (int64, error) { + return strconv.ParseInt(string(n), 10, 64) +} + +// An errorContext provides context for type errors during decoding. +type errorContext struct { + Struct reflect.Type + FieldStack []string +} + +// decodeState represents the state while decoding a JSON value. +type decodeState struct { + data []byte + off int // next read offset in data + opcode int // last read result + scan scanner + errorContext *errorContext + savedError error + useNumber bool + disallowUnknownFields bool + + discriminatorTypeFieldName string + discriminatorValueFieldName string + discriminatorToTypeFn DiscriminatorToTypeFunc +} + +// readIndex returns the position of the last byte read. +func (d *decodeState) readIndex() int { + return d.off - 1 +} + +// phasePanicMsg is used as a panic message when we end up with something that +// shouldn't happen. It can indicate a bug in the JSON decoder, or that +// something is editing the data slice while the decoder executes. +const phasePanicMsg = "JSON decoder out of sync - data changing underfoot?" + +func (d *decodeState) init(data []byte) *decodeState { + d.data = data + d.off = 0 + d.savedError = nil + if d.errorContext != nil { + d.errorContext.Struct = nil + // Reuse the allocated space for the FieldStack slice. + d.errorContext.FieldStack = d.errorContext.FieldStack[:0] + } + return d +} + +// saveError saves the first err it is called with, +// for reporting at the end of the unmarshal. +func (d *decodeState) saveError(err error) { + if d.savedError == nil { + d.savedError = d.addErrorContext(err) + } +} + +// addErrorContext returns a new error enhanced with information from d.errorContext +func (d *decodeState) addErrorContext(err error) error { + if d.errorContext != nil && (d.errorContext.Struct != nil || len(d.errorContext.FieldStack) > 0) { + switch err := err.(type) { + case *UnmarshalTypeError: + err.Struct = d.errorContext.Struct.Name() + err.Field = strings.Join(d.errorContext.FieldStack, ".") + } + } + return err +} + +// skip scans to the end of what was started. +func (d *decodeState) skip() { + s, data, i := &d.scan, d.data, d.off + depth := len(s.parseState) + for { + op := s.step(s, data[i]) + i++ + if len(s.parseState) < depth { + d.off = i + d.opcode = op + return + } + } +} + +// scanNext processes the byte at d.data[d.off]. +func (d *decodeState) scanNext() { + if d.off < len(d.data) { + d.opcode = d.scan.step(&d.scan, d.data[d.off]) + d.off++ + } else { + d.opcode = d.scan.eof() + d.off = len(d.data) + 1 // mark processed EOF with len+1 + } +} + +// scanWhile processes bytes in d.data[d.off:] until it +// receives a scan code not equal to op. +func (d *decodeState) scanWhile(op int) { + s, data, i := &d.scan, d.data, d.off + for i < len(data) { + newOp := s.step(s, data[i]) + i++ + if newOp != op { + d.opcode = newOp + d.off = i + return + } + } + + d.off = len(data) + 1 // mark processed EOF with len+1 + d.opcode = d.scan.eof() +} + +// rescanLiteral is similar to scanWhile(scanContinue), but it specialises the +// common case where we're decoding a literal. The decoder scans the input +// twice, once for syntax errors and to check the length of the value, and the +// second to perform the decoding. +// +// Only in the second step do we use decodeState to tokenize literals, so we +// know there aren't any syntax errors. We can take advantage of that knowledge, +// and scan a literal's bytes much more quickly. +func (d *decodeState) rescanLiteral() { + data, i := d.data, d.off +Switch: + switch data[i-1] { + case '"': // string + for ; i < len(data); i++ { + switch data[i] { + case '\\': + i++ // escaped char + case '"': + i++ // tokenize the closing quote too + break Switch + } + } + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-': // number + for ; i < len(data); i++ { + switch data[i] { + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '.', 'e', 'E', '+', '-': + default: + break Switch + } + } + case 't': // true + i += len("rue") + case 'f': // false + i += len("alse") + case 'n': // null + i += len("ull") + } + if i < len(data) { + d.opcode = stateEndValue(&d.scan, data[i]) + } else { + d.opcode = scanEnd + } + d.off = i + 1 +} + +// value consumes a JSON value from d.data[d.off-1:], decoding into v, and +// reads the following byte ahead. If v is invalid, the value is discarded. +// The first byte of the value has been read already. +func (d *decodeState) value(v reflect.Value) error { + switch d.opcode { + default: + panic(phasePanicMsg) + + case scanBeginArray: + if v.IsValid() { + if err := d.array(v); err != nil { + return err + } + } else { + d.skip() + } + d.scanNext() + + case scanBeginObject: + if v.IsValid() { + if err := d.object(v); err != nil { + return err + } + } else { + d.skip() + } + d.scanNext() + + case scanBeginLiteral: + // All bytes inside literal return scanContinue op code. + start := d.readIndex() + d.rescanLiteral() + + if v.IsValid() { + if err := d.literalStore(d.data[start:d.readIndex()], v, false); err != nil { + return err + } + } + } + return nil +} + +type unquotedValue struct{} + +// valueQuoted is like value but decodes a +// quoted string literal or literal null into an interface value. +// If it finds anything other than a quoted string literal or null, +// valueQuoted returns unquotedValue{}. +func (d *decodeState) valueQuoted() interface{} { + switch d.opcode { + default: + panic(phasePanicMsg) + + case scanBeginArray, scanBeginObject: + d.skip() + d.scanNext() + + case scanBeginLiteral: + v := d.literalInterface() + switch v.(type) { + case nil, string: + return v + } + } + return unquotedValue{} +} + +// indirect walks down v allocating pointers as needed, +// until it gets to a non-pointer. +// If it encounters an Unmarshaler, indirect stops and returns that. +// If decodingNull is true, indirect stops at the first settable pointer so it +// can be set to nil. +func indirect(v reflect.Value, decodingNull bool) (Unmarshaler, encoding.TextUnmarshaler, reflect.Value) { + // Issue #24153 indicates that it is generally not a guaranteed property + // that you may round-trip a reflect.Value by calling Value.Addr().Elem() + // and expect the value to still be settable for values derived from + // unexported embedded struct fields. + // + // The logic below effectively does this when it first addresses the value + // (to satisfy possible pointer methods) and continues to dereference + // subsequent pointers as necessary. + // + // After the first round-trip, we set v back to the original value to + // preserve the original RW flags contained in reflect.Value. + v0 := v + haveAddr := false + + // If v is a named type and is addressable, + // start with its address, so that if the type has pointer methods, + // we find them. + if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() { + haveAddr = true + v = v.Addr() + } + for { + // Load value from interface, but only if the result will be + // usefully addressable. + if v.Kind() == reflect.Interface && !v.IsNil() { + e := v.Elem() + if e.Kind() == reflect.Ptr && !e.IsNil() && (!decodingNull || e.Elem().Kind() == reflect.Ptr) { + haveAddr = false + v = e + continue + } + } + + if v.Kind() != reflect.Ptr { + break + } + + if decodingNull && v.CanSet() { + break + } + + // Prevent infinite loop if v is an interface pointing to its own address: + // var v interface{} + // v = &v + if v.Elem().Kind() == reflect.Interface && v.Elem().Elem() == v { + v = v.Elem() + break + } + if v.IsNil() { + v.Set(reflect.New(v.Type().Elem())) + } + if v.Type().NumMethod() > 0 && v.CanInterface() { + if u, ok := v.Interface().(Unmarshaler); ok { + return u, nil, reflect.Value{} + } + if !decodingNull { + if u, ok := v.Interface().(encoding.TextUnmarshaler); ok { + return nil, u, reflect.Value{} + } + } + } + + if haveAddr { + v = v0 // restore original value after round-trip Value.Addr().Elem() + haveAddr = false + } else { + v = v.Elem() + } + } + return nil, nil, v +} + +// array consumes an array from d.data[d.off-1:], decoding into v. +// The first byte of the array ('[') has been read already. +func (d *decodeState) array(v reflect.Value) error { + // Check for unmarshaler. + u, ut, pv := indirect(v, false) + if u != nil { + start := d.readIndex() + d.skip() + return u.UnmarshalJSON(d.data[start:d.off]) + } + if ut != nil { + d.saveError(&UnmarshalTypeError{Value: "array", Type: v.Type(), Offset: int64(d.off)}) + d.skip() + return nil + } + v = pv + + // Check type of target. + switch v.Kind() { + case reflect.Interface: + if v.NumMethod() == 0 { + // Decoding into nil interface? Switch to non-reflect code. + ai := d.arrayInterface() + v.Set(reflect.ValueOf(ai)) + return nil + } + // Otherwise it's invalid. + fallthrough + default: + d.saveError(&UnmarshalTypeError{Value: "array", Type: v.Type(), Offset: int64(d.off)}) + d.skip() + return nil + case reflect.Array, reflect.Slice: + break + } + + i := 0 + for { + // Look ahead for ] - can only happen on first iteration. + d.scanWhile(scanSkipSpace) + if d.opcode == scanEndArray { + break + } + + // Get element of array, growing if necessary. + if v.Kind() == reflect.Slice { + // Grow slice if necessary + if i >= v.Cap() { + newcap := v.Cap() + v.Cap()/2 + if newcap < 4 { + newcap = 4 + } + newv := reflect.MakeSlice(v.Type(), v.Len(), newcap) + reflect.Copy(newv, v) + v.Set(newv) + } + if i >= v.Len() { + v.SetLen(i + 1) + } + } + + if i < v.Len() { + // Decode into element. + if err := d.value(v.Index(i)); err != nil { + return err + } + } else { + // Ran out of fixed array: skip. + if err := d.value(reflect.Value{}); err != nil { + return err + } + } + i++ + + // Next token must be , or ]. + if d.opcode == scanSkipSpace { + d.scanWhile(scanSkipSpace) + } + if d.opcode == scanEndArray { + break + } + if d.opcode != scanArrayValue { + panic(phasePanicMsg) + } + } + + if i < v.Len() { + if v.Kind() == reflect.Array { + // Array. Zero the rest. + z := reflect.Zero(v.Type().Elem()) + for ; i < v.Len(); i++ { + v.Index(i).Set(z) + } + } else { + v.SetLen(i) + } + } + if i == 0 && v.Kind() == reflect.Slice { + v.Set(reflect.MakeSlice(v.Type(), 0, 0)) + } + return nil +} + +var nullLiteral = []byte("null") +var textUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem() + +// object consumes an object from d.data[d.off-1:], decoding into v. +// The first byte ('{') of the object has been read already. +func (d *decodeState) object(v reflect.Value) error { + // Check for unmarshaler. + u, ut, pv := indirect(v, false) + if u != nil { + start := d.readIndex() + d.skip() + return u.UnmarshalJSON(d.data[start:d.off]) + } + if ut != nil { + d.saveError(&UnmarshalTypeError{Value: "object", Type: v.Type(), Offset: int64(d.off)}) + d.skip() + return nil + } + v = pv + t := v.Type() + + // Decoding into nil interface? Switch to non-reflect code. + if v.Kind() == reflect.Interface && v.NumMethod() == 0 && !d.isDiscriminatorSet() { + oi := d.objectInterface() + v.Set(reflect.ValueOf(oi)) + return nil + } + + var fields structFields + + // Check type of target: + // struct or + // map[T1]T2 where T1 is string, an integer type, + // or an encoding.TextUnmarshaler + switch v.Kind() { + case reflect.Map: + // Map key must either have string kind, have an integer kind, + // or be an encoding.TextUnmarshaler. + switch t.Key().Kind() { + case reflect.String, + reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + default: + if !reflect.PtrTo(t.Key()).Implements(textUnmarshalerType) { + d.saveError(&UnmarshalTypeError{Value: "object", Type: t, Offset: int64(d.off)}) + d.skip() + return nil + } + } + if v.IsNil() { + v.Set(reflect.MakeMap(t)) + } + case reflect.Struct: + fields = cachedTypeFields(t) + // ok + default: + if d.isDiscriminatorSet() { + return d.discriminatorInterfaceDecode(t, v) + } + d.saveError(&UnmarshalTypeError{Value: "object", Type: t, Offset: int64(d.off)}) + d.skip() + return nil + } + + var mapElem reflect.Value + var origErrorContext errorContext + if d.errorContext != nil { + origErrorContext = *d.errorContext + } + + for { + // Read opening " of string key or closing }. + d.scanWhile(scanSkipSpace) + if d.opcode == scanEndObject { + // closing } - can only happen on first iteration. + break + } + if d.opcode != scanBeginLiteral { + panic(phasePanicMsg) + } + + // Read key. + start := d.readIndex() + d.rescanLiteral() + item := d.data[start:d.readIndex()] + key, ok := unquoteBytes(item) + if !ok { + panic(phasePanicMsg) + } + + // Figure out field corresponding to key. + var subv reflect.Value + destring := false // whether the value is wrapped in a string to be decoded first + + if v.Kind() == reflect.Map { + elemType := t.Elem() + if !mapElem.IsValid() { + mapElem = reflect.New(elemType).Elem() + } else { + mapElem.Set(reflect.Zero(elemType)) + } + subv = mapElem + } else { + var f *field + if i, ok := fields.nameIndex[string(key)]; ok { + // Found an exact name match. + f = &fields.list[i] + } else { + // Fall back to the expensive case-insensitive + // linear search. + for i := range fields.list { + ff := &fields.list[i] + if ff.equalFold(ff.nameBytes, key) { + f = ff + break + } + } + } + if f != nil { + subv = v + destring = f.quoted + for _, i := range f.index { + if subv.Kind() == reflect.Ptr { + if subv.IsNil() { + // If a struct embeds a pointer to an unexported type, + // it is not possible to set a newly allocated value + // since the field is unexported. + // + // See https://golang.org/issue/21357 + if !subv.CanSet() { + d.saveError(fmt.Errorf("json: cannot set embedded pointer to unexported struct: %v", subv.Type().Elem())) + // Invalidate subv to ensure d.value(subv) skips over + // the JSON value without assigning it to subv. + subv = reflect.Value{} + destring = false + break + } + subv.Set(reflect.New(subv.Type().Elem())) + } + subv = subv.Elem() + } + subv = subv.Field(i) + } + if d.errorContext == nil { + d.errorContext = new(errorContext) + } + d.errorContext.FieldStack = append(d.errorContext.FieldStack, f.name) + d.errorContext.Struct = t + } else if d.disallowUnknownFields { + d.saveError(fmt.Errorf("json: unknown field %q", key)) + } + } + + // Read : before value. + if d.opcode == scanSkipSpace { + d.scanWhile(scanSkipSpace) + } + if d.opcode != scanObjectKey { + panic(phasePanicMsg) + } + d.scanWhile(scanSkipSpace) + + if destring { + switch qv := d.valueQuoted().(type) { + case nil: + if err := d.literalStore(nullLiteral, subv, false); err != nil { + return err + } + case string: + if err := d.literalStore([]byte(qv), subv, true); err != nil { + return err + } + default: + d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal unquoted value into %v", subv.Type())) + } + } else { + if err := d.value(subv); err != nil { + return err + } + } + + // Write value back to map; + // if using struct, subv points into struct already. + if v.Kind() == reflect.Map { + kt := t.Key() + var kv reflect.Value + switch { + case reflect.PtrTo(kt).Implements(textUnmarshalerType): + kv = reflect.New(kt) + if err := d.literalStore(item, kv, true); err != nil { + return err + } + kv = kv.Elem() + case kt.Kind() == reflect.String: + kv = reflect.ValueOf(key).Convert(kt) + default: + switch kt.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + s := string(key) + n, err := strconv.ParseInt(s, 10, 64) + if err != nil || reflect.Zero(kt).OverflowInt(n) { + d.saveError(&UnmarshalTypeError{Value: "number " + s, Type: kt, Offset: int64(start + 1)}) + break + } + kv = reflect.ValueOf(n).Convert(kt) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + s := string(key) + n, err := strconv.ParseUint(s, 10, 64) + if err != nil || reflect.Zero(kt).OverflowUint(n) { + d.saveError(&UnmarshalTypeError{Value: "number " + s, Type: kt, Offset: int64(start + 1)}) + break + } + kv = reflect.ValueOf(n).Convert(kt) + default: + panic("json: Unexpected key type") // should never occur + } + } + if kv.IsValid() { + if !d.isDiscriminatorSet() || kv.String() != d.discriminatorTypeFieldName { + v.SetMapIndex(kv, subv) + } + } + } + + // Next token must be , or }. + if d.opcode == scanSkipSpace { + d.scanWhile(scanSkipSpace) + } + if d.errorContext != nil { + // Reset errorContext to its original state. + // Keep the same underlying array for FieldStack, to reuse the + // space and avoid unnecessary allocs. + d.errorContext.FieldStack = d.errorContext.FieldStack[:len(origErrorContext.FieldStack)] + d.errorContext.Struct = origErrorContext.Struct + } + if d.opcode == scanEndObject { + break + } + if d.opcode != scanObjectValue { + panic(phasePanicMsg) + } + } + return nil +} + +// convertNumber converts the number literal s to a float64 or a Number +// depending on the setting of d.useNumber. +func (d *decodeState) convertNumber(s string) (interface{}, error) { + if d.useNumber { + return Number(s), nil + } + f, err := strconv.ParseFloat(s, 64) + if err != nil { + return nil, &UnmarshalTypeError{Value: "number " + s, Type: reflect.TypeOf(0.0), Offset: int64(d.off)} + } + return f, nil +} + +var numberType = reflect.TypeOf(Number("")) + +// literalStore decodes a literal stored in item into v. +// +// fromQuoted indicates whether this literal came from unwrapping a +// string from the ",string" struct tag option. this is used only to +// produce more helpful error messages. +func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool) error { + // Check for unmarshaler. + if len(item) == 0 { + //Empty string given + d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) + return nil + } + isNull := item[0] == 'n' // null + u, ut, pv := indirect(v, isNull) + if u != nil { + return u.UnmarshalJSON(item) + } + if ut != nil { + if item[0] != '"' { + if fromQuoted { + d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) + return nil + } + val := "number" + switch item[0] { + case 'n': + val = "null" + case 't', 'f': + val = "bool" + } + d.saveError(&UnmarshalTypeError{Value: val, Type: v.Type(), Offset: int64(d.readIndex())}) + return nil + } + s, ok := unquoteBytes(item) + if !ok { + if fromQuoted { + return fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type()) + } + panic(phasePanicMsg) + } + return ut.UnmarshalText(s) + } + + v = pv + + switch c := item[0]; c { + case 'n': // null + // The main parser checks that only true and false can reach here, + // but if this was a quoted string input, it could be anything. + if fromQuoted && string(item) != "null" { + d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) + break + } + switch v.Kind() { + case reflect.Interface, reflect.Ptr, reflect.Map, reflect.Slice: + v.Set(reflect.Zero(v.Type())) + // otherwise, ignore null for primitives/string + } + case 't', 'f': // true, false + value := item[0] == 't' + // The main parser checks that only true and false can reach here, + // but if this was a quoted string input, it could be anything. + if fromQuoted && string(item) != "true" && string(item) != "false" { + d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) + break + } + switch v.Kind() { + default: + if fromQuoted { + d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) + } else { + d.saveError(&UnmarshalTypeError{Value: "bool", Type: v.Type(), Offset: int64(d.readIndex())}) + } + case reflect.Bool: + v.SetBool(value) + case reflect.Interface: + if v.NumMethod() == 0 { + v.Set(reflect.ValueOf(value)) + } else { + d.saveError(&UnmarshalTypeError{Value: "bool", Type: v.Type(), Offset: int64(d.readIndex())}) + } + } + + case '"': // string + s, ok := unquoteBytes(item) + if !ok { + if fromQuoted { + return fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type()) + } + panic(phasePanicMsg) + } + switch v.Kind() { + default: + d.saveError(&UnmarshalTypeError{Value: "string", Type: v.Type(), Offset: int64(d.readIndex())}) + case reflect.Slice: + if v.Type().Elem().Kind() != reflect.Uint8 { + d.saveError(&UnmarshalTypeError{Value: "string", Type: v.Type(), Offset: int64(d.readIndex())}) + break + } + b := make([]byte, base64.StdEncoding.DecodedLen(len(s))) + n, err := base64.StdEncoding.Decode(b, s) + if err != nil { + d.saveError(err) + break + } + v.SetBytes(b[:n]) + case reflect.String: + if v.Type() == numberType && !isValidNumber(string(s)) { + return fmt.Errorf("json: invalid number literal, trying to unmarshal %q into Number", item) + } + v.SetString(string(s)) + case reflect.Interface: + if v.NumMethod() == 0 { + v.Set(reflect.ValueOf(string(s))) + } else { + d.saveError(&UnmarshalTypeError{Value: "string", Type: v.Type(), Offset: int64(d.readIndex())}) + } + } + + default: // number + if c != '-' && (c < '0' || c > '9') { + if fromQuoted { + return fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type()) + } + panic(phasePanicMsg) + } + s := string(item) + switch v.Kind() { + default: + if v.Kind() == reflect.String && v.Type() == numberType { + // s must be a valid number, because it's + // already been tokenized. + v.SetString(s) + break + } + if fromQuoted { + return fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type()) + } + d.saveError(&UnmarshalTypeError{Value: "number", Type: v.Type(), Offset: int64(d.readIndex())}) + case reflect.Interface: + n, err := d.convertNumber(s) + if err != nil { + d.saveError(err) + break + } + if v.NumMethod() != 0 { + d.saveError(&UnmarshalTypeError{Value: "number", Type: v.Type(), Offset: int64(d.readIndex())}) + break + } + v.Set(reflect.ValueOf(n)) + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + n, err := strconv.ParseInt(s, 10, 64) + if err != nil || v.OverflowInt(n) { + d.saveError(&UnmarshalTypeError{Value: "number " + s, Type: v.Type(), Offset: int64(d.readIndex())}) + break + } + v.SetInt(n) + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + n, err := strconv.ParseUint(s, 10, 64) + if err != nil || v.OverflowUint(n) { + d.saveError(&UnmarshalTypeError{Value: "number " + s, Type: v.Type(), Offset: int64(d.readIndex())}) + break + } + v.SetUint(n) + + case reflect.Float32, reflect.Float64: + n, err := strconv.ParseFloat(s, v.Type().Bits()) + if err != nil || v.OverflowFloat(n) { + d.saveError(&UnmarshalTypeError{Value: "number " + s, Type: v.Type(), Offset: int64(d.readIndex())}) + break + } + v.SetFloat(n) + } + } + return nil +} + +// The xxxInterface routines build up a value to be stored +// in an empty interface. They are not strictly necessary, +// but they avoid the weight of reflection in this common case. + +// valueInterface is like value but returns interface{} +func (d *decodeState) valueInterface() (val interface{}) { + switch d.opcode { + default: + panic(phasePanicMsg) + case scanBeginArray: + val = d.arrayInterface() + d.scanNext() + case scanBeginObject: + val = d.objectInterface() + d.scanNext() + case scanBeginLiteral: + val = d.literalInterface() + } + return +} + +// arrayInterface is like array but returns []interface{}. +func (d *decodeState) arrayInterface() []interface{} { + var v = make([]interface{}, 0) + for { + // Look ahead for ] - can only happen on first iteration. + d.scanWhile(scanSkipSpace) + if d.opcode == scanEndArray { + break + } + + v = append(v, d.valueInterface()) + + // Next token must be , or ]. + if d.opcode == scanSkipSpace { + d.scanWhile(scanSkipSpace) + } + if d.opcode == scanEndArray { + break + } + if d.opcode != scanArrayValue { + panic(phasePanicMsg) + } + } + return v +} + +// objectInterface is like object but returns map[string]interface{}. +func (d *decodeState) objectInterface() map[string]interface{} { + m := make(map[string]interface{}) + for { + // Read opening " of string key or closing }. + d.scanWhile(scanSkipSpace) + if d.opcode == scanEndObject { + // closing } - can only happen on first iteration. + break + } + if d.opcode != scanBeginLiteral { + panic(phasePanicMsg) + } + + // Read string key. + start := d.readIndex() + d.rescanLiteral() + item := d.data[start:d.readIndex()] + key, ok := unquote(item) + if !ok { + panic(phasePanicMsg) + } + + // Read : before value. + if d.opcode == scanSkipSpace { + d.scanWhile(scanSkipSpace) + } + if d.opcode != scanObjectKey { + panic(phasePanicMsg) + } + d.scanWhile(scanSkipSpace) + + // Read value. + m[key] = d.valueInterface() + + // Next token must be , or }. + if d.opcode == scanSkipSpace { + d.scanWhile(scanSkipSpace) + } + if d.opcode == scanEndObject { + break + } + if d.opcode != scanObjectValue { + panic(phasePanicMsg) + } + } + return m +} + +// literalInterface consumes and returns a literal from d.data[d.off-1:] and +// it reads the following byte ahead. The first byte of the literal has been +// read already (that's how the caller knows it's a literal). +func (d *decodeState) literalInterface() interface{} { + // All bytes inside literal return scanContinue op code. + start := d.readIndex() + d.rescanLiteral() + + item := d.data[start:d.readIndex()] + + switch c := item[0]; c { + case 'n': // null + return nil + + case 't', 'f': // true, false + return c == 't' + + case '"': // string + s, ok := unquote(item) + if !ok { + panic(phasePanicMsg) + } + return s + + default: // number + if c != '-' && (c < '0' || c > '9') { + panic(phasePanicMsg) + } + n, err := d.convertNumber(string(item)) + if err != nil { + d.saveError(err) + } + return n + } +} + +// getu4 decodes \uXXXX from the beginning of s, returning the hex value, +// or it returns -1. +func getu4(s []byte) rune { + if len(s) < 6 || s[0] != '\\' || s[1] != 'u' { + return -1 + } + var r rune + for _, c := range s[2:6] { + switch { + case '0' <= c && c <= '9': + c = c - '0' + case 'a' <= c && c <= 'f': + c = c - 'a' + 10 + case 'A' <= c && c <= 'F': + c = c - 'A' + 10 + default: + return -1 + } + r = r*16 + rune(c) + } + return r +} + +// unquote converts a quoted JSON string literal s into an actual string t. +// The rules are different than for Go, so cannot use strconv.Unquote. +func unquote(s []byte) (t string, ok bool) { + s, ok = unquoteBytes(s) + t = string(s) + return +} + +func unquoteBytes(s []byte) (t []byte, ok bool) { + if len(s) < 2 || s[0] != '"' || s[len(s)-1] != '"' { + return + } + s = s[1 : len(s)-1] + + // Check for unusual characters. If there are none, + // then no unquoting is needed, so return a slice of the + // original bytes. + r := 0 + for r < len(s) { + c := s[r] + if c == '\\' || c == '"' || c < ' ' { + break + } + if c < utf8.RuneSelf { + r++ + continue + } + rr, size := utf8.DecodeRune(s[r:]) + if rr == utf8.RuneError && size == 1 { + break + } + r += size + } + if r == len(s) { + return s, true + } + + b := make([]byte, len(s)+2*utf8.UTFMax) + w := copy(b, s[0:r]) + for r < len(s) { + // Out of room? Can only happen if s is full of + // malformed UTF-8 and we're replacing each + // byte with RuneError. + if w >= len(b)-2*utf8.UTFMax { + nb := make([]byte, (len(b)+utf8.UTFMax)*2) + copy(nb, b[0:w]) + b = nb + } + switch c := s[r]; { + case c == '\\': + r++ + if r >= len(s) { + return + } + switch s[r] { + default: + return + case '"', '\\', '/', '\'': + b[w] = s[r] + r++ + w++ + case 'b': + b[w] = '\b' + r++ + w++ + case 'f': + b[w] = '\f' + r++ + w++ + case 'n': + b[w] = '\n' + r++ + w++ + case 'r': + b[w] = '\r' + r++ + w++ + case 't': + b[w] = '\t' + r++ + w++ + case 'u': + r-- + rr := getu4(s[r:]) + if rr < 0 { + return + } + r += 6 + if utf16.IsSurrogate(rr) { + rr1 := getu4(s[r:]) + if dec := utf16.DecodeRune(rr, rr1); dec != unicode.ReplacementChar { + // A valid pair; consume. + r += 6 + w += utf8.EncodeRune(b[w:], dec) + break + } + // Invalid surrogate; fall back to replacement rune. + rr = unicode.ReplacementChar + } + w += utf8.EncodeRune(b[w:], rr) + } + + // Quote, control characters are invalid. + case c == '"', c < ' ': + return + + // ASCII + case c < utf8.RuneSelf: + b[w] = c + r++ + w++ + + // Coerce to well-formed UTF-8. + default: + rr, size := utf8.DecodeRune(s[r:]) + r += size + w += utf8.EncodeRune(b[w:], rr) + } + } + return b[0:w], true +} diff --git a/vendor/github.com/vmware/govmomi/vim25/json/discriminator.go b/vendor/github.com/vmware/govmomi/vim25/json/discriminator.go new file mode 100644 index 0000000000..ce315dd527 --- /dev/null +++ b/vendor/github.com/vmware/govmomi/vim25/json/discriminator.go @@ -0,0 +1,568 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package json + +import ( + "fmt" + "reflect" + "regexp" + "strconv" + "sync" +) + +// DiscriminatorToTypeFunc is used to get a reflect.Type from its +// discriminator. +type DiscriminatorToTypeFunc func(discriminator string) (reflect.Type, bool) + +// TypeToDiscriminatorFunc is used to get a discriminator string from a +// reflect.Type. Empty return value suppresses discriminator rendering. +type TypeToDiscriminatorFunc func(reflect.Type) (discriminator string) + +// DefaultDiscriminatorFunc is shorthand for the ShortName func and is used when +// no other discriminator func is set explicitly +var DefaultDiscriminatorFunc = ShortName + +// ShortName returns the type name in golang without the package name +func ShortName(t reflect.Type) (discriminator string) { + tn := t.Name() + if tn == "" { + return t.String() + } + return tn +} + +// FullName return the name of the type prefixed with the package name as +// appropriate +func FullName(t reflect.Type) (discriminator string) { + tn := t.Name() + if tn == "" { + return t.String() + } + if pp := t.PkgPath(); pp != "" { + return fmt.Sprintf("%s.%s", pp, tn) + } + return tn +} + +// DiscriminatorEncodeMode is a mask that describes the different encode +// options. +type DiscriminatorEncodeMode uint8 + +const ( + // DiscriminatorEncodeTypeNameRootValue causes the type name to be encoded + // for the root value. + DiscriminatorEncodeTypeNameRootValue DiscriminatorEncodeMode = 1 << iota + + // DiscriminatorEncodeTypeNameAllObjects causes the type name to be encoded + // for all struct and map values. Please note this specifically does not + // apply to the root value. + DiscriminatorEncodeTypeNameAllObjects + + // DiscriminatorEncodeTypeNameIfRequired is the default behavior when + // the discriminator is set, and the type name is only encoded if required. + DiscriminatorEncodeTypeNameIfRequired DiscriminatorEncodeMode = 0 +) + +func (m DiscriminatorEncodeMode) root() bool { + return m&DiscriminatorEncodeTypeNameRootValue > 0 +} + +func (m DiscriminatorEncodeMode) all() bool { + return m&DiscriminatorEncodeTypeNameAllObjects > 0 +} + +func (d *decodeState) isDiscriminatorSet() bool { + return d.discriminatorTypeFieldName != "" && + d.discriminatorValueFieldName != "" +} + +// discriminatorOpType describes the current operation related to +// discriminators when reading a JSON object's fields. +type discriminatorOpType uint8 + +const ( + // discriminatorOpTypeNameField indicates the discriminator type name + // field was discovered. + discriminatorOpTypeNameField = iota + 1 + + // discriminatorOpValueField indicates the discriminator value field + // was discovered. + discriminatorOpValueField +) + +func (d *decodeState) discriminatorGetValue() (reflect.Value, error) { + // Record the current offset so we know where the data starts. + offset := d.readIndex() + + // Create a temporary decodeState used to inspect the current object + // and determine its discriminator type and decode its value. + dd := &decodeState{ + disallowUnknownFields: d.disallowUnknownFields, + useNumber: d.useNumber, + discriminatorToTypeFn: d.discriminatorToTypeFn, + discriminatorTypeFieldName: d.discriminatorTypeFieldName, + discriminatorValueFieldName: d.discriminatorValueFieldName, + } + dd.init(append([]byte{}, d.data[offset:]...)) + defer freeScanner(&dd.scan) + dd.scan.reset() + + var ( + t reflect.Type // the instance of the type + valueOff = -1 // the offset of a possible discriminator value + ) + + dd.scanWhile(scanSkipSpace) + if dd.opcode != scanBeginObject { + panic(phasePanicMsg) + } + + for { + dd.scanWhile(scanSkipSpace) + if dd.opcode == scanEndObject { + // closing } - can only happen on first iteration. + break + } + if dd.opcode != scanBeginLiteral { + panic(phasePanicMsg) + } + + // Read key. + start := dd.readIndex() + dd.rescanLiteral() + item := dd.data[start:dd.readIndex()] + key, ok := unquote(item) + if !ok { + panic(phasePanicMsg) + } + + // Check to see if the key is related to the discriminator. + var discriminatorOp discriminatorOpType + switch key { + case d.discriminatorTypeFieldName: + discriminatorOp = discriminatorOpTypeNameField + case d.discriminatorValueFieldName: + discriminatorOp = discriminatorOpValueField + } + + // Read : before value. + if dd.opcode == scanSkipSpace { + dd.scanWhile(scanSkipSpace) + } + + if dd.opcode != scanObjectKey { + panic(phasePanicMsg) + } + dd.scanWhile(scanSkipSpace) + + // Read value. + valOff := dd.readIndex() + val := dd.valueInterface() + + switch discriminatorOp { + case discriminatorOpTypeNameField: + tn, ok := val.(string) + if !ok { + return reflect.Value{}, fmt.Errorf( + "json: discriminator type at offset %d is not string", + offset+valOff) + } + if tn == "" { + return reflect.Value{}, fmt.Errorf( + "json: discriminator type at offset %d is empty", + offset+valOff) + } + + // Parse the type name into a type instance. + ti, err := discriminatorParseTypeName(tn, d.discriminatorToTypeFn) + if err != nil { + return reflect.Value{}, err + } + + // Assign the type instance to the outer variable, t. + t = ti + + // Primitive types and types with Unmarshaler are wrapped in a + // structure with type and value fields. Structures and Maps not + // implementing Unmarshaler use discriminator embedded within their + // content. + if useNestedDiscriminator(t) { + // If the type is a map or a struct not implementing Unmarshaler + // then it is not necessary to continue walking over the current + // JSON object since it will be completely re-scanned to decode + // its value into the discovered type. + dd.opcode = scanEndObject + } else { + // Otherwise if the value offset has been discovered then it is + // safe to stop walking over the current JSON object as well. + if valueOff > -1 { + dd.opcode = scanEndObject + } + } + case discriminatorOpValueField: + valueOff = valOff + + // If the type has been discovered then it is safe to stop walking + // over the current JSON object. + if t != nil { + dd.opcode = scanEndObject + } + } + + // Next token must be , or }. + if dd.opcode == scanSkipSpace { + dd.scanWhile(scanSkipSpace) + } + if dd.opcode == scanEndObject { + break + } + if dd.opcode != scanObjectValue { + panic(phasePanicMsg) + } + } + + // If there is not a type discriminator then return early. + if t == nil { + return reflect.Value{}, fmt.Errorf("json: missing discriminator") + } + + // Instantiate a new instance of the discriminated type. + var v reflect.Value + switch t.Kind() { + case reflect.Slice: + // MakeSlice returns a value that is not addressable. + // Instead, use MakeSlice to get the type, then use + // reflect.New to create an addressable value. + v = reflect.New(reflect.MakeSlice(t, 0, 0).Type()).Elem() + case reflect.Map: + // MakeMap returns a value that is not addressable. + // Instead, use MakeMap to get the type, then use + // reflect.New to create an addressable value. + v = reflect.New(reflect.MakeMap(t).Type()).Elem() + case reflect.Complex64, reflect.Complex128: + return reflect.Value{}, fmt.Errorf("json: unsupported discriminator type: %s", t.Kind()) + default: + v = reflect.New(t) + } + + // Reset the decode state to prepare for decoding the data. + dd.scan.reset() + + if useNestedDiscriminator(t) { + // Set the offset to zero since the entire object will be decoded + // into v. + dd.off = 0 + } else { + // Set the offset to what it was before the discriminator value was + // read so only the value field is decoded into v. + dd.off = valueOff + } + // This will initialize the correct scan step and op code. + dd.scanWhile(scanSkipSpace) + + // Decode the data into the value. + if err := dd.value(v); err != nil { + return reflect.Value{}, err + } + + // Check the saved error as well since the decoder.value function does not + // always return an error. If the reflected value is still zero, then it is + // likely the decoder was unable to decode the value. + if err := dd.savedError; err != nil { + switch v.Kind() { + case reflect.Ptr, reflect.Interface: + v = v.Elem() + } + if v.IsZero() { + return reflect.Value{}, err + } + } + + return v, nil +} + +func (d *decodeState) discriminatorInterfaceDecode(t reflect.Type, v reflect.Value) error { + + defer func() { + // Advance the decode state, throwing away the value. + _ = d.objectInterface() + }() + + dv, err := d.discriminatorGetValue() + if err != nil { + return err + } + + switch dv.Kind() { + case reflect.Map, reflect.Slice: + if dv.Type().AssignableTo(t) { + v.Set(dv) + return nil + } + if pdv := dv.Addr(); pdv.Type().AssignableTo(t) { + v.Set(pdv) + return nil + } + case reflect.Ptr: + if dve := dv.Elem(); dve.Type().AssignableTo(t) { + v.Set(dve) + return nil + } + if dv.Type().AssignableTo(t) { + v.Set(dv) + return nil + } + } + + return fmt.Errorf("json: unsupported discriminator kind: %s", dv.Kind()) +} + +func (o encOpts) isDiscriminatorSet() bool { + return o.discriminatorTypeFieldName != "" && + o.discriminatorValueFieldName != "" +} + +func discriminatorInterfaceEncode(e *encodeState, v reflect.Value, opts encOpts) { + v = v.Elem() + + if v.Type().Implements(marshalerType) { + discriminatorValue := opts.discriminatorValueFn(v.Type()) + if discriminatorValue == "" { + marshalerEncoder(e, v, opts) + } + e.WriteString(`{"`) + e.WriteString(opts.discriminatorTypeFieldName) + e.WriteString(`":"`) + e.WriteString(discriminatorValue) + e.WriteString(`","`) + e.WriteString(opts.discriminatorValueFieldName) + e.WriteString(`":`) + marshalerEncoder(e, v, opts) + e.WriteByte('}') + return + } + + switch v.Kind() { + case reflect.Chan, reflect.Func, reflect.Invalid: + e.error(&UnsupportedValueError{v, fmt.Sprintf("invalid kind: %s", v.Kind())}) + case reflect.Map: + e.discriminatorEncodeTypeName = true + newMapEncoder(v.Type())(e, v, opts) + case reflect.Struct: + e.discriminatorEncodeTypeName = true + newStructEncoder(v.Type())(e, v, opts) + case reflect.Ptr: + discriminatorInterfaceEncode(e, v, opts) + default: + discriminatorValue := opts.discriminatorValueFn(v.Type()) + if discriminatorValue == "" { + e.reflectValue(v, opts) + return + } + e.WriteString(`{"`) + e.WriteString(opts.discriminatorTypeFieldName) + e.WriteString(`":"`) + e.WriteString(discriminatorValue) + e.WriteString(`","`) + e.WriteString(opts.discriminatorValueFieldName) + e.WriteString(`":`) + e.reflectValue(v, opts) + e.WriteByte('}') + } +} + +func discriminatorMapEncode(e *encodeState, v reflect.Value, opts encOpts) { + if !e.discriminatorEncodeTypeName && !opts.discriminatorEncodeMode.all() { + return + } + discriminatorValue := opts.discriminatorValueFn(v.Type()) + if discriminatorValue == "" { + return + } + e.WriteByte('"') + e.WriteString(opts.discriminatorTypeFieldName) + e.WriteString(`":"`) + e.WriteString(discriminatorValue) + e.WriteByte('"') + if v.Len() > 0 { + e.WriteByte(',') + } + e.discriminatorEncodeTypeName = false +} + +func discriminatorStructEncode(e *encodeState, v reflect.Value, opts encOpts) byte { + if !e.discriminatorEncodeTypeName && !opts.discriminatorEncodeMode.all() { + return '{' + } + discriminatorValue := opts.discriminatorValueFn(v.Type()) + if discriminatorValue == "" { + return '{' + } + e.WriteString(`{"`) + e.WriteString(opts.discriminatorTypeFieldName) + e.WriteString(`":"`) + e.WriteString(discriminatorValue) + e.WriteByte('"') + e.discriminatorEncodeTypeName = false + return ',' +} + +var unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem() + +// Discriminator is nested in map and struct unless they implement Unmarshaler. +func useNestedDiscriminator(t reflect.Type) bool { + if t.Implements(unmarshalerType) || reflect.PtrTo(t).Implements(unmarshalerType) { + return false + } + kind := t.Kind() + if kind == reflect.Struct || kind == reflect.Map { + return true + } + return false +} + +var discriminatorTypeRegistry = map[string]reflect.Type{ + "uint": reflect.TypeOf(uint(0)), + "uint8": reflect.TypeOf(uint8(0)), + "uint16": reflect.TypeOf(uint16(0)), + "uint32": reflect.TypeOf(uint32(0)), + "uint64": reflect.TypeOf(uint64(0)), + "uintptr": reflect.TypeOf(uintptr(0)), + "int": reflect.TypeOf(int(0)), + "int8": reflect.TypeOf(int8(0)), + "int16": reflect.TypeOf(int16(0)), + "int32": reflect.TypeOf(int32(0)), + "int64": reflect.TypeOf(int64(0)), + "float32": reflect.TypeOf(float32(0)), + "float64": reflect.TypeOf(float64(0)), + "bool": reflect.TypeOf(true), + "string": reflect.TypeOf(""), + "any": reflect.TypeOf((*interface{})(nil)).Elem(), + "interface{}": reflect.TypeOf((*interface{})(nil)).Elem(), + "interface {}": reflect.TypeOf((*interface{})(nil)).Elem(), + + // Not supported, but here to prevent the decoder from panicing + // if encountered. + "complex64": reflect.TypeOf(complex64(0)), + "complex128": reflect.TypeOf(complex128(0)), +} + +// discriminatorPointerTypeCache caches the pointer type for another type. +// For example, a key that was the int type would have a value that is the +// *int type. +var discriminatorPointerTypeCache sync.Map // map[reflect.Type]reflect.Type + +// cachedPointerType returns the pointer type for another and avoids repeated +// work by using a cache. +func cachedPointerType(t reflect.Type) reflect.Type { + if value, ok := discriminatorPointerTypeCache.Load(t); ok { + return value.(reflect.Type) + } + pt := reflect.New(t).Type() + value, _ := discriminatorPointerTypeCache.LoadOrStore(t, pt) + return value.(reflect.Type) +} + +var ( + mapPatt = regexp.MustCompile(`^\*?map\[([^\]]+)\](.+)$`) + arrayPatt = regexp.MustCompile(`^\*?\[(\d+)\](.+)$`) + slicePatt = regexp.MustCompile(`^\*?\[\](.+)$`) +) + +// discriminatorParseTypeName returns a reflect.Type for the given type name. +func discriminatorParseTypeName( + typeName string, + typeFn DiscriminatorToTypeFunc) (reflect.Type, error) { + + // Check to see if the type is an array, map, or slice. + var ( + aln = -1 // array length + etn string // map or slice element type name + ktn string // map key type name + ) + if m := arrayPatt.FindStringSubmatch(typeName); len(m) > 0 { + i, err := strconv.Atoi(m[1]) + if err != nil { + return nil, err + } + aln = i + etn = m[2] + } else if m := slicePatt.FindStringSubmatch(typeName); len(m) > 0 { + etn = m[1] + } else if m := mapPatt.FindStringSubmatch(typeName); len(m) > 0 { + ktn = m[1] + etn = m[2] + } + + // indirectTypeName checks to see if the type name begins with a + // "*" characters. If it does, then the type name sans the "*" + // character is returned along with a true value indicating the + // type is a pointer. Otherwise the original type name is returned + // along with a false value. + indirectTypeName := func(tn string) (string, bool) { + if len(tn) > 1 && tn[0] == '*' { + return tn[1:], true + } + return tn, false + } + + lookupType := func(tn string) (reflect.Type, bool) { + // Get the actual type name and a flag indicating whether the + // type is a pointer. + n, p := indirectTypeName(tn) + + var t reflect.Type + ok := false + // look up the type in the external registry to allow name override. + if typeFn != nil { + t, ok = typeFn(n) + } + if !ok { + // Use the built-in registry if the external registry fails + if t, ok = discriminatorTypeRegistry[n]; !ok { + return nil, false + } + } + // If the type was a pointer then get the type's pointer type. + if p { + t = cachedPointerType(t) + } + return t, true + } + + var t reflect.Type + + if ktn == "" && etn != "" { + et, ok := lookupType(etn) + if !ok { + return nil, fmt.Errorf("json: invalid array/slice element type: %s", etn) + } + if aln > -1 { + // Array + t = reflect.ArrayOf(aln, et) + } else { + // Slice + t = reflect.SliceOf(et) + } + } else if ktn != "" && etn != "" { + // Map + kt, ok := lookupType(ktn) + if !ok { + return nil, fmt.Errorf("json: invalid map key type: %s", ktn) + } + et, ok := lookupType(etn) + if !ok { + return nil, fmt.Errorf("json: invalid map element type: %s", etn) + } + t = reflect.MapOf(kt, et) + } else { + var ok bool + if t, ok = lookupType(typeName); !ok { + return nil, fmt.Errorf("json: invalid discriminator type: %s", typeName) + } + } + + return t, nil +} diff --git a/vendor/github.com/vmware/govmomi/vim25/json/encode.go b/vendor/github.com/vmware/govmomi/vim25/json/encode.go new file mode 100644 index 0000000000..0c8aa202fe --- /dev/null +++ b/vendor/github.com/vmware/govmomi/vim25/json/encode.go @@ -0,0 +1,1453 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package json implements encoding and decoding of JSON as defined in +// RFC 7159. The mapping between JSON and Go values is described +// in the documentation for the Marshal and Unmarshal functions. +// +// See "JSON and Go" for an introduction to this package: +// https://golang.org/doc/articles/json_and_go.html +package json + +import ( + "bytes" + "encoding" + "encoding/base64" + "fmt" + "math" + "reflect" + "sort" + "strconv" + "strings" + "sync" + "unicode" + "unicode/utf8" +) + +// Marshal returns the JSON encoding of v. +// +// Marshal traverses the value v recursively. +// If an encountered value implements the Marshaler interface +// and is not a nil pointer, Marshal calls its MarshalJSON method +// to produce JSON. If no MarshalJSON method is present but the +// value implements encoding.TextMarshaler instead, Marshal calls +// its MarshalText method and encodes the result as a JSON string. +// The nil pointer exception is not strictly necessary +// but mimics a similar, necessary exception in the behavior of +// UnmarshalJSON. +// +// Otherwise, Marshal uses the following type-dependent default encodings: +// +// Boolean values encode as JSON booleans. +// +// Floating point, integer, and Number values encode as JSON numbers. +// +// String values encode as JSON strings coerced to valid UTF-8, +// replacing invalid bytes with the Unicode replacement rune. +// So that the JSON will be safe to embed inside HTML