~corey.bryant/charms/trusty/cinder/use-stable

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/openstack/context.py

  • Committer: james.page at ubuntu
  • Date: 2014-10-08 10:42:20 UTC
  • mfrom: (50.2.1 cinder)
  • Revision ID: james.page@ubuntu.com-20141008104220-3pv89skoe4wdv59c
[jamespage,r=gnuoy] Add support for worker configuration

Show diffs side-by-side

added added

removed removed

Lines of Context:
903
903
            return {
904
904
                'bind_host': '0.0.0.0'
905
905
            }
 
906
 
 
907
 
 
908
class WorkerConfigContext(OSContextGenerator):
 
909
 
 
910
    @property
 
911
    def num_cpus(self):
 
912
        try:
 
913
            from psutil import NUM_CPUS
 
914
        except ImportError:
 
915
            apt_install('python-psutil', fatal=True)
 
916
            from psutil import NUM_CPUS
 
917
        return NUM_CPUS
 
918
 
 
919
    def __call__(self):
 
920
        multiplier = config('worker-multiplier') or 1
 
921
        ctxt = {
 
922
            "workers": self.num_cpus * multiplier
 
923
        }
 
924
        return ctxt