def add(self, **opts): ''' Add a new axon to the AxonHost. Example: # add another axon to the host with defaults axfo = axho.add() ''' iden = guid() opts['iden'] = iden # store iden as a specified option fullopts = dict(self.opts) fullopts.update(opts) bytemax = fullopts.get('bytemax') if not fullopts.get('clone'): bytemax += fullopts.get('syncmax') volinfo = s_thisplat.getVolInfo(self.datadir) free = volinfo.get('free') total = volinfo.get('total') if bytemax > free: raise NotEnoughFree(bytemax) axondir = gendir(self.datadir, '%s.axon' % iden) jssave(opts, axondir, 'axon.opts') # FIXME fork axon = Axon(axondir, **fullopts) self.axons[iden] = axon return axon.axfo
def add(self, **opts): ''' Add a new axon to the AxonHost. Example: # add another axon to the host with defaults axfo = axho.add() ''' iden = guid() opts['iden'] = iden # store iden as a specified option fullopts = dict(self.opts) fullopts.update(opts) bytemax = fullopts.get('bytemax') if not fullopts.get('clone'): bytemax += fullopts.get('syncmax') volinfo = s_thisplat.getVolInfo(self.datadir) free = volinfo.get('free') total = volinfo.get('total') if bytemax > free: raise Exception('NotEnoughFree') axondir = gendir(self.datadir,'%s.axon' % iden) jssave(opts,axondir,'axon.opts') # FIXME fork axon = Axon(axondir,**fullopts) self.axons[iden] = axon return axon.axfo
def usage(self): ''' Return volume usage info. ''' volinfo = s_thisplat.getVolInfo(self.datadir) return volinfo
def add(self, **opts): ''' Add a new axon to the AxonHost. Args: **opts: kwarg values which supersede the defaults of the AxonHost when making the Axon. Examples: Add another Axon to the host with defaults:: axfo = host.add() Returns: ((str, dict)): A Axon information tuple containing configuration and link data. ''' iden = s_common.guid() fullopts = self.makeAxonOpts() fullopts['axon:iden'] = iden # store iden as a specified option fullopts.update(opts) bytemax = fullopts.get('axon:bytemax') clone = fullopts.get('axon:clone') volinfo = s_thisplat.getVolInfo(self.datadir) free = volinfo.get('free') total = volinfo.get('total') maxsize = self.getConfOpt('axonhost:maxsize') if maxsize and (self.usedspace + bytemax) > maxsize: raise s_common.NotEnoughFree( mesg= 'Not enough free space on the AxonHost (due to axonhost:maxsize) to ' 'create the new Axon.', bytemax=bytemax, maxsize=maxsize, usedspace=self.usedspace) if (self.usedspace + bytemax) > free: raise s_common.NotEnoughFree( mesg= 'Not enough free space on the volume when considering the allocations' ' of existing Axons.', bytemax=bytemax, free=free, usedspace=self.usedspace) if bytemax > free: raise s_common.NotEnoughFree( mesg= 'Not enough free space on the volume to create the new Axon.', bytemax=bytemax, free=free) axondir = s_common.gendir(self.datadir, '%s.axon' % iden) s_common.jssave(fullopts, axondir, 'axon.opts') # FIXME fork axon = Axon(axondir, **fullopts) self.usedspace = self.usedspace + bytemax self.axons[iden] = axon if clone: self.cloneaxons.append(iden) return axon.axfo
def usage(self): ''' Return volume usage info. ''' volinfo = s_thisplat.getVolInfo( self.datadir ) return volinfo