Exemplo n.º 1
0
 def __init__(self):
     super(IndirectionCloud, self).__init__()
     self.app_config = ApplicationConfiguration().configuration
     self.log = logging.getLogger('%s.%s' %
                                  (__name__, self.__class__.__name__))
     self.pim = PersistentImageManager.default_manager()
     self.res_mgr = ReservationManager()
Exemplo n.º 2
0
 def setUp(self):
     self.test_path = '/tmp/imagefactory.unittest.ReservationManager'
     self.test_file = '%s/reservation.test' % self.test_path
     os.mkdir(self.test_path)
     fstat = os.statvfs(self.test_path)
     self.max_free = fstat.f_bavail * fstat.f_frsize
     self.min_free = self.max_free / 2
     self.res_mgr = ReservationManager()
Exemplo n.º 3
0
 def __init__(self):
     super(TinMan, self).__init__()
     self.cloud_plugin_content = []
     config_obj = ApplicationConfiguration()
     self.app_config = config_obj.configuration
     self.res_mgr = ReservationManager()
     self.log = logging.getLogger('%s.%s' %
                                  (__name__, self.__class__.__name__))
     self.parameters = None
     self.install_script_object = None
     self.guest = None
Exemplo n.º 4
0
 def testJobQueue(self):
     """
     TODO: Docstring for testJobQueue
     """
     job_number = 3
     job_threads = []
     job_output = []
     for i in range(job_number):
         for name in ReservationManager().queues:
             job_threads.append(
                 MockJob(kwargs=dict(
                     qname=name, position=i, output=job_output)))
     for job in job_threads:
         job.start()
     for job in job_threads:
         if job.isAlive():
             job.join()
     #self.log.info(job_output)
     self.assertEqual((3 * job_number * len(ReservationManager().queues)),
                      len(job_output))
Exemplo n.º 5
0
 def run(self):
     resmgr = ReservationManager()
     str_args = (self.qname, self.position)
     self.output.append('enter-%s-%d' % str_args)
     resmgr.enter_queue(self.qname)
     self.output.append('start-%s-%d' % str_args)
     if (self.qname == 'local'):
         time.sleep(4)
     else:
         time.sleep(1)
     self.output.append('exit-%s-%d' % str_args)
     resmgr.exit_queue(self.qname)
Exemplo n.º 6
0
    def threadsafe_generate_install_media(self, guest):
        # Oz caching of install media and modified install media is not thread safe
        # Make it safe here using some locks
        # We can only have one active generate_install_media() call for each unique tuple:
        #  (OS, update, architecture, installtype)

        tdl = guest.tdl
        queue_name = "%s-%s-%s-%s" % (tdl.distro, tdl.update, tdl.arch,
                                      tdl.installtype)
        res_mgr = ReservationManager()
        res_mgr.get_named_lock(queue_name)
        try:
            guest.generate_install_media(force_download=False)
        finally:
            res_mgr.release_named_lock(queue_name)
Exemplo n.º 7
0
 def _singleton_init(self):
     self.log = logging.getLogger('%s.%s' % (__name__, self.__class__.__name__))
     self.pending_uploads = dict()
     self.pending_uploads_lock = BoundedSemaphore()
     self.pim = PersistentImageManager.default_manager()
     self.res = ReservationManager()
     self.secondaries = { } 
     if os.path.isfile(SECONDARIES):
         try:
             secs = open(SECONDARIES, "r")
             self.secondaries = json.load(secs)
             secs.close()
         except:
             self.log.warning("Unable to load JSON for secondaries from %s", SECONDARIES)
     if not 'targets' in self.secondaries:
         self.secondaries['targets'] = { }
     if not 'providers' in self.secondaries:
         self.secondaries['providers'] = { }
Exemplo n.º 8
0
 def testSingleton(self):
     """
     Prove this class produces a singelton object.
     """
     self.assertEqual(id(self.res_mgr), id(ReservationManager()))