Skip to content

Commit

Permalink
Add rbd tests
Browse files Browse the repository at this point in the history
  • Loading branch information
codenrhoden committed Dec 13, 2016
1 parent 59fa60e commit 73295b8
Show file tree
Hide file tree
Showing 2 changed files with 326 additions and 10 deletions.
25 changes: 16 additions & 9 deletions drivers/storage/rbd/executor/rbd_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ func (d *driver) InstanceID(
ctx types.Context,
opts types.Store) (*types.InstanceID, error) {

return GetInstanceID()
return GetInstanceID(nil, nil)
}

// GetInstanceID returns the instance ID object
func GetInstanceID() (*types.InstanceID, error) {
func GetInstanceID(
monIPs []net.IP,
localIntfs []net.Addr) (*types.InstanceID, error) {
/* Ceph doesn't have only one unique identifier per client, it can have
several. With the way the RBD driver is used, we will see multiple
identifiers used, and therefore returning any of those identifiers
Expand All @@ -110,17 +112,22 @@ func GetInstanceID() (*types.InstanceID, error) {
segment so we grab the IP from the default route.
*/

monIPs, err := getCephMonIPs()
if err != nil {
return nil, err
var err error
if nil == monIPs {
monIPs, err = getCephMonIPs()
if err != nil {
return nil, err
}
}
if len(monIPs) == 0 {
return nil, goof.New("No Ceph Monitors found")
}

localIntfs, err := net.InterfaceAddrs()
if err != nil {
return nil, err
if nil == localIntfs {
localIntfs, err = net.InterfaceAddrs()
if err != nil {
return nil, err
}
}

iid := &types.InstanceID{Driver: rbd.Name}
Expand All @@ -135,7 +142,7 @@ func GetInstanceID() (*types.InstanceID, error) {
}
}

// No luck finding L2 match, use default gateway
// No luck finding L2 match, check for default/static route to monitor
localIP, err := getSrcIP(monIPs[0].String())
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit 73295b8

Please sign in to comment.