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 = ClusterRepository(self.storage_path) cluster = Cluster( "mycluster", cloud_provider, setup, repository, conf_login['user_key_name'], conf_login['user_key_public'], 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
class ClusterRepositoryTests(MemRepositoryTests): def setUp(self): self.path = tempfile.mkdtemp() self.storage = ClusterRepository(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') nt.assert_true(os.path.exists(clusterpath)) self.storage.delete(cluster) nt.assert_false(os.path.exists(clusterpath))
def create_repository(self): storage_path = self.general_conf['storage'] repository = ClusterRepository(storage_path) return repository
def setUp(self): self.path = tempfile.mkdtemp() self.storage = ClusterRepository(self.path)