repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
libopenstorage/openstorage
cluster/mock/cluster.mock.go
GetData
func (m *MockCluster) GetData() (map[string]*api.Node, error) { ret := m.ctrl.Call(m, "GetData") ret0, _ := ret[0].(map[string]*api.Node) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockCluster) GetData() (map[string]*api.Node, error) { ret := m.ctrl.Call(m, "GetData") ret0, _ := ret[0].(map[string]*api.Node) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockCluster", ")", "GetData", "(", ")", "(", "map", "[", "string", "]", "*", "api", ".", "Node", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "map", "[", "string", "]", "*", "api", ".", "Node", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// GetData mocks base method
[ "GetData", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L244-L249
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
GetGossipState
func (m *MockCluster) GetGossipState() *cluster.ClusterState { ret := m.ctrl.Call(m, "GetGossipState") ret0, _ := ret[0].(*cluster.ClusterState) return ret0 }
go
func (m *MockCluster) GetGossipState() *cluster.ClusterState { ret := m.ctrl.Call(m, "GetGossipState") ret0, _ := ret[0].(*cluster.ClusterState) return ret0 }
[ "func", "(", "m", "*", "MockCluster", ")", "GetGossipState", "(", ")", "*", "cluster", ".", "ClusterState", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "*", "cluster", ".", "ClusterState", ")", "\n", "return", "ret0", "\n", "}" ]
// GetGossipState mocks base method
[ "GetGossipState", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L257-L261
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
GetNodeConf
func (m *MockCluster) GetNodeConf(arg0 string) (*osdconfig.NodeConfig, error) { ret := m.ctrl.Call(m, "GetNodeConf", arg0) ret0, _ := ret[0].(*osdconfig.NodeConfig) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockCluster) GetNodeConf(arg0 string) (*osdconfig.NodeConfig, error) { ret := m.ctrl.Call(m, "GetNodeConf", arg0) ret0, _ := ret[0].(*osdconfig.NodeConfig) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockCluster", ")", "GetNodeConf", "(", "arg0", "string", ")", "(", "*", "osdconfig", ".", "NodeConfig", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "*", "osdconfig", ".", "NodeConfig", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// GetNodeConf mocks base method
[ "GetNodeConf", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L269-L274
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
GetPair
func (m *MockCluster) GetPair(arg0 string) (*api.ClusterPairGetResponse, error) { ret := m.ctrl.Call(m, "GetPair", arg0) ret0, _ := ret[0].(*api.ClusterPairGetResponse) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockCluster) GetPair(arg0 string) (*api.ClusterPairGetResponse, error) { ret := m.ctrl.Call(m, "GetPair", arg0) ret0, _ := ret[0].(*api.ClusterPairGetResponse) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockCluster", ")", "GetPair", "(", "arg0", "string", ")", "(", "*", "api", ".", "ClusterPairGetResponse", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "*", "api", ".", "ClusterPairGetResponse", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// GetPair mocks base method
[ "GetPair", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L295-L300
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
GetPairToken
func (m *MockCluster) GetPairToken(arg0 bool) (*api.ClusterPairTokenGetResponse, error) { ret := m.ctrl.Call(m, "GetPairToken", arg0) ret0, _ := ret[0].(*api.ClusterPairTokenGetResponse) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockCluster) GetPairToken(arg0 bool) (*api.ClusterPairTokenGetResponse, error) { ret := m.ctrl.Call(m, "GetPairToken", arg0) ret0, _ := ret[0].(*api.ClusterPairTokenGetResponse) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockCluster", ")", "GetPairToken", "(", "arg0", "bool", ")", "(", "*", "api", ".", "ClusterPairTokenGetResponse", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "*", "api", ".", "ClusterPairTokenGetResponse", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// GetPairToken mocks base method
[ "GetPairToken", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L308-L313
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
GetSelfDomain
func (m *MockCluster) GetSelfDomain() (*clusterdomain.ClusterDomainInfo, error) { ret := m.ctrl.Call(m, "GetSelfDomain") ret0, _ := ret[0].(*clusterdomain.ClusterDomainInfo) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockCluster) GetSelfDomain() (*clusterdomain.ClusterDomainInfo, error) { ret := m.ctrl.Call(m, "GetSelfDomain") ret0, _ := ret[0].(*clusterdomain.ClusterDomainInfo) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockCluster", ")", "GetSelfDomain", "(", ")", "(", "*", "clusterdomain", ".", "ClusterDomainInfo", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "*", "clusterdomain", ".", "ClusterDomainInfo", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// GetSelfDomain mocks base method
[ "GetSelfDomain", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L321-L326
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
InspectDomain
func (m *MockCluster) InspectDomain(arg0 string) (*clusterdomain.ClusterDomainInfo, error) { ret := m.ctrl.Call(m, "InspectDomain", arg0) ret0, _ := ret[0].(*clusterdomain.ClusterDomainInfo) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockCluster) InspectDomain(arg0 string) (*clusterdomain.ClusterDomainInfo, error) { ret := m.ctrl.Call(m, "InspectDomain", arg0) ret0, _ := ret[0].(*clusterdomain.ClusterDomainInfo) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockCluster", ")", "InspectDomain", "(", "arg0", "string", ")", "(", "*", "clusterdomain", ".", "ClusterDomainInfo", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "*", "clusterdomain", ".", "ClusterDomainInfo", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// InspectDomain mocks base method
[ "InspectDomain", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L347-L352
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
NodeRemoveDone
func (m *MockCluster) NodeRemoveDone(arg0 string, arg1 error) { m.ctrl.Call(m, "NodeRemoveDone", arg0, arg1) }
go
func (m *MockCluster) NodeRemoveDone(arg0 string, arg1 error) { m.ctrl.Call(m, "NodeRemoveDone", arg0, arg1) }
[ "func", "(", "m", "*", "MockCluster", ")", "NodeRemoveDone", "(", "arg0", "string", ",", "arg1", "error", ")", "{", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ")", "\n", "}" ]
// NodeRemoveDone mocks base method
[ "NodeRemoveDone", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L360-L362
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
NodeStatus
func (m *MockCluster) NodeStatus() (api.Status, error) { ret := m.ctrl.Call(m, "NodeStatus") ret0, _ := ret[0].(api.Status) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockCluster) NodeStatus() (api.Status, error) { ret := m.ctrl.Call(m, "NodeStatus") ret0, _ := ret[0].(api.Status) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockCluster", ")", "NodeStatus", "(", ")", "(", "api", ".", "Status", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "api", ".", "Status", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// NodeStatus mocks base method
[ "NodeStatus", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L370-L375
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
ObjectStoreDelete
func (m *MockCluster) ObjectStoreDelete(arg0 string) error { ret := m.ctrl.Call(m, "ObjectStoreDelete", arg0) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockCluster) ObjectStoreDelete(arg0 string) error { ret := m.ctrl.Call(m, "ObjectStoreDelete", arg0) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockCluster", ")", "ObjectStoreDelete", "(", "arg0", "string", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// ObjectStoreDelete mocks base method
[ "ObjectStoreDelete", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L396-L400
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
ObjectStoreInspect
func (m *MockCluster) ObjectStoreInspect(arg0 string) (*api.ObjectstoreInfo, error) { ret := m.ctrl.Call(m, "ObjectStoreInspect", arg0) ret0, _ := ret[0].(*api.ObjectstoreInfo) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockCluster) ObjectStoreInspect(arg0 string) (*api.ObjectstoreInfo, error) { ret := m.ctrl.Call(m, "ObjectStoreInspect", arg0) ret0, _ := ret[0].(*api.ObjectstoreInfo) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockCluster", ")", "ObjectStoreInspect", "(", "arg0", "string", ")", "(", "*", "api", ".", "ObjectstoreInfo", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "*", "api", ".", "ObjectstoreInfo", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// ObjectStoreInspect mocks base method
[ "ObjectStoreInspect", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L408-L413
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
PeerStatus
func (m *MockCluster) PeerStatus(arg0 string) (map[string]api.Status, error) { ret := m.ctrl.Call(m, "PeerStatus", arg0) ret0, _ := ret[0].(map[string]api.Status) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockCluster) PeerStatus(arg0 string) (map[string]api.Status, error) { ret := m.ctrl.Call(m, "PeerStatus", arg0) ret0, _ := ret[0].(map[string]api.Status) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockCluster", ")", "PeerStatus", "(", "arg0", "string", ")", "(", "map", "[", "string", "]", "api", ".", "Status", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "map", "[", "string", "]", "api", ".", "Status", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// PeerStatus mocks base method
[ "PeerStatus", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L433-L438
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
ProcessPairRequest
func (m *MockCluster) ProcessPairRequest(arg0 *api.ClusterPairProcessRequest) (*api.ClusterPairProcessResponse, error) { ret := m.ctrl.Call(m, "ProcessPairRequest", arg0) ret0, _ := ret[0].(*api.ClusterPairProcessResponse) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockCluster) ProcessPairRequest(arg0 *api.ClusterPairProcessRequest) (*api.ClusterPairProcessResponse, error) { ret := m.ctrl.Call(m, "ProcessPairRequest", arg0) ret0, _ := ret[0].(*api.ClusterPairProcessResponse) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockCluster", ")", "ProcessPairRequest", "(", "arg0", "*", "api", ".", "ClusterPairProcessRequest", ")", "(", "*", "api", ".", "ClusterPairProcessResponse", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "*", "api", ".", "ClusterPairProcessResponse", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// ProcessPairRequest mocks base method
[ "ProcessPairRequest", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L446-L451
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
SchedPolicyEnumerate
func (m *MockCluster) SchedPolicyEnumerate() ([]*schedpolicy.SchedPolicy, error) { ret := m.ctrl.Call(m, "SchedPolicyEnumerate") ret0, _ := ret[0].([]*schedpolicy.SchedPolicy) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockCluster) SchedPolicyEnumerate() ([]*schedpolicy.SchedPolicy, error) { ret := m.ctrl.Call(m, "SchedPolicyEnumerate") ret0, _ := ret[0].([]*schedpolicy.SchedPolicy) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockCluster", ")", "SchedPolicyEnumerate", "(", ")", "(", "[", "]", "*", "schedpolicy", ".", "SchedPolicy", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "[", "]", "*", "schedpolicy", ".", "SchedPolicy", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// SchedPolicyEnumerate mocks base method
[ "SchedPolicyEnumerate", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L507-L512
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
SchedPolicyGet
func (m *MockCluster) SchedPolicyGet(arg0 string) (*schedpolicy.SchedPolicy, error) { ret := m.ctrl.Call(m, "SchedPolicyGet", arg0) ret0, _ := ret[0].(*schedpolicy.SchedPolicy) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockCluster) SchedPolicyGet(arg0 string) (*schedpolicy.SchedPolicy, error) { ret := m.ctrl.Call(m, "SchedPolicyGet", arg0) ret0, _ := ret[0].(*schedpolicy.SchedPolicy) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockCluster", ")", "SchedPolicyGet", "(", "arg0", "string", ")", "(", "*", "schedpolicy", ".", "SchedPolicy", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "*", "schedpolicy", ".", "SchedPolicy", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// SchedPolicyGet mocks base method
[ "SchedPolicyGet", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L520-L525
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
SecretGet
func (m *MockCluster) SecretGet(arg0 string) (interface{}, error) { ret := m.ctrl.Call(m, "SecretGet", arg0) ret0, _ := ret[0].(interface{}) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockCluster) SecretGet(arg0 string) (interface{}, error) { ret := m.ctrl.Call(m, "SecretGet", arg0) ret0, _ := ret[0].(interface{}) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockCluster", ")", "SecretGet", "(", "arg0", "string", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "interface", "{", "}", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// SecretGet mocks base method
[ "SecretGet", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L557-L562
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
SecretGetDefaultSecretKey
func (m *MockCluster) SecretGetDefaultSecretKey() (interface{}, error) { ret := m.ctrl.Call(m, "SecretGetDefaultSecretKey") ret0, _ := ret[0].(interface{}) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockCluster) SecretGetDefaultSecretKey() (interface{}, error) { ret := m.ctrl.Call(m, "SecretGetDefaultSecretKey") ret0, _ := ret[0].(interface{}) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockCluster", ")", "SecretGetDefaultSecretKey", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "interface", "{", "}", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// SecretGetDefaultSecretKey mocks base method
[ "SecretGetDefaultSecretKey", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L570-L575
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
SecretSet
func (m *MockCluster) SecretSet(arg0 string, arg1 interface{}) error { ret := m.ctrl.Call(m, "SecretSet", arg0, arg1) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockCluster) SecretSet(arg0 string, arg1 interface{}) error { ret := m.ctrl.Call(m, "SecretSet", arg0, arg1) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockCluster", ")", "SecretSet", "(", "arg0", "string", ",", "arg1", "interface", "{", "}", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// SecretSet mocks base method
[ "SecretSet", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L595-L599
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
SecretSet
func (mr *MockClusterMockRecorder) SecretSet(arg0, arg1 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SecretSet", reflect.TypeOf((*MockCluster)(nil).SecretSet), arg0, arg1) }
go
func (mr *MockClusterMockRecorder) SecretSet(arg0, arg1 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SecretSet", reflect.TypeOf((*MockCluster)(nil).SecretSet), arg0, arg1) }
[ "func", "(", "mr", "*", "MockClusterMockRecorder", ")", "SecretSet", "(", "arg0", ",", "arg1", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockCluster", ")", "(", "nil", ")", ".", "SecretSet", ")", ",", "arg0", ",", "arg1", ")", "\n", "}" ]
// SecretSet indicates an expected call of SecretSet
[ "SecretSet", "indicates", "an", "expected", "call", "of", "SecretSet" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L602-L604
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
SecretSetDefaultSecretKey
func (m *MockCluster) SecretSetDefaultSecretKey(arg0 string, arg1 bool) error { ret := m.ctrl.Call(m, "SecretSetDefaultSecretKey", arg0, arg1) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockCluster) SecretSetDefaultSecretKey(arg0 string, arg1 bool) error { ret := m.ctrl.Call(m, "SecretSetDefaultSecretKey", arg0, arg1) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockCluster", ")", "SecretSetDefaultSecretKey", "(", "arg0", "string", ",", "arg1", "bool", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// SecretSetDefaultSecretKey mocks base method
[ "SecretSetDefaultSecretKey", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L607-L611
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
SetClusterConf
func (m *MockCluster) SetClusterConf(arg0 *osdconfig.ClusterConfig) error { ret := m.ctrl.Call(m, "SetClusterConf", arg0) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockCluster) SetClusterConf(arg0 *osdconfig.ClusterConfig) error { ret := m.ctrl.Call(m, "SetClusterConf", arg0) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockCluster", ")", "SetClusterConf", "(", "arg0", "*", "osdconfig", ".", "ClusterConfig", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// SetClusterConf mocks base method
[ "SetClusterConf", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L619-L623
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
SetNodeConf
func (m *MockCluster) SetNodeConf(arg0 *osdconfig.NodeConfig) error { ret := m.ctrl.Call(m, "SetNodeConf", arg0) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockCluster) SetNodeConf(arg0 *osdconfig.NodeConfig) error { ret := m.ctrl.Call(m, "SetNodeConf", arg0) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockCluster", ")", "SetNodeConf", "(", "arg0", "*", "osdconfig", ".", "NodeConfig", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// SetNodeConf mocks base method
[ "SetNodeConf", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L631-L635
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
SetSize
func (m *MockCluster) SetSize(arg0 int) error { ret := m.ctrl.Call(m, "SetSize", arg0) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockCluster) SetSize(arg0 int) error { ret := m.ctrl.Call(m, "SetSize", arg0) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockCluster", ")", "SetSize", "(", "arg0", "int", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// SetSize mocks base method
[ "SetSize", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L643-L647
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
StartWithConfiguration
func (m *MockCluster) StartWithConfiguration(arg0 int, arg1 bool, arg2 string, arg3 []string, arg4 string, arg5 *cluster.ClusterServerConfiguration) error { ret := m.ctrl.Call(m, "StartWithConfiguration", arg0, arg1, arg2, arg3, arg4, arg5) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockCluster) StartWithConfiguration(arg0 int, arg1 bool, arg2 string, arg3 []string, arg4 string, arg5 *cluster.ClusterServerConfiguration) error { ret := m.ctrl.Call(m, "StartWithConfiguration", arg0, arg1, arg2, arg3, arg4, arg5) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockCluster", ")", "StartWithConfiguration", "(", "arg0", "int", ",", "arg1", "bool", ",", "arg2", "string", ",", "arg3", "[", "]", "string", ",", "arg4", "string", ",", "arg5", "*", "cluster", ".", "ClusterServerConfiguration", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", ",", "arg4", ",", "arg5", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// StartWithConfiguration mocks base method
[ "StartWithConfiguration", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L679-L683
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
StartWithConfiguration
func (mr *MockClusterMockRecorder) StartWithConfiguration(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartWithConfiguration", reflect.TypeOf((*MockCluster)(nil).StartWithConfiguration), arg0, arg1, arg2, arg3, arg4, arg5) }
go
func (mr *MockClusterMockRecorder) StartWithConfiguration(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartWithConfiguration", reflect.TypeOf((*MockCluster)(nil).StartWithConfiguration), arg0, arg1, arg2, arg3, arg4, arg5) }
[ "func", "(", "mr", "*", "MockClusterMockRecorder", ")", "StartWithConfiguration", "(", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", ",", "arg4", ",", "arg5", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockCluster", ")", "(", "nil", ")", ".", "StartWithConfiguration", ")", ",", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", ",", "arg4", ",", "arg5", ")", "\n", "}" ]
// StartWithConfiguration indicates an expected call of StartWithConfiguration
[ "StartWithConfiguration", "indicates", "an", "expected", "call", "of", "StartWithConfiguration" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L686-L688
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
UpdateDomainState
func (m *MockCluster) UpdateDomainState(arg0 string, arg1 types.ClusterDomainState) error { ret := m.ctrl.Call(m, "UpdateDomainState", arg0, arg1) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockCluster) UpdateDomainState(arg0 string, arg1 types.ClusterDomainState) error { ret := m.ctrl.Call(m, "UpdateDomainState", arg0, arg1) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockCluster", ")", "UpdateDomainState", "(", "arg0", "string", ",", "arg1", "types", ".", "ClusterDomainState", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// UpdateDomainState mocks base method
[ "UpdateDomainState", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L703-L707
train
libopenstorage/openstorage
cluster/mock/cluster.mock.go
Uuid
func (m *MockCluster) Uuid() string { ret := m.ctrl.Call(m, "Uuid") ret0, _ := ret[0].(string) return ret0 }
go
func (m *MockCluster) Uuid() string { ret := m.ctrl.Call(m, "Uuid") ret0, _ := ret[0].(string) return ret0 }
[ "func", "(", "m", "*", "MockCluster", ")", "Uuid", "(", ")", "string", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "string", ")", "\n", "return", "ret0", "\n", "}" ]
// Uuid mocks base method
[ "Uuid", "mocks", "base", "method" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/mock/cluster.mock.go#L739-L743
train
libopenstorage/openstorage
api/server/sdk/node.go
Enumerate
func (s *NodeServer) Enumerate( ctx context.Context, req *api.SdkNodeEnumerateRequest, ) (*api.SdkNodeEnumerateResponse, error) { if s.cluster() == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } c, err := s.cluster().Enumerate() if err != nil { return nil, status.Error(codes.Internal, err.Error()) } nodeIds := make([]string, len(c.Nodes)) for i, v := range c.Nodes { nodeIds[i] = v.Id } return &api.SdkNodeEnumerateResponse{ NodeIds: nodeIds, }, nil }
go
func (s *NodeServer) Enumerate( ctx context.Context, req *api.SdkNodeEnumerateRequest, ) (*api.SdkNodeEnumerateResponse, error) { if s.cluster() == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } c, err := s.cluster().Enumerate() if err != nil { return nil, status.Error(codes.Internal, err.Error()) } nodeIds := make([]string, len(c.Nodes)) for i, v := range c.Nodes { nodeIds[i] = v.Id } return &api.SdkNodeEnumerateResponse{ NodeIds: nodeIds, }, nil }
[ "func", "(", "s", "*", "NodeServer", ")", "Enumerate", "(", "ctx", "context", ".", "Context", ",", "req", "*", "api", ".", "SdkNodeEnumerateRequest", ",", ")", "(", "*", "api", ".", "SdkNodeEnumerateResponse", ",", "error", ")", "{", "if", "s", ".", "cluster", "(", ")", "==", "nil", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "Unavailable", ",", "\"", "\"", ")", "\n", "}", "\n", "c", ",", "err", ":=", "s", ".", "cluster", "(", ")", ".", "Enumerate", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "Internal", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n\n", "nodeIds", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "c", ".", "Nodes", ")", ")", "\n", "for", "i", ",", "v", ":=", "range", "c", ".", "Nodes", "{", "nodeIds", "[", "i", "]", "=", "v", ".", "Id", "\n", "}", "\n\n", "return", "&", "api", ".", "SdkNodeEnumerateResponse", "{", "NodeIds", ":", "nodeIds", ",", "}", ",", "nil", "\n", "}" ]
// Enumerate returns the ids of all the nodes in the cluster
[ "Enumerate", "returns", "the", "ids", "of", "all", "the", "nodes", "in", "the", "cluster" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/server/sdk/node.go#L39-L59
train
libopenstorage/openstorage
api/server/sdk/node.go
Inspect
func (s *NodeServer) Inspect( ctx context.Context, req *api.SdkNodeInspectRequest, ) (*api.SdkNodeInspectResponse, error) { if s.cluster() == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if len(req.GetNodeId()) == 0 { return nil, status.Error(codes.InvalidArgument, "Node id must be provided") } node, err := s.cluster().Inspect(req.GetNodeId()) if err != nil { if err == kvdb.ErrNotFound { return nil, status.Errorf( codes.NotFound, "Id %s not found", req.GetNodeId()) } return nil, status.Error(codes.Internal, err.Error()) } return &api.SdkNodeInspectResponse{ Node: node.ToStorageNode(), }, nil }
go
func (s *NodeServer) Inspect( ctx context.Context, req *api.SdkNodeInspectRequest, ) (*api.SdkNodeInspectResponse, error) { if s.cluster() == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if len(req.GetNodeId()) == 0 { return nil, status.Error(codes.InvalidArgument, "Node id must be provided") } node, err := s.cluster().Inspect(req.GetNodeId()) if err != nil { if err == kvdb.ErrNotFound { return nil, status.Errorf( codes.NotFound, "Id %s not found", req.GetNodeId()) } return nil, status.Error(codes.Internal, err.Error()) } return &api.SdkNodeInspectResponse{ Node: node.ToStorageNode(), }, nil }
[ "func", "(", "s", "*", "NodeServer", ")", "Inspect", "(", "ctx", "context", ".", "Context", ",", "req", "*", "api", ".", "SdkNodeInspectRequest", ",", ")", "(", "*", "api", ".", "SdkNodeInspectResponse", ",", "error", ")", "{", "if", "s", ".", "cluster", "(", ")", "==", "nil", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "Unavailable", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "len", "(", "req", ".", "GetNodeId", "(", ")", ")", "==", "0", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "\n\n", "node", ",", "err", ":=", "s", ".", "cluster", "(", ")", ".", "Inspect", "(", "req", ".", "GetNodeId", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "kvdb", ".", "ErrNotFound", "{", "return", "nil", ",", "status", ".", "Errorf", "(", "codes", ".", "NotFound", ",", "\"", "\"", ",", "req", ".", "GetNodeId", "(", ")", ")", "\n", "}", "\n", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "Internal", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n\n", "return", "&", "api", ".", "SdkNodeInspectResponse", "{", "Node", ":", "node", ".", "ToStorageNode", "(", ")", ",", "}", ",", "nil", "\n", "}" ]
// Inspect returns information about a specific node
[ "Inspect", "returns", "information", "about", "a", "specific", "node" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/server/sdk/node.go#L62-L88
train
libopenstorage/openstorage
pkg/auth/claims.go
getUsername
func getUsername(usernameClaim UsernameClaimType, claims *Claims) string { switch usernameClaim { case UsernameClaimTypeEmail: return claims.Email case UsernameClaimTypeName: return claims.Name } return claims.Subject }
go
func getUsername(usernameClaim UsernameClaimType, claims *Claims) string { switch usernameClaim { case UsernameClaimTypeEmail: return claims.Email case UsernameClaimTypeName: return claims.Name } return claims.Subject }
[ "func", "getUsername", "(", "usernameClaim", "UsernameClaimType", ",", "claims", "*", "Claims", ")", "string", "{", "switch", "usernameClaim", "{", "case", "UsernameClaimTypeEmail", ":", "return", "claims", ".", "Email", "\n", "case", "UsernameClaimTypeName", ":", "return", "claims", ".", "Name", "\n", "}", "\n", "return", "claims", ".", "Subject", "\n", "}" ]
// utility function to get username
[ "utility", "function", "to", "get", "username" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/auth/claims.go#L49-L57
train
libopenstorage/openstorage
pkg/flexvolume/flexvolume.go
BytesToJSONOptions
func BytesToJSONOptions(value []byte) (map[string]string, error) { if value == nil || len(value) == 0 { return nil, nil } m := make(map[string]string) if err := json.Unmarshal(value, &m); err != nil { return nil, err } return m, nil }
go
func BytesToJSONOptions(value []byte) (map[string]string, error) { if value == nil || len(value) == 0 { return nil, nil } m := make(map[string]string) if err := json.Unmarshal(value, &m); err != nil { return nil, err } return m, nil }
[ "func", "BytesToJSONOptions", "(", "value", "[", "]", "byte", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "if", "value", "==", "nil", "||", "len", "(", "value", ")", "==", "0", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "m", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "value", ",", "&", "m", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "m", ",", "nil", "\n", "}" ]
// BytesToJSONOptions converts a JSON string to a map of JSON options.
[ "BytesToJSONOptions", "converts", "a", "JSON", "string", "to", "a", "map", "of", "JSON", "options", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/flexvolume/flexvolume.go#L38-L47
train
libopenstorage/openstorage
pkg/flexvolume/flexvolume.go
JSONOptionsToBytes
func JSONOptionsToBytes(jsonOptions map[string]string) ([]byte, error) { if jsonOptions == nil || len(jsonOptions) == 0 { return nil, nil } return json.Marshal(jsonOptions) }
go
func JSONOptionsToBytes(jsonOptions map[string]string) ([]byte, error) { if jsonOptions == nil || len(jsonOptions) == 0 { return nil, nil } return json.Marshal(jsonOptions) }
[ "func", "JSONOptionsToBytes", "(", "jsonOptions", "map", "[", "string", "]", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "jsonOptions", "==", "nil", "||", "len", "(", "jsonOptions", ")", "==", "0", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "return", "json", ".", "Marshal", "(", "jsonOptions", ")", "\n", "}" ]
// JSONOptionsToBytes converts a map of JSON Options to a JSON string.
[ "JSONOptionsToBytes", "converts", "a", "map", "of", "JSON", "Options", "to", "a", "JSON", "string", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/flexvolume/flexvolume.go#L50-L55
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStorageAlertsHandler
func RegisterOpenStorageAlertsHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageAlertsHandlerClient(ctx, mux, NewOpenStorageAlertsClient(conn)) }
go
func RegisterOpenStorageAlertsHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageAlertsHandlerClient(ctx, mux, NewOpenStorageAlertsClient(conn)) }
[ "func", "RegisterOpenStorageAlertsHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterOpenStorageAlertsHandlerClient", "(", "ctx", ",", "mux", ",", "NewOpenStorageAlertsClient", "(", "conn", ")", ")", "\n", "}" ]
// RegisterOpenStorageAlertsHandler registers the http handlers for service OpenStorageAlerts to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterOpenStorageAlertsHandler", "registers", "the", "http", "handlers", "for", "service", "OpenStorageAlerts", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L1491-L1493
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStorageRoleHandler
func RegisterOpenStorageRoleHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageRoleHandlerClient(ctx, mux, NewOpenStorageRoleClient(conn)) }
go
func RegisterOpenStorageRoleHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageRoleHandlerClient(ctx, mux, NewOpenStorageRoleClient(conn)) }
[ "func", "RegisterOpenStorageRoleHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterOpenStorageRoleHandlerClient", "(", "ctx", ",", "mux", ",", "NewOpenStorageRoleClient", "(", "conn", ")", ")", "\n", "}" ]
// RegisterOpenStorageRoleHandler registers the http handlers for service OpenStorageRole to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterOpenStorageRoleHandler", "registers", "the", "http", "handlers", "for", "service", "OpenStorageRole", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L1602-L1604
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStorageIdentityHandler
func RegisterOpenStorageIdentityHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageIdentityHandlerClient(ctx, mux, NewOpenStorageIdentityClient(conn)) }
go
func RegisterOpenStorageIdentityHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageIdentityHandlerClient(ctx, mux, NewOpenStorageIdentityClient(conn)) }
[ "func", "RegisterOpenStorageIdentityHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterOpenStorageIdentityHandlerClient", "(", "ctx", ",", "mux", ",", "NewOpenStorageIdentityClient", "(", "conn", ")", ")", "\n", "}" ]
// RegisterOpenStorageIdentityHandler registers the http handlers for service OpenStorageIdentity to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterOpenStorageIdentityHandler", "registers", "the", "http", "handlers", "for", "service", "OpenStorageIdentity", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L1812-L1814
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStorageClusterHandlerFromEndpoint
func RegisterOpenStorageClusterHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.Dial(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterOpenStorageClusterHandler(ctx, mux, conn) }
go
func RegisterOpenStorageClusterHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.Dial(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterOpenStorageClusterHandler(ctx, mux, conn) }
[ "func", "RegisterOpenStorageClusterHandlerFromEndpoint", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "endpoint", "string", ",", "opts", "[", "]", "grpc", ".", "DialOption", ")", "(", "err", "error", ")", "{", "conn", ",", "err", ":=", "grpc", ".", "Dial", "(", "endpoint", ",", "opts", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "if", "cerr", ":=", "conn", ".", "Close", "(", ")", ";", "cerr", "!=", "nil", "{", "grpclog", ".", "Printf", "(", "\"", "\"", ",", "endpoint", ",", "cerr", ")", "\n", "}", "\n", "return", "\n", "}", "\n", "go", "func", "(", ")", "{", "<-", "ctx", ".", "Done", "(", ")", "\n", "if", "cerr", ":=", "conn", ".", "Close", "(", ")", ";", "cerr", "!=", "nil", "{", "grpclog", ".", "Printf", "(", "\"", "\"", ",", "endpoint", ",", "cerr", ")", "\n", "}", "\n", "}", "(", ")", "\n", "}", "(", ")", "\n\n", "return", "RegisterOpenStorageClusterHandler", "(", "ctx", ",", "mux", ",", "conn", ")", "\n", "}" ]
// RegisterOpenStorageClusterHandlerFromEndpoint is same as RegisterOpenStorageClusterHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done.
[ "RegisterOpenStorageClusterHandlerFromEndpoint", "is", "same", "as", "RegisterOpenStorageClusterHandler", "but", "automatically", "dials", "to", "endpoint", "and", "closes", "the", "connection", "when", "ctx", "gets", "done", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L1898-L1919
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStorageClusterHandler
func RegisterOpenStorageClusterHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageClusterHandlerClient(ctx, mux, NewOpenStorageClusterClient(conn)) }
go
func RegisterOpenStorageClusterHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageClusterHandlerClient(ctx, mux, NewOpenStorageClusterClient(conn)) }
[ "func", "RegisterOpenStorageClusterHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterOpenStorageClusterHandlerClient", "(", "ctx", ",", "mux", ",", "NewOpenStorageClusterClient", "(", "conn", ")", ")", "\n", "}" ]
// RegisterOpenStorageClusterHandler registers the http handlers for service OpenStorageCluster to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterOpenStorageClusterHandler", "registers", "the", "http", "handlers", "for", "service", "OpenStorageCluster", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L1923-L1925
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStorageClusterPairHandler
func RegisterOpenStorageClusterPairHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageClusterPairHandlerClient(ctx, mux, NewOpenStorageClusterPairClient(conn)) }
go
func RegisterOpenStorageClusterPairHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageClusterPairHandlerClient(ctx, mux, NewOpenStorageClusterPairClient(conn)) }
[ "func", "RegisterOpenStorageClusterPairHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterOpenStorageClusterPairHandlerClient", "(", "ctx", ",", "mux", ",", "NewOpenStorageClusterPairClient", "(", "conn", ")", ")", "\n", "}" ]
// RegisterOpenStorageClusterPairHandler registers the http handlers for service OpenStorageClusterPair to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterOpenStorageClusterPairHandler", "registers", "the", "http", "handlers", "for", "service", "OpenStorageClusterPair", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L2001-L2003
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStorageClusterDomainsHandler
func RegisterOpenStorageClusterDomainsHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageClusterDomainsHandlerClient(ctx, mux, NewOpenStorageClusterDomainsClient(conn)) }
go
func RegisterOpenStorageClusterDomainsHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageClusterDomainsHandlerClient(ctx, mux, NewOpenStorageClusterDomainsClient(conn)) }
[ "func", "RegisterOpenStorageClusterDomainsHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterOpenStorageClusterDomainsHandlerClient", "(", "ctx", ",", "mux", ",", "NewOpenStorageClusterDomainsClient", "(", "conn", ")", ")", "\n", "}" ]
// RegisterOpenStorageClusterDomainsHandler registers the http handlers for service OpenStorageClusterDomains to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterOpenStorageClusterDomainsHandler", "registers", "the", "http", "handlers", "for", "service", "OpenStorageClusterDomains", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L2244-L2246
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStorageNodeHandler
func RegisterOpenStorageNodeHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageNodeHandlerClient(ctx, mux, NewOpenStorageNodeClient(conn)) }
go
func RegisterOpenStorageNodeHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageNodeHandlerClient(ctx, mux, NewOpenStorageNodeClient(conn)) }
[ "func", "RegisterOpenStorageNodeHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterOpenStorageNodeHandlerClient", "(", "ctx", ",", "mux", ",", "NewOpenStorageNodeClient", "(", "conn", ")", ")", "\n", "}" ]
// RegisterOpenStorageNodeHandler registers the http handlers for service OpenStorageNode to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterOpenStorageNodeHandler", "registers", "the", "http", "handlers", "for", "service", "OpenStorageNode", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L2421-L2423
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStorageVolumeHandler
func RegisterOpenStorageVolumeHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageVolumeHandlerClient(ctx, mux, NewOpenStorageVolumeClient(conn)) }
go
func RegisterOpenStorageVolumeHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageVolumeHandlerClient(ctx, mux, NewOpenStorageVolumeClient(conn)) }
[ "func", "RegisterOpenStorageVolumeHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterOpenStorageVolumeHandlerClient", "(", "ctx", ",", "mux", ",", "NewOpenStorageVolumeClient", "(", "conn", ")", ")", "\n", "}" ]
// RegisterOpenStorageVolumeHandler registers the http handlers for service OpenStorageVolume to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterOpenStorageVolumeHandler", "registers", "the", "http", "handlers", "for", "service", "OpenStorageVolume", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L2565-L2567
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStorageMountAttachHandler
func RegisterOpenStorageMountAttachHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageMountAttachHandlerClient(ctx, mux, NewOpenStorageMountAttachClient(conn)) }
go
func RegisterOpenStorageMountAttachHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageMountAttachHandlerClient(ctx, mux, NewOpenStorageMountAttachClient(conn)) }
[ "func", "RegisterOpenStorageMountAttachHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterOpenStorageMountAttachHandlerClient", "(", "ctx", ",", "mux", ",", "NewOpenStorageMountAttachClient", "(", "conn", ")", ")", "\n", "}" ]
// RegisterOpenStorageMountAttachHandler registers the http handlers for service OpenStorageMountAttach to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterOpenStorageMountAttachHandler", "registers", "the", "http", "handlers", "for", "service", "OpenStorageMountAttach", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L3105-L3107
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStorageMigrateHandler
func RegisterOpenStorageMigrateHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageMigrateHandlerClient(ctx, mux, NewOpenStorageMigrateClient(conn)) }
go
func RegisterOpenStorageMigrateHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageMigrateHandlerClient(ctx, mux, NewOpenStorageMigrateClient(conn)) }
[ "func", "RegisterOpenStorageMigrateHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterOpenStorageMigrateHandlerClient", "(", "ctx", ",", "mux", ",", "NewOpenStorageMigrateClient", "(", "conn", ")", ")", "\n", "}" ]
// RegisterOpenStorageMigrateHandler registers the http handlers for service OpenStorageMigrate to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterOpenStorageMigrateHandler", "registers", "the", "http", "handlers", "for", "service", "OpenStorageMigrate", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L3282-L3284
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStorageObjectstoreHandler
func RegisterOpenStorageObjectstoreHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageObjectstoreHandlerClient(ctx, mux, NewOpenStorageObjectstoreClient(conn)) }
go
func RegisterOpenStorageObjectstoreHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageObjectstoreHandlerClient(ctx, mux, NewOpenStorageObjectstoreClient(conn)) }
[ "func", "RegisterOpenStorageObjectstoreHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterOpenStorageObjectstoreHandlerClient", "(", "ctx", ",", "mux", ",", "NewOpenStorageObjectstoreClient", "(", "conn", ")", ")", "\n", "}" ]
// RegisterOpenStorageObjectstoreHandler registers the http handlers for service OpenStorageObjectstore to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterOpenStorageObjectstoreHandler", "registers", "the", "http", "handlers", "for", "service", "OpenStorageObjectstore", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L3426-L3428
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStorageCredentialsHandler
func RegisterOpenStorageCredentialsHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageCredentialsHandlerClient(ctx, mux, NewOpenStorageCredentialsClient(conn)) }
go
func RegisterOpenStorageCredentialsHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageCredentialsHandlerClient(ctx, mux, NewOpenStorageCredentialsClient(conn)) }
[ "func", "RegisterOpenStorageCredentialsHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterOpenStorageCredentialsHandlerClient", "(", "ctx", ",", "mux", ",", "NewOpenStorageCredentialsClient", "(", "conn", ")", ")", "\n", "}" ]
// RegisterOpenStorageCredentialsHandler registers the http handlers for service OpenStorageCredentials to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterOpenStorageCredentialsHandler", "registers", "the", "http", "handlers", "for", "service", "OpenStorageCredentials", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L3603-L3605
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStorageSchedulePolicyHandler
func RegisterOpenStorageSchedulePolicyHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageSchedulePolicyHandlerClient(ctx, mux, NewOpenStorageSchedulePolicyClient(conn)) }
go
func RegisterOpenStorageSchedulePolicyHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageSchedulePolicyHandlerClient(ctx, mux, NewOpenStorageSchedulePolicyClient(conn)) }
[ "func", "RegisterOpenStorageSchedulePolicyHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterOpenStorageSchedulePolicyHandlerClient", "(", "ctx", ",", "mux", ",", "NewOpenStorageSchedulePolicyClient", "(", "conn", ")", ")", "\n", "}" ]
// RegisterOpenStorageSchedulePolicyHandler registers the http handlers for service OpenStorageSchedulePolicy to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterOpenStorageSchedulePolicyHandler", "registers", "the", "http", "handlers", "for", "service", "OpenStorageSchedulePolicy", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L3813-L3815
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStorageCloudBackupHandler
func RegisterOpenStorageCloudBackupHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageCloudBackupHandlerClient(ctx, mux, NewOpenStorageCloudBackupClient(conn)) }
go
func RegisterOpenStorageCloudBackupHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStorageCloudBackupHandlerClient(ctx, mux, NewOpenStorageCloudBackupClient(conn)) }
[ "func", "RegisterOpenStorageCloudBackupHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterOpenStorageCloudBackupHandlerClient", "(", "ctx", ",", "mux", ",", "NewOpenStorageCloudBackupClient", "(", "conn", ")", ")", "\n", "}" ]
// RegisterOpenStorageCloudBackupHandler registers the http handlers for service OpenStorageCloudBackup to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterOpenStorageCloudBackupHandler", "registers", "the", "http", "handlers", "for", "service", "OpenStorageCloudBackup", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L4023-L4025
train
libopenstorage/openstorage
api/api.pb.gw.go
RegisterOpenStoragePolicyHandler
func RegisterOpenStoragePolicyHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStoragePolicyHandlerClient(ctx, mux, NewOpenStoragePolicyClient(conn)) }
go
func RegisterOpenStoragePolicyHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpenStoragePolicyHandlerClient(ctx, mux, NewOpenStoragePolicyClient(conn)) }
[ "func", "RegisterOpenStoragePolicyHandler", "(", "ctx", "context", ".", "Context", ",", "mux", "*", "runtime", ".", "ServeMux", ",", "conn", "*", "grpc", ".", "ClientConn", ")", "error", "{", "return", "RegisterOpenStoragePolicyHandlerClient", "(", "ctx", ",", "mux", ",", "NewOpenStoragePolicyClient", "(", "conn", ")", ")", "\n", "}" ]
// RegisterOpenStoragePolicyHandler registers the http handlers for service OpenStoragePolicy to "mux". // The handlers forward requests to the grpc endpoint over "conn".
[ "RegisterOpenStoragePolicyHandler", "registers", "the", "http", "handlers", "for", "service", "OpenStoragePolicy", "to", "mux", ".", "The", "handlers", "forward", "requests", "to", "the", "grpc", "endpoint", "over", "conn", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/api.pb.gw.go#L4464-L4466
train
libopenstorage/openstorage
pkg/auth/token.go
TokenClaims
func TokenClaims(rawtoken string) (*Claims, error) { parts := strings.Split(rawtoken, ".") // There are supposed to be three parts for the token if len(parts) < 3 { return nil, fmt.Errorf("Token is invalid: %v", rawtoken) } // Access claims in the token claimBytes, err := jwt.DecodeSegment(parts[1]) if err != nil { return nil, fmt.Errorf("Failed to decode claims: %v", err) } var claims *Claims // Unmarshal claims err = json.Unmarshal(claimBytes, &claims) if err != nil { return nil, fmt.Errorf("Unable to get information from the claims in the token: %v", err) } return claims, nil }
go
func TokenClaims(rawtoken string) (*Claims, error) { parts := strings.Split(rawtoken, ".") // There are supposed to be three parts for the token if len(parts) < 3 { return nil, fmt.Errorf("Token is invalid: %v", rawtoken) } // Access claims in the token claimBytes, err := jwt.DecodeSegment(parts[1]) if err != nil { return nil, fmt.Errorf("Failed to decode claims: %v", err) } var claims *Claims // Unmarshal claims err = json.Unmarshal(claimBytes, &claims) if err != nil { return nil, fmt.Errorf("Unable to get information from the claims in the token: %v", err) } return claims, nil }
[ "func", "TokenClaims", "(", "rawtoken", "string", ")", "(", "*", "Claims", ",", "error", ")", "{", "parts", ":=", "strings", ".", "Split", "(", "rawtoken", ",", "\"", "\"", ")", "\n\n", "// There are supposed to be three parts for the token", "if", "len", "(", "parts", ")", "<", "3", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "rawtoken", ")", "\n", "}", "\n\n", "// Access claims in the token", "claimBytes", ",", "err", ":=", "jwt", ".", "DecodeSegment", "(", "parts", "[", "1", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "var", "claims", "*", "Claims", "\n\n", "// Unmarshal claims", "err", "=", "json", ".", "Unmarshal", "(", "claimBytes", ",", "&", "claims", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "return", "claims", ",", "nil", "\n", "}" ]
// TokenClaims returns the claims for the raw JWT token.
[ "TokenClaims", "returns", "the", "claims", "for", "the", "raw", "JWT", "token", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/auth/token.go#L40-L62
train
libopenstorage/openstorage
pkg/auth/token.go
TokenIssuer
func TokenIssuer(rawtoken string) (string, error) { claims, err := TokenClaims(rawtoken) if err != nil { return "", err } // Return issuer if len(claims.Issuer) != 0 { return claims.Issuer, nil } else { return "", fmt.Errorf("Issuer was not specified in the token") } }
go
func TokenIssuer(rawtoken string) (string, error) { claims, err := TokenClaims(rawtoken) if err != nil { return "", err } // Return issuer if len(claims.Issuer) != 0 { return claims.Issuer, nil } else { return "", fmt.Errorf("Issuer was not specified in the token") } }
[ "func", "TokenIssuer", "(", "rawtoken", "string", ")", "(", "string", ",", "error", ")", "{", "claims", ",", "err", ":=", "TokenClaims", "(", "rawtoken", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "// Return issuer", "if", "len", "(", "claims", ".", "Issuer", ")", "!=", "0", "{", "return", "claims", ".", "Issuer", ",", "nil", "\n", "}", "else", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "}" ]
// TokenIssuer returns the issuer for the raw JWT token.
[ "TokenIssuer", "returns", "the", "issuer", "for", "the", "raw", "JWT", "token", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/auth/token.go#L65-L77
train
libopenstorage/openstorage
pkg/auth/token.go
IsJwtToken
func IsJwtToken(authstring string) bool { _, _, err := new(jwt.Parser).ParseUnverified(authstring, jwt.MapClaims{}) return err == nil }
go
func IsJwtToken(authstring string) bool { _, _, err := new(jwt.Parser).ParseUnverified(authstring, jwt.MapClaims{}) return err == nil }
[ "func", "IsJwtToken", "(", "authstring", "string", ")", "bool", "{", "_", ",", "_", ",", "err", ":=", "new", "(", "jwt", ".", "Parser", ")", ".", "ParseUnverified", "(", "authstring", ",", "jwt", ".", "MapClaims", "{", "}", ")", "\n", "return", "err", "==", "nil", "\n", "}" ]
// IsJwtToken returns true if the provided string is a valid jwt token
[ "IsJwtToken", "returns", "true", "if", "the", "provided", "string", "is", "a", "valid", "jwt", "token" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/auth/token.go#L80-L83
train
libopenstorage/openstorage
pkg/auth/token.go
Token
func Token( claims *Claims, signature *Signature, options *Options, ) (string, error) { mapclaims := jwt.MapClaims{ "sub": claims.Subject, "iss": claims.Issuer, "email": claims.Email, "name": claims.Name, "roles": claims.Roles, "iat": time.Now().Add(-options.IATSubtract).Unix(), "exp": options.Expiration, } if claims.Groups != nil { mapclaims["groups"] = claims.Groups } token := jwt.NewWithClaims(signature.Type, mapclaims) signedtoken, err := token.SignedString(signature.Key) if err != nil { return "", err } return signedtoken, nil }
go
func Token( claims *Claims, signature *Signature, options *Options, ) (string, error) { mapclaims := jwt.MapClaims{ "sub": claims.Subject, "iss": claims.Issuer, "email": claims.Email, "name": claims.Name, "roles": claims.Roles, "iat": time.Now().Add(-options.IATSubtract).Unix(), "exp": options.Expiration, } if claims.Groups != nil { mapclaims["groups"] = claims.Groups } token := jwt.NewWithClaims(signature.Type, mapclaims) signedtoken, err := token.SignedString(signature.Key) if err != nil { return "", err } return signedtoken, nil }
[ "func", "Token", "(", "claims", "*", "Claims", ",", "signature", "*", "Signature", ",", "options", "*", "Options", ",", ")", "(", "string", ",", "error", ")", "{", "mapclaims", ":=", "jwt", ".", "MapClaims", "{", "\"", "\"", ":", "claims", ".", "Subject", ",", "\"", "\"", ":", "claims", ".", "Issuer", ",", "\"", "\"", ":", "claims", ".", "Email", ",", "\"", "\"", ":", "claims", ".", "Name", ",", "\"", "\"", ":", "claims", ".", "Roles", ",", "\"", "\"", ":", "time", ".", "Now", "(", ")", ".", "Add", "(", "-", "options", ".", "IATSubtract", ")", ".", "Unix", "(", ")", ",", "\"", "\"", ":", "options", ".", "Expiration", ",", "}", "\n", "if", "claims", ".", "Groups", "!=", "nil", "{", "mapclaims", "[", "\"", "\"", "]", "=", "claims", ".", "Groups", "\n", "}", "\n", "token", ":=", "jwt", ".", "NewWithClaims", "(", "signature", ".", "Type", ",", "mapclaims", ")", "\n", "signedtoken", ",", "err", ":=", "token", ".", "SignedString", "(", "signature", ".", "Key", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "signedtoken", ",", "nil", "\n", "}" ]
// Token returns a signed JWT containing the claims provided
[ "Token", "returns", "a", "signed", "JWT", "containing", "the", "claims", "provided" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/auth/token.go#L86-L111
train
libopenstorage/openstorage
pkg/chaos/chaos.go
Add
func Add(pkg string, fn string, desc string) ID { id := ID(atomic.AddInt32(&count, 1)) chaos[id] = &Chaos{ID: id, Pkg: pkg, Fn: fn, Desc: desc, Enabled: false} return id }
go
func Add(pkg string, fn string, desc string) ID { id := ID(atomic.AddInt32(&count, 1)) chaos[id] = &Chaos{ID: id, Pkg: pkg, Fn: fn, Desc: desc, Enabled: false} return id }
[ "func", "Add", "(", "pkg", "string", ",", "fn", "string", ",", "desc", "string", ")", "ID", "{", "id", ":=", "ID", "(", "atomic", ".", "AddInt32", "(", "&", "count", ",", "1", ")", ")", "\n", "chaos", "[", "id", "]", "=", "&", "Chaos", "{", "ID", ":", "id", ",", "Pkg", ":", "pkg", ",", "Fn", ":", "fn", ",", "Desc", ":", "desc", ",", "Enabled", ":", "false", "}", "\n", "return", "id", "\n", "}" ]
// Add new chaos point. The ID returned can be used to perform operations on this Chaos Point.
[ "Add", "new", "chaos", "point", ".", "The", "ID", "returned", "can", "be", "used", "to", "perform", "operations", "on", "this", "Chaos", "Point", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/chaos/chaos.go#L63-L67
train
libopenstorage/openstorage
pkg/chaos/chaos.go
Enumerate
func Enumerate(pkg string) []Chaos { ko := make([]Chaos, 0, 10) for _, v := range chaos { if pkg == "" || pkg == v.Pkg { ko = append(ko, *v) } } return ko }
go
func Enumerate(pkg string) []Chaos { ko := make([]Chaos, 0, 10) for _, v := range chaos { if pkg == "" || pkg == v.Pkg { ko = append(ko, *v) } } return ko }
[ "func", "Enumerate", "(", "pkg", "string", ")", "[", "]", "Chaos", "{", "ko", ":=", "make", "(", "[", "]", "Chaos", ",", "0", ",", "10", ")", "\n", "for", "_", ",", "v", ":=", "range", "chaos", "{", "if", "pkg", "==", "\"", "\"", "||", "pkg", "==", "v", ".", "Pkg", "{", "ko", "=", "append", "(", "ko", ",", "*", "v", ")", "\n", "}", "\n", "}", "\n", "return", "ko", "\n", "}" ]
// Enumerate all chaos points in the system for specified package. // If the pkg is "" enumerate all chaos points.
[ "Enumerate", "all", "chaos", "points", "in", "the", "system", "for", "specified", "package", ".", "If", "the", "pkg", "is", "enumerate", "all", "chaos", "points", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/chaos/chaos.go#L71-L80
train
libopenstorage/openstorage
pkg/chaos/chaos.go
Enable
func Enable(id ID, when When, what Action) error { if v, ok := chaos[id]; !ok { return ErrNoEnt } else { v.Enabled = true v.When = when v.What = what } return nil }
go
func Enable(id ID, when When, what Action) error { if v, ok := chaos[id]; !ok { return ErrNoEnt } else { v.Enabled = true v.When = when v.What = what } return nil }
[ "func", "Enable", "(", "id", "ID", ",", "when", "When", ",", "what", "Action", ")", "error", "{", "if", "v", ",", "ok", ":=", "chaos", "[", "id", "]", ";", "!", "ok", "{", "return", "ErrNoEnt", "\n", "}", "else", "{", "v", ".", "Enabled", "=", "true", "\n", "v", ".", "When", "=", "when", "\n", "v", ".", "What", "=", "what", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Enable chaos point identified by ID.
[ "Enable", "chaos", "point", "identified", "by", "ID", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/chaos/chaos.go#L83-L92
train
libopenstorage/openstorage
pkg/chaos/chaos.go
Disable
func Disable(id ID) error { if v, ok := chaos[id]; !ok { return ErrNoEnt } else { v.Enabled = false } return nil }
go
func Disable(id ID) error { if v, ok := chaos[id]; !ok { return ErrNoEnt } else { v.Enabled = false } return nil }
[ "func", "Disable", "(", "id", "ID", ")", "error", "{", "if", "v", ",", "ok", ":=", "chaos", "[", "id", "]", ";", "!", "ok", "{", "return", "ErrNoEnt", "\n", "}", "else", "{", "v", ".", "Enabled", "=", "false", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Disable chaos point identified by ID.
[ "Disable", "chaos", "point", "identified", "by", "ID", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/chaos/chaos.go#L95-L102
train
libopenstorage/openstorage
pkg/chaos/chaos.go
Now
func Now(id ID) error { if !activated { return nil } if v, ok := chaos[id]; ok && v.Enabled { v.Count++ if v.When == Once || (v.Count%(r.Int()%10)) == 0 { if v.What == Error { return ErrChaos } } else { panic(fmt.Sprintf("Chaos triggered panic")) } } return nil }
go
func Now(id ID) error { if !activated { return nil } if v, ok := chaos[id]; ok && v.Enabled { v.Count++ if v.When == Once || (v.Count%(r.Int()%10)) == 0 { if v.What == Error { return ErrChaos } } else { panic(fmt.Sprintf("Chaos triggered panic")) } } return nil }
[ "func", "Now", "(", "id", "ID", ")", "error", "{", "if", "!", "activated", "{", "return", "nil", "\n", "}", "\n", "if", "v", ",", "ok", ":=", "chaos", "[", "id", "]", ";", "ok", "&&", "v", ".", "Enabled", "{", "v", ".", "Count", "++", "\n", "if", "v", ".", "When", "==", "Once", "||", "(", "v", ".", "Count", "%", "(", "r", ".", "Int", "(", ")", "%", "10", ")", ")", "==", "0", "{", "if", "v", ".", "What", "==", "Error", "{", "return", "ErrChaos", "\n", "}", "\n", "}", "else", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Now will trigger chaos point if it is enabled.
[ "Now", "will", "trigger", "chaos", "point", "if", "it", "is", "enabled", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/chaos/chaos.go#L105-L121
train
libopenstorage/openstorage
api/flexvolume/flexvolume.go
StartFlexVolumeAPI
func StartFlexVolumeAPI(port uint16, defaultDriver string) error { grpcServer := grpc.NewServer(grpc.MaxConcurrentStreams(math.MaxUint32)) flexvolume.RegisterAPIServer(grpcServer, flexvolume.NewAPIServer(newFlexVolumeClient(defaultDriver))) listener, err := net.Listen("tcp", fmt.Sprintf(":%d", port)) if err != nil { return err } go func() { if err := grpcServer.Serve(listener); err != nil { logrus.Errorln(err.Error()) } }() return nil }
go
func StartFlexVolumeAPI(port uint16, defaultDriver string) error { grpcServer := grpc.NewServer(grpc.MaxConcurrentStreams(math.MaxUint32)) flexvolume.RegisterAPIServer(grpcServer, flexvolume.NewAPIServer(newFlexVolumeClient(defaultDriver))) listener, err := net.Listen("tcp", fmt.Sprintf(":%d", port)) if err != nil { return err } go func() { if err := grpcServer.Serve(listener); err != nil { logrus.Errorln(err.Error()) } }() return nil }
[ "func", "StartFlexVolumeAPI", "(", "port", "uint16", ",", "defaultDriver", "string", ")", "error", "{", "grpcServer", ":=", "grpc", ".", "NewServer", "(", "grpc", ".", "MaxConcurrentStreams", "(", "math", ".", "MaxUint32", ")", ")", "\n", "flexvolume", ".", "RegisterAPIServer", "(", "grpcServer", ",", "flexvolume", ".", "NewAPIServer", "(", "newFlexVolumeClient", "(", "defaultDriver", ")", ")", ")", "\n", "listener", ",", "err", ":=", "net", ".", "Listen", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "port", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "go", "func", "(", ")", "{", "if", "err", ":=", "grpcServer", ".", "Serve", "(", "listener", ")", ";", "err", "!=", "nil", "{", "logrus", ".", "Errorln", "(", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "}", "(", ")", "\n", "return", "nil", "\n", "}" ]
// StartFlexVolumeAPI starts the flexvolume API on the given port.
[ "StartFlexVolumeAPI", "starts", "the", "flexvolume", "API", "on", "the", "given", "port", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/flexvolume/flexvolume.go#L146-L159
train
libopenstorage/openstorage
api/server/sdk/volume_node_ops.go
Attach
func (s *VolumeServer) Attach( ctx context.Context, req *api.SdkVolumeAttachRequest, ) (*api.SdkVolumeAttachResponse, error) { if s.cluster() == nil || s.driver(ctx) == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if len(req.GetVolumeId()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply volume id") } // Get access rights if err := s.checkAccessForVolumeId(ctx, req.GetVolumeId(), api.Ownership_Write); err != nil { return nil, err } // Check options options := req.GetDriverOptions() if options == nil { options = make(map[string]string) } if req.GetOptions() != nil { if len(req.GetOptions().GetSecretContext()) != 0 { options[mountattachoptions.OptionsSecretContext] = req.GetOptions().GetSecretContext() } if len(req.GetOptions().GetSecretKey()) != 0 { options[mountattachoptions.OptionsSecretKey] = req.GetOptions().GetSecretKey() } if len(req.GetOptions().GetSecretName()) != 0 { options[mountattachoptions.OptionsSecret] = req.GetOptions().GetSecretName() } } devPath, err := s.driver(ctx).Attach(req.GetVolumeId(), options) if err == volume.ErrVolAttachedOnRemoteNode { return nil, status.Error(codes.AlreadyExists, err.Error()) } else if err != nil { return nil, status.Errorf( codes.Internal, "failed to attach volume: %v", err.Error()) } return &api.SdkVolumeAttachResponse{DevicePath: devPath}, nil }
go
func (s *VolumeServer) Attach( ctx context.Context, req *api.SdkVolumeAttachRequest, ) (*api.SdkVolumeAttachResponse, error) { if s.cluster() == nil || s.driver(ctx) == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if len(req.GetVolumeId()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply volume id") } // Get access rights if err := s.checkAccessForVolumeId(ctx, req.GetVolumeId(), api.Ownership_Write); err != nil { return nil, err } // Check options options := req.GetDriverOptions() if options == nil { options = make(map[string]string) } if req.GetOptions() != nil { if len(req.GetOptions().GetSecretContext()) != 0 { options[mountattachoptions.OptionsSecretContext] = req.GetOptions().GetSecretContext() } if len(req.GetOptions().GetSecretKey()) != 0 { options[mountattachoptions.OptionsSecretKey] = req.GetOptions().GetSecretKey() } if len(req.GetOptions().GetSecretName()) != 0 { options[mountattachoptions.OptionsSecret] = req.GetOptions().GetSecretName() } } devPath, err := s.driver(ctx).Attach(req.GetVolumeId(), options) if err == volume.ErrVolAttachedOnRemoteNode { return nil, status.Error(codes.AlreadyExists, err.Error()) } else if err != nil { return nil, status.Errorf( codes.Internal, "failed to attach volume: %v", err.Error()) } return &api.SdkVolumeAttachResponse{DevicePath: devPath}, nil }
[ "func", "(", "s", "*", "VolumeServer", ")", "Attach", "(", "ctx", "context", ".", "Context", ",", "req", "*", "api", ".", "SdkVolumeAttachRequest", ",", ")", "(", "*", "api", ".", "SdkVolumeAttachResponse", ",", "error", ")", "{", "if", "s", ".", "cluster", "(", ")", "==", "nil", "||", "s", ".", "driver", "(", "ctx", ")", "==", "nil", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "Unavailable", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "len", "(", "req", ".", "GetVolumeId", "(", ")", ")", "==", "0", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// Get access rights", "if", "err", ":=", "s", ".", "checkAccessForVolumeId", "(", "ctx", ",", "req", ".", "GetVolumeId", "(", ")", ",", "api", ".", "Ownership_Write", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Check options", "options", ":=", "req", ".", "GetDriverOptions", "(", ")", "\n", "if", "options", "==", "nil", "{", "options", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "}", "\n", "if", "req", ".", "GetOptions", "(", ")", "!=", "nil", "{", "if", "len", "(", "req", ".", "GetOptions", "(", ")", ".", "GetSecretContext", "(", ")", ")", "!=", "0", "{", "options", "[", "mountattachoptions", ".", "OptionsSecretContext", "]", "=", "req", ".", "GetOptions", "(", ")", ".", "GetSecretContext", "(", ")", "\n", "}", "\n", "if", "len", "(", "req", ".", "GetOptions", "(", ")", ".", "GetSecretKey", "(", ")", ")", "!=", "0", "{", "options", "[", "mountattachoptions", ".", "OptionsSecretKey", "]", "=", "req", ".", "GetOptions", "(", ")", ".", "GetSecretKey", "(", ")", "\n", "}", "\n", "if", "len", "(", "req", ".", "GetOptions", "(", ")", ".", "GetSecretName", "(", ")", ")", "!=", "0", "{", "options", "[", "mountattachoptions", ".", "OptionsSecret", "]", "=", "req", ".", "GetOptions", "(", ")", ".", "GetSecretName", "(", ")", "\n", "}", "\n", "}", "\n\n", "devPath", ",", "err", ":=", "s", ".", "driver", "(", "ctx", ")", ".", "Attach", "(", "req", ".", "GetVolumeId", "(", ")", ",", "options", ")", "\n", "if", "err", "==", "volume", ".", "ErrVolAttachedOnRemoteNode", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "AlreadyExists", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "nil", ",", "status", ".", "Errorf", "(", "codes", ".", "Internal", ",", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n\n", "return", "&", "api", ".", "SdkVolumeAttachResponse", "{", "DevicePath", ":", "devPath", "}", ",", "nil", "\n", "}" ]
// Attach volume to given node
[ "Attach", "volume", "to", "given", "node" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/server/sdk/volume_node_ops.go#L31-L76
train
libopenstorage/openstorage
api/server/sdk/volume_node_ops.go
Detach
func (s *VolumeServer) Detach( ctx context.Context, req *api.SdkVolumeDetachRequest, ) (*api.SdkVolumeDetachResponse, error) { if s.cluster() == nil || s.driver(ctx) == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if len(req.GetVolumeId()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply volume id") } // Get access rights err := s.checkAccessForVolumeId(ctx, req.GetVolumeId(), api.Ownership_Write) if err != nil && !IsErrorNotFound(err) { return nil, err } // Check options options := req.GetDriverOptions() if options == nil { options = make(map[string]string) } options[mountattachoptions.OptionsRedirectDetach] = "true" if req.GetOptions() != nil { options[mountattachoptions.OptionsForceDetach] = fmt.Sprint(req.GetOptions().GetForce()) options[mountattachoptions.OptionsUnmountBeforeDetach] = fmt.Sprint(req.GetOptions().GetUnmountBeforeDetach()) } err = s.driver(ctx).Detach(req.GetVolumeId(), options) if err != nil && !IsErrorNotFound(err) { return nil, status.Errorf( codes.Internal, "Failed to detach volume %s: %v", req.GetVolumeId(), err) } return &api.SdkVolumeDetachResponse{}, nil }
go
func (s *VolumeServer) Detach( ctx context.Context, req *api.SdkVolumeDetachRequest, ) (*api.SdkVolumeDetachResponse, error) { if s.cluster() == nil || s.driver(ctx) == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if len(req.GetVolumeId()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply volume id") } // Get access rights err := s.checkAccessForVolumeId(ctx, req.GetVolumeId(), api.Ownership_Write) if err != nil && !IsErrorNotFound(err) { return nil, err } // Check options options := req.GetDriverOptions() if options == nil { options = make(map[string]string) } options[mountattachoptions.OptionsRedirectDetach] = "true" if req.GetOptions() != nil { options[mountattachoptions.OptionsForceDetach] = fmt.Sprint(req.GetOptions().GetForce()) options[mountattachoptions.OptionsUnmountBeforeDetach] = fmt.Sprint(req.GetOptions().GetUnmountBeforeDetach()) } err = s.driver(ctx).Detach(req.GetVolumeId(), options) if err != nil && !IsErrorNotFound(err) { return nil, status.Errorf( codes.Internal, "Failed to detach volume %s: %v", req.GetVolumeId(), err) } return &api.SdkVolumeDetachResponse{}, nil }
[ "func", "(", "s", "*", "VolumeServer", ")", "Detach", "(", "ctx", "context", ".", "Context", ",", "req", "*", "api", ".", "SdkVolumeDetachRequest", ",", ")", "(", "*", "api", ".", "SdkVolumeDetachResponse", ",", "error", ")", "{", "if", "s", ".", "cluster", "(", ")", "==", "nil", "||", "s", ".", "driver", "(", "ctx", ")", "==", "nil", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "Unavailable", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "len", "(", "req", ".", "GetVolumeId", "(", ")", ")", "==", "0", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// Get access rights", "err", ":=", "s", ".", "checkAccessForVolumeId", "(", "ctx", ",", "req", ".", "GetVolumeId", "(", ")", ",", "api", ".", "Ownership_Write", ")", "\n", "if", "err", "!=", "nil", "&&", "!", "IsErrorNotFound", "(", "err", ")", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Check options", "options", ":=", "req", ".", "GetDriverOptions", "(", ")", "\n", "if", "options", "==", "nil", "{", "options", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "}", "\n", "options", "[", "mountattachoptions", ".", "OptionsRedirectDetach", "]", "=", "\"", "\"", "\n", "if", "req", ".", "GetOptions", "(", ")", "!=", "nil", "{", "options", "[", "mountattachoptions", ".", "OptionsForceDetach", "]", "=", "fmt", ".", "Sprint", "(", "req", ".", "GetOptions", "(", ")", ".", "GetForce", "(", ")", ")", "\n", "options", "[", "mountattachoptions", ".", "OptionsUnmountBeforeDetach", "]", "=", "fmt", ".", "Sprint", "(", "req", ".", "GetOptions", "(", ")", ".", "GetUnmountBeforeDetach", "(", ")", ")", "\n", "}", "\n\n", "err", "=", "s", ".", "driver", "(", "ctx", ")", ".", "Detach", "(", "req", ".", "GetVolumeId", "(", ")", ",", "options", ")", "\n", "if", "err", "!=", "nil", "&&", "!", "IsErrorNotFound", "(", "err", ")", "{", "return", "nil", ",", "status", ".", "Errorf", "(", "codes", ".", "Internal", ",", "\"", "\"", ",", "req", ".", "GetVolumeId", "(", ")", ",", "err", ")", "\n", "}", "\n\n", "return", "&", "api", ".", "SdkVolumeDetachResponse", "{", "}", ",", "nil", "\n", "}" ]
// Detach function for volume node detach
[ "Detach", "function", "for", "volume", "node", "detach" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/server/sdk/volume_node_ops.go#L79-L118
train
libopenstorage/openstorage
api/server/sdk/volume_node_ops.go
Mount
func (s *VolumeServer) Mount( ctx context.Context, req *api.SdkVolumeMountRequest, ) (*api.SdkVolumeMountResponse, error) { if s.cluster() == nil || s.driver(ctx) == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if len(req.GetVolumeId()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply volume id") } if len(req.GetMountPath()) == 0 { return nil, status.Error(codes.InvalidArgument, "Invalid Mount Path") } // Get access rights err := s.checkAccessForVolumeId(ctx, req.GetVolumeId(), api.Ownership_Write) if err != nil { return nil, err } err = s.driver(ctx).Mount(req.GetVolumeId(), req.GetMountPath(), req.GetDriverOptions()) if err != nil { return nil, status.Errorf( codes.Internal, "Failed to mount volume %s: %v", req.GetVolumeId(), err.Error()) } return &api.SdkVolumeMountResponse{}, err }
go
func (s *VolumeServer) Mount( ctx context.Context, req *api.SdkVolumeMountRequest, ) (*api.SdkVolumeMountResponse, error) { if s.cluster() == nil || s.driver(ctx) == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if len(req.GetVolumeId()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply volume id") } if len(req.GetMountPath()) == 0 { return nil, status.Error(codes.InvalidArgument, "Invalid Mount Path") } // Get access rights err := s.checkAccessForVolumeId(ctx, req.GetVolumeId(), api.Ownership_Write) if err != nil { return nil, err } err = s.driver(ctx).Mount(req.GetVolumeId(), req.GetMountPath(), req.GetDriverOptions()) if err != nil { return nil, status.Errorf( codes.Internal, "Failed to mount volume %s: %v", req.GetVolumeId(), err.Error()) } return &api.SdkVolumeMountResponse{}, err }
[ "func", "(", "s", "*", "VolumeServer", ")", "Mount", "(", "ctx", "context", ".", "Context", ",", "req", "*", "api", ".", "SdkVolumeMountRequest", ",", ")", "(", "*", "api", ".", "SdkVolumeMountResponse", ",", "error", ")", "{", "if", "s", ".", "cluster", "(", ")", "==", "nil", "||", "s", ".", "driver", "(", "ctx", ")", "==", "nil", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "Unavailable", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "len", "(", "req", ".", "GetVolumeId", "(", ")", ")", "==", "0", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "req", ".", "GetMountPath", "(", ")", ")", "==", "0", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// Get access rights", "err", ":=", "s", ".", "checkAccessForVolumeId", "(", "ctx", ",", "req", ".", "GetVolumeId", "(", ")", ",", "api", ".", "Ownership_Write", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "err", "=", "s", ".", "driver", "(", "ctx", ")", ".", "Mount", "(", "req", ".", "GetVolumeId", "(", ")", ",", "req", ".", "GetMountPath", "(", ")", ",", "req", ".", "GetDriverOptions", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "status", ".", "Errorf", "(", "codes", ".", "Internal", ",", "\"", "\"", ",", "req", ".", "GetVolumeId", "(", ")", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "return", "&", "api", ".", "SdkVolumeMountResponse", "{", "}", ",", "err", "\n", "}" ]
// Mount function for volume node detach
[ "Mount", "function", "for", "volume", "node", "detach" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/server/sdk/volume_node_ops.go#L121-L152
train
libopenstorage/openstorage
api/server/sdk/volume_node_ops.go
Unmount
func (s *VolumeServer) Unmount( ctx context.Context, req *api.SdkVolumeUnmountRequest, ) (*api.SdkVolumeUnmountResponse, error) { if s.cluster() == nil || s.driver(ctx) == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if len(req.GetVolumeId()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply volume id") } if len(req.GetMountPath()) == 0 { return nil, status.Error(codes.InvalidArgument, "Invalid Mount Path") } options := req.GetDriverOptions() if options == nil { options = make(map[string]string) } if req.GetOptions() != nil { options[mountattachoptions.OptionsDeleteAfterUnmount] = fmt.Sprint(req.GetOptions().GetDeleteMountPath()) if req.GetOptions().GetDeleteMountPath() { options[mountattachoptions.OptionsWaitBeforeDelete] = fmt.Sprint(!req.GetOptions().GetNoDelayBeforeDeletingMountPath()) } } // Get access rights err := s.checkAccessForVolumeId(ctx, req.GetVolumeId(), api.Ownership_Write) if err != nil && !IsErrorNotFound(err) { return nil, err } // Unmount volume if err = s.driver(ctx).Unmount(req.GetVolumeId(), req.GetMountPath(), options); err != nil { return nil, status.Errorf( codes.Internal, "Failed to unmount volume %s: %v", req.GetVolumeId(), err.Error()) } return &api.SdkVolumeUnmountResponse{}, nil }
go
func (s *VolumeServer) Unmount( ctx context.Context, req *api.SdkVolumeUnmountRequest, ) (*api.SdkVolumeUnmountResponse, error) { if s.cluster() == nil || s.driver(ctx) == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if len(req.GetVolumeId()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply volume id") } if len(req.GetMountPath()) == 0 { return nil, status.Error(codes.InvalidArgument, "Invalid Mount Path") } options := req.GetDriverOptions() if options == nil { options = make(map[string]string) } if req.GetOptions() != nil { options[mountattachoptions.OptionsDeleteAfterUnmount] = fmt.Sprint(req.GetOptions().GetDeleteMountPath()) if req.GetOptions().GetDeleteMountPath() { options[mountattachoptions.OptionsWaitBeforeDelete] = fmt.Sprint(!req.GetOptions().GetNoDelayBeforeDeletingMountPath()) } } // Get access rights err := s.checkAccessForVolumeId(ctx, req.GetVolumeId(), api.Ownership_Write) if err != nil && !IsErrorNotFound(err) { return nil, err } // Unmount volume if err = s.driver(ctx).Unmount(req.GetVolumeId(), req.GetMountPath(), options); err != nil { return nil, status.Errorf( codes.Internal, "Failed to unmount volume %s: %v", req.GetVolumeId(), err.Error()) } return &api.SdkVolumeUnmountResponse{}, nil }
[ "func", "(", "s", "*", "VolumeServer", ")", "Unmount", "(", "ctx", "context", ".", "Context", ",", "req", "*", "api", ".", "SdkVolumeUnmountRequest", ",", ")", "(", "*", "api", ".", "SdkVolumeUnmountResponse", ",", "error", ")", "{", "if", "s", ".", "cluster", "(", ")", "==", "nil", "||", "s", ".", "driver", "(", "ctx", ")", "==", "nil", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "Unavailable", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "len", "(", "req", ".", "GetVolumeId", "(", ")", ")", "==", "0", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "len", "(", "req", ".", "GetMountPath", "(", ")", ")", "==", "0", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "\n\n", "options", ":=", "req", ".", "GetDriverOptions", "(", ")", "\n", "if", "options", "==", "nil", "{", "options", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "}", "\n", "if", "req", ".", "GetOptions", "(", ")", "!=", "nil", "{", "options", "[", "mountattachoptions", ".", "OptionsDeleteAfterUnmount", "]", "=", "fmt", ".", "Sprint", "(", "req", ".", "GetOptions", "(", ")", ".", "GetDeleteMountPath", "(", ")", ")", "\n\n", "if", "req", ".", "GetOptions", "(", ")", ".", "GetDeleteMountPath", "(", ")", "{", "options", "[", "mountattachoptions", ".", "OptionsWaitBeforeDelete", "]", "=", "fmt", ".", "Sprint", "(", "!", "req", ".", "GetOptions", "(", ")", ".", "GetNoDelayBeforeDeletingMountPath", "(", ")", ")", "\n", "}", "\n", "}", "\n\n", "// Get access rights", "err", ":=", "s", ".", "checkAccessForVolumeId", "(", "ctx", ",", "req", ".", "GetVolumeId", "(", ")", ",", "api", ".", "Ownership_Write", ")", "\n", "if", "err", "!=", "nil", "&&", "!", "IsErrorNotFound", "(", "err", ")", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Unmount volume", "if", "err", "=", "s", ".", "driver", "(", "ctx", ")", ".", "Unmount", "(", "req", ".", "GetVolumeId", "(", ")", ",", "req", ".", "GetMountPath", "(", ")", ",", "options", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "status", ".", "Errorf", "(", "codes", ".", "Internal", ",", "\"", "\"", ",", "req", ".", "GetVolumeId", "(", ")", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n\n", "return", "&", "api", ".", "SdkVolumeUnmountResponse", "{", "}", ",", "nil", "\n", "}" ]
// Unmount volume from given node
[ "Unmount", "volume", "from", "given", "node" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/server/sdk/volume_node_ops.go#L155-L199
train
libopenstorage/openstorage
cli/graph.go
GraphDriverCommands
func GraphDriverCommands(name string) []cli.Command { g := &graphDriver{name: name} graphCommands := []cli.Command{ { Name: "status", Aliases: []string{"s"}, Usage: "Status on the usage of a Graph Driver", Action: g.status, }, } return graphCommands }
go
func GraphDriverCommands(name string) []cli.Command { g := &graphDriver{name: name} graphCommands := []cli.Command{ { Name: "status", Aliases: []string{"s"}, Usage: "Status on the usage of a Graph Driver", Action: g.status, }, } return graphCommands }
[ "func", "GraphDriverCommands", "(", "name", "string", ")", "[", "]", "cli", ".", "Command", "{", "g", ":=", "&", "graphDriver", "{", "name", ":", "name", "}", "\n\n", "graphCommands", ":=", "[", "]", "cli", ".", "Command", "{", "{", "Name", ":", "\"", "\"", ",", "Aliases", ":", "[", "]", "string", "{", "\"", "\"", "}", ",", "Usage", ":", "\"", "\"", ",", "Action", ":", "g", ".", "status", ",", "}", ",", "}", "\n\n", "return", "graphCommands", "\n", "}" ]
// GraphDriverCommands exports CLI comamnds for a GraphDriver.
[ "GraphDriverCommands", "exports", "CLI", "comamnds", "for", "a", "GraphDriver", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cli/graph.go#L18-L31
train
libopenstorage/openstorage
api/server/sdk/server_interceptors.go
rwlockIntercepter
func (s *sdkGrpcServer) rwlockIntercepter( ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (interface{}, error) { s.lock.RLock() defer s.lock.RUnlock() return handler(ctx, req) }
go
func (s *sdkGrpcServer) rwlockIntercepter( ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (interface{}, error) { s.lock.RLock() defer s.lock.RUnlock() return handler(ctx, req) }
[ "func", "(", "s", "*", "sdkGrpcServer", ")", "rwlockIntercepter", "(", "ctx", "context", ".", "Context", ",", "req", "interface", "{", "}", ",", "info", "*", "grpc", ".", "UnaryServerInfo", ",", "handler", "grpc", ".", "UnaryHandler", ",", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "s", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "lock", ".", "RUnlock", "(", ")", "\n\n", "return", "handler", "(", "ctx", ",", "req", ")", "\n", "}" ]
// This interceptor provides a way to lock out any calls while we adjust the server
[ "This", "interceptor", "provides", "a", "way", "to", "lock", "out", "any", "calls", "while", "we", "adjust", "the", "server" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/server/sdk/server_interceptors.go#L43-L53
train
libopenstorage/openstorage
api/server/sdk/server_interceptors.go
auth
func (s *sdkGrpcServer) auth(ctx context.Context) (context.Context, error) { // Obtain token from metadata in the context token, err := grpc_auth.AuthFromMD(ctx, ContextMetadataTokenKey) if err != nil { return nil, err } // Determine issuer issuer, err := auth.TokenIssuer(token) if err != nil { return nil, status.Errorf(codes.PermissionDenied, "Unable to obtain issuer from token: %v", err) } // Authenticate user if authenticator, ok := s.config.Security.Authenticators[issuer]; ok { var claims *auth.Claims claims, err = authenticator.AuthenticateToken(ctx, token) if err == nil { // Add authorization information back into the context so that other // functions can get access to this information. // If this is in the context is how functions will know that security is enabled. ctx = auth.ContextSaveUserInfo(ctx, &auth.UserInfo{ Username: authenticator.Username(claims), Claims: *claims, }) return ctx, nil } else { return nil, status.Error(codes.PermissionDenied, err.Error()) } } else { return nil, status.Errorf(codes.PermissionDenied, "%s is not a trusted issuer", issuer) } }
go
func (s *sdkGrpcServer) auth(ctx context.Context) (context.Context, error) { // Obtain token from metadata in the context token, err := grpc_auth.AuthFromMD(ctx, ContextMetadataTokenKey) if err != nil { return nil, err } // Determine issuer issuer, err := auth.TokenIssuer(token) if err != nil { return nil, status.Errorf(codes.PermissionDenied, "Unable to obtain issuer from token: %v", err) } // Authenticate user if authenticator, ok := s.config.Security.Authenticators[issuer]; ok { var claims *auth.Claims claims, err = authenticator.AuthenticateToken(ctx, token) if err == nil { // Add authorization information back into the context so that other // functions can get access to this information. // If this is in the context is how functions will know that security is enabled. ctx = auth.ContextSaveUserInfo(ctx, &auth.UserInfo{ Username: authenticator.Username(claims), Claims: *claims, }) return ctx, nil } else { return nil, status.Error(codes.PermissionDenied, err.Error()) } } else { return nil, status.Errorf(codes.PermissionDenied, "%s is not a trusted issuer", issuer) } }
[ "func", "(", "s", "*", "sdkGrpcServer", ")", "auth", "(", "ctx", "context", ".", "Context", ")", "(", "context", ".", "Context", ",", "error", ")", "{", "// Obtain token from metadata in the context", "token", ",", "err", ":=", "grpc_auth", ".", "AuthFromMD", "(", "ctx", ",", "ContextMetadataTokenKey", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Determine issuer", "issuer", ",", "err", ":=", "auth", ".", "TokenIssuer", "(", "token", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "status", ".", "Errorf", "(", "codes", ".", "PermissionDenied", ",", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "// Authenticate user", "if", "authenticator", ",", "ok", ":=", "s", ".", "config", ".", "Security", ".", "Authenticators", "[", "issuer", "]", ";", "ok", "{", "var", "claims", "*", "auth", ".", "Claims", "\n", "claims", ",", "err", "=", "authenticator", ".", "AuthenticateToken", "(", "ctx", ",", "token", ")", "\n", "if", "err", "==", "nil", "{", "// Add authorization information back into the context so that other", "// functions can get access to this information.", "// If this is in the context is how functions will know that security is enabled.", "ctx", "=", "auth", ".", "ContextSaveUserInfo", "(", "ctx", ",", "&", "auth", ".", "UserInfo", "{", "Username", ":", "authenticator", ".", "Username", "(", "claims", ")", ",", "Claims", ":", "*", "claims", ",", "}", ")", "\n", "return", "ctx", ",", "nil", "\n", "}", "else", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "PermissionDenied", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "}", "else", "{", "return", "nil", ",", "status", ".", "Errorf", "(", "codes", ".", "PermissionDenied", ",", "\"", "\"", ",", "issuer", ")", "\n", "}", "\n", "}" ]
// Authenticate user and add authorization information back in the context
[ "Authenticate", "user", "and", "add", "authorization", "information", "back", "in", "the", "context" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/server/sdk/server_interceptors.go#L56-L88
train
libopenstorage/openstorage
graph/graphdriver.go
Get
func Get(name string) (graphdriver.Driver, error) { if v, ok := instances[name]; ok { return v, nil } return nil, ErrDriverNotFound }
go
func Get(name string) (graphdriver.Driver, error) { if v, ok := instances[name]; ok { return v, nil } return nil, ErrDriverNotFound }
[ "func", "Get", "(", "name", "string", ")", "(", "graphdriver", ".", "Driver", ",", "error", ")", "{", "if", "v", ",", "ok", ":=", "instances", "[", "name", "]", ";", "ok", "{", "return", "v", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "ErrDriverNotFound", "\n", "}" ]
// Get returns an already registered driver
[ "Get", "returns", "an", "already", "registered", "driver" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/graph/graphdriver.go#L27-L32
train
libopenstorage/openstorage
graph/graphdriver.go
New
func New(name, root string, options []string) (graphdriver.Driver, error) { mutex.Lock() defer mutex.Unlock() if _, ok := instances[name]; ok { return nil, ErrExist } if initFunc, exists := drivers[name]; exists { driver, err := initFunc(root, options, nil, nil) if err != nil { return nil, err } instances[name] = driver return driver, err } return nil, ErrNotSupported }
go
func New(name, root string, options []string) (graphdriver.Driver, error) { mutex.Lock() defer mutex.Unlock() if _, ok := instances[name]; ok { return nil, ErrExist } if initFunc, exists := drivers[name]; exists { driver, err := initFunc(root, options, nil, nil) if err != nil { return nil, err } instances[name] = driver return driver, err } return nil, ErrNotSupported }
[ "func", "New", "(", "name", ",", "root", "string", ",", "options", "[", "]", "string", ")", "(", "graphdriver", ".", "Driver", ",", "error", ")", "{", "mutex", ".", "Lock", "(", ")", "\n", "defer", "mutex", ".", "Unlock", "(", ")", "\n\n", "if", "_", ",", "ok", ":=", "instances", "[", "name", "]", ";", "ok", "{", "return", "nil", ",", "ErrExist", "\n", "}", "\n\n", "if", "initFunc", ",", "exists", ":=", "drivers", "[", "name", "]", ";", "exists", "{", "driver", ",", "err", ":=", "initFunc", "(", "root", ",", "options", ",", "nil", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "instances", "[", "name", "]", "=", "driver", "\n", "return", "driver", ",", "err", "\n", "}", "\n", "return", "nil", ",", "ErrNotSupported", "\n", "}" ]
// New creates a new graphdriver interface
[ "New", "creates", "a", "new", "graphdriver", "interface" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/graph/graphdriver.go#L35-L52
train
libopenstorage/openstorage
graph/graphdriver.go
Register
func Register(name string, initFunc InitFunc) error { mutex.Lock() defer mutex.Unlock() if _, exists := drivers[name]; exists { return ErrExist } drivers[name] = initFunc return nil }
go
func Register(name string, initFunc InitFunc) error { mutex.Lock() defer mutex.Unlock() if _, exists := drivers[name]; exists { return ErrExist } drivers[name] = initFunc return nil }
[ "func", "Register", "(", "name", "string", ",", "initFunc", "InitFunc", ")", "error", "{", "mutex", ".", "Lock", "(", ")", "\n", "defer", "mutex", ".", "Unlock", "(", ")", "\n", "if", "_", ",", "exists", ":=", "drivers", "[", "name", "]", ";", "exists", "{", "return", "ErrExist", "\n", "}", "\n", "drivers", "[", "name", "]", "=", "initFunc", "\n", "return", "nil", "\n", "}" ]
// Register registers a graphdriver
[ "Register", "registers", "a", "graphdriver" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/graph/graphdriver.go#L55-L63
train
libopenstorage/openstorage
api/server/docker.go
addTokenMetadata
func addTokenMetadata(ctx context.Context, token string) context.Context { md := metadata.New(map[string]string{ "authorization": "bearer " + token, }) return metadata.NewOutgoingContext(ctx, md) }
go
func addTokenMetadata(ctx context.Context, token string) context.Context { md := metadata.New(map[string]string{ "authorization": "bearer " + token, }) return metadata.NewOutgoingContext(ctx, md) }
[ "func", "addTokenMetadata", "(", "ctx", "context", ".", "Context", ",", "token", "string", ")", "context", ".", "Context", "{", "md", ":=", "metadata", ".", "New", "(", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "\"", "\"", "+", "token", ",", "}", ")", "\n", "return", "metadata", ".", "NewOutgoingContext", "(", "ctx", ",", "md", ")", "\n", "}" ]
// addTokenMetadata adds the token to a given context's metadata
[ "addTokenMetadata", "adds", "the", "token", "to", "a", "given", "context", "s", "metadata" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/server/docker.go#L286-L291
train
libopenstorage/openstorage
api/server/docker.go
secretTokenFromStore
func (d *driver) secretTokenFromStore(secret string) (string, error) { if d.secretsStore == nil { return "", fmt.Errorf("A secret was passed in, but no secrets provider has been initialized") } token, err := d.secretsStore.GetToken(secret, "") if err != nil { return "", err } return token, nil }
go
func (d *driver) secretTokenFromStore(secret string) (string, error) { if d.secretsStore == nil { return "", fmt.Errorf("A secret was passed in, but no secrets provider has been initialized") } token, err := d.secretsStore.GetToken(secret, "") if err != nil { return "", err } return token, nil }
[ "func", "(", "d", "*", "driver", ")", "secretTokenFromStore", "(", "secret", "string", ")", "(", "string", ",", "error", ")", "{", "if", "d", ".", "secretsStore", "==", "nil", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "token", ",", "err", ":=", "d", ".", "secretsStore", ".", "GetToken", "(", "secret", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "token", ",", "nil", "\n", "}" ]
// secretTokenFromStore pulls the token from the configured secret store for // a given secret name and context.
[ "secretTokenFromStore", "pulls", "the", "token", "from", "the", "configured", "secret", "store", "for", "a", "given", "secret", "name", "and", "context", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/server/docker.go#L295-L306
train
libopenstorage/openstorage
volume/volume_not_supported.go
Stats
func (s *statsNotSupported) Stats( volumeID string, cumulative bool, ) (*api.Stats, error) { return nil, ErrNotSupported }
go
func (s *statsNotSupported) Stats( volumeID string, cumulative bool, ) (*api.Stats, error) { return nil, ErrNotSupported }
[ "func", "(", "s", "*", "statsNotSupported", ")", "Stats", "(", "volumeID", "string", ",", "cumulative", "bool", ",", ")", "(", "*", "api", ".", "Stats", ",", "error", ")", "{", "return", "nil", ",", "ErrNotSupported", "\n", "}" ]
// Stats returns stats
[ "Stats", "returns", "stats" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/volume/volume_not_supported.go#L74-L79
train
libopenstorage/openstorage
volume/volume_not_supported.go
CapacityUsage
func (s *statsNotSupported) CapacityUsage( ID string, ) (*api.CapacityUsageResponse, error) { return nil, ErrNotSupported }
go
func (s *statsNotSupported) CapacityUsage( ID string, ) (*api.CapacityUsageResponse, error) { return nil, ErrNotSupported }
[ "func", "(", "s", "*", "statsNotSupported", ")", "CapacityUsage", "(", "ID", "string", ",", ")", "(", "*", "api", ".", "CapacityUsageResponse", ",", "error", ")", "{", "return", "nil", ",", "ErrNotSupported", "\n", "}" ]
// GetCapacityUsage gets exclusive and shared capacity // usage of snap
[ "GetCapacityUsage", "gets", "exclusive", "and", "shared", "capacity", "usage", "of", "snap" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/volume/volume_not_supported.go#L93-L97
train
libopenstorage/openstorage
pkg/keylock/keylock.go
ByName
func ByName(klName string) KeyLock { klLock.Lock() defer klLock.Unlock() kl, ok := klMap[klName] if !ok { kl = New() klMap[klName] = kl } return kl }
go
func ByName(klName string) KeyLock { klLock.Lock() defer klLock.Unlock() kl, ok := klMap[klName] if !ok { kl = New() klMap[klName] = kl } return kl }
[ "func", "ByName", "(", "klName", "string", ")", "KeyLock", "{", "klLock", ".", "Lock", "(", ")", "\n", "defer", "klLock", ".", "Unlock", "(", ")", "\n\n", "kl", ",", "ok", ":=", "klMap", "[", "klName", "]", "\n", "if", "!", "ok", "{", "kl", "=", "New", "(", ")", "\n", "klMap", "[", "klName", "]", "=", "kl", "\n", "}", "\n", "return", "kl", "\n", "}" ]
// ByName creates a new instance or returns an existing instance // if found in the map.
[ "ByName", "creates", "a", "new", "instance", "or", "returns", "an", "existing", "instance", "if", "found", "in", "the", "map", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/keylock/keylock.go#L67-L77
train
libopenstorage/openstorage
alerts/filter.go
getUniqueKeysFromFilters
func getUniqueKeysFromFilters(filters ...Filter) (map[string]bool, error) { keys := make(map[string]bool) // sort filters so we know how to query if len(filters) > 0 { sort.Sort(Filters(filters)) for _, filter := range filters { key := kvdbKey switch filter.GetFilterType() { // only these filter types benefit from efficient kvdb querying. // for everything else we enumerate and then filter. case resourceTypeFilter: v, ok := filter.GetValue().(api.ResourceType) if !ok { return nil, typeAssertionError } key = filepath.Join(key, v.String()) case alertTypeFilter: v, ok := filter.GetValue().(alertInfo) if !ok { return nil, typeAssertionError } key = filepath.Join(key, v.resourceType.String(), strconv.FormatInt(v.alertType, 16)) case resourceIDFilter: v, ok := filter.GetValue().(alertInfo) if !ok { return nil, typeAssertionError } key = filepath.Join(key, v.resourceType.String(), strconv.FormatInt(v.alertType, 16), v.resourceID) } keyPath, _ := filepath.Split(key) keyPath = strings.Trim(keyPath, "/") if !keys[keyPath] { keys[key] = true } } } else { keys[kvdbKey] = true } // remove all keys that access sub tree of another key var keysToDelete []string for key := range keys { keyPath := key for len(keyPath) > 0 { keyPath, _ = filepath.Split(keyPath) keyPath = strings.Trim(keyPath, "/") if keys[keyPath] { keysToDelete = append(keysToDelete, key) break } } } for _, key := range keysToDelete { delete(keys, key) } return keys, nil }
go
func getUniqueKeysFromFilters(filters ...Filter) (map[string]bool, error) { keys := make(map[string]bool) // sort filters so we know how to query if len(filters) > 0 { sort.Sort(Filters(filters)) for _, filter := range filters { key := kvdbKey switch filter.GetFilterType() { // only these filter types benefit from efficient kvdb querying. // for everything else we enumerate and then filter. case resourceTypeFilter: v, ok := filter.GetValue().(api.ResourceType) if !ok { return nil, typeAssertionError } key = filepath.Join(key, v.String()) case alertTypeFilter: v, ok := filter.GetValue().(alertInfo) if !ok { return nil, typeAssertionError } key = filepath.Join(key, v.resourceType.String(), strconv.FormatInt(v.alertType, 16)) case resourceIDFilter: v, ok := filter.GetValue().(alertInfo) if !ok { return nil, typeAssertionError } key = filepath.Join(key, v.resourceType.String(), strconv.FormatInt(v.alertType, 16), v.resourceID) } keyPath, _ := filepath.Split(key) keyPath = strings.Trim(keyPath, "/") if !keys[keyPath] { keys[key] = true } } } else { keys[kvdbKey] = true } // remove all keys that access sub tree of another key var keysToDelete []string for key := range keys { keyPath := key for len(keyPath) > 0 { keyPath, _ = filepath.Split(keyPath) keyPath = strings.Trim(keyPath, "/") if keys[keyPath] { keysToDelete = append(keysToDelete, key) break } } } for _, key := range keysToDelete { delete(keys, key) } return keys, nil }
[ "func", "getUniqueKeysFromFilters", "(", "filters", "...", "Filter", ")", "(", "map", "[", "string", "]", "bool", ",", "error", ")", "{", "keys", ":=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n\n", "// sort filters so we know how to query", "if", "len", "(", "filters", ")", ">", "0", "{", "sort", ".", "Sort", "(", "Filters", "(", "filters", ")", ")", "\n\n", "for", "_", ",", "filter", ":=", "range", "filters", "{", "key", ":=", "kvdbKey", "\n", "switch", "filter", ".", "GetFilterType", "(", ")", "{", "// only these filter types benefit from efficient kvdb querying.", "// for everything else we enumerate and then filter.", "case", "resourceTypeFilter", ":", "v", ",", "ok", ":=", "filter", ".", "GetValue", "(", ")", ".", "(", "api", ".", "ResourceType", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "typeAssertionError", "\n", "}", "\n", "key", "=", "filepath", ".", "Join", "(", "key", ",", "v", ".", "String", "(", ")", ")", "\n", "case", "alertTypeFilter", ":", "v", ",", "ok", ":=", "filter", ".", "GetValue", "(", ")", ".", "(", "alertInfo", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "typeAssertionError", "\n", "}", "\n", "key", "=", "filepath", ".", "Join", "(", "key", ",", "v", ".", "resourceType", ".", "String", "(", ")", ",", "strconv", ".", "FormatInt", "(", "v", ".", "alertType", ",", "16", ")", ")", "\n", "case", "resourceIDFilter", ":", "v", ",", "ok", ":=", "filter", ".", "GetValue", "(", ")", ".", "(", "alertInfo", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "typeAssertionError", "\n", "}", "\n", "key", "=", "filepath", ".", "Join", "(", "key", ",", "v", ".", "resourceType", ".", "String", "(", ")", ",", "strconv", ".", "FormatInt", "(", "v", ".", "alertType", ",", "16", ")", ",", "v", ".", "resourceID", ")", "\n", "}", "\n\n", "keyPath", ",", "_", ":=", "filepath", ".", "Split", "(", "key", ")", "\n", "keyPath", "=", "strings", ".", "Trim", "(", "keyPath", ",", "\"", "\"", ")", "\n", "if", "!", "keys", "[", "keyPath", "]", "{", "keys", "[", "key", "]", "=", "true", "\n", "}", "\n\n", "}", "\n", "}", "else", "{", "keys", "[", "kvdbKey", "]", "=", "true", "\n", "}", "\n\n", "// remove all keys that access sub tree of another key", "var", "keysToDelete", "[", "]", "string", "\n", "for", "key", ":=", "range", "keys", "{", "keyPath", ":=", "key", "\n", "for", "len", "(", "keyPath", ")", ">", "0", "{", "keyPath", ",", "_", "=", "filepath", ".", "Split", "(", "keyPath", ")", "\n", "keyPath", "=", "strings", ".", "Trim", "(", "keyPath", ",", "\"", "\"", ")", "\n", "if", "keys", "[", "keyPath", "]", "{", "keysToDelete", "=", "append", "(", "keysToDelete", ",", "key", ")", "\n", "break", "\n", "}", "\n", "}", "\n", "}", "\n\n", "for", "_", ",", "key", ":=", "range", "keysToDelete", "{", "delete", "(", "keys", ",", "key", ")", "\n", "}", "\n\n", "return", "keys", ",", "nil", "\n", "}" ]
// getUniqueKeysFromFilters analyzes filters and outputs a map of unique keys such that // these keys do not point to sub trees of one another.
[ "getUniqueKeysFromFilters", "analyzes", "filters", "and", "outputs", "a", "map", "of", "unique", "keys", "such", "that", "these", "keys", "do", "not", "point", "to", "sub", "trees", "of", "one", "another", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/alerts/filter.go#L314-L378
train
libopenstorage/openstorage
volume/drivers/nfs/nfs.go
getNewSnapVolName
func (d *driver) getNewSnapVolName(volumeID string) string { return volumeID + "-" + strconv.FormatUint(uint64(time.Now().Unix()), 10) }
go
func (d *driver) getNewSnapVolName(volumeID string) string { return volumeID + "-" + strconv.FormatUint(uint64(time.Now().Unix()), 10) }
[ "func", "(", "d", "*", "driver", ")", "getNewSnapVolName", "(", "volumeID", "string", ")", "string", "{", "return", "volumeID", "+", "\"", "\"", "+", "strconv", ".", "FormatUint", "(", "uint64", "(", "time", ".", "Now", "(", ")", ".", "Unix", "(", ")", ")", ",", "10", ")", "\n", "}" ]
//append unix time to volumeID
[ "append", "unix", "time", "to", "volumeID" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/volume/drivers/nfs/nfs.go#L212-L214
train
libopenstorage/openstorage
volume/drivers/common/common.go
NewVolume
func NewVolume( volumeID string, fsType api.FSType, volumeLocator *api.VolumeLocator, source *api.Source, volumeSpec *api.VolumeSpec, ) *api.Volume { return &api.Volume{ Id: volumeID, Locator: volumeLocator, Ctime: prototime.Now(), Spec: volumeSpec, Source: source, LastScan: prototime.Now(), Format: fsType, State: api.VolumeState_VOLUME_STATE_AVAILABLE, Status: api.VolumeStatus_VOLUME_STATUS_UP, } }
go
func NewVolume( volumeID string, fsType api.FSType, volumeLocator *api.VolumeLocator, source *api.Source, volumeSpec *api.VolumeSpec, ) *api.Volume { return &api.Volume{ Id: volumeID, Locator: volumeLocator, Ctime: prototime.Now(), Spec: volumeSpec, Source: source, LastScan: prototime.Now(), Format: fsType, State: api.VolumeState_VOLUME_STATE_AVAILABLE, Status: api.VolumeStatus_VOLUME_STATUS_UP, } }
[ "func", "NewVolume", "(", "volumeID", "string", ",", "fsType", "api", ".", "FSType", ",", "volumeLocator", "*", "api", ".", "VolumeLocator", ",", "source", "*", "api", ".", "Source", ",", "volumeSpec", "*", "api", ".", "VolumeSpec", ",", ")", "*", "api", ".", "Volume", "{", "return", "&", "api", ".", "Volume", "{", "Id", ":", "volumeID", ",", "Locator", ":", "volumeLocator", ",", "Ctime", ":", "prototime", ".", "Now", "(", ")", ",", "Spec", ":", "volumeSpec", ",", "Source", ":", "source", ",", "LastScan", ":", "prototime", ".", "Now", "(", ")", ",", "Format", ":", "fsType", ",", "State", ":", "api", ".", "VolumeState_VOLUME_STATE_AVAILABLE", ",", "Status", ":", "api", ".", "VolumeStatus_VOLUME_STATUS_UP", ",", "}", "\n", "}" ]
// NewVolume returns a new api.Volume for a driver Create call.
[ "NewVolume", "returns", "a", "new", "api", ".", "Volume", "for", "a", "driver", "Create", "call", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/volume/drivers/common/common.go#L11-L29
train
libopenstorage/openstorage
volume/drivers/common/common.go
NewDefaultStoreEnumerator
func NewDefaultStoreEnumerator(driver string, kvdb kvdb.Kvdb) volume.StoreEnumerator { return newDefaultStoreEnumerator(driver, kvdb) }
go
func NewDefaultStoreEnumerator(driver string, kvdb kvdb.Kvdb) volume.StoreEnumerator { return newDefaultStoreEnumerator(driver, kvdb) }
[ "func", "NewDefaultStoreEnumerator", "(", "driver", "string", ",", "kvdb", "kvdb", ".", "Kvdb", ")", "volume", ".", "StoreEnumerator", "{", "return", "newDefaultStoreEnumerator", "(", "driver", ",", "kvdb", ")", "\n", "}" ]
// NewDefaultStoreEnumerator returns a default store enumerator
[ "NewDefaultStoreEnumerator", "returns", "a", "default", "store", "enumerator" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/volume/drivers/common/common.go#L32-L34
train
libopenstorage/openstorage
api/server/sdk/schedule_policy.go
Create
func (s *SchedulePolicyServer) Create( ctx context.Context, req *api.SdkSchedulePolicyCreateRequest, ) (*api.SdkSchedulePolicyCreateResponse, error) { if s.cluster() == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if req.GetSchedulePolicy() == nil { return nil, status.Error(codes.InvalidArgument, "SchedulePolicy object cannot be nil") } else if len(req.GetSchedulePolicy().GetName()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply Schedule name") } else if req.GetSchedulePolicy().GetSchedules() == nil || len(req.GetSchedulePolicy().GetSchedules()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must a supply Schedule") } for _, sdkSched := range req.GetSchedulePolicy().GetSchedules() { if sdkSched.GetRetain() < 1 { return nil, status.Error(codes.InvalidArgument, "Must retain more than 0") } } out, err := sdkSchedToRetainInternalSpecYamlByte(req.GetSchedulePolicy().GetSchedules()) if err != nil { return nil, err } err = s.cluster().SchedPolicyCreate(req.GetSchedulePolicy().GetName(), string(out)) if err != nil { return nil, status.Errorf( codes.Internal, "failed to create schedule policy: %v", err.Error()) } return &api.SdkSchedulePolicyCreateResponse{}, err }
go
func (s *SchedulePolicyServer) Create( ctx context.Context, req *api.SdkSchedulePolicyCreateRequest, ) (*api.SdkSchedulePolicyCreateResponse, error) { if s.cluster() == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if req.GetSchedulePolicy() == nil { return nil, status.Error(codes.InvalidArgument, "SchedulePolicy object cannot be nil") } else if len(req.GetSchedulePolicy().GetName()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply Schedule name") } else if req.GetSchedulePolicy().GetSchedules() == nil || len(req.GetSchedulePolicy().GetSchedules()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must a supply Schedule") } for _, sdkSched := range req.GetSchedulePolicy().GetSchedules() { if sdkSched.GetRetain() < 1 { return nil, status.Error(codes.InvalidArgument, "Must retain more than 0") } } out, err := sdkSchedToRetainInternalSpecYamlByte(req.GetSchedulePolicy().GetSchedules()) if err != nil { return nil, err } err = s.cluster().SchedPolicyCreate(req.GetSchedulePolicy().GetName(), string(out)) if err != nil { return nil, status.Errorf( codes.Internal, "failed to create schedule policy: %v", err.Error()) } return &api.SdkSchedulePolicyCreateResponse{}, err }
[ "func", "(", "s", "*", "SchedulePolicyServer", ")", "Create", "(", "ctx", "context", ".", "Context", ",", "req", "*", "api", ".", "SdkSchedulePolicyCreateRequest", ",", ")", "(", "*", "api", ".", "SdkSchedulePolicyCreateResponse", ",", "error", ")", "{", "if", "s", ".", "cluster", "(", ")", "==", "nil", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "Unavailable", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "req", ".", "GetSchedulePolicy", "(", ")", "==", "nil", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "else", "if", "len", "(", "req", ".", "GetSchedulePolicy", "(", ")", ".", "GetName", "(", ")", ")", "==", "0", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "else", "if", "req", ".", "GetSchedulePolicy", "(", ")", ".", "GetSchedules", "(", ")", "==", "nil", "||", "len", "(", "req", ".", "GetSchedulePolicy", "(", ")", ".", "GetSchedules", "(", ")", ")", "==", "0", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "\n\n", "for", "_", ",", "sdkSched", ":=", "range", "req", ".", "GetSchedulePolicy", "(", ")", ".", "GetSchedules", "(", ")", "{", "if", "sdkSched", ".", "GetRetain", "(", ")", "<", "1", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "out", ",", "err", ":=", "sdkSchedToRetainInternalSpecYamlByte", "(", "req", ".", "GetSchedulePolicy", "(", ")", ".", "GetSchedules", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "err", "=", "s", ".", "cluster", "(", ")", ".", "SchedPolicyCreate", "(", "req", ".", "GetSchedulePolicy", "(", ")", ".", "GetName", "(", ")", ",", "string", "(", "out", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "status", ".", "Errorf", "(", "codes", ".", "Internal", ",", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n\n", "return", "&", "api", ".", "SdkSchedulePolicyCreateResponse", "{", "}", ",", "err", "\n", "}" ]
// Create method creates schedule policy
[ "Create", "method", "creates", "schedule", "policy" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/server/sdk/schedule_policy.go#L40-L76
train
libopenstorage/openstorage
api/server/sdk/schedule_policy.go
Update
func (s *SchedulePolicyServer) Update( ctx context.Context, req *api.SdkSchedulePolicyUpdateRequest, ) (*api.SdkSchedulePolicyUpdateResponse, error) { if s.cluster() == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if req.GetSchedulePolicy() == nil { return nil, status.Error(codes.InvalidArgument, "SchedulePolicy object cannot be nil") } else if len(req.GetSchedulePolicy().GetName()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply Schedule name") } else if req.GetSchedulePolicy().GetSchedules() == nil || len(req.GetSchedulePolicy().GetSchedules()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply Schedule") } for _, sdkSched := range req.GetSchedulePolicy().GetSchedules() { if sdkSched.GetRetain() < 1 { return nil, status.Error(codes.InvalidArgument, "Must retain more than 0") } } out, err := sdkSchedToRetainInternalSpecYamlByte(req.GetSchedulePolicy().GetSchedules()) if err != nil { return nil, err } err = s.cluster().SchedPolicyUpdate(req.GetSchedulePolicy().GetName(), string(out)) if err != nil { if err == kvdb.ErrNotFound { return nil, status.Errorf( codes.NotFound, "Schedule policy %s not found", req.GetSchedulePolicy().GetName()) } return nil, status.Errorf( codes.Internal, "Failed to update schedule policy: %v", err.Error()) } return &api.SdkSchedulePolicyUpdateResponse{}, err }
go
func (s *SchedulePolicyServer) Update( ctx context.Context, req *api.SdkSchedulePolicyUpdateRequest, ) (*api.SdkSchedulePolicyUpdateResponse, error) { if s.cluster() == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if req.GetSchedulePolicy() == nil { return nil, status.Error(codes.InvalidArgument, "SchedulePolicy object cannot be nil") } else if len(req.GetSchedulePolicy().GetName()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply Schedule name") } else if req.GetSchedulePolicy().GetSchedules() == nil || len(req.GetSchedulePolicy().GetSchedules()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply Schedule") } for _, sdkSched := range req.GetSchedulePolicy().GetSchedules() { if sdkSched.GetRetain() < 1 { return nil, status.Error(codes.InvalidArgument, "Must retain more than 0") } } out, err := sdkSchedToRetainInternalSpecYamlByte(req.GetSchedulePolicy().GetSchedules()) if err != nil { return nil, err } err = s.cluster().SchedPolicyUpdate(req.GetSchedulePolicy().GetName(), string(out)) if err != nil { if err == kvdb.ErrNotFound { return nil, status.Errorf( codes.NotFound, "Schedule policy %s not found", req.GetSchedulePolicy().GetName()) } return nil, status.Errorf( codes.Internal, "Failed to update schedule policy: %v", err.Error()) } return &api.SdkSchedulePolicyUpdateResponse{}, err }
[ "func", "(", "s", "*", "SchedulePolicyServer", ")", "Update", "(", "ctx", "context", ".", "Context", ",", "req", "*", "api", ".", "SdkSchedulePolicyUpdateRequest", ",", ")", "(", "*", "api", ".", "SdkSchedulePolicyUpdateResponse", ",", "error", ")", "{", "if", "s", ".", "cluster", "(", ")", "==", "nil", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "Unavailable", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "req", ".", "GetSchedulePolicy", "(", ")", "==", "nil", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "else", "if", "len", "(", "req", ".", "GetSchedulePolicy", "(", ")", ".", "GetName", "(", ")", ")", "==", "0", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "else", "if", "req", ".", "GetSchedulePolicy", "(", ")", ".", "GetSchedules", "(", ")", "==", "nil", "||", "len", "(", "req", ".", "GetSchedulePolicy", "(", ")", ".", "GetSchedules", "(", ")", ")", "==", "0", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "\n\n", "for", "_", ",", "sdkSched", ":=", "range", "req", ".", "GetSchedulePolicy", "(", ")", ".", "GetSchedules", "(", ")", "{", "if", "sdkSched", ".", "GetRetain", "(", ")", "<", "1", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "out", ",", "err", ":=", "sdkSchedToRetainInternalSpecYamlByte", "(", "req", ".", "GetSchedulePolicy", "(", ")", ".", "GetSchedules", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "err", "=", "s", ".", "cluster", "(", ")", ".", "SchedPolicyUpdate", "(", "req", ".", "GetSchedulePolicy", "(", ")", ".", "GetName", "(", ")", ",", "string", "(", "out", ")", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "kvdb", ".", "ErrNotFound", "{", "return", "nil", ",", "status", ".", "Errorf", "(", "codes", ".", "NotFound", ",", "\"", "\"", ",", "req", ".", "GetSchedulePolicy", "(", ")", ".", "GetName", "(", ")", ")", "\n", "}", "\n", "return", "nil", ",", "status", ".", "Errorf", "(", "codes", ".", "Internal", ",", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n\n", "return", "&", "api", ".", "SdkSchedulePolicyUpdateResponse", "{", "}", ",", "err", "\n", "}" ]
// Update method updates schedule policy
[ "Update", "method", "updates", "schedule", "policy" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/server/sdk/schedule_policy.go#L79-L120
train
libopenstorage/openstorage
api/server/sdk/schedule_policy.go
Delete
func (s *SchedulePolicyServer) Delete( ctx context.Context, req *api.SdkSchedulePolicyDeleteRequest, ) (*api.SdkSchedulePolicyDeleteResponse, error) { if s.cluster() == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if len(req.GetName()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply Schedule name") } err := s.cluster().SchedPolicyDelete(req.GetName()) if err != nil && err != kvdb.ErrNotFound { return nil, status.Errorf( codes.Internal, "Failed to delete schedule policy: %v", err.Error()) } return &api.SdkSchedulePolicyDeleteResponse{}, nil }
go
func (s *SchedulePolicyServer) Delete( ctx context.Context, req *api.SdkSchedulePolicyDeleteRequest, ) (*api.SdkSchedulePolicyDeleteResponse, error) { if s.cluster() == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if len(req.GetName()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply Schedule name") } err := s.cluster().SchedPolicyDelete(req.GetName()) if err != nil && err != kvdb.ErrNotFound { return nil, status.Errorf( codes.Internal, "Failed to delete schedule policy: %v", err.Error()) } return &api.SdkSchedulePolicyDeleteResponse{}, nil }
[ "func", "(", "s", "*", "SchedulePolicyServer", ")", "Delete", "(", "ctx", "context", ".", "Context", ",", "req", "*", "api", ".", "SdkSchedulePolicyDeleteRequest", ",", ")", "(", "*", "api", ".", "SdkSchedulePolicyDeleteResponse", ",", "error", ")", "{", "if", "s", ".", "cluster", "(", ")", "==", "nil", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "Unavailable", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "len", "(", "req", ".", "GetName", "(", ")", ")", "==", "0", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "\n\n", "err", ":=", "s", ".", "cluster", "(", ")", ".", "SchedPolicyDelete", "(", "req", ".", "GetName", "(", ")", ")", "\n", "if", "err", "!=", "nil", "&&", "err", "!=", "kvdb", ".", "ErrNotFound", "{", "return", "nil", ",", "status", ".", "Errorf", "(", "codes", ".", "Internal", ",", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n\n", "return", "&", "api", ".", "SdkSchedulePolicyDeleteResponse", "{", "}", ",", "nil", "\n", "}" ]
// Delete method deletes schedule policy
[ "Delete", "method", "deletes", "schedule", "policy" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/server/sdk/schedule_policy.go#L123-L144
train
libopenstorage/openstorage
api/server/sdk/schedule_policy.go
Enumerate
func (s *SchedulePolicyServer) Enumerate( ctx context.Context, req *api.SdkSchedulePolicyEnumerateRequest, ) (*api.SdkSchedulePolicyEnumerateResponse, error) { if s.cluster() == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } policies, err := s.cluster().SchedPolicyEnumerate() if err != nil { return nil, status.Errorf( codes.Internal, "Failed to enumerate schedule policy: %v", err.Error()) } sdkpolicies := []*api.SdkSchedulePolicy{} for _, policy := range policies { schedules, err := retainInternalSpecYamlByteToSdkSched([]byte(policy.Schedule)) if err != nil { return nil, err } p := &api.SdkSchedulePolicy{ Name: policy.Name, Schedules: schedules, } sdkpolicies = append(sdkpolicies, p) } return &api.SdkSchedulePolicyEnumerateResponse{Policies: sdkpolicies}, err }
go
func (s *SchedulePolicyServer) Enumerate( ctx context.Context, req *api.SdkSchedulePolicyEnumerateRequest, ) (*api.SdkSchedulePolicyEnumerateResponse, error) { if s.cluster() == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } policies, err := s.cluster().SchedPolicyEnumerate() if err != nil { return nil, status.Errorf( codes.Internal, "Failed to enumerate schedule policy: %v", err.Error()) } sdkpolicies := []*api.SdkSchedulePolicy{} for _, policy := range policies { schedules, err := retainInternalSpecYamlByteToSdkSched([]byte(policy.Schedule)) if err != nil { return nil, err } p := &api.SdkSchedulePolicy{ Name: policy.Name, Schedules: schedules, } sdkpolicies = append(sdkpolicies, p) } return &api.SdkSchedulePolicyEnumerateResponse{Policies: sdkpolicies}, err }
[ "func", "(", "s", "*", "SchedulePolicyServer", ")", "Enumerate", "(", "ctx", "context", ".", "Context", ",", "req", "*", "api", ".", "SdkSchedulePolicyEnumerateRequest", ",", ")", "(", "*", "api", ".", "SdkSchedulePolicyEnumerateResponse", ",", "error", ")", "{", "if", "s", ".", "cluster", "(", ")", "==", "nil", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "Unavailable", ",", "\"", "\"", ")", "\n", "}", "\n\n", "policies", ",", "err", ":=", "s", ".", "cluster", "(", ")", ".", "SchedPolicyEnumerate", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "status", ".", "Errorf", "(", "codes", ".", "Internal", ",", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "sdkpolicies", ":=", "[", "]", "*", "api", ".", "SdkSchedulePolicy", "{", "}", "\n", "for", "_", ",", "policy", ":=", "range", "policies", "{", "schedules", ",", "err", ":=", "retainInternalSpecYamlByteToSdkSched", "(", "[", "]", "byte", "(", "policy", ".", "Schedule", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "p", ":=", "&", "api", ".", "SdkSchedulePolicy", "{", "Name", ":", "policy", ".", "Name", ",", "Schedules", ":", "schedules", ",", "}", "\n", "sdkpolicies", "=", "append", "(", "sdkpolicies", ",", "p", ")", "\n", "}", "\n\n", "return", "&", "api", ".", "SdkSchedulePolicyEnumerateResponse", "{", "Policies", ":", "sdkpolicies", "}", ",", "err", "\n", "}" ]
// Enumerate method enumerates schedule policies
[ "Enumerate", "method", "enumerates", "schedule", "policies" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/server/sdk/schedule_policy.go#L147-L179
train
libopenstorage/openstorage
api/server/sdk/schedule_policy.go
Inspect
func (s *SchedulePolicyServer) Inspect( ctx context.Context, req *api.SdkSchedulePolicyInspectRequest, ) (*api.SdkSchedulePolicyInspectResponse, error) { if s.cluster() == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if len(req.GetName()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply Schedule name") } policy, err := s.cluster().SchedPolicyGet(req.GetName()) if err != nil { if err == kvdb.ErrNotFound { return nil, status.Errorf( codes.NotFound, "Schedule policy %s not found", req.GetName()) } return nil, status.Errorf( codes.Internal, "Failed to inspect schedule policy: %v", err.Error()) } schedules, err := retainInternalSpecYamlByteToSdkSched([]byte(policy.Schedule)) if err != nil { return nil, err } sdkpolicy := &api.SdkSchedulePolicy{ Name: policy.Name, Schedules: schedules, } return &api.SdkSchedulePolicyInspectResponse{Policy: sdkpolicy}, err }
go
func (s *SchedulePolicyServer) Inspect( ctx context.Context, req *api.SdkSchedulePolicyInspectRequest, ) (*api.SdkSchedulePolicyInspectResponse, error) { if s.cluster() == nil { return nil, status.Error(codes.Unavailable, "Resource has not been initialized") } if len(req.GetName()) == 0 { return nil, status.Error(codes.InvalidArgument, "Must supply Schedule name") } policy, err := s.cluster().SchedPolicyGet(req.GetName()) if err != nil { if err == kvdb.ErrNotFound { return nil, status.Errorf( codes.NotFound, "Schedule policy %s not found", req.GetName()) } return nil, status.Errorf( codes.Internal, "Failed to inspect schedule policy: %v", err.Error()) } schedules, err := retainInternalSpecYamlByteToSdkSched([]byte(policy.Schedule)) if err != nil { return nil, err } sdkpolicy := &api.SdkSchedulePolicy{ Name: policy.Name, Schedules: schedules, } return &api.SdkSchedulePolicyInspectResponse{Policy: sdkpolicy}, err }
[ "func", "(", "s", "*", "SchedulePolicyServer", ")", "Inspect", "(", "ctx", "context", ".", "Context", ",", "req", "*", "api", ".", "SdkSchedulePolicyInspectRequest", ",", ")", "(", "*", "api", ".", "SdkSchedulePolicyInspectResponse", ",", "error", ")", "{", "if", "s", ".", "cluster", "(", ")", "==", "nil", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "Unavailable", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "len", "(", "req", ".", "GetName", "(", ")", ")", "==", "0", "{", "return", "nil", ",", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "}", "\n\n", "policy", ",", "err", ":=", "s", ".", "cluster", "(", ")", ".", "SchedPolicyGet", "(", "req", ".", "GetName", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "kvdb", ".", "ErrNotFound", "{", "return", "nil", ",", "status", ".", "Errorf", "(", "codes", ".", "NotFound", ",", "\"", "\"", ",", "req", ".", "GetName", "(", ")", ")", "\n", "}", "\n", "return", "nil", ",", "status", ".", "Errorf", "(", "codes", ".", "Internal", ",", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n\n", "schedules", ",", "err", ":=", "retainInternalSpecYamlByteToSdkSched", "(", "[", "]", "byte", "(", "policy", ".", "Schedule", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "sdkpolicy", ":=", "&", "api", ".", "SdkSchedulePolicy", "{", "Name", ":", "policy", ".", "Name", ",", "Schedules", ":", "schedules", ",", "}", "\n\n", "return", "&", "api", ".", "SdkSchedulePolicyInspectResponse", "{", "Policy", ":", "sdkpolicy", "}", ",", "err", "\n", "}" ]
// Inspect method inspects schedule policy
[ "Inspect", "method", "inspects", "schedule", "policy" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/server/sdk/schedule_policy.go#L182-L219
train
libopenstorage/openstorage
pkg/mount/device.go
NewDeviceMounter
func NewDeviceMounter( devPrefixes []string, mountImpl MountImpl, allowedDirs []string, trashLocation string, ) (*deviceMounter, error) { m := &deviceMounter{ Mounter: Mounter{ mountImpl: mountImpl, mounts: make(DeviceMap), paths: make(PathMap), allowedDirs: allowedDirs, kl: keylock.New(), trashLocation: trashLocation, }, } err := m.Load(devPrefixes) if err != nil { return nil, err } if len(m.trashLocation) > 0 { if err := os.MkdirAll(m.trashLocation, 0755); err != nil { return nil, err } } return m, nil }
go
func NewDeviceMounter( devPrefixes []string, mountImpl MountImpl, allowedDirs []string, trashLocation string, ) (*deviceMounter, error) { m := &deviceMounter{ Mounter: Mounter{ mountImpl: mountImpl, mounts: make(DeviceMap), paths: make(PathMap), allowedDirs: allowedDirs, kl: keylock.New(), trashLocation: trashLocation, }, } err := m.Load(devPrefixes) if err != nil { return nil, err } if len(m.trashLocation) > 0 { if err := os.MkdirAll(m.trashLocation, 0755); err != nil { return nil, err } } return m, nil }
[ "func", "NewDeviceMounter", "(", "devPrefixes", "[", "]", "string", ",", "mountImpl", "MountImpl", ",", "allowedDirs", "[", "]", "string", ",", "trashLocation", "string", ",", ")", "(", "*", "deviceMounter", ",", "error", ")", "{", "m", ":=", "&", "deviceMounter", "{", "Mounter", ":", "Mounter", "{", "mountImpl", ":", "mountImpl", ",", "mounts", ":", "make", "(", "DeviceMap", ")", ",", "paths", ":", "make", "(", "PathMap", ")", ",", "allowedDirs", ":", "allowedDirs", ",", "kl", ":", "keylock", ".", "New", "(", ")", ",", "trashLocation", ":", "trashLocation", ",", "}", ",", "}", "\n", "err", ":=", "m", ".", "Load", "(", "devPrefixes", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "len", "(", "m", ".", "trashLocation", ")", ">", "0", "{", "if", "err", ":=", "os", ".", "MkdirAll", "(", "m", ".", "trashLocation", ",", "0755", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "m", ",", "nil", "\n", "}" ]
// NewDeviceMounter returns a new deviceMounter
[ "NewDeviceMounter", "returns", "a", "new", "deviceMounter" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/device.go#L20-L49
train
libopenstorage/openstorage
pkg/mount/device.go
Reload
func (m *deviceMounter) Reload(device string) error { newDm, err := NewDeviceMounter([]string{device}, m.mountImpl, m.Mounter.allowedDirs, m.trashLocation, ) if err != nil { return err } return m.reload(device, newDm.mounts[device]) }
go
func (m *deviceMounter) Reload(device string) error { newDm, err := NewDeviceMounter([]string{device}, m.mountImpl, m.Mounter.allowedDirs, m.trashLocation, ) if err != nil { return err } return m.reload(device, newDm.mounts[device]) }
[ "func", "(", "m", "*", "deviceMounter", ")", "Reload", "(", "device", "string", ")", "error", "{", "newDm", ",", "err", ":=", "NewDeviceMounter", "(", "[", "]", "string", "{", "device", "}", ",", "m", ".", "mountImpl", ",", "m", ".", "Mounter", ".", "allowedDirs", ",", "m", ".", "trashLocation", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "m", ".", "reload", "(", "device", ",", "newDm", ".", "mounts", "[", "device", "]", ")", "\n", "}" ]
// Reload reloads the mount table
[ "Reload", "reloads", "the", "mount", "table" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/device.go#L52-L62
train
libopenstorage/openstorage
volume/drivers/fuse/fuse.go
NewVolumeDriver
func NewVolumeDriver(name string, baseDirPath string, provider Provider) volume.VolumeDriver { return newVolumeDriver(name, baseDirPath, provider) }
go
func NewVolumeDriver(name string, baseDirPath string, provider Provider) volume.VolumeDriver { return newVolumeDriver(name, baseDirPath, provider) }
[ "func", "NewVolumeDriver", "(", "name", "string", ",", "baseDirPath", "string", ",", "provider", "Provider", ")", "volume", ".", "VolumeDriver", "{", "return", "newVolumeDriver", "(", "name", ",", "baseDirPath", ",", "provider", ")", "\n", "}" ]
// NewVolumeDriver creates a new volume.VolumeDriver for fuse.
[ "NewVolumeDriver", "creates", "a", "new", "volume", ".", "VolumeDriver", "for", "fuse", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/volume/drivers/fuse/fuse.go#L17-L19
train
libopenstorage/openstorage
pkg/mount/nfs.go
NewNFSMounter
func NewNFSMounter(servers []string, mountImpl MountImpl, allowedDirs []string, ) (Manager, error) { m := &nfsMounter{ servers: servers, Mounter: Mounter{ mountImpl: mountImpl, mounts: make(DeviceMap), paths: make(PathMap), allowedDirs: allowedDirs, kl: keylock.New(), }, } err := m.Load([]string{""}) if err != nil { return nil, err } return m, nil }
go
func NewNFSMounter(servers []string, mountImpl MountImpl, allowedDirs []string, ) (Manager, error) { m := &nfsMounter{ servers: servers, Mounter: Mounter{ mountImpl: mountImpl, mounts: make(DeviceMap), paths: make(PathMap), allowedDirs: allowedDirs, kl: keylock.New(), }, } err := m.Load([]string{""}) if err != nil { return nil, err } return m, nil }
[ "func", "NewNFSMounter", "(", "servers", "[", "]", "string", ",", "mountImpl", "MountImpl", ",", "allowedDirs", "[", "]", "string", ",", ")", "(", "Manager", ",", "error", ")", "{", "m", ":=", "&", "nfsMounter", "{", "servers", ":", "servers", ",", "Mounter", ":", "Mounter", "{", "mountImpl", ":", "mountImpl", ",", "mounts", ":", "make", "(", "DeviceMap", ")", ",", "paths", ":", "make", "(", "PathMap", ")", ",", "allowedDirs", ":", "allowedDirs", ",", "kl", ":", "keylock", ".", "New", "(", ")", ",", "}", ",", "}", "\n", "err", ":=", "m", ".", "Load", "(", "[", "]", "string", "{", "\"", "\"", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "m", ",", "nil", "\n", "}" ]
// NewnfsMounter returns a Mounter specific to parse NFS mounts. This can work // VFS also if 'servers' is nil. Use NFSAllServers if the destination server // is unknown.
[ "NewnfsMounter", "returns", "a", "Mounter", "specific", "to", "parse", "NFS", "mounts", ".", "This", "can", "work", "VFS", "also", "if", "servers", "is", "nil", ".", "Use", "NFSAllServers", "if", "the", "destination", "server", "is", "unknown", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/nfs.go#L28-L47
train
libopenstorage/openstorage
pkg/mount/nfs.go
serverExists
func (m *nfsMounter) serverExists(server string) bool { for _, v := range m.servers { if v == server || v == NFSAllServers { return true } } return false }
go
func (m *nfsMounter) serverExists(server string) bool { for _, v := range m.servers { if v == server || v == NFSAllServers { return true } } return false }
[ "func", "(", "m", "*", "nfsMounter", ")", "serverExists", "(", "server", "string", ")", "bool", "{", "for", "_", ",", "v", ":=", "range", "m", ".", "servers", "{", "if", "v", "==", "server", "||", "v", "==", "NFSAllServers", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
//serverExists utility function to test if a server is part of driver config
[ "serverExists", "utility", "function", "to", "test", "if", "a", "server", "is", "part", "of", "driver", "config" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/nfs.go#L68-L75
train
libopenstorage/openstorage
pkg/dbg/profile_dump.go
DumpGoMemoryTrace
func DumpGoMemoryTrace() { m := &runtime.MemStats{} runtime.ReadMemStats(m) res := fmt.Sprintf("%#v", m) logrus.Infof("==== Dumping Memory Profile ===") logrus.Infof(res) }
go
func DumpGoMemoryTrace() { m := &runtime.MemStats{} runtime.ReadMemStats(m) res := fmt.Sprintf("%#v", m) logrus.Infof("==== Dumping Memory Profile ===") logrus.Infof(res) }
[ "func", "DumpGoMemoryTrace", "(", ")", "{", "m", ":=", "&", "runtime", ".", "MemStats", "{", "}", "\n", "runtime", ".", "ReadMemStats", "(", "m", ")", "\n", "res", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ")", "\n", "logrus", ".", "Infof", "(", "\"", "\"", ")", "\n", "logrus", ".", "Infof", "(", "res", ")", "\n", "}" ]
// DumpGoMemoryTrace output memory profile to logs.
[ "DumpGoMemoryTrace", "output", "memory", "profile", "to", "logs", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/dbg/profile_dump.go#L20-L26
train
libopenstorage/openstorage
pkg/dbg/profile_dump.go
DumpGoProfile
func DumpGoProfile() error { trace := make([]byte, 5120*1024) len := runtime.Stack(trace, true) return ioutil.WriteFile(path+time.Now().Format(fnameFmt)+".stack", trace[:len], 0644) }
go
func DumpGoProfile() error { trace := make([]byte, 5120*1024) len := runtime.Stack(trace, true) return ioutil.WriteFile(path+time.Now().Format(fnameFmt)+".stack", trace[:len], 0644) }
[ "func", "DumpGoProfile", "(", ")", "error", "{", "trace", ":=", "make", "(", "[", "]", "byte", ",", "5120", "*", "1024", ")", "\n", "len", ":=", "runtime", ".", "Stack", "(", "trace", ",", "true", ")", "\n", "return", "ioutil", ".", "WriteFile", "(", "path", "+", "time", ".", "Now", "(", ")", ".", "Format", "(", "fnameFmt", ")", "+", "\"", "\"", ",", "trace", "[", ":", "len", "]", ",", "0644", ")", "\n", "}" ]
// DumpGoProfile output goroutines to file.
[ "DumpGoProfile", "output", "goroutines", "to", "file", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/dbg/profile_dump.go#L29-L33
train
libopenstorage/openstorage
pkg/dbg/log.go
Panicf
func Panicf(format string, args ...interface{}) { logrus.Warnf(format, args...) err := DumpGoProfile() if err != nil { logrus.Fatal(err) } DumpHeap() os.Exit(6) }
go
func Panicf(format string, args ...interface{}) { logrus.Warnf(format, args...) err := DumpGoProfile() if err != nil { logrus.Fatal(err) } DumpHeap() os.Exit(6) }
[ "func", "Panicf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "logrus", ".", "Warnf", "(", "format", ",", "args", "...", ")", "\n", "err", ":=", "DumpGoProfile", "(", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "Fatal", "(", "err", ")", "\n", "}", "\n", "DumpHeap", "(", ")", "\n", "os", ".", "Exit", "(", "6", ")", "\n", "}" ]
// Panicf outputs error message, dumps threads and exits.
[ "Panicf", "outputs", "error", "message", "dumps", "threads", "and", "exits", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/dbg/log.go#L10-L18
train
libopenstorage/openstorage
pkg/dbg/log.go
Assert
func Assert(condition bool, format string, args ...interface{}) { if !condition { Panicf(format, args...) } }
go
func Assert(condition bool, format string, args ...interface{}) { if !condition { Panicf(format, args...) } }
[ "func", "Assert", "(", "condition", "bool", ",", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "!", "condition", "{", "Panicf", "(", "format", ",", "args", "...", ")", "\n", "}", "\n", "}" ]
// Assert Panicf's if the condition evaluates to false.
[ "Assert", "Panicf", "s", "if", "the", "condition", "evaluates", "to", "false", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/dbg/log.go#L21-L25
train
libopenstorage/openstorage
pkg/device/device.go
NewSingleLetter
func NewSingleLetter(devPrefix, devices string) (*SingleLetter, error) { s := &SingleLetter{ devPrefix: devPrefix, devices: devices, } return s, nil }
go
func NewSingleLetter(devPrefix, devices string) (*SingleLetter, error) { s := &SingleLetter{ devPrefix: devPrefix, devices: devices, } return s, nil }
[ "func", "NewSingleLetter", "(", "devPrefix", ",", "devices", "string", ")", "(", "*", "SingleLetter", ",", "error", ")", "{", "s", ":=", "&", "SingleLetter", "{", "devPrefix", ":", "devPrefix", ",", "devices", ":", "devices", ",", "}", "\n", "return", "s", ",", "nil", "\n", "}" ]
// NewSingleLetter instance of Matrix
[ "NewSingleLetter", "instance", "of", "Matrix" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/device/device.go#L40-L46
train
libopenstorage/openstorage
pkg/device/device.go
Assign
func (s *SingleLetter) Assign() (string, error) { s.Lock() defer s.Unlock() if len(s.devices) == 0 { return "", fmt.Errorf("No free device IDs") } device := s.devPrefix + s.devices[:1] s.devices = s.devices[1:] return device, nil }
go
func (s *SingleLetter) Assign() (string, error) { s.Lock() defer s.Unlock() if len(s.devices) == 0 { return "", fmt.Errorf("No free device IDs") } device := s.devPrefix + s.devices[:1] s.devices = s.devices[1:] return device, nil }
[ "func", "(", "s", "*", "SingleLetter", ")", "Assign", "(", ")", "(", "string", ",", "error", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "if", "len", "(", "s", ".", "devices", ")", "==", "0", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "device", ":=", "s", ".", "devPrefix", "+", "s", ".", "devices", "[", ":", "1", "]", "\n", "s", ".", "devices", "=", "s", ".", "devices", "[", "1", ":", "]", "\n", "return", "device", ",", "nil", "\n", "}" ]
// Assign new device letter
[ "Assign", "new", "device", "letter" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/device/device.go#L49-L58
train
libopenstorage/openstorage
pkg/device/device.go
Release
func (s *SingleLetter) Release(dev string) error { s.Lock() defer s.Unlock() if !strings.HasPrefix(dev, s.devPrefix) { return ErrEinval } dev = dev[len(s.devPrefix):] s.devices += dev return nil }
go
func (s *SingleLetter) Release(dev string) error { s.Lock() defer s.Unlock() if !strings.HasPrefix(dev, s.devPrefix) { return ErrEinval } dev = dev[len(s.devPrefix):] s.devices += dev return nil }
[ "func", "(", "s", "*", "SingleLetter", ")", "Release", "(", "dev", "string", ")", "error", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "if", "!", "strings", ".", "HasPrefix", "(", "dev", ",", "s", ".", "devPrefix", ")", "{", "return", "ErrEinval", "\n", "}", "\n", "dev", "=", "dev", "[", "len", "(", "s", ".", "devPrefix", ")", ":", "]", "\n", "s", ".", "devices", "+=", "dev", "\n", "return", "nil", "\n", "}" ]
// Release device letter to devices pool.
[ "Release", "device", "letter", "to", "devices", "pool", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/device/device.go#L61-L70
train
libopenstorage/openstorage
cluster/manager/manager.go
Init
func Init(cfg config.ClusterConfig) error { if inst != nil { return errClusterInitialized } kv := kvdb.Instance() if kv == nil { return errors.New("KVDB is not yet initialized. " + "A valid KVDB instance required for the cluster to start.") } inst = &ClusterManager{ listeners: list.New(), config: cfg, kv: kv, nodeCache: make(map[string]api.Node), nodeStatuses: make(map[string]api.Status), systemTokenManager: auth.SystemTokenManagerInst(), } return nil }
go
func Init(cfg config.ClusterConfig) error { if inst != nil { return errClusterInitialized } kv := kvdb.Instance() if kv == nil { return errors.New("KVDB is not yet initialized. " + "A valid KVDB instance required for the cluster to start.") } inst = &ClusterManager{ listeners: list.New(), config: cfg, kv: kv, nodeCache: make(map[string]api.Node), nodeStatuses: make(map[string]api.Status), systemTokenManager: auth.SystemTokenManagerInst(), } return nil }
[ "func", "Init", "(", "cfg", "config", ".", "ClusterConfig", ")", "error", "{", "if", "inst", "!=", "nil", "{", "return", "errClusterInitialized", "\n", "}", "\n\n", "kv", ":=", "kvdb", ".", "Instance", "(", ")", "\n", "if", "kv", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", "+", "\"", "\"", ")", "\n", "}", "\n\n", "inst", "=", "&", "ClusterManager", "{", "listeners", ":", "list", ".", "New", "(", ")", ",", "config", ":", "cfg", ",", "kv", ":", "kv", ",", "nodeCache", ":", "make", "(", "map", "[", "string", "]", "api", ".", "Node", ")", ",", "nodeStatuses", ":", "make", "(", "map", "[", "string", "]", "api", ".", "Status", ")", ",", "systemTokenManager", ":", "auth", ".", "SystemTokenManagerInst", "(", ")", ",", "}", "\n\n", "return", "nil", "\n", "}" ]
// Init instantiates a new cluster manager.
[ "Init", "instantiates", "a", "new", "cluster", "manager", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/manager/manager.go#L105-L126
train
libopenstorage/openstorage
cluster/manager/manager.go
ExternalIp
func ExternalIp(config *config.ClusterConfig) (string, string, error) { mgmtIp := "" dataIp := "" var err error if config.MgmtIp == "" && config.MgtIface != "" { mgmtIp, err = ifaceNameToIp(config.MgtIface) if err != nil { return "", "", errors.New("Invalid data network interface " + "specified.") } } else if config.MgmtIp != "" { mgmtIp = config.MgmtIp } if config.DataIp == "" && config.DataIface != "" { dataIp, err = ifaceNameToIp(config.DataIface) if err != nil { return "", "", errors.New("Invalid data network interface " + "specified.") } } else if config.DataIp != "" { dataIp = config.DataIp } if mgmtIp != "" && dataIp != "" { return mgmtIp, dataIp, nil } else if mgmtIp != "" { // dataIp is empty return mgmtIp, mgmtIp, nil } else if dataIp != "" { // mgmtIp is empty return dataIp, dataIp, nil } // both are empty, try to pick first available interface for both // No network interface specified, pick first default. ifaces, err := net.Interfaces() if err != nil { return "", "", err } for _, iface := range ifaces { if iface.Flags&net.FlagUp == 0 { continue // interface down } if iface.Flags&net.FlagLoopback != 0 { continue // loopback interface } mgmtIp, err = ifaceToIp(&iface) if err != nil { logrus.Printf("Skipping interface without IP: %v: %v", iface, err) continue } return mgmtIp, mgmtIp, err } return "", "", errors.New("Node not connected to the network.") }
go
func ExternalIp(config *config.ClusterConfig) (string, string, error) { mgmtIp := "" dataIp := "" var err error if config.MgmtIp == "" && config.MgtIface != "" { mgmtIp, err = ifaceNameToIp(config.MgtIface) if err != nil { return "", "", errors.New("Invalid data network interface " + "specified.") } } else if config.MgmtIp != "" { mgmtIp = config.MgmtIp } if config.DataIp == "" && config.DataIface != "" { dataIp, err = ifaceNameToIp(config.DataIface) if err != nil { return "", "", errors.New("Invalid data network interface " + "specified.") } } else if config.DataIp != "" { dataIp = config.DataIp } if mgmtIp != "" && dataIp != "" { return mgmtIp, dataIp, nil } else if mgmtIp != "" { // dataIp is empty return mgmtIp, mgmtIp, nil } else if dataIp != "" { // mgmtIp is empty return dataIp, dataIp, nil } // both are empty, try to pick first available interface for both // No network interface specified, pick first default. ifaces, err := net.Interfaces() if err != nil { return "", "", err } for _, iface := range ifaces { if iface.Flags&net.FlagUp == 0 { continue // interface down } if iface.Flags&net.FlagLoopback != 0 { continue // loopback interface } mgmtIp, err = ifaceToIp(&iface) if err != nil { logrus.Printf("Skipping interface without IP: %v: %v", iface, err) continue } return mgmtIp, mgmtIp, err } return "", "", errors.New("Node not connected to the network.") }
[ "func", "ExternalIp", "(", "config", "*", "config", ".", "ClusterConfig", ")", "(", "string", ",", "string", ",", "error", ")", "{", "mgmtIp", ":=", "\"", "\"", "\n", "dataIp", ":=", "\"", "\"", "\n\n", "var", "err", "error", "\n", "if", "config", ".", "MgmtIp", "==", "\"", "\"", "&&", "config", ".", "MgtIface", "!=", "\"", "\"", "{", "mgmtIp", ",", "err", "=", "ifaceNameToIp", "(", "config", ".", "MgtIface", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "errors", ".", "New", "(", "\"", "\"", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "else", "if", "config", ".", "MgmtIp", "!=", "\"", "\"", "{", "mgmtIp", "=", "config", ".", "MgmtIp", "\n", "}", "\n\n", "if", "config", ".", "DataIp", "==", "\"", "\"", "&&", "config", ".", "DataIface", "!=", "\"", "\"", "{", "dataIp", ",", "err", "=", "ifaceNameToIp", "(", "config", ".", "DataIface", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "errors", ".", "New", "(", "\"", "\"", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "else", "if", "config", ".", "DataIp", "!=", "\"", "\"", "{", "dataIp", "=", "config", ".", "DataIp", "\n", "}", "\n\n", "if", "mgmtIp", "!=", "\"", "\"", "&&", "dataIp", "!=", "\"", "\"", "{", "return", "mgmtIp", ",", "dataIp", ",", "nil", "\n", "}", "else", "if", "mgmtIp", "!=", "\"", "\"", "{", "// dataIp is empty", "return", "mgmtIp", ",", "mgmtIp", ",", "nil", "\n", "}", "else", "if", "dataIp", "!=", "\"", "\"", "{", "// mgmtIp is empty", "return", "dataIp", ",", "dataIp", ",", "nil", "\n", "}", "// both are empty, try to pick first available interface for both", "\n\n", "// No network interface specified, pick first default.", "ifaces", ",", "err", ":=", "net", ".", "Interfaces", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "for", "_", ",", "iface", ":=", "range", "ifaces", "{", "if", "iface", ".", "Flags", "&", "net", ".", "FlagUp", "==", "0", "{", "continue", "// interface down", "\n", "}", "\n", "if", "iface", ".", "Flags", "&", "net", ".", "FlagLoopback", "!=", "0", "{", "continue", "// loopback interface", "\n", "}", "\n\n", "mgmtIp", ",", "err", "=", "ifaceToIp", "(", "&", "iface", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "Printf", "(", "\"", "\"", ",", "iface", ",", "err", ")", "\n", "continue", "\n", "}", "\n", "return", "mgmtIp", ",", "mgmtIp", ",", "err", "\n", "}", "\n\n", "return", "\"", "\"", ",", "\"", "\"", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
// ExternalIp returns the mgmt and data ip based on the config
[ "ExternalIp", "returns", "the", "mgmt", "and", "data", "ip", "based", "on", "the", "config" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/manager/manager.go#L196-L252
train
libopenstorage/openstorage
cluster/manager/manager.go
Inspect
func (c *ClusterManager) Inspect(nodeID string) (api.Node, error) { c.nodeCacheLock.Lock() defer c.nodeCacheLock.Unlock() return c.getNodeEntry(nodeID, &cluster.ClusterInfo{}) }
go
func (c *ClusterManager) Inspect(nodeID string) (api.Node, error) { c.nodeCacheLock.Lock() defer c.nodeCacheLock.Unlock() return c.getNodeEntry(nodeID, &cluster.ClusterInfo{}) }
[ "func", "(", "c", "*", "ClusterManager", ")", "Inspect", "(", "nodeID", "string", ")", "(", "api", ".", "Node", ",", "error", ")", "{", "c", ".", "nodeCacheLock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "nodeCacheLock", ".", "Unlock", "(", ")", "\n", "return", "c", ".", "getNodeEntry", "(", "nodeID", ",", "&", "cluster", ".", "ClusterInfo", "{", "}", ")", "\n", "}" ]
// Inspect inspects given node and returns the state
[ "Inspect", "inspects", "given", "node", "and", "returns", "the", "state" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/manager/manager.go#L293-L297
train
libopenstorage/openstorage
cluster/manager/manager.go
AddEventListener
func (c *ClusterManager) AddEventListener(listener cluster.ClusterListener) error { logrus.Printf("Adding cluster event listener: %s", listener.String()) c.listeners.PushBack(listener) return nil }
go
func (c *ClusterManager) AddEventListener(listener cluster.ClusterListener) error { logrus.Printf("Adding cluster event listener: %s", listener.String()) c.listeners.PushBack(listener) return nil }
[ "func", "(", "c", "*", "ClusterManager", ")", "AddEventListener", "(", "listener", "cluster", ".", "ClusterListener", ")", "error", "{", "logrus", ".", "Printf", "(", "\"", "\"", ",", "listener", ".", "String", "(", ")", ")", "\n", "c", ".", "listeners", ".", "PushBack", "(", "listener", ")", "\n", "return", "nil", "\n", "}" ]
// AddEventListener adds a new listener
[ "AddEventListener", "adds", "a", "new", "listener" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/manager/manager.go#L300-L304
train
libopenstorage/openstorage
cluster/manager/manager.go
UpdateData
func (c *ClusterManager) UpdateData(nodeData map[string]interface{}) error { c.selfNodeLock.Lock() defer c.selfNodeLock.Unlock() for dataKey, dataValue := range nodeData { c.selfNode.NodeData[dataKey] = dataValue } return nil }
go
func (c *ClusterManager) UpdateData(nodeData map[string]interface{}) error { c.selfNodeLock.Lock() defer c.selfNodeLock.Unlock() for dataKey, dataValue := range nodeData { c.selfNode.NodeData[dataKey] = dataValue } return nil }
[ "func", "(", "c", "*", "ClusterManager", ")", "UpdateData", "(", "nodeData", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "c", ".", "selfNodeLock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "selfNodeLock", ".", "Unlock", "(", ")", "\n", "for", "dataKey", ",", "dataValue", ":=", "range", "nodeData", "{", "c", ".", "selfNode", ".", "NodeData", "[", "dataKey", "]", "=", "dataValue", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// UpdateData updates self node data
[ "UpdateData", "updates", "self", "node", "data" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/manager/manager.go#L307-L314
train
libopenstorage/openstorage
cluster/manager/manager.go
GetData
func (c *ClusterManager) GetData() (map[string]*api.Node, error) { nodes := make(map[string]*api.Node) c.nodeCacheLock.Lock() defer c.nodeCacheLock.Unlock() for _, value := range c.nodeCache { copyValue := value.Copy() nodes[value.Id] = copyValue } return nodes, nil }
go
func (c *ClusterManager) GetData() (map[string]*api.Node, error) { nodes := make(map[string]*api.Node) c.nodeCacheLock.Lock() defer c.nodeCacheLock.Unlock() for _, value := range c.nodeCache { copyValue := value.Copy() nodes[value.Id] = copyValue } return nodes, nil }
[ "func", "(", "c", "*", "ClusterManager", ")", "GetData", "(", ")", "(", "map", "[", "string", "]", "*", "api", ".", "Node", ",", "error", ")", "{", "nodes", ":=", "make", "(", "map", "[", "string", "]", "*", "api", ".", "Node", ")", "\n", "c", ".", "nodeCacheLock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "nodeCacheLock", ".", "Unlock", "(", ")", "\n", "for", "_", ",", "value", ":=", "range", "c", ".", "nodeCache", "{", "copyValue", ":=", "value", ".", "Copy", "(", ")", "\n", "nodes", "[", "value", ".", "Id", "]", "=", "copyValue", "\n", "}", "\n", "return", "nodes", ",", "nil", "\n", "}" ]
// GetData returns self node's data
[ "GetData", "returns", "self", "node", "s", "data" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/cluster/manager/manager.go#L347-L356
train