mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Merge pull request #54631 from venkat-443/master
Automatic merge from submit-queue (batch tested with PRs 60376, 55584, 60358, 54631, 60291). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Update vendored Quobyte API This update patch includes Quobyte API improvements. [JSON API fix](https://github.com/quobyte/api/issues/12) [API Tenant calls](https://github.com/quobyte/api/pull/10)
This commit is contained in:
commit
4dd458163a
2
Godeps/Godeps.json
generated
2
Godeps/Godeps.json
generated
@ -2515,7 +2515,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/quobyte/api",
|
"ImportPath": "github.com/quobyte/api",
|
||||||
"Rev": "cb10db90715b14d4784465d2fa3b915dfacc0628"
|
"Rev": "f2b94aa4aa4f8fcf279fe667ccd916abe6a064d5"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/rancher/go-rancher/client",
|
"ImportPath": "github.com/rancher/go-rancher/client",
|
||||||
|
3
vendor/github.com/quobyte/api/README.md
generated
vendored
3
vendor/github.com/quobyte/api/README.md
generated
vendored
@ -1,6 +1,6 @@
|
|||||||
# Quobyte API Clients
|
# Quobyte API Clients
|
||||||
|
|
||||||
Get the quoybte api client
|
Get the quobyte api client
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go get github.com/quobyte/api
|
go get github.com/quobyte/api
|
||||||
@ -18,6 +18,7 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
client := quobyte_api.NewQuobyteClient("http://apiserver:7860", "user", "password")
|
client := quobyte_api.NewQuobyteClient("http://apiserver:7860", "user", "password")
|
||||||
|
client.SetAPIRetryPolicy(quobyte_api.RetryInfinitely) // Default quobyte_api.RetryInteractive
|
||||||
req := &quobyte_api.CreateVolumeRequest{
|
req := &quobyte_api.CreateVolumeRequest{
|
||||||
Name: "MyVolume",
|
Name: "MyVolume",
|
||||||
RootUserID: "root",
|
RootUserID: "root",
|
||||||
|
66
vendor/github.com/quobyte/api/quobyte.go
generated
vendored
66
vendor/github.com/quobyte/api/quobyte.go
generated
vendored
@ -5,11 +5,28 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// retry policy codes
|
||||||
|
const (
|
||||||
|
RetryNever string = "NEVER"
|
||||||
|
RetryInteractive string = "INTERACTIVE"
|
||||||
|
RetryInfinitely string = "INFINITELY"
|
||||||
|
RetryOncePerTarget string = "ONCE_PER_TARGET"
|
||||||
|
)
|
||||||
|
|
||||||
type QuobyteClient struct {
|
type QuobyteClient struct {
|
||||||
client *http.Client
|
client *http.Client
|
||||||
url string
|
url string
|
||||||
username string
|
username string
|
||||||
password string
|
password string
|
||||||
|
apiRetryPolicy string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (client *QuobyteClient) SetAPIRetryPolicy(retry string) {
|
||||||
|
client.apiRetryPolicy = retry
|
||||||
|
}
|
||||||
|
|
||||||
|
func (client *QuobyteClient) GetAPIRetryPolicy() string {
|
||||||
|
return client.apiRetryPolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewQuobyteClient creates a new Quobyte API client
|
// NewQuobyteClient creates a new Quobyte API client
|
||||||
@ -19,6 +36,7 @@ func NewQuobyteClient(url string, username string, password string) *QuobyteClie
|
|||||||
url: url,
|
url: url,
|
||||||
username: username,
|
username: username,
|
||||||
password: password,
|
password: password,
|
||||||
|
apiRetryPolicy: RetryInteractive,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +98,7 @@ func (client *QuobyteClient) GetClientList(tenant string) (GetClientListResponse
|
|||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetVolumeQuota sets a Quota to the specified Volume
|
||||||
func (client *QuobyteClient) SetVolumeQuota(volumeUUID string, quotaSize uint64) error {
|
func (client *QuobyteClient) SetVolumeQuota(volumeUUID string, quotaSize uint64) error {
|
||||||
request := &setQuotaRequest{
|
request := &setQuotaRequest{
|
||||||
Quotas: []*quota{
|
Quotas: []*quota{
|
||||||
@ -102,3 +121,50 @@ func (client *QuobyteClient) SetVolumeQuota(volumeUUID string, quotaSize uint64)
|
|||||||
|
|
||||||
return client.sendRequest("setQuota", request, nil)
|
return client.sendRequest("setQuota", request, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetTenant returns the Tenant configuration for all specified tenants
|
||||||
|
func (client *QuobyteClient) GetTenant(tenantIDs []string) (GetTenantResponse, error) {
|
||||||
|
request := &getTenantRequest{TenantIDs: tenantIDs}
|
||||||
|
|
||||||
|
var response GetTenantResponse
|
||||||
|
err := client.sendRequest("getTenant", request, &response)
|
||||||
|
if err != nil {
|
||||||
|
return response, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return response, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTenantMap returns a map that contains all tenant names and there ID's
|
||||||
|
func (client *QuobyteClient) GetTenantMap() (map[string]string, error) {
|
||||||
|
result := map[string]string{}
|
||||||
|
response, err := client.GetTenant([]string{})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tenant := range response.Tenants {
|
||||||
|
result[tenant.Name] = tenant.TenantID
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetTenant creates a Tenant with the specified name
|
||||||
|
func (client *QuobyteClient) SetTenant(tenantName string) (string, error) {
|
||||||
|
request := &setTenantRequest{
|
||||||
|
&TenantDomainConfiguration{
|
||||||
|
Name: tenantName,
|
||||||
|
},
|
||||||
|
retryPolicy{client.GetAPIRetryPolicy()},
|
||||||
|
}
|
||||||
|
|
||||||
|
var response setTenantResponse
|
||||||
|
err := client.sendRequest("setTenant", request, &response)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.TenantID, nil
|
||||||
|
}
|
||||||
|
6
vendor/github.com/quobyte/api/rpc_client.go
generated
vendored
6
vendor/github.com/quobyte/api/rpc_client.go
generated
vendored
@ -7,6 +7,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -88,6 +89,11 @@ func decodeResponse(ioReader io.Reader, reply interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (client QuobyteClient) sendRequest(method string, request interface{}, response interface{}) error {
|
func (client QuobyteClient) sendRequest(method string, request interface{}, response interface{}) error {
|
||||||
|
etype := reflect.ValueOf(request).Elem()
|
||||||
|
field := etype.FieldByName("RetryPolicy")
|
||||||
|
if field.IsValid() {
|
||||||
|
field.SetString(client.GetAPIRetryPolicy())
|
||||||
|
}
|
||||||
message, err := encodeRequest(method, request)
|
message, err := encodeRequest(method, request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
39
vendor/github.com/quobyte/api/types.go
generated
vendored
39
vendor/github.com/quobyte/api/types.go
generated
vendored
@ -1,5 +1,9 @@
|
|||||||
package quobyte
|
package quobyte
|
||||||
|
|
||||||
|
type retryPolicy struct {
|
||||||
|
RetryPolicy string `json:"retry,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// CreateVolumeRequest represents a CreateVolumeRequest
|
// CreateVolumeRequest represents a CreateVolumeRequest
|
||||||
type CreateVolumeRequest struct {
|
type CreateVolumeRequest struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
@ -9,11 +13,13 @@ type CreateVolumeRequest struct {
|
|||||||
ConfigurationName string `json:"configuration_name,omitempty"`
|
ConfigurationName string `json:"configuration_name,omitempty"`
|
||||||
AccessMode uint32 `json:"access_mode,string,omitempty"`
|
AccessMode uint32 `json:"access_mode,string,omitempty"`
|
||||||
TenantID string `json:"tenant_id,omitempty"`
|
TenantID string `json:"tenant_id,omitempty"`
|
||||||
|
retryPolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
type resolveVolumeNameRequest struct {
|
type resolveVolumeNameRequest struct {
|
||||||
VolumeName string `json:"volume_name,omitempty"`
|
VolumeName string `json:"volume_name,omitempty"`
|
||||||
TenantDomain string `json:"tenant_domain,omitempty"`
|
TenantDomain string `json:"tenant_domain,omitempty"`
|
||||||
|
retryPolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
type volumeUUID struct {
|
type volumeUUID struct {
|
||||||
@ -22,6 +28,7 @@ type volumeUUID struct {
|
|||||||
|
|
||||||
type getClientListRequest struct {
|
type getClientListRequest struct {
|
||||||
TenantDomain string `json:"tenant_domain,omitempty"`
|
TenantDomain string `json:"tenant_domain,omitempty"`
|
||||||
|
retryPolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetClientListResponse struct {
|
type GetClientListResponse struct {
|
||||||
@ -53,4 +60,36 @@ type quota struct {
|
|||||||
|
|
||||||
type setQuotaRequest struct {
|
type setQuotaRequest struct {
|
||||||
Quotas []*quota `json:"quotas,omitempty"`
|
Quotas []*quota `json:"quotas,omitempty"`
|
||||||
|
retryPolicy
|
||||||
|
}
|
||||||
|
|
||||||
|
type getTenantRequest struct {
|
||||||
|
TenantIDs []string `json:"tenant_id,omitempty"`
|
||||||
|
retryPolicy
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetTenantResponse struct {
|
||||||
|
Tenants []*TenantDomainConfiguration `json:"tenant,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TenantDomainConfiguration struct {
|
||||||
|
TenantID string `json:"tenant_id,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
RestrictToNetwork []string `json:"restrict_to_network,omitempty"`
|
||||||
|
VolumeAccess []*TenantDomainConfigurationVolumeAccess `json:"volume_access,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TenantDomainConfigurationVolumeAccess struct {
|
||||||
|
VolumeUUID string `json:"volume_uuid,omitempty"`
|
||||||
|
RestrictToNetwork string `json:"restrict_to_network,omitempty"`
|
||||||
|
ReadOnly bool `json:"read_only,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type setTenantRequest struct {
|
||||||
|
Tenants *TenantDomainConfiguration `json:"tenant,omitempty"`
|
||||||
|
retryPolicy
|
||||||
|
}
|
||||||
|
|
||||||
|
type setTenantResponse struct {
|
||||||
|
TenantID string `json:"tenant_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user