Commit 41076f17 authored by Harsh Desai's avatar Harsh Desai

cache portworx API port

- reused client whenever possible - refactor get client function into explicit cluster-wide and local functions Signed-off-by: 's avatarHarsh Desai <harsh@portworx.com>
parent 40cf4b75
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"fmt" "fmt"
"os" "os"
volumeclient "github.com/libopenstorage/openstorage/api/client/volume"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
...@@ -43,7 +44,7 @@ func ProbeVolumePlugins() []volume.VolumePlugin { ...@@ -43,7 +44,7 @@ func ProbeVolumePlugins() []volume.VolumePlugin {
type portworxVolumePlugin struct { type portworxVolumePlugin struct {
host volume.VolumeHost host volume.VolumeHost
util *PortworxVolumeUtil util *portworxVolumeUtil
} }
var _ volume.VolumePlugin = &portworxVolumePlugin{} var _ volume.VolumePlugin = &portworxVolumePlugin{}
...@@ -61,8 +62,18 @@ func getPath(uid types.UID, volName string, host volume.VolumeHost) string { ...@@ -61,8 +62,18 @@ func getPath(uid types.UID, volName string, host volume.VolumeHost) string {
} }
func (plugin *portworxVolumePlugin) Init(host volume.VolumeHost) error { func (plugin *portworxVolumePlugin) Init(host volume.VolumeHost) error {
client, err := volumeclient.NewDriverClient(
fmt.Sprintf("http://%s:%d", host.GetHostName(), osdMgmtDefaultPort),
pxdDriverName, osdDriverVersion, pxDriverName)
if err != nil {
return err
}
plugin.host = host plugin.host = host
plugin.util = &PortworxVolumeUtil{} plugin.util = &portworxVolumeUtil{
portworxClient: client,
}
return nil return nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment