Ejemplo n.º 1
0
  @Test
  public void testCreatePrimaryStorage() {
    DataStoreProvider provider =
        dataStoreProviderMgr.getDataStoreProvider("sample primary data store provider");
    Map<String, Object> params = new HashMap<String, Object>();
    URI uri = null;
    try {
      uri = new URI(this.getPrimaryStorageUrl());
    } catch (URISyntaxException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    params.put("url", this.getPrimaryStorageUrl());
    params.put("server", uri.getHost());
    params.put("path", uri.getPath());
    params.put("protocol", StoragePoolType.NetworkFilesystem);
    params.put("dcId", dcId.toString());
    params.put("clusterId", clusterId.toString());
    params.put("name", this.primaryName);
    params.put("port", "1");
    params.put("roles", DataStoreRole.Primary.toString());
    params.put("uuid", UUID.nameUUIDFromBytes(this.getPrimaryStorageUrl().getBytes()).toString());
    params.put("providerName", String.valueOf(provider.getName()));

    DataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle();
    this.primaryStore = lifeCycle.initialize(params);
    ClusterScope scope = new ClusterScope(clusterId, podId, dcId);
    lifeCycle.attachCluster(this.primaryStore, scope);
  }
Ejemplo n.º 2
0
  public DataStore createPrimaryDataStore() {
    try {
      DataStoreProvider provider =
          dataStoreProviderMgr.getDataStoreProvider("sample primary data store provider");
      Map<String, Object> params = new HashMap<String, Object>();
      URI uri = new URI(this.getPrimaryStorageUrl());
      params.put("url", this.getPrimaryStorageUrl());
      params.put("server", uri.getHost());
      params.put("path", uri.getPath());
      params.put("protocol", Storage.StoragePoolType.NetworkFilesystem);
      params.put("dcId", dcId.toString());
      params.put("clusterId", clusterId.toString());
      params.put("name", this.primaryName);
      params.put("port", "1");
      params.put("roles", DataStoreRole.Primary.toString());
      params.put("uuid", UUID.nameUUIDFromBytes(this.getPrimaryStorageUrl().getBytes()).toString());
      params.put("providerName", String.valueOf(provider.getName()));

      DataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle();
      DataStore store = lifeCycle.initialize(params);
      ClusterScope scope = new ClusterScope(clusterId, podId, dcId);
      lifeCycle.attachCluster(store, scope);

      /*
       * PrimaryDataStoreProvider provider =
       * primaryDataStoreProviderMgr.getDataStoreProvider
       * ("sample primary data store provider");
       * primaryDataStoreProviderMgr.configure("primary data store mgr",
       * new HashMap<String, Object>());
       *
       * List<PrimaryDataStoreVO> ds =
       * primaryStoreDao.findPoolByName(this.primaryName); if (ds.size()
       * >= 1) { PrimaryDataStoreVO store = ds.get(0); if
       * (store.getRemoved() == null) { return
       * provider.getDataStore(store.getId()); } }
       *
       *
       * Map<String, String> params = new HashMap<String, String>();
       * params.put("url", this.getPrimaryStorageUrl());
       * params.put("dcId", dcId.toString()); params.put("clusterId",
       * clusterId.toString()); params.put("name", this.primaryName);
       * PrimaryDataStoreInfo primaryDataStoreInfo =
       * provider.registerDataStore(params); PrimaryDataStoreLifeCycle lc
       * = primaryDataStoreInfo.getLifeCycle(); ClusterScope scope = new
       * ClusterScope(clusterId, podId, dcId); lc.attachCluster(scope);
       * return primaryDataStoreInfo;
       */
      return store;
    } catch (Exception e) {
      return null;
    }
  }
Ejemplo n.º 3
0
 private DataStore createImageStore() {
   DataStoreProvider provider =
       dataStoreProviderMgr.getDataStoreProvider("sample image data store provider");
   Map<String, Object> params = new HashMap<String, Object>();
   String name = UUID.randomUUID().toString();
   params.put("name", name);
   params.put("uuid", name);
   params.put("protocol", "http");
   params.put("scope", ScopeType.GLOBAL.toString());
   params.put("providerName", name);
   DataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle();
   DataStore store = lifeCycle.initialize(params);
   return store;
 }