Fix panic when instance doesn't exist remotely

Signed-off-by: Nathan LeClaire <nathan.leclaire@gmail.com>
This commit is contained in:
Nathan LeClaire 2015-03-03 14:48:04 -08:00
parent a7d1a70442
commit 8d0bf21c6d
2 changed files with 7 additions and 3 deletions

View File

@ -402,6 +402,8 @@ func (d *Driver) GetState() (state.State, error) {
return state.Stopping, nil
case "stopped":
return state.Stopped, nil
default:
return state.Error, nil
}
return state.None, nil
}

View File

@ -501,9 +501,11 @@ func (e *EC2) GetInstance(instanceId string) (EC2Instance, error) {
return ec2Instance, fmt.Errorf("Error unmarshalling AWS response XML: %s", err)
}
reservationSet := unmarshalledResponse.ReservationSet[0]
instance := reservationSet.InstancesSet[0]
return instance, nil
if len(unmarshalledResponse.ReservationSet) > 0 {
reservationSet := unmarshalledResponse.ReservationSet[0]
ec2Instance = reservationSet.InstancesSet[0]
}
return ec2Instance, nil
}
func (e *EC2) StartInstance(instanceId string) error {