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) sexy.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 sexy.backend_exec("net-ipv4", "apply", networks)
def commandline_apply(cls, args): """Apply changes using the backend""" 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.hosts_list(args.type) elif args.all: hosts = cls.hosts_list() else: hosts = args.fqdn sexy.backend_exec("host", "apply", hosts)
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) sexy.backend_exec("host", "del", [args.fqdn])
def commandline_disk_add(cls, args): cls.exists_or_raise_error(args.fqdn) host = cls(fqdn=args.fqdn) size_bytes = cls.convert_si_prefixed_size_values(args.size) if args.name: if args.name in host.disk: raise Error("Disk already exists: %s" % args.name) name = args.name else: name = host.get_next_name("disk") host.disk[name] = size_bytes sexy.backend_exec("host", "disk_add", [args.fqdn, name, str(size_bytes)]) log.info("Added disk %s (%s Bytes)" % (name, size_bytes))