def endpoints(request, n=5): """ A collection on endpoints (default 5). """ # Create N endpoints. names = map(lambda x: "endpoint-%d" % x, range(n)) r = reactor(request) for name in names: # Save all with an empty configuration. r.endpoints().create(name, {}) # Create the collection of endpoints. from reactor.endpoint import Endpoint endpoints = map(lambda x: Endpoint(r.endpoints().get(x)[0]), names) # Ensure all watches have fired to # synchronize manager's active state. zk_conn(request).sync() return endpoints
def __init__(self, scale_manager): self.scale_manager = scale_manager Endpoint.__init__(self, "api", self.api_config(), scale_manager) # Make sure that this service is running. self.update_state(None)
def update_config(self, config_str): new_config = EndpointConfig(config_str) Endpoint.update_config(self, str(self.api_config(new_config)))