This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "feat: add endpoints to put/get san_mapping_list"
- Loading branch information
Showing
13 changed files
with
436 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright (c) 2014 Rackspace, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import abc | ||
|
||
import six | ||
|
||
|
||
@six.add_metaclass(abc.ABCMeta) | ||
class SanMappingQueue(object): | ||
"""Interface definition for Akamai Domain san cert mapping. | ||
The purpose of this queue is to buffer the client's | ||
domain to san certificate mapping. The mapping is used to kick | ||
off a task that updates akamai configuration at pre-defined intervals. | ||
""" | ||
|
||
def __init__(self, conf): | ||
self._conf = conf | ||
|
||
def enqueue_san_mapping(self, san_domain_map): | ||
"""Add new SAN mapping element to the queue. | ||
:param san_domain_map: a new element to add to the queue | ||
:type san_domain_map: dict | ||
""" | ||
raise NotImplementedError | ||
|
||
def dequeue_san_mapping(self, consume=True): | ||
"""Remove and return an item from the queue. | ||
:param consume: if true the mapping is removed from the list and | ||
returned otherwise the mapping is retrieved queue | ||
""" | ||
raise NotImplementedError | ||
|
||
def traverse_queue(self): | ||
"""Traverse queue and return all items on the queue in a list""" | ||
raise NotImplementedError | ||
|
||
def put_queue_data(self, queue_data_list): | ||
"""Clear the queue and put new queue data list in the queue. | ||
:param queue_data_list: new queue data to replace current queue data | ||
:type queue_data_list: [dict()] -- list of dictionaries | ||
""" | ||
raise NotImplementedError |
95 changes: 95 additions & 0 deletions
95
poppy/provider/akamai/domain_san_mapping_queue/zk_san_mapping_queue.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Copyright (c) 2014 Rackspace, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from kazoo.recipe import queue | ||
from oslo_config import cfg | ||
|
||
from poppy.common import decorators | ||
from poppy.provider.akamai.domain_san_mapping_queue import base | ||
from poppy.provider.akamai import utils | ||
|
||
|
||
AKAMAI_OPTIONS = [ | ||
# queue backend configs | ||
cfg.StrOpt( | ||
'queue_backend_type', | ||
help='SAN Cert Queueing backend'), | ||
cfg.ListOpt( | ||
'queue_backend_host', | ||
default=['localhost'], | ||
help='default queue backend server hosts'), | ||
cfg.IntOpt( | ||
'queue_backend_port', | ||
default=2181, | ||
help='default' | ||
' default queue backend server port (e.g: 2181)'), | ||
cfg.StrOpt( | ||
'san_mapping_queue_path', | ||
default='/san_mapping_queue', | ||
help='Zookeeper path ' | ||
'for san_mapping_queue' | ||
), | ||
] | ||
|
||
AKAMAI_GROUP = 'drivers:provider:akamai:queue' | ||
|
||
|
||
class ZookeeperSanMappingQueue(base.SanMappingQueue): | ||
|
||
def __init__(self, conf): | ||
super(ZookeeperSanMappingQueue, self).__init__(conf) | ||
|
||
self._conf.register_opts(AKAMAI_OPTIONS, | ||
group=AKAMAI_GROUP) | ||
self.akamai_conf = self._conf[AKAMAI_GROUP] | ||
|
||
@decorators.lazy_property(write=False) | ||
def san_mapping_queue_backend(self): | ||
return queue.LockingQueue( | ||
self.zk_client, | ||
self.akamai_conf.san_mapping_queue_path) | ||
|
||
@decorators.lazy_property(write=False) | ||
def zk_client(self): | ||
return utils.connect_to_zookeeper_queue_backend(self.akamai_conf) | ||
|
||
def enqueue_san_mapping(self, san_domain_map): | ||
self.san_mapping_queue_backend.put(san_domain_map) | ||
|
||
def traverse_queue(self): | ||
res = [] | ||
while len(self.san_mapping_queue_backend) > 0: | ||
item = self.san_mapping_queue_backend.get() | ||
self.san_mapping_queue_backend.consume() | ||
res.append(item) | ||
self.san_mapping_queue_backend.put_all(res) | ||
return res | ||
|
||
def put_queue_data(self, queue_data): | ||
# put queue data will replace all existing | ||
# queue data with the incoming new queue_data | ||
# dequeue all the existing data | ||
while len(self.san_mapping_queue_backend) > 0: | ||
self.san_mapping_queue_backend.get() | ||
self.san_mapping_queue_backend.consume() | ||
# put in all the new data | ||
self.san_mapping_queue_backend.put_all(queue_data) | ||
return queue_data | ||
|
||
def dequeue_san_mapping(self, consume=True): | ||
res = self.san_mapping_queue_backend.get() | ||
if consume: | ||
self.san_mapping_queue_backend.consume() | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.