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
799c54fb
Commit
799c54fb
authored
Sep 13, 2016
by
Johannes Scheuermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add vendor code
parent
0b7cb5f2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
324 additions
and
0 deletions
+324
-0
Godeps.json
Godeps/Godeps.json
+4
-0
LICENSES
Godeps/LICENSES
+36
-0
LICENSE
vendor/github.com/quobyte/api/LICENSE
+28
-0
README.md
vendor/github.com/quobyte/api/README.md
+35
-0
quobyte.go
vendor/github.com/quobyte/api/quobyte.go
+79
-0
rpc_client.go
vendor/github.com/quobyte/api/rpc_client.go
+108
-0
types.go
vendor/github.com/quobyte/api/types.go
+34
-0
No files found.
Godeps/Godeps.json
View file @
799c54fb
...
@@ -1908,6 +1908,10 @@
...
@@ -1908,6 +1908,10 @@
"Rev"
:
"454a56f35412459b5e684fd5ec0f9211b94f002a"
"Rev"
:
"454a56f35412459b5e684fd5ec0f9211b94f002a"
},
},
{
{
"ImportPath"
:
"github.com/quobyte/api"
,
"Rev"
:
"bf713b5a4333f44504fa1ce63690de45cfed6413"
},
{
"ImportPath"
:
"github.com/rackspace/gophercloud"
,
"ImportPath"
:
"github.com/rackspace/gophercloud"
,
"Comment"
:
"v1.0.0-920-g934dbf8"
,
"Comment"
:
"v1.0.0-920-g934dbf8"
,
"Rev"
:
"934dbf81977c67c521c75492dc1f55ca74dc5b04"
"Rev"
:
"934dbf81977c67c521c75492dc1f55ca74dc5b04"
...
...
Godeps/LICENSES
View file @
799c54fb
...
@@ -60579,6 +60579,42 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
...
@@ -60579,6 +60579,42 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================================================
================================================================================
= vendor/github.com/quobyte/api licensed under: =
Copyright (c) 2016, Quobyte Inc.
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 quobyte-automation 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 HOLDER 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.
= vendor/github.com/quobyte/api/LICENSE beacc5ea3bcda24bdcec545022dbb0b4 -
================================================================================
================================================================================
= vendor/github.com/rackspace/gophercloud licensed under: =
= vendor/github.com/rackspace/gophercloud licensed under: =
Copyright 2012-2013 Rackspace, Inc.
Copyright 2012-2013 Rackspace, Inc.
vendor/github.com/quobyte/api/LICENSE
0 → 100644
View file @
799c54fb
Copyright (c) 2016, Quobyte Inc.
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 quobyte-automation 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 HOLDER 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.
vendor/github.com/quobyte/api/README.md
0 → 100644
View file @
799c54fb
# Quobyte API Clients
Get the quoybte api client
```
bash
go get github.com/quobyte/api
```
## Usage
```
go
package
main
import
(
"log"
quobyte_api
"github.com/quobyte/api"
)
func
main
()
{
client
:=
quobyte_api
.
NewQuobyteClient
(
"http://apiserver:7860"
,
"user"
,
"password"
)
req
:=
&
quobyte_api
.
CreateVolumeRequest
{
Name
:
"MyVolume"
,
RootUserID
:
"root"
,
RootGroupID
:
"root"
,
ConfigurationName
:
"base"
,
}
volume_uuid
,
err
:=
client
.
CreateVolume
(
req
)
if
err
!=
nil
{
log
.
Fatalf
(
"Error:"
,
err
)
}
log
.
Printf
(
"%s"
,
volume_uuid
)
}
```
vendor/github.com/quobyte/api/quobyte.go
0 → 100644
View file @
799c54fb
// Package quobyte represents a golang API for the Quobyte Storage System
package
quobyte
import
"net/http"
type
QuobyteClient
struct
{
client
*
http
.
Client
url
string
username
string
password
string
}
// NewQuobyteClient creates a new Quobyte API client
func
NewQuobyteClient
(
url
string
,
username
string
,
password
string
)
*
QuobyteClient
{
return
&
QuobyteClient
{
client
:
&
http
.
Client
{},
url
:
url
,
username
:
username
,
password
:
password
,
}
}
// 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
)
{
var
response
volumeUUID
if
err
:=
client
.
sendRequest
(
"createVolume"
,
request
,
&
response
);
err
!=
nil
{
return
""
,
err
}
return
response
.
VolumeUUID
,
nil
}
// ResolveVolumeNameToUUID resolves a volume name to a UUID
func
(
client
*
QuobyteClient
)
ResolveVolumeNameToUUID
(
volumeName
,
tenant
string
)
(
string
,
error
)
{
request
:=
&
resolveVolumeNameRequest
{
VolumeName
:
volumeName
,
TenantDomain
:
tenant
,
}
var
response
volumeUUID
if
err
:=
client
.
sendRequest
(
"resolveVolumeName"
,
request
,
&
response
);
err
!=
nil
{
return
""
,
err
}
return
response
.
VolumeUUID
,
nil
}
// DeleteVolume deletes a Quobyte volume
func
(
client
*
QuobyteClient
)
DeleteVolume
(
UUID
string
)
error
{
return
client
.
sendRequest
(
"deleteVolume"
,
&
volumeUUID
{
VolumeUUID
:
UUID
,
},
nil
)
}
// DeleteVolumeByName deletes a volume by a given name
func
(
client
*
QuobyteClient
)
DeleteVolumeByName
(
volumeName
,
tenant
string
)
error
{
uuid
,
err
:=
client
.
ResolveVolumeNameToUUID
(
volumeName
,
tenant
)
if
err
!=
nil
{
return
err
}
return
client
.
DeleteVolume
(
uuid
)
}
// GetClientList returns a list of all active clients
func
(
client
*
QuobyteClient
)
GetClientList
(
tenant
string
)
(
GetClientListResponse
,
error
)
{
request
:=
&
getClientListRequest
{
TenantDomain
:
tenant
,
}
var
response
GetClientListResponse
if
err
:=
client
.
sendRequest
(
"getClientListRequest"
,
request
,
&
response
);
err
!=
nil
{
return
response
,
err
}
return
response
,
nil
}
vendor/github.com/quobyte/api/rpc_client.go
0 → 100644
View file @
799c54fb
package
quobyte
import
(
"bytes"
"encoding/json"
"errors"
"io"
"math/rand"
"net/http"
"strconv"
)
const
(
emptyResponse
string
=
"Empty result and no error occured"
)
type
request
struct
{
ID
string
`json:"id"`
Version
string
`json:"jsonrpc"`
Method
string
`json:"method"`
Params
interface
{}
`json:"params"`
}
type
response
struct
{
ID
string
`json:"id"`
Version
string
`json:"jsonrpc"`
Result
*
json
.
RawMessage
`json:"result"`
Error
*
json
.
RawMessage
`json:"error"`
}
type
rpcError
struct
{
Code
int64
`json:"code"`
Message
string
`json:"message"`
}
func
(
err
*
rpcError
)
decodeErrorCode
()
string
{
switch
err
.
Code
{
case
-
32600
:
return
"ERROR_CODE_INVALID_REQUEST"
case
-
32603
:
return
"ERROR_CODE_JSON_ENCODING_FAILED"
case
-
32601
:
return
"ERROR_CODE_METHOD_NOT_FOUND"
case
-
32700
:
return
"ERROR_CODE_PARSE_ERROR"
}
return
""
}
func
encodeRequest
(
method
string
,
params
interface
{})
([]
byte
,
error
)
{
return
json
.
Marshal
(
&
request
{
// Generate random ID and convert it to a string
ID
:
strconv
.
FormatInt
(
rand
.
Int63
(),
10
),
Version
:
"2.0"
,
Method
:
method
,
Params
:
params
,
})
}
func
decodeResponse
(
ioReader
io
.
Reader
,
reply
interface
{})
error
{
var
resp
response
if
err
:=
json
.
NewDecoder
(
ioReader
)
.
Decode
(
&
resp
);
err
!=
nil
{
return
err
}
if
resp
.
Error
!=
nil
{
var
rpcErr
rpcError
if
err
:=
json
.
Unmarshal
(
*
resp
.
Error
,
&
rpcErr
);
err
!=
nil
{
return
err
}
if
rpcErr
.
Message
!=
""
{
return
errors
.
New
(
rpcErr
.
Message
)
}
respError
:=
rpcErr
.
decodeErrorCode
()
if
respError
!=
""
{
return
errors
.
New
(
respError
)
}
}
if
resp
.
Result
!=
nil
&&
reply
!=
nil
{
return
json
.
Unmarshal
(
*
resp
.
Result
,
reply
)
}
return
errors
.
New
(
emptyResponse
)
}
func
(
client
QuobyteClient
)
sendRequest
(
method
string
,
request
interface
{},
response
interface
{})
error
{
message
,
err
:=
encodeRequest
(
method
,
request
)
if
err
!=
nil
{
return
err
}
req
,
err
:=
http
.
NewRequest
(
"POST"
,
client
.
url
,
bytes
.
NewBuffer
(
message
))
if
err
!=
nil
{
return
err
}
req
.
Header
.
Set
(
"Content-Type"
,
"application/json"
)
req
.
SetBasicAuth
(
client
.
username
,
client
.
password
)
resp
,
err
:=
client
.
client
.
Do
(
req
)
if
err
!=
nil
{
return
err
}
defer
resp
.
Body
.
Close
()
return
decodeResponse
(
resp
.
Body
,
&
response
)
}
vendor/github.com/quobyte/api/types.go
0 → 100644
View file @
799c54fb
package
quobyte
// CreateVolumeRequest represents a CreateVolumeRequest
type
CreateVolumeRequest
struct
{
Name
string
`json:"name,omitempty"`
RootUserID
string
`json:"root_user_id,omitempty"`
RootGroupID
string
`json:"root_group_id,omitempty"`
ReplicaDeviceIDS
[]
uint64
`json:"replica_device_ids,string,omitempty"`
ConfigurationName
string
`json:"configuration_name,omitempty"`
AccessMode
uint32
`json:"access_mode,string,omitempty"`
TenantID
string
`json:"tenant_id,omitempty"`
}
type
resolveVolumeNameRequest
struct
{
VolumeName
string
`json:"volume_name,omitempty"`
TenantDomain
string
`json:"tenant_domain,omitempty"`
}
type
volumeUUID
struct
{
VolumeUUID
string
`json:"volume_uuid,omitempty"`
}
type
getClientListRequest
struct
{
TenantDomain
string
`json:"tenant_domain,omitempty"`
}
type
GetClientListResponse
struct
{
Clients
[]
Client
`json:"client,omitempty"`
}
type
Client
struct
{
MountedUserName
string
`json:"mount_user_name,omitempty"`
MountedVolumeUUID
string
`json:"mounted_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