def deployment_tasks(self, plugins, stage): tasks = [] for plugin in plugins: puppet_tasks = filter( lambda t: (t['type'] == 'puppet' and t['stage'] == stage), plugin.tasks) shell_tasks = filter( lambda t: (t['type'] == 'shell' and t['stage'] == stage), plugin.tasks) for task in shell_tasks: uids = get_uids_for_roles(self.nodes, task['role']) if not uids: continue tasks.append(self.serialize_task( plugin, task, templates.make_shell_task( uids, task, plugin.slaves_scripts_path))) for task in puppet_tasks: uids = get_uids_for_roles(self.nodes, task['role']) if not uids: continue tasks.append(self.serialize_task( plugin, task, templates.make_puppet_task( uids, task, plugin.slaves_scripts_path))) return tasks
def serialize(self): uids = self.get_uids() self.task['parameters']['cmd'] = self.task['parameters']['cmd'].format( CLUSTER_ID=self.cluster.id, CN_HOSTNAME=objects.Cluster.get_editable_attributes(self.cluster) ['public_ssl']['hostname']['value']) yield templates.make_shell_task(uids, self.task)
def serialize(self): uids = self.get_uids() if uids: self.task['parameters']['cmd'] = \ self.task['parameters']['cmd'].format( CLUSTER_ID=self.cluster.id) yield templates.make_shell_task(uids, self.task)
def deployment_tasks(self, plugins, stage): tasks = [] for plugin in plugins: puppet_tasks = filter( lambda t: (t['type'] == 'puppet' and t['stage'] == stage), plugin.tasks) shell_tasks = filter( lambda t: (t['type'] == 'shell' and t['stage'] == stage), plugin.tasks) for task in shell_tasks: uids = self.get_uids_for_task(task) if not uids: continue tasks.append(self.serialize_task( plugin, task, templates.make_shell_task( uids, task, plugin.slaves_scripts_path))) for task in puppet_tasks: uids = self.get_uids_for_task(task) if not uids: continue tasks.append(self.serialize_task( plugin, task, templates.make_puppet_task( uids, task, plugin.slaves_scripts_path))) return tasks
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() self.task['parameters']['cmd'] = self.task['parameters']['cmd'].format( CLUSTER_ID=self.cluster.id, CN_HOSTNAME=self.cluster.attributes.editable ['public_ssl']['hostname']['value']) yield templates.make_shell_task(uids, self.task)
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 deployment_tasks(self, plugins, stage): tasks = [] for plugin in plugins: plugin_tasks = filter(lambda t: (t['stage'] == stage), plugin.tasks) for task in plugin_tasks: uids = get_uids_for_roles(self.nodes, task['role']) if not uids: continue if task['type'] == 'shell': tasks.append( self.serialize_task( plugin, task, templates.make_shell_task( uids, task, plugin.slaves_scripts_path))) elif task['type'] == 'puppet': tasks.append( self.serialize_task( plugin, task, templates.make_puppet_task( uids, task, plugin.slaves_scripts_path))) else: logger.warn('Task is skipped {0}, because its type is ' 'not supported').format(task) return tasks
def serialize(self): uids = self.get_uids() if uids: cmd = self.task['parameters']['cmd'] self.task['parameters']['cmd'] = cmd.format( CLUSTER_ID=self.cluster.id, CN_HOSTNAME=objects.Cluster.get_editable_attributes( self.cluster)['public_ssl']['hostname']['value']) yield templates.make_shell_task(uids, self.task)
def serialize_tasks(self, node): """Serialize tasks with necessary for orchestrator attributes :param node: dict with serialized node """ tasks = self.graph.get_tasks(node['role']).topology serialized = [] priority = ps.Priority() for task in tasks: if task['type'] == consts.ORCHESTRATOR_TASK_TYPES.puppet: item = templates.make_puppet_task( [node['uid']], task) elif task['type'] == consts.ORCHESTRATOR_TASK_TYPES.shell: item = templates.make_shell_task( [node['uid']], task) item['priority'] = priority.next() serialized.append(item) return serialized