def kraft_list_add(ctx, origin=None, update=False): """ """ if isinstance(origin, list): for o in origin: kraft_list_add(o, update=update) return existing_origins = ctx.obj.settings.get(KRAFTRC_LIST_ORIGINS) if existing_origins is None: existing_origins = list() new_uri = urlparse(origin) if os.path.exists(origin): origin = os.path.abspath(origin) for o in existing_origins: cur_uri = urlparse(o) if (o == origin or (new_uri.netloc == cur_uri.netloc and new_uri.path == cur_uri.path)): logger.warning("Origin already saved: %s" % o) return existing_origins.append(origin) ctx.obj.settings.set(KRAFTRC_LIST_ORIGINS, existing_origins) logger.info("Saved: %s" % origin) if update: with ctx: kraft_update(origin)
def download(ctx, self, manifest=None, localdir=None, version=None, override_existing=False, **kwargs): logger.warning("%s did not replace download()" % self.__class__.__name__)
def __getitem__(self, key): try: return super(Kconfig, self).__getitem__(key) except KeyError: if not self.silent and key not in self.missing_keys: logger.warning( "The %s variable is not set. Defaulting to a blank string." % key ) self.missing_keys.append(key) return ""
def add(self, network): if isinstance(network, Network): # Remove existing network with the same name so as to override for net in self._networks: if net.name == network.name: logger.warning('Overriding existing network %s' % net.name) self._networks.remove(net) break self._networks.append(network) elif isinstance(network, Networks): for net in network.all(): self.add(net)
def get_default_config_files(base_dir): (candidates, path) = find_candidates_in_parent_dirs(SUPPORTED_FILENAMES, base_dir) if not candidates: raise KraftFileNotFound(SUPPORTED_FILENAMES) winner = candidates[0] if len(candidates) > 1: logger.warning("Found multiple config files with supported names: %s", ", ".join(candidates)) logger.warning("Using %s", winner) return [os.path.join(path, winner)]
def create_bridge(self, name=None, dry_run=False): if not self.integrity_ok(): raise NetworkBridgeUnsupported(self.type.name) if name is None: name = self._name if self.bridge_exists(name): logger.warning("Bridge '%s' already exists!" % name) return True if name is not None and len(name) > 0: utils.execute([BRCTL, "addbr", name], dry_run=dry_run) else: raise InvalidBridgeName(name) return True
def add(self, volume): if isinstance(volume, Volume): # Remove existing volume with the same name so as to override for vol in self._volumes: if vol.name == volume.name: logger.warning('Overriding existing volume %s' % vol.name) self._volumes.remove(vol) break self._volumes.append(volume) elif isinstance(volume, dict): self._volumes.add(Volume(**volume)) elif isinstance(volume, VolumeManager): for vol in volume.all(): self.add(vol)
def kraft_list_add(ctx, origin=None): """ """ if isinstance(origin, list): for o in origin: kraft_list_add(o) return new_uri = urlparse(origin) existing_origins = ctx.obj.settings.get(KRAFTRC_LIST_ORIGINS) if existing_origins is None: existing_origins = list() for o in existing_origins: cur_uri = urlparse(o) if new_uri.netloc == cur_uri.netloc and new_uri.path == cur_uri.path: logger.warning("Origin already saved: %s" % o) return existing_origins.append(origin) ctx.obj.settings.set(KRAFTRC_LIST_ORIGINS, existing_origins) logger.info("Saved: %s" % origin)
def probe(ctx, self, origin=None, items=None, return_threads=False): logger.warning("%s did not replace probe()" % self.__class__.__name__) return None, None
def is_type(cls, origin=None): logger.warning("%s did not replace is_type()" % cls.__name__) return False