def get_trains(self): """ Returns available trains dict and the currently configured train as well as the train of currently booted environment. """ data = self.middleware.call_sync('datastore.config', 'system.update') conf = Configuration.Configuration() conf.LoadTrainsConfig() selected = None trains = {} for name, descr in (conf.AvailableTrains() or {}).items(): train = conf._trains.get(name) if train is None: train = Train.Train(name, descr) if not selected and data['upd_train'] == train.Name(): selected = data['upd_train'] trains[train.Name()] = { 'description': train.Description(), 'sequence': train.LastSequence(), } if not data['upd_train'] or not selected: selected = conf.CurrentTrain() return { 'trains': trains, 'current': conf.CurrentTrain(), 'selected': selected, }
def trains(self): conf = Configuration.Configuration() conf.LoadTrainsConfig() trains = conf.AvailableTrains() if trains is None: logger.debug( 'The AvailableTrains call returned None. Check your network connection' ) return None seltrain = self.dispatcher.configstore.get('update.train') data = [] for name in list(trains.keys()): if name in conf._trains: train = conf._trains.get(name) else: train = Train.Train(name) data.append({ 'name': train.Name(), 'description': train.Description(), 'sequence': train.LastSequence(), 'current': True if name == seltrain else False, }) return data
def get_trains_data(self): try: redir_trains = self._get_redir_trains() except Exception: self.logger.warn('Failed to retrieve trains redirection', exc_info=True) redir_trains = {} conf = Configuration.Configuration() conf.LoadTrainsConfig() trains = {} for name, descr in (conf.AvailableTrains() or {}).items(): train = conf._trains.get(name) if train is None: train = Train.Train(name, descr) trains[train.Name()] = { 'description': descr, 'sequence': train.LastSequence(), } return { 'trains': trains, 'current_train': conf.CurrentTrain(), 'trains_redirection': redir_trains, }
def get_trains(self): """ Returns available trains dict and the currently configured train as well as the train of currently booted environment. """ data = self.middleware.call_sync('datastore.config', 'system.update') conf = Configuration.Configuration() conf.LoadTrainsConfig() try: redir_trains = self._get_redir_trains() except Exception: self.logger.warn('Failed to retrieve trains redirection', exc_info=True) redir_trains = {} selected = None trains = {} for name, descr in (conf.AvailableTrains() or {}).items(): train = conf._trains.get(name) if train is None: train = Train.Train(name, descr) try: result = compare_trains(conf.CurrentTrain(), train.Name()) except Exception: self.logger.warning("Failed to compare trains %r and %r", conf.CurrentTrain(), train.Name(), exc_info=True) continue else: if result in BAD_UPGRADES: continue if not selected and data['upd_train'] == train.Name(): selected = data['upd_train'] if name in redir_trains: continue trains[train.Name()] = { 'description': descr, 'sequence': train.LastSequence(), } if not data['upd_train'] or not selected: selected = conf.CurrentTrain() if selected in redir_trains: selected = redir_trains[selected] return { 'trains': trains, 'current': conf.CurrentTrain(), 'selected': selected, }
def trains(self): conf = Configuration.Configuration() conf.LoadTrainsConfig() trains = conf.AvailableTrains() or {} seltrain = self.dispatcher.configstore.get('update.train') data = [] for name in trains.keys(): if name in conf._trains: train = conf._trains.get(name) else: train = Train.Train(name) data.append({ 'name': train.Name(), 'description': train.Description(), 'sequence': train.LastSequence(), 'current': True if name == seltrain else False, }) return data