// GetInstanceID returns the instance ID object
356509
func GetInstanceID(
	ctx types.Context,
	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
	   is actually confusing rather than helpful. Instead, we use the client
	   IP address that is on the interface that can reach the monitors.

	   We loop through all the monitor IPs, looking for a local interface
	   that is on the same L2 segment. If these all fail, We are on an L3
	   segment so we grab the IP from the default route.
	*/

	if ctx == nil {
		ctx = context.Background()
	}

	var err error
	if nil == monIPs {
		monIPs, err = getCephMonIPs(ctx)
		if err != nil {
			return nil, err
		}
	}
	if len(monIPs) == 0 {
		return nil, goof.New("no ceph monitors found")
	}

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

	iid := &types.InstanceID{Driver: rbd.Name}
	for _, intf := range localIntfs {
		localIP, localNet, _ := net.ParseCIDR(intf.String())
		for _, monIP := range monIPs {
			if localNet.Contains(monIP) {
				// Monitor reachable over L2
				iid.ID = localIP.String()
				return iid, nil
			}
		}
	}

	// No luck finding L2 match, check for default/static route to monitor
	localIP, err := getSrcIP(ctx, monIPs[0].String())
	if err != nil {
		return nil, err
	}
	iid.ID = localIP

	return iid, nil
}
1010238
func (s *DescribeVolumesInput) SetInstanceId(v string) *DescribeVolumesInput {
	s.InstanceId = &v
	return s
}
1206152
func (s *DescribeEffectiveInstanceAssociationsInput) SetInstanceId(v string) *DescribeEffectiveInstanceAssociationsInput {
	s.InstanceId = &v
	return s
}
833138
func (s *ListInventoryEntriesInput) SetInstanceId(v string) *ListInventoryEntriesInput {
	s.InstanceId = &v
	return s
}
407276
func (s *Instance) SetInstanceId(v string) *Instance {
	s.InstanceId = &v
	return s
}
686399
func (s *DescribeAssociationInput) SetInstanceId(v string) *DescribeAssociationInput {
	s.InstanceId = &v
	return s
}
1157072
func (s *ListUsersInput) SetInstanceId(v string) *ListUsersInput {
	s.InstanceId = &v
	return s
}
343844
func (s *InstanceAccess) SetInstanceId(v string) *InstanceAccess {
	s.InstanceId = &v
	return s
}
171928
func (s *ListSecurityProfilesInput) SetInstanceId(v string) *ListSecurityProfilesInput {
	s.InstanceId = &v
	return s
}
1269670
func (s *UnassignInstanceInput) SetInstanceId(v string) *UnassignInstanceInput {
	s.InstanceId = &v
	return s
}
118562
func (s *DescribeServiceErrorsInput) SetInstanceId(v string) *DescribeServiceErrorsInput {
	s.InstanceId = &v
	return s
}
891533
func (s *DescribeInstancesInput) SetInstanceId(v string) *DescribeInstancesInput {
	s.InstanceId = &v
	return s
}
778240
func (sensor *Sensor) GetInstanceID() (id SensorID) {
	id = SensorID(C.SDL_SensorGetInstanceID((*C.SDL_Sensor)(sensor)))
	return
}
32229
func InstanceID(ctx context.Context) (*types.InstanceID, bool) {
	v, ok := ctx.Value(InstanceIDKey).(*types.InstanceID)
	return v, ok
}
134267
func (s *InstanceAssociationStatusInfo) SetInstanceId(v string) *InstanceAssociationStatusInfo {
	s.InstanceId = &v
	return s
}
1260672
func (s *GetDeployablePatchSnapshotForInstanceOutput) SetInstanceId(v string) *GetDeployablePatchSnapshotForInstanceOutput {
	s.InstanceId = &v
	return s
}
583990
func (s *DescribeInstancePatchesInput) SetInstanceId(v string) *DescribeInstancePatchesInput {
	s.InstanceId = &v
	return s
}