def commandline_add(cls, args): if cls.exists(args.network): raise Error("Network already exist: %s" % args.network) network = cls(args.network) network.validate_mask(args.mask) network._init_base_dir(args.mask) cinv.backend_exec("net-ipv4", "add", [args.network, args.mask])
def commandline_apply(cls, args): """Apply changes using the backend""" if not args.all and not args.network: raise Error("Required to pass either networks or --all") if args.all: networks = cls.network_list() else: networks = args.network cinv.backend_exec("net-ipv4", "apply", networks)
def disk_add(self, size, name=False): size = self.convert_si_prefixed_size_values(size) if name: if name in self.disk: raise Error("Disk already exists: %s" % name) else: name = self.get_next_name("disk") self.disk[name] = size cinv.backend_exec("host", "disk_add", [self.fqdn, name, str(size)])
def commandline_del(cls, args): if not cls.exists(args.fqdn): if not args.ignore_missing: raise Error("Host does not exist: %s" % args.fqdn) else: return host = cls(fqdn=args.fqdn) if not args.recursive: if host.nic or host.disk: raise Error("Cannot delete, host contains disk or nic: %s" % args.fqdn) log.debug("Removing %s ..." % host.base_dir) shutil.rmtree(host.base_dir) cinv.backend_exec("host", "del", [args.fqdn])
def commandline_apply(cls, args): """Apply changes using the backend""" # FIXME: maybe support only --all - everything else could cause inconsistencies if not args.all and not args.fqdn and not args.type: raise Error("Required to pass either FQDNs, type or --all") if args.type and args.fqdn: raise Error("Cannot combine FQDN list and type") if args.type: hosts = cls.host_list(args.type) elif args.all: hosts = cls.host_list() else: hosts = args.fqdn cinv.backend_exec("host", "apply", hosts)