Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
d5778398
Commit
d5778398
authored
Oct 26, 2017
by
Venkata Subbarao Chunduri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Quobyte API
parent
58fd063a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
133 additions
and
21 deletions
+133
-21
Godeps.json
Godeps/Godeps.json
+1
-1
README.md
vendor/github.com/quobyte/api/README.md
+2
-1
quobyte.go
vendor/github.com/quobyte/api/quobyte.go
+74
-8
rpc_client.go
vendor/github.com/quobyte/api/rpc_client.go
+6
-0
types.go
vendor/github.com/quobyte/api/types.go
+50
-11
No files found.
Godeps/Godeps.json
View file @
d5778398
...
@@ -2386,7 +2386,7 @@
...
@@ -2386,7 +2386,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"
,
...
...
vendor/github.com/quobyte/api/README.md
View file @
d5778398
# Quobyte API Clients
# Quobyte API Clients
Get the quo
yb
te api client
Get the quo
by
te api client
```
bash
```
bash
go get github.com/quobyte/api
go get github.com/quobyte/api
...
@@ -18,6 +18,7 @@ import (
...
@@ -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"
,
...
...
vendor/github.com/quobyte/api/quobyte.go
View file @
d5778398
...
@@ -5,20 +5,38 @@ import (
...
@@ -5,20 +5,38 @@ 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
func
NewQuobyteClient
(
url
string
,
username
string
,
password
string
)
*
QuobyteClient
{
func
NewQuobyteClient
(
url
string
,
username
string
,
password
string
)
*
QuobyteClient
{
return
&
QuobyteClient
{
return
&
QuobyteClient
{
client
:
&
http
.
Client
{},
client
:
&
http
.
Client
{},
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
...
@@ -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)
...
@@ -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
}
vendor/github.com/quobyte/api/rpc_client.go
View file @
d5778398
...
@@ -7,6 +7,7 @@ import (
...
@@ -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 {
...
@@ -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
...
...
vendor/github.com/quobyte/api/types.go
View file @
d5778398
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"`
RootUserID
string
`json:"root_user_id,omitempty"`
RootUserID
string
`json:"root_user_id,omitempty"`
RootGroupID
string
`json:"root_group_id,omitempty"`
RootGroupID
string
`json:"root_group_id,omitempty"`
ReplicaDeviceIDS
[]
uint64
`json:"replica_device_ids,string,omitempty"`
ReplicaDeviceIDS
[]
uint64
`json:"replica_device_ids,string,omitempty"`
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
{
...
@@ -21,7 +27,8 @@ type volumeUUID struct {
...
@@ -21,7 +27,8 @@ 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
{
...
@@ -52,5 +59,37 @@ type quota struct {
...
@@ -52,5 +59,37 @@ 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"`
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment