Ejemplo n.º 1
0
func (fakeBroker *FakeServiceBroker) Deprovision(instanceID string, details brokerapi.DeprovisionDetails, asyncAllowed bool) (brokerapi.IsAsync, error) {
	fakeBroker.BrokerCalled = true

	if fakeBroker.DeprovisionError != nil {
		return brokerapi.IsAsync(false), fakeBroker.DeprovisionError
	}

	fakeBroker.DeprovisionDetails = details
	fakeBroker.DeprovisionedInstanceIDs = append(fakeBroker.DeprovisionedInstanceIDs, instanceID)

	if sliceContains(instanceID, fakeBroker.ProvisionedInstanceIDs) {
		return brokerapi.IsAsync(false), nil
	}
	return brokerapi.IsAsync(false), brokerapi.ErrInstanceDoesNotExist
}
Ejemplo n.º 2
0
func (redisServiceBroker *RedisServiceBroker) Deprovision(instanceID string, details brokerapi.DeprovisionDetails, asyncAllowed bool) (brokerapi.IsAsync, error) {
	isAsync := brokerapi.IsAsync(false)

	for _, instanceCreator := range redisServiceBroker.InstanceCreators {
		instanceExists, _ := instanceCreator.InstanceExists(instanceID)
		if instanceExists {
			return isAsync, instanceCreator.Destroy(instanceID)
		}
	}
	return isAsync, brokerapi.ErrInstanceDoesNotExist
}
// Deprovision a new instance here. If async is allowed, the broker can still
// chose to deprovision the instance synchronously, hence the first return value.
func (b *Broker) Deprovision(service_identifier string, details brokerapi.DeprovisionDetails, asyncAllowed bool) (brokerapi.IsAsync, error) {
	logger := b.logger.WithData(lager.Data{"vhost": service_identifier, "details": details}).Session("deprovision")
	logger.Info("deprovisioning")

	isAsync := brokerapi.IsAsync(false)

	if _, err := b.client.GetVhost(service_identifier); err != nil {
		err = brokerapi.ErrInstanceDoesNotExist
		logger.Error("get-vhost-failed", err)
		return isAsync, err
	}

	if err := b.deleteVhost(service_identifier, logger); err != nil {
		return isAsync, err
	}

	logger.Info("deprovisioning-succeeded")
	return isAsync, nil
}