Skip to content

Commit

Permalink
create res, check if lease exists, remove and error if it doesnt
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaley committed Nov 28, 2016
1 parent 5c63ec3 commit 687f7dc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ipam/reservations.go
Expand Up @@ -40,10 +40,16 @@ func (ipam *Ipam) CreateReservation(reservation models.Reservation) error {
return err
}

return session.DB(IpamDatabase).C(IpamCollectionLeases).Update(
err = session.DB(IpamDatabase).C(IpamCollectionLeases).Update(
bson.M{"reservation": nil, "subnet": reservation.Subnet},
bson.M{"$set": bson.M{"reservation": reservation.ID}},
)
if err != nil {
session.DB(IpamDatabase).C(IpamCollectionReservations).Remove(reservation)
return err
}

return nil
}

// UpdateReservation updates a Reservation.
Expand Down

0 comments on commit 687f7dc

Please sign in to comment.