Add publisher infrastructure
Adds plumbing for "publishers." Publishers are strategy classes responsible for preparing images for distribution. An example publisher should be a BitTorrent publisher that took the image binary, generated a torrent file from it, and started an initial seeder process. The default publisher is nop.Publisher, which takes no action. Change-Id: I8fd952270aaf4fc6962dafc1f287aca0cd0c9828
This commit is contained in:
parent
d4c7315321
commit
56c194f0a0
@ -50,7 +50,6 @@ class Cacher(object):
|
||||
CONF.cachemonkey.fetcher_class)
|
||||
|
||||
self.discoverer = discover.ComputeDiscoverer()
|
||||
self.images = []
|
||||
|
||||
def cache(self):
|
||||
self.images = []
|
||||
@ -58,8 +57,8 @@ class Cacher(object):
|
||||
|
||||
for image in images:
|
||||
filename = self._get(image)
|
||||
image = {'meta': image, 'filename': filename}
|
||||
self.images.append(image)
|
||||
|
||||
self.publisher.publish(image, filename)
|
||||
|
||||
# HACK(belliott) - just process first image for testing
|
||||
break
|
||||
|
0
cachemonkey/publisher/__init__.py
Normal file
0
cachemonkey/publisher/__init__.py
Normal file
27
cachemonkey/publisher/nop.py
Normal file
27
cachemonkey/publisher/nop.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Copyright 2014 Rackspace Hosting
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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 cachemonkey.openstack.common import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Publisher(object):
|
||||
"""A do-nothing publisher. Use when no special work is required to
|
||||
prepare an image for distribution to computes.
|
||||
"""
|
||||
|
||||
def publish(self, image, filename):
|
||||
pass
|
0
cachemonkey/tests/publisher/__init__.py
Normal file
0
cachemonkey/tests/publisher/__init__.py
Normal file
27
cachemonkey/tests/publisher/test_nop.py
Normal file
27
cachemonkey/tests/publisher/test_nop.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Copyright 2014 Rackspace Hosting
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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 oslotest import base
|
||||
|
||||
from cachemonkey.publisher import nop
|
||||
|
||||
|
||||
class NopPublisherTestCase(base.BaseTestCase):
|
||||
|
||||
def test_nop(self):
|
||||
publisher = nop.Publisher()
|
||||
image = {'id': '1234'}
|
||||
filename = '/abc/def'
|
||||
publisher.publish(image, filename)
|
Loading…
x
Reference in New Issue
Block a user