コード例 #1
0
ファイル: test_dtrs.py プロジェクト: timf/epu
class TestDeployableTypeRegistryService(IonTestCase):
    """Testing deployable type lookups
    """

    @defer.inlineCallbacks
    def setUp(self):

        self.registry = {}

        yield self._start_container()
        procs = [
            {'name':'dtrs','module':'epu.ionproc.dtrs', 
                'class':'DeployableTypeRegistryService', 
                'spawnargs' : {'registry' : self.registry}},
                ]
        yield self._spawn_processes(procs)

        dtrsId = yield self.procRegistry.get("dtrs")

        self.client = DeployableTypeRegistryClient(pid=dtrsId)

    @defer.inlineCallbacks
    def tearDown(self):
        yield self._stop_container()
        self.client = None

    @defer.inlineCallbacks
    def test_dtrs_lookup(self):
        self.registry['base-cluster-1'] = _DT_ALL_DEFAULT
        
        req_nodes = {
            'head-node' : {'site' : 'nimbus-test'},
            'worker-node' : {'site' : 'nimbus-test'}}

        result = yield self.client.lookup('base-cluster-1', nodes=req_nodes)
        doc = result['document']
        nodes = result['nodes']
        for node in nodes.itervalues():
            self.assertTrue('iaas_image' in node)

        got_error = False
        try:
            yield self.client.lookup('this-dt-doesnt-exist', nodes)
        except DeployableTypeLookupError, e:
            log.info('Got expected error: ' + str(e))
            got_error = True
        self.assertTrue(got_error)

        req_nodes['head-node']['site'] = 'this-site-doesnt-exist'
        got_error = False
        try:
            yield self.client.lookup('base-cluster-1', req_nodes)
        except DeployableTypeLookupError, e:
            log.info('Got expected error: ' + str(e))
            got_error = True
コード例 #2
0
class ProvisionerService(ServiceProcess):
    """Provisioner service interface
    """

    # Declaration of service
    declare = ServiceProcess.service_declare(name='provisioner',
                                             version='0.1.0',
                                             dependencies=[])

    @defer.inlineCallbacks
    def slc_init(self):
        cei_events.event("provisioner", "init_begin")

        try:
            store = self.spawn_args['store']
            site_drivers = self.spawn_args['site_drivers']
            context_client = self.spawn_args['context_client']
        except KeyError, e:
            raise KeyError("Missing provisioner spawn_arg: " + str(e))

        self.store = store

        notifier = self.spawn_args.get('notifier')
        self.notifier = notifier or ProvisionerNotifier(self)
        self.dtrs = DeployableTypeRegistryClient(self)

        self.core = ProvisionerCore(self.store, self.notifier, self.dtrs,
                                    site_drivers, context_client)
        yield self.core.recover()
        cei_events.event("provisioner", "init_end")

        # operator can disable new launches
        self.enabled = True
        self.terminate_all_deferred = None
コード例 #3
0
    def setUp(self):

        self.registry = {}

        yield self._start_container()
        procs = [
            {
                'name': 'dtrs',
                'module': 'epu.ionproc.dtrs',
                'class': 'DeployableTypeRegistryService',
                'spawnargs': {
                    'registry': self.registry
                }
            },
        ]
        yield self._spawn_processes(procs)

        dtrsId = yield self.procRegistry.get("dtrs")

        self.client = DeployableTypeRegistryClient(pid=dtrsId)
コード例 #4
0
ファイル: test_dtrs.py プロジェクト: timf/epu
    def setUp(self):

        self.registry = {}

        yield self._start_container()
        procs = [
            {'name':'dtrs','module':'epu.ionproc.dtrs', 
                'class':'DeployableTypeRegistryService', 
                'spawnargs' : {'registry' : self.registry}},
                ]
        yield self._spawn_processes(procs)

        dtrsId = yield self.procRegistry.get("dtrs")

        self.client = DeployableTypeRegistryClient(pid=dtrsId)
コード例 #5
0
class TestDeployableTypeRegistryService(IonTestCase):
    """Testing deployable type lookups
    """
    @defer.inlineCallbacks
    def setUp(self):

        self.registry = {}

        yield self._start_container()
        procs = [
            {
                'name': 'dtrs',
                'module': 'epu.ionproc.dtrs',
                'class': 'DeployableTypeRegistryService',
                'spawnargs': {
                    'registry': self.registry
                }
            },
        ]
        yield self._spawn_processes(procs)

        dtrsId = yield self.procRegistry.get("dtrs")

        self.client = DeployableTypeRegistryClient(pid=dtrsId)

    @defer.inlineCallbacks
    def tearDown(self):
        yield self._stop_container()
        self.client = None

    @defer.inlineCallbacks
    def test_dtrs_lookup(self):
        self.registry['base-cluster-1'] = _DT_ALL_DEFAULT

        req_nodes = {
            'head-node': {
                'site': 'nimbus-test'
            },
            'worker-node': {
                'site': 'nimbus-test'
            }
        }

        result = yield self.client.lookup('base-cluster-1', nodes=req_nodes)
        doc = result['document']
        nodes = result['nodes']
        for node in nodes.itervalues():
            self.assertTrue('iaas_image' in node)

        got_error = False
        try:
            yield self.client.lookup('this-dt-doesnt-exist', nodes)
        except DeployableTypeLookupError, e:
            log.info('Got expected error: ' + str(e))
            got_error = True
        self.assertTrue(got_error)

        req_nodes['head-node']['site'] = 'this-site-doesnt-exist'
        got_error = False
        try:
            yield self.client.lookup('base-cluster-1', req_nodes)
        except DeployableTypeLookupError, e:
            log.info('Got expected error: ' + str(e))
            got_error = True