def hardware(self): return { 'cpu_model': get_sysctl("hw.model"), 'cpu_cores': get_sysctl("hw.ncpu"), 'cpu_clockrate': get_sysctl("hw.clockrate"), 'memory_size': get_sysctl("hw.physmem") }
def hardware(self): vm_guest = get_sysctl("kern.vm_guest") return { 'cpu_model': get_sysctl("hw.model"), 'cpu_cores': get_sysctl("hw.ncpu"), 'cpu_clockrate': get_sysctl("hw.clockrate"), 'memory_size': get_sysctl("hw.physmem"), 'vm_guest': None if vm_guest == 'none' else vm_guest }
def _get_class_cpu(self): result = [] ncpus = get_sysctl('hw.ncpu') model = get_sysctl('hw.model').strip('\x00') for i in range(0, ncpus): freq = None temp = None with contextlib.suppress(OSError): freq = get_sysctl('dev.cpu.{0}.freq'.format(i)), with contextlib.suppress(OSError): temp = get_sysctl('dev.cpu.{0}.temperature'.format(i)) result.append({'name': model, 'freq': freq, 'temperature': temp}) return result
def _get_class_network(self): result = [] for i in netif.list_interfaces().keys(): if i.startswith('lo'): continue desc = get_sysctl(re.sub('(\w+)([0-9]+)', 'dev.\\1.\\2.%desc', i)) result.append({'name': i, 'description': desc}) return result
def _get_class_network(self): result = [] for i in list(netif.list_interfaces().keys()): if i.startswith('lo'): continue desc = get_sysctl(re.sub('(\w+)([0-9]+)', 'dev.\\1.\\2.%desc', i)) result.append({ 'name': i, 'description': desc }) return result
def configure_params(cifs): conf = smbconf.SambaConfig('registry') conf['netbios name'] = cifs['netbiosname'][0] conf['netbios aliases'] = ' '.join(cifs['netbiosname'][1:]) if cifs['bind_addresses']: conf['interfaces'] = ' '.join(['127.0.0.1'] + cifs['bind_addresses']) conf['workgroup'] = cifs['workgroup'] conf['server string'] = cifs['description'] conf['encrypt passwords'] = 'yes' conf['dns proxy'] = 'no' conf['strict locking'] = 'no' conf['oplocks'] = 'yes' conf['deadtime'] = '15' conf['max log size'] = '51200' conf['max open files'] = str(int(get_sysctl('kern.maxfilesperproc')) - 25) if cifs['syslog']: conf['syslog only'] = 'yes' conf['syslog'] = '1' conf['load printers'] = 'no' conf['printing'] = 'bsd' conf['printcap name'] = '/dev/null' conf['disable spoolss'] = 'yes' conf['getwd cache'] = 'yes' conf['guest account'] = cifs['guest_user'] conf['map to guest'] = 'Bad User' conf['obey pam restrictions'] = yesno(cifs['obey_pam_restrictions']) conf['directory name cache size'] = '0' conf['kernel change notify'] = 'no' conf['panic action'] = '/usr/local/libexec/samba/samba-backtrace' conf['nsupdate command'] = '/usr/local/bin/samba-nsupdate -g' conf['ea support'] = 'yes' conf['store dos attributes'] = 'yes' conf['lm announce'] = 'yes' conf['hostname lookups'] = yesno(cifs['hostlookup']) conf['unix extensions'] = yesno(cifs['unixext']) conf['time server'] = yesno(cifs['time_server']) conf['null passwords'] = yesno(cifs['empty_password']) conf['acl allow execute always'] = yesno(cifs['execute_always']) conf['acl check permissions'] = 'true' conf['dos filemode'] = 'yes' conf['multicast dns register'] = yesno(cifs['zeroconf']) conf['local master'] = yesno(cifs['local_master']) conf['server role'] = 'auto' conf['log level'] = str(getattr(LogLevel, cifs['log_level']).value) conf['username map'] = '/usr/local/etc/smbusers' conf['idmap config *: range'] = '90000001-100000000' conf['idmap config *: backend'] = 'tdb'
def _get_class_network(self): result = [] for i in list(netif.list_interfaces().keys()): if i.startswith(tuple(netif.CLONED_PREFIXES)): continue try: desc = get_sysctl( re.sub('(\\w+)([0-9]+)', 'dev.\\1.\\2.%desc', i)) result.append({'name': i, 'description': desc}) except FileNotFoundError: continue return result
def _get_class_network(self): result = [] for i in list(netif.list_interfaces().keys()): if i.startswith(tuple(netif.CLONED_PREFIXES)): continue try: desc = get_sysctl(re.sub('(\w+)([0-9]+)', 'dev.\\1.\\2.%desc', i)) result.append({ 'name': i, 'description': desc }) except FileNotFoundError: continue return result
def configure_params(smb, ad=False): conf = smbconf.SambaConfig('registry') conf.transaction_start() try: conf['netbios name'] = smb['netbiosname'][0] conf['netbios aliases'] = ' '.join(smb['netbiosname'][1:]) if smb['bind_addresses']: conf['interfaces'] = ' '.join(['127.0.0.1'] + smb['bind_addresses']) conf['server string'] = smb['description'] conf['server max protocol'] = smb['max_protocol'] conf['server min protocol'] = smb['min_protocol'] conf['encrypt passwords'] = 'yes' conf['dns proxy'] = 'no' conf['strict locking'] = 'no' conf['oplocks'] = 'yes' conf['deadtime'] = '15' conf['max log size'] = '51200' conf['max open files'] = str( int(get_sysctl('kern.maxfilesperproc')) - 25) conf['logging'] = 'logd@10' if 'filemask' in smb: if smb['filemask'] is not None: conf['create mode'] = perm_to_oct_string( get_unix_permissions(smb['filemask'])).zfill(4) if 'dirmask' in smb: if smb['dirmask'] is not None: conf['directory mode'] = perm_to_oct_string( get_unix_permissions(smb['dirmask'])).zfill(4) conf['load printers'] = 'no' conf['printing'] = 'bsd' conf['printcap name'] = '/dev/null' conf['disable spoolss'] = 'yes' conf['getwd cache'] = 'yes' conf['guest account'] = smb['guest_user'] conf['map to guest'] = 'Bad User' conf['obey pam restrictions'] = yesno(smb['obey_pam_restrictions']) conf['directory name cache size'] = '0' conf['kernel change notify'] = 'no' conf['panic action'] = '/usr/local/libexec/samba/samba-backtrace' conf['nsupdate command'] = '/usr/local/bin/samba-nsupdate -g' conf['ea support'] = 'yes' conf['store dos attributes'] = 'yes' conf['lm announce'] = 'yes' conf['hostname lookups'] = yesno(smb['hostlookup']) conf['unix extensions'] = yesno(smb['unixext']) conf['time server'] = yesno(smb['time_server']) conf['null passwords'] = yesno(smb['empty_password']) conf['acl allow execute always'] = yesno(smb['execute_always']) conf['acl check permissions'] = 'true' conf['dos filemode'] = 'yes' conf['multicast dns register'] = yesno(smb['zeroconf']) conf['passdb backend'] = 'freenas' conf['log level'] = str(getattr(LogLevel, smb['log_level']).value) conf['username map'] = '/usr/local/etc/smbusers' conf['idmap config *: range'] = '90000001-100000000' conf['idmap config *: backend'] = 'tdb' conf['ntlm auth'] = 'yes' if not ad: conf['local master'] = yesno(smb['local_master']) conf['server role'] = 'auto' conf['workgroup'] = smb['workgroup'] except BaseException as err: logger.error('Failed to update samba registry: {0}'.format(err), exc_info=True) conf.transaction_cancel() else: conf.transaction_commit()
def configure_params(smb, ad=False): conf = smbconf.SambaConfig('registry') conf.transaction_start() try: conf['netbios name'] = smb['netbiosname'][0] conf['netbios aliases'] = ' '.join(smb['netbiosname'][1:]) if smb['bind_addresses']: conf['interfaces'] = ' '.join(['127.0.0.1'] + smb['bind_addresses']) conf['server string'] = smb['description'] conf['server max protocol'] = smb['max_protocol'] conf['server min protocol'] = smb['min_protocol'] conf['encrypt passwords'] = 'yes' conf['dns proxy'] = 'no' conf['strict locking'] = 'no' conf['oplocks'] = 'yes' conf['deadtime'] = '15' conf['max log size'] = '51200' conf['max open files'] = str(int(get_sysctl('kern.maxfilesperproc')) - 25) conf['logging'] = 'logd@10' if 'filemask' in smb: if smb['filemask'] is not None: conf['create mode'] = perm_to_oct_string(get_unix_permissions(smb['filemask'])).zfill(4) if 'dirmask' in smb: if smb['dirmask'] is not None: conf['directory mode'] = perm_to_oct_string(get_unix_permissions(smb['dirmask'])).zfill(4) conf['load printers'] = 'no' conf['printing'] = 'bsd' conf['printcap name'] = '/dev/null' conf['disable spoolss'] = 'yes' conf['getwd cache'] = 'yes' conf['guest account'] = smb['guest_user'] conf['map to guest'] = 'Bad User' conf['obey pam restrictions'] = yesno(smb['obey_pam_restrictions']) conf['directory name cache size'] = '0' conf['kernel change notify'] = 'no' conf['panic action'] = '/usr/local/libexec/samba/samba-backtrace' conf['nsupdate command'] = '/usr/local/bin/samba-nsupdate -g' conf['ea support'] = 'yes' conf['store dos attributes'] = 'yes' conf['lm announce'] = 'yes' conf['hostname lookups'] = yesno(smb['hostlookup']) conf['unix extensions'] = yesno(smb['unixext']) conf['time server'] = yesno(smb['time_server']) conf['null passwords'] = yesno(smb['empty_password']) conf['acl allow execute always'] = yesno(smb['execute_always']) conf['acl check permissions'] = 'true' conf['dos filemode'] = 'yes' conf['multicast dns register'] = yesno(smb['zeroconf']) conf['passdb backend'] = 'freenas' conf['log level'] = str(getattr(LogLevel, smb['log_level']).value) conf['username map'] = '/usr/local/etc/smbusers' conf['idmap config *: range'] = '90000001-100000000' conf['idmap config *: backend'] = 'tdb' conf['ntlm auth'] = 'yes' if not ad: conf['local master'] = yesno(smb['local_master']) conf['server role'] = 'auto' conf['workgroup'] = smb['workgroup'] except BaseException as err: logger.error('Failed to update samba registry: {0}'.format(err), exc_info=True) conf.transaction_cancel() else: conf.transaction_commit()
def configure_params(smb, ad=False): conf = smbconf.SambaConfig("registry") conf["netbios name"] = smb["netbiosname"][0] conf["netbios aliases"] = " ".join(smb["netbiosname"][1:]) if smb["bind_addresses"]: conf["interfaces"] = " ".join(["127.0.0.1"] + smb["bind_addresses"]) conf["server string"] = smb["description"] conf["encrypt passwords"] = "yes" conf["dns proxy"] = "no" conf["strict locking"] = "no" conf["oplocks"] = "yes" conf["deadtime"] = "15" conf["max log size"] = "51200" conf["max open files"] = str(int(get_sysctl("kern.maxfilesperproc")) - 25) if smb["syslog"]: conf["syslog only"] = "yes" conf["syslog"] = "1" if "filemask" in smb: if smb["filemask"] is not None: conf["create mode"] = perm_to_oct_string(get_unix_permissions(smb["filemask"])).zfill(4) if "dirmask" in smb: if smb["dirmask"] is not None: conf["directory mode"] = perm_to_oct_string(get_unix_permissions(smb["dirmask"])).zfill(4) conf["load printers"] = "no" conf["printing"] = "bsd" conf["printcap name"] = "/dev/null" conf["disable spoolss"] = "yes" conf["getwd cache"] = "yes" conf["guest account"] = smb["guest_user"] conf["map to guest"] = "Bad User" conf["obey pam restrictions"] = yesno(smb["obey_pam_restrictions"]) conf["directory name cache size"] = "0" conf["kernel change notify"] = "no" conf["panic action"] = "/usr/local/libexec/samba/samba-backtrace" conf["nsupdate command"] = "/usr/local/bin/samba-nsupdate -g" conf["ea support"] = "yes" conf["store dos attributes"] = "yes" conf["lm announce"] = "yes" conf["hostname lookups"] = yesno(smb["hostlookup"]) conf["unix extensions"] = yesno(smb["unixext"]) conf["time server"] = yesno(smb["time_server"]) conf["null passwords"] = yesno(smb["empty_password"]) conf["acl allow execute always"] = yesno(smb["execute_always"]) conf["acl check permissions"] = "true" conf["dos filemode"] = "yes" conf["multicast dns register"] = yesno(smb["zeroconf"]) conf["passdb backend"] = "freenas" conf["log level"] = str(getattr(LogLevel, smb["log_level"]).value) conf["username map"] = "/usr/local/etc/smbusers" conf["idmap config *: range"] = "90000001-100000000" conf["idmap config *: backend"] = "tdb" if not ad: conf["local master"] = yesno(smb["local_master"]) conf["server role"] = "auto" conf["workgroup"] = smb["workgroup"]
def start_executors(self): for i in range(0, max(get_sysctl("hw.ncpu"), 2)): self.logger.info('Starting task executor #{0}...'.format(i)) self.executors.append(TaskExecutor(self, i))
def start_executors(self): for i in range(0, get_sysctl("hw.ncpu")): self.logger.info('Starting task executor #{0}...'.format(i)) self.executors.append(TaskExecutor(self, i))
def host_uuid(self): return get_sysctl("kern.hostuuid")[:-1]
def hardware(self): return { 'cpu_model': get_sysctl("hw.model"), 'cpu_cores': get_sysctl("hw.ncpu"), 'memory_size': get_sysctl("hw.physmem") }