Project

Profile

Help

Story #984 ยป 0001-Name-of-the-puppet-module-should-be-in-format-name-a.patch

ipanova@redhat.com, 05/18/2016 01:59 PM

View differences:

docs/tech-reference/plugin_report.rst
[
{
"version": "3.2.0",
"name": "stdlib",
"name": "puppetlabs/stdlib",
"author": "puppetlabs"
},
"failed to download: not found"
......
"success_unit_keys": [
{
"version": "4.1.0",
"name": "stdlib",
"name": "puppetlabs/stdlib",
"author": "puppetlabs"
}
]
......
``success_unit_keys``
An array containing objects representing unit keys of modules that were
successfully published.
successfully published.
docs/tech-reference/type.rst
contributor "Puppet Labs" has the username "puppetlabs".
``name``
Module's name only, not including the author section. For the module
identified as "puppetlabs/stdlib", this field would be "stdlib".
Module's name. For the module identified as "puppetlabs/stdlib", this field would be
"puppetlabs/stdlib" and it should correspond to name mentioned in the module's metadata.
``version``
Module's version, which according to Puppet Labs' documentation, should follow
docs/user-guide/quick-start.rst
::
$ pulp-admin puppet repo modules --repo-id=repo1
Name: libvirt
Name: thias-libvirt
Version: 0.0.1
Author: thias
Dependencies:
......
Tag List: rhel, libvirt, kvm, CentOS
Types:
Name: virt
Name: carlasouza-virt
Version: 1.0.0
Author: carlasouza
Dependencies:
......
::
$ pulp-admin puppet repo modules --repo-id=repo1 --str-eq='name=libvirt'
Name: libvirt
$ pulp-admin puppet repo modules --repo-id=repo1 --str-eq='name=thias-libvirt'
Name: thias-libvirt
Version: 0.0.1
Author: thias
Dependencies:
......
::
$ pulp-admin puppet repo modules --repo-id=repo1 --match='license=^GPL.*'
Name: virt
Name: carlasouza-virt
Version: 1.0.0
Author: carlasouza
Dependencies:
......
$ pulp-admin puppet repo create --repo-id=repo2
Successfully created repository [repo2]
$ pulp-admin puppet repo copy --from-repo-id=repo1 --to-repo-id=repo2 --str-eq='name=libvirt'
$ pulp-admin puppet repo copy --from-repo-id=repo1 --to-repo-id=repo2 --str-eq='name=thias-libvirt'
Progress on this task can be viewed using the commands under "repo tasks".
$ pulp-admin repo tasks list --repo-id=repo1
docs/user-guide/release-notes/2.8.x.rst
Pulp Puppet 2.8 Release Notes
=============================
Pulp Puppet 2.8.4
=================
New Behaviours
--------------
From now on the name of the puppet module will correspond to the name specified in its metadata.
Pulp Puppet 2.8.3
=================
Due to a Pulp platform release, this plugin's version has been incremented.
There are no changes from the previous release.
Pulp Puppet 2.8.2
=================
pulp_puppet_extensions_admin/pulp_puppet/extensions/admin/consumer/content.py
parts = unit.split('/', 2)
if len(parts) < 2:
raise ValueError
unit_key = {'author': parts[0], 'name': parts[1]}
unit_key = {'name': "/".join((parts[0], parts[1])), 'author': parts[0]}
if len(parts) == 3:
unit_key['version'] = parts[2]
ret.append({'type_id': constants.TYPE_PUPPET_MODULE, 'unit_key': unit_key})
pulp_puppet_extensions_admin/test/unit/test_consumer_content.py
self.assertEqual(unit.get('type_id'), constants.TYPE_PUPPET_MODULE)
unit_key = unit.get('unit_key', {})
self.assertEqual(unit_key.get('author'), 'foo')
self.assertEqual(unit_key.get('name'), 'bar')
self.assertEqual(unit_key.get('name'), 'foo/bar')
self.assertTrue('version' not in unit_key)
def test_single_unit_with_version(self):
......
self.assertEqual(unit.get('type_id'), constants.TYPE_PUPPET_MODULE)
unit_key = unit.get('unit_key', {})
self.assertEqual(unit_key.get('author'), 'foo')
self.assertEqual(unit_key.get('name'), 'bar')
self.assertEqual(unit_key.get('name'), 'foo/bar')
self.assertEqual(unit_key.get('version'), '1.2.3')
def test_units(self):
......
self.assertEqual(unit.get('type_id'), constants.TYPE_PUPPET_MODULE)
unit_key = unit.get('unit_key', {})
self.assertTrue(unit_key.get('author') in ['foo', 'abc'])
self.assertTrue(unit_key.get('name') in ['bar', 'xyz'])
self.assertTrue(unit_key.get('name') in ['foo/bar', 'abc/xyz'])
self.assertTrue('version' not in unit_key)
pulp_puppet_handlers/pulp_puppet/handlers/puppet.py
# need this so we can easily access original unit objects when constructing
# new requests below
units_by_full_name = dict(('%s/%s'% (u['author'], u['name']), u) for u in units)
units_by_full_name = dict(('%s'% (u['name']), u) for u in units)
# loop over the results, and keep trying to uninstall failed attempts as
# a dumb but effective way of dealing with dependency-related failures.
......
for unit in units:
# prepare the command
full_name = '%s/%s' % (unit['author'], unit['name'])
full_name = unit['name']
args = ['puppet', 'module', operation, '--render-as', 'json']
if forge_url:
args.extend(['--module_repository', forge_url])
pulp_puppet_handlers/test/unit/test_module_handler.py
class TestInstall(ModuleHandlerTest):
UNITS = [
{'author': 'puppetlabs', 'name': 'stdlib', 'version': '3.1.1'},
{'author': 'puppetlabs', 'name': 'java'},
{'author': 'puppetlabs', 'name': 'puppetlabs/stdlib', 'version': '3.1.1'},
{'author': 'puppetlabs', 'name': 'puppetlabs/java'},
]
POPEN_OUTPUT = [(
......
class TestUpdate(ModuleHandlerTest):
UNITS = [
{'author': 'puppetlabs', 'name': 'stdlib'},
{'author': 'puppetlabs', 'name': 'puppetlabs/stdlib'},
]
POPEN_STDOUT = """notice: Preparing to upgrade 'puppetlabs-stdlib' ...
......
class TestUninstall(ModuleHandlerTest):
UNITS = [
{'author': 'puppetlabs', 'name': 'stdlib'},
{'author': 'puppetlabs', 'name': 'java'},
{'author': 'puppetlabs', 'name': 'puppetlabs/stdlib'},
{'author': 'puppetlabs', 'name': 'puppetlabs/java'},
]
# one failed attempt, then two successful attempts
......
class TestPerformOperation(ModuleHandlerTest):
UNITS = [
{'author': 'puppetlabs', 'name': 'stdlib', 'version': '3.1.1'},
{'author': 'puppetlabs', 'name': 'java'},
{'author': 'puppetlabs', 'name': 'puppetlabs/stdlib', 'version': '3.1.1'},
{'author': 'puppetlabs', 'name': 'puppetlabs/java'},
]
POPEN_OUTPUT = [(
"""notice: Preparing to install into /etc/puppet/modules ...
pulp_puppet_plugins/pulp_puppet/plugins/db/models.py
""" Backwards compatible with __repr__ from pulp.plugins.model.AssociatedUnit """
return str(self)
@staticmethod
def split_filename(filename):
"""
Splits a module's filename into two parts 'author' and 'name' and returns them as a dict.
Split the filename of a module into into two parts and return it as a dict with the keys
'author' and 'name'. The module filenamename is expected to be in the format 'author-name'
or 'author/name'.
:param filename: The module's filename to be split into author and name.
:type filename: basestring
:return: A dictionary with 'author' and 'name' containing the author and name respectively.
:rtype: A dict of strings.
"""
try:
author, name = filename.split("-", 1)
except ValueError:
# This is the forge format, but Puppet still allows it
author, name = filename.split("/", 1)
return {'author': author, 'name': name}
@classmethod
def from_metadata(cls, metadata):
"""
pulp_puppet_plugins/pulp_puppet/plugins/importers/forge.py
metadata = metadata_module.extract_metadata(downloaded_filename,
self.repo.working_dir)
# Overwrite the author and name
metadata.update(Module.split_filename(metadata['name']))
# Create and save the Module
module = Module.from_metadata(metadata)
module.set_storage_path(os.path.basename(downloaded_filename))
pulp_puppet_plugins/pulp_puppet/plugins/importers/upload.py
new_file_path = os.path.join(os.path.dirname(file_path), original_filename)
shutil.move(file_path, new_file_path)
# Overwrite the author and name
extracted_data.update(Module.split_filename(extracted_data['name']))
uploaded_module = Module.from_metadata(extracted_data)
uploaded_module.set_storage_path(os.path.basename(new_file_path))
try:
    (1-1/1)