def _check_provider_exists(provider_id): """Check whether a provider exists or not. """ provider = Provider.fetch(provider_id) if provider: raise _errors.ProviderError("Provider (%s) already exists." % (provider_id, ))
def _check_machines_exist(provider): """Check whether there is a machine associated to a provider or not. """ for machine in Machine.machines(provider.provider_id): raise _errors.ProviderError( "There are machines associated to the provider (%s)." % (provider.provider_id, ))
def _retrieve_provider(provider_id): """Return a provider object from an id. """ provider = Provider.fetch(provider_id) if not provider: raise _errors.ProviderError("Provider (%s) does not exist." % (provider_id, )) return provider