robottelo.products
¶
Manage RH products repositories and custom repositories.
The main purpose of this feature is to manage product repositories especially the RH one in the context of a special distro and cdn settings.
The repository data creation became transparent when supplying only the target distro.
Example Usage:
We know that sat tool key = ‘rhst’
Working with generic repos.
Generic repos has no way to guess the custom repo url in case of settings.cdn = false , that why the GenericRHRepo without custom url always return cdn repo data:
sat_repo = GenericRHRepository(key=PRODUCT_KEY_SAT_TOOLS)
print(sat_repo.cdn) >> True
# today the default distro is rhel7
print(sat_repo.distro) >> rhel7
print(sat_repo.data) >>
{
'arch': 'x86_64',
'cdn': True,
'product': 'Red Hat Enterprise Linux Server',
'releasever': None,
'repository': 'Red Hat Satellite Tools 6.2 for RHEL 7 Server RPMs x86_64',
'repository-id': 'rhel-7-server-satellite-tools-6.2-rpms',
'repository-set': 'Red Hat Satellite Tools 6.2 (for RHEL 7 Server) (RPMs)'
}
# Generic CDN RH repository with specific distro "DISTRO_RHEL6"
sat_repo = GenericRHRepository(
distro=DISTRO_RHEL6, key=PRODUCT_KEY_SAT_TOOLS)
print(sat_repo.distro) >> rhel6
print(sat_repo.data) >>
{
'arch': 'x86_64',
'cdn': True,
'product': 'Red Hat Enterprise Linux Server',
'releasever': None,
'repository': 'Red Hat Satellite Tools 6.2 for RHEL 6 Server RPMs x86_64',
'repository-id': 'rhel-6-server-satellite-tools-6.2-rpms',
'repository-set': 'Red Hat Satellite Tools 6.2 (for RHEL 6 Server) (RPMs)'
}
# Generic RH repository with custom url
sat_repo = GenericRHRepository(
key=PRODUCT_KEY_SAT_TOOLS, url='http://sat-tools.example.com')
# because default settings.cdn=False and we have a custom url
print(sat_repo.cdn) >> False
print(sat_repo.distro) >> rhel7
print(sat_repo.data) >>
{'cdn': False, 'url': 'http://sat-tools.example.com'}
# Generic RH repository with custom url and force cdn
sat_repo = GenericRHRepository(
key=PRODUCT_KEY_SAT_TOOLS,
url='http://sat-tools.example.com',
cdn=True
)
print(sat_repo.data) >>
{
'arch': 'x86_64',
'cdn': True,
'product': 'Red Hat Enterprise Linux Server',
'releasever': None,
'repository': 'Red Hat Satellite Tools 6.2 for RHEL 7 Server RPMs x86_64',
'repository-id': 'rhel-7-server-satellite-tools-6.2-rpms',
'repository-set': 'Red Hat Satellite Tools 6.2 (for RHEL 7 Server) (RPMs)'
}
# We have created a SatelliteToolsRepository that automatically detect it's
# custom url in settings, so there no need to explicitly initialise with
# url, simply the distro is needed (in case of specific one), otherwise
# the default distro will be used.
# SatelliteToolsRepository RH repo use settings urls and cdn
sat_repo = SatelliteToolsRepository()
print(sat_repo.cdn) >> False
print(sat_repo.distro) >> rhel7
print(sat_repo.data) >>
{
'cdn': False,
# part of the url was hidden
'url': 'XXXXXXXXXXXXXXXXXXX/Tools_6_3_RHEL7/custom/'
'Satellite_Tools_6_3_Composes/Satellite_Tools_x86_64/'
}
# SatelliteToolsRepository RH repo use settings urls with 'force cdn')
sat_repo = SatelliteToolsRepository(cdn=True)
print(sat_repo.cdn >> True
print(sat_repo.distro >> rhel7
print(sat_repo.data >>
{
'arch': 'x86_64',
'cdn': True,
'product': 'Red Hat Enterprise Linux Server',
'releasever': None,
'repository': 'Red Hat Satellite Tools 6.2 for RHEL 7 Server RPMs x86_64',
'repository-id': 'rhel-7-server-satellite-tools-6.2-rpms',
'repository-set': 'Red Hat Satellite Tools 6.2 (for RHEL 7 Server) (RPMs)'
}
# we can also indicate the distro, the same as for the generic one the
# data will be switched for that distro
# Working with RepositoryCollection using the default distro
repos_collection = RepositoryCollection(
repositories=[
RHELRepository(),
SatelliteToolsRepository(),
SatelliteCapsuleRepository(),
CustomYumRepository(url=FAKE_0_YUM_REPO)
]
)
repos_collection.distro >> None
repos_collection.repos_data >>
[{'cdn': False,
'url': 'http://XXXXXXXXX/RHEL-7/7.4/Server/x86_64/os/'},
{'cdn': False,
'url': 'http://XXXXXXXXXXX/Tools_6_3_RHEL7/custom/'
'Satellite_Tools_6_3_Composes/Satellite_Tools_x86_64/'
},
{'cdn': False,
'url': 'http://XXXXXXXXXX/Satellite_6_3_RHEL7/custom/'
'Satellite_6_3_Composes/Satellite_6_3_RHEL7'
},
{'cdn': False, 'url': 'http://inecas.fedorapeople.org/fakerepos/zoo/'}
]
repos_collection.need_subscription >> False
# Working with RepositoryCollection with force distro RHEL6 and force cdn
# on some repos
repos_collection = RepositoryCollection(
distro=DISTRO_RHEL6,
repositories=[
SatelliteToolsRepository(cdn=True),
SatelliteCapsuleRepository(),
YumRepository(url=FAKE_0_YUM_REPO)
]
)
repos_collection.distro >> rhel6
repos_collection.repos_data >>
[
{'arch': 'x86_64',
'cdn': True,
'product': 'Red Hat Enterprise Linux Server',
'releasever': None,
'repository': 'Red Hat Satellite Tools 6.2 for RHEL 6 Server RPMs'
' x86_64',
'repository-id': 'rhel-6-server-satellite-tools-6.2-rpms',
'repository-set': 'Red Hat Satellite Tools 6.2 (for RHEL 6 Server)
'(RPMs)'
},
{
'arch': 'x86_64',
'cdn': True,
'product': 'Red Hat Satellite Capsule',
'releasever': None,
'repository': 'Red Hat Satellite Capsule 6.2 for RHEL 6 Server RPMs '
'x86_64',
'repository-id': 'rhel-6-server-satellite-capsule-6.2-rpms',
'repository-set': 'Red Hat Satellite Capsule 6.2 (for RHEL 6 Server) '
'(RPMs)'
},
{'cdn': False, 'url': 'http://inecas.fedorapeople.org/fakerepos/zoo/'}
]
repos_collection.need_subscription >> True
# Note: satellite capsule repo will query the server for a distro and if
# the same distro as the sat server is used will use the settings url
# (if cdn=False) else it will use the cdn one.
# Please consult the RepositoryCollection for some usage functions
# also test usage located at:
# tests/foreman/cli/test_vm_install_products_package.py
Module Contents¶
Classes¶
Base repository class for custom and RH repositories |
|
Custom Yum repository |
|
Custom Docker repository |
|
Custom Puppet repository |
|
Custom OSTree repository |
|
Generic RH repository |
|
RHEL repository |
|
Satellite Tools Repository |
|
Satellite capsule repository |
|
Virtualization Agents repository |
|
Generic RH repository |
|
Red Hat Ansible Engine Repository |
|
Repository collection |
Functions¶
|
Attributes¶
- robottelo.products.REPO_TYPE_YUM¶
- robottelo.products.REPO_TYPE_DOCKER¶
- robottelo.products.REPO_TYPE_PUPPET¶
- robottelo.products.REPO_TYPE_OSTREE¶
- robottelo.products.DOWNLOAD_POLICY_ON_DEMAND = on_demand¶
- robottelo.products.DOWNLOAD_POLICY_IMMEDIATE = immediate¶
- robottelo.products.DOWNLOAD_POLICY_BACKGROUND = background¶
- robottelo.products.PRODUCT_KEY_RHEL = rhel¶
- robottelo.products.PRODUCT_KEY_SAT_TOOLS = rhst¶
- robottelo.products.PRODUCT_KEY_SAT_CAPSULE = rhsc¶
- robottelo.products.PRODUCT_KEY_VIRT_AGENTS = rhva6¶
- robottelo.products.PRODUCT_KEY_CLOUD_FORMS_TOOLS = rhct6¶
- robottelo.products.PRODUCT_KEY_ANSIBLE_ENGINE = rhae2¶
- robottelo.products._server_distro :str¶
- exception robottelo.products.RepositoryAlreadyDefinedError¶
Bases:
Exception
Raised when a repository has already a predefined key
- exception robottelo.products.DistroNotSupportedError¶
Bases:
Exception
Raised when using a non supported distro
- exception robottelo.products.RepositoryDataNotFound¶
Bases:
Exception
Raised when repository data cannot be found for a predefined distro
- exception robottelo.products.OnlyOneOSRepositoryAllowed¶
Bases:
Exception
Raised when trying to more than one OS repository to a collection
- exception robottelo.products.RepositoryAlreadyCreated¶
Bases:
Exception
Raised when a repository content is already created and trying to launch the create an other time
- exception robottelo.products.ReposContentSetupWasNotPerformed¶
Bases:
Exception
Raised when trying to setup a VM but the repositories content was not setup
- robottelo.products.get_server_distro() → str¶
- class robottelo.products.BaseRepository(url=None, distro=None, content_type=None)¶
Base repository class for custom and RH repositories
- _url :Optional[str]¶
- _distro :Optional[str]¶
- _type :Optional[str]¶
- _repo_info :Optional[Dict]¶
- property url(self) → Optional[str]¶
- property cdn(self) → bool¶
- property data(self) → Dict¶
- property distro(self) → Optional[str]¶
Return the current distro
- property content_type(self) → str¶
- __repr__(self)¶
Return repr(self).
- property repo_info(self) → Optional[Dict]¶
- create(self: int, organization_id: int, product_id: str, download_policy: bool = DOWNLOAD_POLICY_ON_DEMAND, synchronize=True) → Dict¶
Create the repository for the supplied product id
- synchronize(self)¶
Synchronize the repository
- add_to_content_view(self: int, organization_id: int, content_view_id) → None¶
Associate repository content to content-view
- class robottelo.products.YumRepository(url=None, distro=None, content_type=None)¶
Bases:
BaseRepository
Custom Yum repository
- _type :str¶
- class robottelo.products.DockerRepository(url=None, distro=None, upstream_name=None)¶
Bases:
BaseRepository
Custom Docker repository
- _type :str¶
- property upstream_name(self)¶
- create(self, organization_id, product_id, download_policy=None, synchronize=True)¶
Create the repository for the supplied product id
- class robottelo.products.PuppetRepository(: str, url: Optional[str] = None, distro: List[Dict[str, str]] = None, modules=None)¶
Bases:
BaseRepository
Custom Puppet repository
- _type :str¶
- property puppet_modules(self)¶
- add_to_content_view(self: int, organization_id: int, content_view_id) → None¶
Associate repository content to content-view
- class robottelo.products.OSTreeRepository(url=None, distro=None, content_type=None)¶
Bases:
BaseRepository
Custom OSTree repository
- _type¶
- class robottelo.products.GenericRHRepository(distro=None, key=None, cdn=False, url=None)¶
Bases:
BaseRepository
Generic RH repository
- _type¶
- _distro :str¶
- _key :str¶
- _repo_data :Dict¶
- _url :Optional[str]¶
- property url(self)¶
- property cdn(self)¶
- property key(self)¶
- property distro(self)¶
Return the current distro
- _get_repo_data(self: Optional[str], distro=None) → Dict¶
Return the repo data as registered in constant module and bound to distro.
- property repo_data(self) → Dict¶
- _repo_is_distro(self: Optional[Dict], repo_data=None) → bool¶
return whether the repo data is for an OS distro product repository
- property is_distro_repository(self) → bool¶
- property distro_major_version(self)¶
- property distro_repository(self) → Optional[RHELRepository]¶
Return the OS distro repository object relied to this repository
Suppose we have a repository for a product that must be installed on RHEL, but for proper installation needs some dependencies packages from the OS repository. This function will return the right OS repository object for later setup.
- for example:
capsule_repo = SatelliteCapsuleRepository() # the capsule_repo will represent a capsule repo for default distro rhel_repo = capsule_repo.distro_repository # the rhel repo representation object for default distro will be # returned, if not found raise exception
- property rh_repository_id(self) → Optional[str]¶
- property data(self) → Dict¶
- __repr__(self)¶
Return repr(self).
- create(self: int, organization_id: Optional[int], product_id: Optional[str] = None, download_policy: Optional[bool] = DOWNLOAD_POLICY_ON_DEMAND, synchronize=True) → Dict¶
Create an RH repository
- class robottelo.products.RHELRepository(distro=None, key=None, cdn=False, url=None)¶
Bases:
GenericRHRepository
RHEL repository
- _key¶
- property url(self)¶
- class robottelo.products.SatelliteToolsRepository(distro=None, key=None, cdn=False, url=None)¶
Bases:
GenericRHRepository
Satellite Tools Repository
- _key¶
- property url(self)¶
- class robottelo.products.SatelliteCapsuleRepository(distro=None, key=None, cdn=False, url=None)¶
Bases:
GenericRHRepository
Satellite capsule repository
- _key¶
- property url(self)¶
- class robottelo.products.VirtualizationAgentsRepository(distro=None, key=None, cdn=False, url=None)¶
Bases:
GenericRHRepository
Virtualization Agents repository
- _key¶
- _distro¶
- class robottelo.products.RHELCloudFormsTools(distro=None, key=None, cdn=False, url=None)¶
Bases:
GenericRHRepository
Generic RH repository
- _distro¶
- _key¶
- class robottelo.products.RHELAnsibleEngineRepository(distro=None, key=None, cdn=False, url=None)¶
Bases:
GenericRHRepository
Red Hat Ansible Engine Repository
- _key¶
- class robottelo.products.RepositoryCollection(distro=None, repositories=None)¶
Repository collection
- _distro :str¶
- _org :Dict¶
- _items :List[BaseRepository] = []¶
- _repos_info :List[Dict] = []¶
- _custom_product_info :Dict¶
- _os_repo :RHELRepository¶
- _setup_content_data :Dict[str, Dict]¶
- property distro(self) → str¶
- property repos_info(self) → List[Dict]¶
- property custom_product(self)¶
- property os_repo(self) → RHELRepository¶
- property repos_data(self) → List[Dict]¶
- property rh_repos(self) → List[BaseRepository]¶
- property custom_repos(self) → List[BaseRepository]¶
- property rh_repos_info(self) → List[Dict]¶
- property custom_repos_info(self) → List[Dict]¶
- property setup_content_data(self)¶
- property need_subscription(self) → bool¶
- property organization(self)¶
- add_item(self, item) → None¶
Add repository to collection
- Parameters
item (BaseRepository) – Item to add
- Returns
None
- add_items(self, items)¶
Add multiple repositories to collection
- Parameters
items (List[BaseRepository]) – Items to add
- Returns
None
- __iter__(self)¶
- setup(self: int, org_id: str, download_policy: bool = DOWNLOAD_POLICY_ON_DEMAND, synchronize=True) → Tuple[Dict, List[Dict]]¶
Setup the repositories on server.
- Recommended usage: repository only setup, for full content setup see
setup_content.
- setup_content_view(self: int, org_id: int, lce_id=None) → Tuple[Dict, Dict]¶
Setup organization content view by adding all the repositories, publishing and promoting to lce if needed.
- static setup_activation_key(org_id: int, content_view_id: int, lce_id: int, subscription_names: Optional[List[str]] = None) → Dict¶
Create activation and associate content-view, lifecycle environment and subscriptions
- static organization_has_manifest(organization_id)¶
Check if an organization has a manifest, an organization has manifest if one of it’s subscriptions have the account defined.
- setup_content(self: int, org_id: int, lce_id: bool, upload_manifest: str = False, download_policy: Optional[List[str]] = DOWNLOAD_POLICY_ON_DEMAND, rh_subscriptions=None) → Dict[str, Any]¶
Setup content view and activation key of all the repositories.
- Parameters
org_id – The organization id
lce_id – The lifecycle environment id
upload_manifest – Whether to upload the manifest (The manifest is uploaded only if needed)
download_policy – The repositories download policy
rh_subscriptions – The RH subscriptions to be added to activation key
- setup_virtual_machine(self, vm, patch_os_release=False, install_katello_agent=True, enable_rh_repos=True, enable_custom_repos=False, configure_rhel_repo=False)¶
Setup The virtual machine basic task, eg: install katello ca, register vm host, enable rh repos and install katello-agent
- Parameters
vm (VirtualMachine) – The Virtual machine to setup.
patch_os_release (bool) – whether to patch the VM with os version.
install_katello_agent (bool) – whether to install katello-agent
enable_rh_repos (bool) – whether to enable RH repositories
enable_custom_repos (bool) – whether to enable custom repositories
configure_rhel_repo (bool) – Whether to configure the distro Red Hat repository, this is needed to configure manually RHEL custom repo url as sync time is very big (more than 2 hours for RHEL 7Server) and not critical for some contexts.