def run_sync(self): uuid = self.config.get('machine', 'uuid') key = self.config.get('machine', 'key') try: res = self.cs.machine_sync(uuid, key, template=True) except ServiceException as e: print(e) return 1 m = Machine(res['template']) t = Template(res['template']) t.system_prepare() # describe process for dry runs if self.args.dry_run: tx = t.system_transaction() packages_install = list(tx.install_set) packages_install.sort(key=lambda x: x.name) packages_remove = list(tx.remove_set) packages_remove.sort(key=lambda x: x.name) if len(packages_install) or len(packages_remove): print( 'The following would be installed to (+) and removed from (-) the system:' ) for p in packages_install: print(' + ' + str(p)) for p in packages_remove: print(' - ' + str(p)) print() print('Summary:') print(' - Package(s): %d' % (len(packages_install) + len(packages_remove))) print() else: print('No system changes required.') print('No action peformed during this dry-run.') return 0 # TODO: progress for download, install and removal t.to_system_apply(clean=False) print('info: machine synced.') return 0
def run_sync(self): uuid = self.config.get('machine', 'uuid') key = self.config.get('machine', 'key') try: res = self.cs.machine_sync(uuid, key, template=True) except ServiceException as e: print(e) return 1 m = Machine(res['template']) t = Template(res['template']) t.system_prepare() # describe process for dry runs if self.args.dry_run: tx = t.system_transaction() packages_install = list(tx.install_set) packages_install.sort(key=lambda x: x.name) packages_remove = list(tx.remove_set) packages_remove.sort(key=lambda x: x.name) if len(packages_install) or len(packages_remove): print('The following would be installed to (+) and removed from (-) the system:') for p in packages_install: print(' + ' + str(p)) for p in packages_remove: print(' - ' + str(p)) print() print('Summary:') print(' - Package(s): %d' % (len(packages_install)+len(packages_remove))) print() else: print('No system changes required.') print('No action peformed during this dry-run.') return 0 # TODO: progress for download, install and removal t.to_system_apply(clean=False) print('info: machine synced.') return 0