@@ -74,6 +74,7 @@ type sioClient struct {
7474 spClient * sio.StoragePool
7575 provisionMode string
7676 sdcPath string
77+ sdcGuid string
7778 instanceID string
7879 inited bool
7980 diskRegex * regexp.Regexp
@@ -292,30 +293,45 @@ func (c *sioClient) DeleteVolume(id sioVolumeID) error {
292293 return nil
293294}
294295
296+ // IID returns the scaleio instance id for node
295297func (c * sioClient ) IID () (string , error ) {
296298 if err := c .init (); err != nil {
297299 return "" , err
298300 }
299301
302+ // if instanceID not set, retrieve it
300303 if c .instanceID == "" {
301- cmd := c .getSdcCmd ()
302- output , err := c .exec .Run (cmd , "--query_guid" )
304+ guid , err := c .getGuid ()
303305 if err != nil {
304- glog .Error (log ("drv_cfg --query_guid failed: %v" , err ))
305306 return "" , err
306307 }
307- guid := strings .TrimSpace (string (output ))
308308 sdc , err := c .sysClient .FindSdc ("SdcGuid" , guid )
309309 if err != nil {
310- glog .Error (log ("failed to get sdc info %s" , err ))
310+ glog .Error (log ("failed to retrieve sdc info %s" , err ))
311311 return "" , err
312312 }
313313 c .instanceID = sdc .Sdc .ID
314- glog .V (4 ).Info (log ("got instanceID %s" , c .instanceID ))
314+ glog .V (4 ).Info (log ("retrieved instanceID %s" , c .instanceID ))
315315 }
316316 return c .instanceID , nil
317317}
318318
319+ // getGuid returns instance GUID, if not set using resource labels
320+ // it attemps to fallback to using drv_cfg binary
321+ func (c * sioClient ) getGuid () (string , error ) {
322+ if c .sdcGuid == "" {
323+ glog .V (4 ).Info (log ("sdc guid label not set, falling back to using drv_cfg" ))
324+ cmd := c .getSdcCmd ()
325+ output , err := c .exec .Run (cmd , "--query_guid" )
326+ if err != nil {
327+ glog .Error (log ("drv_cfg --query_guid failed: %v" , err ))
328+ return "" , err
329+ }
330+ c .sdcGuid = strings .TrimSpace (string (output ))
331+ }
332+ return c .sdcGuid , nil
333+ }
334+
319335// getSioDiskPaths traverse local disk devices to retrieve device path
320336// The path is extracted from /dev/disk/by-id; each sio device path has format:
321337// emc-vol-<mdmID-volID> e.g.:
0 commit comments