Skip to content
This repository has been archived by the owner on Dec 17, 2022. It is now read-only.

Commit

Permalink
Migration to openbrokerapi 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mickybart committed Apr 23, 2018
1 parent 6c9180f commit ffa4281
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 18 deletions.
54 changes: 37 additions & 17 deletions atlasbroker/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,32 @@
Core of the Atlas broker
"""

from openbrokerapi.service_broker import *
from openbrokerapi.api import *
from openbrokerapi.errors import ErrBindingDoesNotExist, ErrInstanceDoesNotExist
from openbrokerapi.catalog import (
ServicePlan
)
from openbrokerapi.service_broker import (
ServiceBroker,
Service,
ProvisionedServiceSpec,
UpdateServiceSpec,
Binding,
DeprovisionServiceSpec,
LastOperation,
UnbindDetails,
ProvisionDetails,
UpdateDetails,
BindDetails,
DeprovisionDetails
)
from openbrokerapi.errors import (
ErrBindingDoesNotExist,
ErrInstanceDoesNotExist
)

from .backend import AtlasBrokerBackend
from .errors import ErrPlanUnsupported

class AtlasBroker(Service):
class AtlasBroker(ServiceBroker):
"""Atlas Broker
Implement a service broker by overriding methods of Service
Expand All @@ -35,21 +53,23 @@ class AtlasBroker(Service):
config (config): Configuration of the broker
"""
def __init__(self, config):
super().__init__(
id=config.broker["id"],
name=config.broker["name"],
description=config.broker["description"],
bindable=config.broker["bindable"],
plans=config.broker["plans"],
tags=config.broker["tags"],
requires=config.broker["requires"],
metadata=config.broker["metadata"],
dashboard_client=config.broker["dashboard_client"],
plan_updateable=config.broker["plan_updateable"],
)

# Create the AtlasBrokerBackend
self._backend = AtlasBrokerBackend(config)
self._config = config

def catalog(self):
return Service(
id=self._config.broker["id"],
name=self._config.broker["name"],
description=self._config.broker["description"],
bindable=self._config.broker["bindable"],
plans=self._config.broker["plans"],
tags=self._config.broker["tags"],
requires=self._config.broker["requires"],
metadata=self._config.broker["metadata"],
dashboard_client=self._config.broker["dashboard_client"],
plan_updateable=self._config.broker["plan_updateable"],
)

def provision(self, instance_id: str, service_details: ProvisionDetails, async_allowed: bool) -> ProvisionedServiceSpec:
"""Provision the new instance
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
version='1.1.3',
python_requires='>=3.5',
packages=find_packages(),
install_requires=['flask', 'openbrokerapi==1.0.0', 'pymongo', 'pwgen', 'atlasapi'],
install_requires=['flask', 'openbrokerapi>=2.0.0', 'pymongo', 'pwgen', 'atlasapi'],

# Metadata
author="Yellow Pages Inc.",
Expand Down

0 comments on commit ffa4281

Please sign in to comment.