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
6eef91b7
Commit
6eef91b7
authored
May 30, 2018
by
Venkata Subbarao Chunduri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Quobyte API update
parent
15cd3552
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
1 deletion
+46
-1
Godeps.json
Godeps/Godeps.json
+1
-1
quobyte.go
vendor/github.com/quobyte/api/quobyte.go
+33
-0
rpc_client.go
vendor/github.com/quobyte/api/rpc_client.go
+4
-0
types.go
vendor/github.com/quobyte/api/types.go
+8
-0
No files found.
Godeps/Godeps.json
View file @
6eef91b7
...
@@ -2528,7 +2528,7 @@
...
@@ -2528,7 +2528,7 @@
},
},
{
{
"ImportPath"
:
"github.com/quobyte/api"
,
"ImportPath"
:
"github.com/quobyte/api"
,
"Rev"
:
"
f2b94aa4aa4f8fcf279fe667ccd916abe6a064d5
"
"Rev"
:
"
206ef832283c1a0144bbc762be2634d49987b5ff
"
},
},
{
{
"ImportPath"
:
"github.com/rancher/go-rancher/client"
,
"ImportPath"
:
"github.com/rancher/go-rancher/client"
,
...
...
vendor/github.com/quobyte/api/quobyte.go
View file @
6eef91b7
...
@@ -2,7 +2,9 @@
...
@@ -2,7 +2,9 @@
package
quobyte
package
quobyte
import
(
import
(
"log"
"net/http"
"net/http"
"regexp"
)
)
// retry policy codes
// retry policy codes
...
@@ -43,6 +45,17 @@ func NewQuobyteClient(url string, username string, password string) *QuobyteClie
...
@@ -43,6 +45,17 @@ func NewQuobyteClient(url string, username string, password string) *QuobyteClie
// CreateVolume creates a new Quobyte volume. Its root directory will be owned by given user and group
// CreateVolume creates a new Quobyte volume. Its root directory will be owned by given user and group
func
(
client
QuobyteClient
)
CreateVolume
(
request
*
CreateVolumeRequest
)
(
string
,
error
)
{
func
(
client
QuobyteClient
)
CreateVolume
(
request
*
CreateVolumeRequest
)
(
string
,
error
)
{
var
response
volumeUUID
var
response
volumeUUID
if
request
.
TenantID
!=
""
&&
!
IsValidUUID
(
request
.
TenantID
)
{
log
.
Printf
(
"Tenant name resolution: Resolving %s to UUID
\n
"
,
request
.
TenantID
)
tenantUUID
,
err
:=
client
.
ResolveTenantNameToUUID
(
request
.
TenantID
)
if
err
!=
nil
{
return
""
,
err
}
request
.
TenantID
=
tenantUUID
}
if
err
:=
client
.
sendRequest
(
"createVolume"
,
request
,
&
response
);
err
!=
nil
{
if
err
:=
client
.
sendRequest
(
"createVolume"
,
request
,
&
response
);
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
...
@@ -168,3 +181,23 @@ func (client *QuobyteClient) SetTenant(tenantName string) (string, error) {
...
@@ -168,3 +181,23 @@ func (client *QuobyteClient) SetTenant(tenantName string) (string, error) {
return
response
.
TenantID
,
nil
return
response
.
TenantID
,
nil
}
}
// IsValidUUID Validates given uuid
func
IsValidUUID
(
uuid
string
)
bool
{
r
:=
regexp
.
MustCompile
(
"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$"
)
return
r
.
MatchString
(
uuid
)
}
// ResolveTenantNameToUUID Returns UUID for given name, error if not found.
func
(
client
*
QuobyteClient
)
ResolveTenantNameToUUID
(
name
string
)
(
string
,
error
)
{
request
:=
&
resolveTenantNameRequest
{
TenantName
:
name
,
}
var
response
resolveTenantNameResponse
err
:=
client
.
sendRequest
(
"resolveTenantName"
,
request
,
&
response
)
if
err
!=
nil
{
return
""
,
err
}
return
response
.
TenantID
,
nil
}
vendor/github.com/quobyte/api/rpc_client.go
View file @
6eef91b7
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"encoding/json"
"encoding/json"
"errors"
"errors"
"io"
"io"
"log"
"math/rand"
"math/rand"
"net/http"
"net/http"
"reflect"
"reflect"
...
@@ -110,5 +111,8 @@ func (client QuobyteClient) sendRequest(method string, request interface{}, resp
...
@@ -110,5 +111,8 @@ func (client QuobyteClient) sendRequest(method string, request interface{}, resp
}
}
defer
resp
.
Body
.
Close
()
defer
resp
.
Body
.
Close
()
if
resp
.
StatusCode
<
200
||
resp
.
StatusCode
>
299
{
log
.
Printf
(
"Warning: HTTP status code for request is %s
\n
"
,
strconv
.
Itoa
(
resp
.
StatusCode
))
}
return
decodeResponse
(
resp
.
Body
,
&
response
)
return
decodeResponse
(
resp
.
Body
,
&
response
)
}
}
vendor/github.com/quobyte/api/types.go
View file @
6eef91b7
...
@@ -22,6 +22,14 @@ type resolveVolumeNameRequest struct {
...
@@ -22,6 +22,14 @@ type resolveVolumeNameRequest struct {
retryPolicy
retryPolicy
}
}
type
resolveTenantNameRequest
struct
{
TenantName
string
`json:"tenant_name,omitempty"`
}
type
resolveTenantNameResponse
struct
{
TenantID
string
`json:"tenant_id,omitempty"`
}
type
volumeUUID
struct
{
type
volumeUUID
struct
{
VolumeUUID
string
`json:"volume_uuid,omitempty"`
VolumeUUID
string
`json:"volume_uuid,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