def serialize(self): uids = self.get_uids() operating_system = self.cluster.release.operating_system repos = objects.Attributes.merged_attrs_values( self.cluster.attributes)['repo_setup']['repos'] if operating_system == consts.RELEASE_OS.centos: for repo in repos: yield templates.make_centos_repo_task(uids, repo) yield templates.make_yum_clean(uids) elif operating_system == consts.RELEASE_OS.ubuntu: # NOTE(ikalnitsky): # We have to clear /etc/apt/sources.list, because it # has a lot of invalid repos right after provisioning # and that lead us to deployment failures. yield templates.make_shell_task(uids, { 'parameters': { 'cmd': '> /etc/apt/sources.list', 'timeout': 60 }}) yield templates.make_ubuntu_apt_disable_ipv6(uids) # NOTE(kozhukalov): # This task is to allow installing packages from # unauthenticated repositories. yield templates.make_ubuntu_unauth_repos_task(uids) for repo in repos: yield templates.make_ubuntu_sources_task(uids, repo) if repo.get('priority'): # do not add preferences task to task list if we can't # complete it (e.g. can't retrieve or parse Release file) task = templates.make_ubuntu_preferences_task(uids, repo) if task is not None: yield task yield templates.make_apt_update_task(uids)
def serialize(self): uids = self.get_uids() operating_system = self.cluster.release.operating_system repo_metadata = self.cluster.release.orchestrator_data.repo_metadata repo_name = 'nailgun' context = { 'MASTER_IP': settings.MASTER_IP, 'OPENSTACK_VERSION': self.cluster.release.version } # repo_metadata stores its values by key of release for release, repo_url_mask in six.iteritems(repo_metadata): repo_url = self.make_repo_url(repo_url_mask, context) if operating_system == consts.RELEASE_OS.centos: yield templates.make_centos_repo_task(repo_name, repo_url, uids) elif operating_system == consts.RELEASE_OS.ubuntu: yield templates.make_versioned_ubuntu(repo_name, repo_url, uids) if operating_system == consts.RELEASE_OS.centos: yield templates.make_yum_clean(uids) elif operating_system == consts.RELEASE_OS.ubuntu: yield templates.make_apt_update_task(uids)
def serialize(self): uids = self.get_uids() operating_system = self.cluster.release.operating_system repos = objects.Attributes.merged_attrs_values( self.cluster.attributes)['repo_setup']['repos'] if operating_system == consts.RELEASE_OS.centos: for repo in repos: yield templates.make_centos_repo_task(uids, repo) yield templates.make_yum_clean(uids) elif operating_system == consts.RELEASE_OS.ubuntu: # NOTE(ikalnitsky): # We have to clear /etc/apt/sources.list, because it # has a lot of invalid repos right after provisioning # and that lead us to deployment failures. yield templates.make_shell_task(uids, { 'parameters': { 'cmd': '> /etc/apt/sources.list', 'timeout': 10 }}) yield templates.make_ubuntu_apt_disable_ipv6(uids) # NOTE(kozhukalov): # This task is to allow installing packages from # unauthenticated repositories. yield templates.make_ubuntu_unauth_repos_task(uids) for repo in repos: yield templates.make_ubuntu_sources_task(uids, repo) if repo.get('priority'): # do not add preferences task to task list if we can't # complete it (e.g. can't retrieve or parse Release file) task = templates.make_ubuntu_preferences_task(uids, repo) if task is not None: yield task yield templates.make_apt_update_task(uids)
def create_repositories(self, plugins): operating_system = self.cluster.release.operating_system for plugin in plugins: uids = self._get_node_uids_for_plugin_tasks(plugin) # If there are no nodes for tasks execution # or if there are no files in repository if not uids or not plugin.repo_files(self.cluster): continue if operating_system == consts.RELEASE_OS.centos: repo = self.get_centos_repo(plugin) yield self.serialize_task( plugin, templates.make_centos_repo_task(uids, repo)) elif operating_system == consts.RELEASE_OS.ubuntu: repo = self.get_ubuntu_repo(plugin) yield self.serialize_task( plugin, templates.make_ubuntu_sources_task(uids, repo)) # do not add preferences task to task list if we can't # complete it (e.g. can't retrieve or parse Release file) task = templates.make_ubuntu_preferences_task(uids, repo) if task is not None: yield self.serialize_task(plugin, task) # apt-get update executed after every additional source.list # to be able understand what plugin source.list caused error yield self.serialize_task(plugin, templates.make_apt_update_task(uids)) else: raise errors.InvalidOperatingSystem( 'Operating system {0} is invalid'.format(operating_system))
def test_make_centos_repo_task_wo_priority(self): result = tasks_templates.make_centos_repo_task( [1, 2, 3], {"name": "plugin_name", "type": "rpm", "uri": "http://url"} ) self.assertEqual( result, { "parameters": { "data": ("[plugin_name]\nname=Plugin plugin_name repository\n" "baseurl=http://url\ngpgcheck=0"), "path": "/etc/yum.repos.d/plugin_name.repo", }, "type": "upload_file", "uids": [1, 2, 3], }, )
def test_make_centos_repo_task_wo_priority(self): result = tasks_templates.make_centos_repo_task( [1, 2, 3], { 'name': 'plugin_name', 'type': 'rpm', 'uri': 'http://url', }) self.assertEqual( result, {'parameters': { 'data': ('[plugin_name]\nname=Plugin plugin_name repository\n' 'baseurl=http://url\ngpgcheck=0'), 'path': '/etc/yum.repos.d/plugin_name.repo'}, 'type': 'upload_file', 'uids': [1, 2, 3]})
def create_repositories(self, plugins): operating_system = self.cluster.release.operating_system repo_tasks = [] for plugin in plugins: uids = get_uids_for_tasks(self.nodes, plugin.tasks) # If there are no nodes for tasks execution # or if there are no files in repository if not uids or not plugin.repo_files(self.cluster): continue if operating_system == consts.RELEASE_OS.centos: repo = self.get_centos_repo(plugin) repo_tasks.append( self.serialize_task( plugin, templates.make_centos_repo_task(uids, repo))) elif operating_system == consts.RELEASE_OS.ubuntu: repo = self.get_ubuntu_repo(plugin) repo_tasks.append( self.serialize_task( plugin, templates.make_ubuntu_sources_task(uids, repo))) # do not add preferences task to task list if we can't # complete it (e.g. can't retrieve or parse Release file) task = self.serialize_task( plugin, templates.make_ubuntu_preferences_task(uids, repo)) if task is not None: repo_tasks.append(task) # apt-get update executed after every additional source.list # to be able understand what plugin source.list caused error repo_tasks.append( self.serialize_task( plugin, templates.make_apt_update_task(uids))) else: raise errors.InvalidOperatingSystem( 'Operating system {0} is invalid'.format(operating_system)) return repo_tasks
def create_repositories(self, plugins): operating_system = self.cluster.release.operating_system repo_tasks = [] for plugin in plugins: uids = get_uids_for_tasks(self.nodes, plugin.tasks) # If there are not nodes for tasks execution # or if there are no files in repository if not uids or not plugin.repo_files(self.cluster): continue if operating_system == consts.RELEASE_OS.centos: repo_tasks.append( self.serialize_task( plugin, {}, templates.make_centos_repo_task( plugin.full_name, plugin.repo_url(self.cluster), uids))) elif operating_system == consts.RELEASE_OS.ubuntu: repo_tasks.append( self.serialize_task( plugin, {}, templates.make_multiversion_ubuntu( plugin.full_name, plugin.repo_url(self.cluster), uids))) #apt-get upgrade executed after every additional source.list #to be able understand what plugin source.list caused error repo_tasks.append( self.serialize_task( plugin, {}, templates.make_apt_update_task(uids))) else: raise errors.InvalidOperatingSystem( 'Operating system {0} is invalid'.format(operating_system)) return repo_tasks
def create_repositories(self, plugins): operating_system = self.cluster.release.operating_system repo_tasks = [] for plugin in plugins: uids = self.get_uids_for_tasks(plugin.tasks) # If there are not nodes for tasks execution # or if there are no files in repository if not uids or not plugin.repo_files(self.cluster): continue if operating_system == consts.RELEASE_OS.centos: repo_tasks.append( self.serialize_task( plugin, {}, templates.make_centos_repo_task( plugin.full_name, plugin.repo_url(self.cluster), uids))) elif operating_system == consts.RELEASE_OS.ubuntu: repo_tasks.append( self.serialize_task( plugin, {}, templates.make_ubuntu_repo_task( plugin.full_name, plugin.repo_url(self.cluster), uids))) #apt-get upgrade executed after every additional source.list #to be able understand what plugin source.list caused error repo_tasks.append( self.serialize_task( plugin, {}, templates.make_apt_update_task(uids))) else: raise errors.InvalidOperatingSystem( 'Operating system {0} is invalid'.format(operating_system)) return repo_tasks