Esempio n. 1
0
    def get_cluster(self, cloud_provider=None, config=None, nodes=None):
        if not cloud_provider:
            cloud_provider = BotoCloudProvider("https://hobbes.gc3.uzh.ch/",
                                               "nova", "a-key", "s-key")
        if not config:
            config = Configuration().get_config(self.path)

        setup = Mock()
        configurator = Configurator(config)
        conf_login = configurator.cluster_conf['mycluster']['login']
        repository = PickleRepository(self.storage_path)

        cluster = Cluster(
            name="mycluster",
            cloud_provider=cloud_provider,
            setup_provider=setup,
            repository=repository,
            user_key_name=conf_login['user_key_name'],
            user_key_public=conf_login['user_key_public'],
            user_key_private=conf_login['user_key_private'],
        )

        if not nodes:
            nodes = {"compute": 2, "frontend": 1}

        for kind, num in nodes.iteritems():
            conf_kind = configurator.cluster_conf['mycluster']['nodes'][kind]
            cluster.add_nodes(kind, num, conf_kind['image_id'],
                              conf_login['image_user'], conf_kind['flavor'],
                              conf_kind['security_group'])

        return cluster
Esempio n. 2
0
class PickleRepositoryTests(MemRepositoryTests):
    def setUp(self):
        self.path = tempfile.mkdtemp()
        self.storage = PickleRepository(self.path)

    def tearDown(self):
        shutil.rmtree(self.path, ignore_errors=True)
        del self.storage

    def test_delete(self):
        pass

    def test_save_and_delete(self):
        cluster = FakeCluster("test1")
        self.storage.save_or_update(cluster)

        clusterpath = os.path.join(self.path, "test1.pickle")
        assert os.path.exists(clusterpath)

        self.storage.delete(cluster)
        assert not os.path.exists(clusterpath)
Esempio n. 3
0
class PickleRepositoryTests(MemRepositoryTests):
    def setUp(self):
        self.path = tempfile.mkdtemp()
        self.storage = PickleRepository(self.path)

    def tearDown(self):
        shutil.rmtree(self.path, ignore_errors=True)
        del self.storage

    def test_delete(self):
        pass

    def test_save_and_delete(self):
        cluster = Cluster('test1')
        self.storage.save_or_update(cluster)

        clusterpath = os.path.join(self.path, 'test1.pickle')
        assert os.path.exists(clusterpath)

        self.storage.delete(cluster)
        assert not os.path.exists(clusterpath)
Esempio n. 4
0
 def setUp(self):
     self.path = tempfile.mkdtemp()
     self.storage = PickleRepository(self.path)
Esempio n. 5
0
 def create_repository(self):
     storage_path = self.general_conf['storage']
     repository = PickleRepository(storage_path)
     return repository
Esempio n. 6
0
 def setUp(self):
     self.path = tempfile.mkdtemp()
     self.storage = PickleRepository(self.path)