Ejemplo n.º 1
0
func (m *RemoteManager) WatchLease(ctx context.Context, network string, sn ip.IP4Net, cursor interface{}) (subnet.LeaseWatchResult, error) {
	url := m.mkurl(network, "leases", subnet.MakeSubnetKey(sn))

	wr := subnet.LeaseWatchResult{}
	err := m.watch(ctx, url, cursor, &wr)
	if err != nil {
		return subnet.LeaseWatchResult{}, err
	}
	if _, ok := wr.Cursor.(string); !ok {
		return subnet.LeaseWatchResult{}, fmt.Errorf("watch returned non-string cursor")
	}

	return wr, nil
}
Ejemplo n.º 2
0
func (m *RemoteManager) RemoveReservation(ctx context.Context, network string, sn ip.IP4Net) error {
	url := m.mkurl(network, "reservations", subnet.MakeSubnetKey(sn))

	resp, err := m.httpVerb(ctx, "DELETE", url, "", nil)
	if err != nil {
		return err
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		return httpError(resp)
	}

	return nil
}