cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [46/57] [abbrv] Move previous AncientImageDataStore provider and DefaultImageDataStore provider code into plugins.
Date Sat, 06 Apr 2013 00:35:19 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageDataStoreDriverImpl.java
b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageDataStoreDriverImpl.java
new file mode 100644
index 0000000..cf42ac3
--- /dev/null
+++ b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageDataStoreDriverImpl.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.driver;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.storage.command.CreateObjectAnswer;
+import org.apache.cloudstack.storage.command.CreateObjectCommand;
+import org.apache.cloudstack.storage.endpoint.EndPointSelector;
+import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
+
+import com.cloud.storage.dao.VMTemplateDao;
+
+//http-read-only based image store
+public class SampleImageDataStoreDriverImpl implements ImageDataStoreDriver {
+    @Inject
+    EndPointSelector selector;
+    @Inject
+    VMTemplateDao imageDataDao;
+    public SampleImageDataStoreDriverImpl() {
+    }
+
+    @Override
+    public String grantAccess(DataObject data, EndPoint ep) {
+        return data.getUri();
+    }
+
+    @Override
+    public boolean revokeAccess(DataObject data, EndPoint ep) {
+        // TODO Auto-generated method stub
+        return true;
+    }
+
+    @Override
+    public Set<DataObject> listObjects(DataStore store) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void createAsync(DataObject data,
+            AsyncCompletionCallback<CreateCmdResult> callback) {
+        //for default http data store, can create http based template/iso
+        CreateCmdResult result = new CreateCmdResult("", null);
+        if (!data.getUri().startsWith("http")) {
+            result.setResult("can't register an image which is not a http link");
+            callback.complete(result);
+            return;
+        }
+        
+        if (data.getSize() == null && data.getType() == DataObjectType.TEMPLATE)
{
+            //the template size is unknown during registration, need to find out the size
of template
+            EndPoint ep = selector.select(data);
+            if (ep == null) {
+                result.setResult("can't find storage client for:" + data.getId() + "," +
data.getType());
+                callback.complete(result);
+                return;
+            }
+            CreateObjectCommand createCmd = new CreateObjectCommand(data.getUri());
+            CreateObjectAnswer answer = (CreateObjectAnswer)ep.sendMessage(createCmd);
+            if (answer.getResult()) {
+                //update imagestorevo
+               
+                result = new CreateCmdResult(answer.getPath(), answer.getSize());
+            } else {
+                result.setResult(answer.getDetails());
+            }
+            
+        }
+        
+        callback.complete(result);
+    }
+
+    @Override
+    public void deleteAsync(DataObject data,
+            AsyncCompletionCallback<CommandResult> callback) {
+        CommandResult result = new CommandResult();
+        callback.complete(result);
+    }
+
+    @Override
+    public boolean canCopy(DataObject srcData, DataObject destData) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public void copyAsync(DataObject srcdata, DataObject destData,
+            AsyncCompletionCallback<CopyCommandResult> callback) {
+        // TODO Auto-generated method stub
+        
+    }
+
+	@Override
+	public void resize(DataObject data,
+			AsyncCompletionCallback<CreateCmdResult> callback) {
+		// TODO Auto-generated method stub
+		
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageDataStoreLifeCycle.java
b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageDataStoreLifeCycle.java
new file mode 100644
index 0000000..0af5afb
--- /dev/null
+++ b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageDataStoreLifeCycle.java
@@ -0,0 +1,108 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.storage.datastore.lifecycle;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
+import org.apache.cloudstack.storage.image.datastore.ImageDataStoreHelper;
+import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
+
+import com.cloud.agent.api.StoragePoolInfo;
+
+public class SampleImageDataStoreLifeCycle implements ImageDataStoreLifeCycle {
+    @Inject
+	protected ImageDataStoreDao imageStoreDao;
+	@Inject
+	ImageDataStoreHelper imageStoreHelper;
+	@Inject
+	ImageDataStoreManager imageStoreMgr;
+	public SampleImageDataStoreLifeCycle() {
+	}
+
+
+    @Override
+    public DataStore initialize(Map<String, Object> dsInfos) {
+        ImageDataStoreVO ids = imageStoreHelper.createImageDataStore(dsInfos);
+        return imageStoreMgr.getImageDataStore(ids.getId());
+    }
+
+
+    @Override
+    public boolean attachCluster(DataStore store, ClusterScope scope) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+
+    @Override
+    public boolean attachHost(DataStore store, HostScope scope,
+            StoragePoolInfo existingInfo) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+
+    @Override
+    public boolean attachZone(DataStore dataStore, ZoneScope scope) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+
+    @Override
+    public boolean dettach() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+
+    @Override
+    public boolean unmanaged() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+
+    @Override
+    public boolean maintain(DataStore store) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+
+    @Override
+    public boolean cancelMaintain(DataStore store) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+
+    @Override
+    public boolean deleteDataStore(DataStore store) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageDataStoreProvider.java
b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageDataStoreProvider.java
new file mode 100644
index 0000000..c6a8e0a
--- /dev/null
+++ b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageDataStoreProvider.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.provider;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataStoreProvider;
+import org.apache.cloudstack.storage.datastore.driver.SampleImageDataStoreDriverImpl;
+import org.apache.cloudstack.storage.datastore.lifecycle.SampleImageDataStoreLifeCycle;
+import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
+import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
+
+import com.cloud.utils.component.ComponentContext;
+
+public class SampleImageDataStoreProvider implements ImageDataStoreProvider {
+    private final String name = "sample image data store provider";
+    protected ImageDataStoreLifeCycle lifeCycle;
+    protected ImageDataStoreDriver driver;
+    @Inject
+    ImageDataStoreManager storeMgr;
+    long id;
+    String uuid;
+    @Override
+    public DataStoreLifeCycle getDataStoreLifeCycle() {
+        return lifeCycle;
+    }
+
+    @Override
+    public String getName() {
+        return this.name;
+    }
+
+    @Override
+    public boolean configure(Map<String, Object> params) {
+        lifeCycle = ComponentContext.inject(SampleImageDataStoreLifeCycle.class);
+        driver = ComponentContext.inject(SampleImageDataStoreDriverImpl.class);
+
+        storeMgr.registerDriver(this.getName(), driver);
+        return true;
+    }
+
+    @Override
+    public Set<DataStoreProviderType> getTypes() {
+        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
+        types.add(DataStoreProviderType.IMAGE);
+        return types;
+    }
+
+    @Override
+    public DataStoreDriver getDataStoreDriver() {
+        return this.driver;
+    }
+
+    @Override
+    public HypervisorHostListener getHostListener() {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackPrimaryDataStoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackPrimaryDataStoreProviderImpl.java
b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackPrimaryDataStoreProviderImpl.java
index 4d46d99..af1d0c4 100644
--- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackPrimaryDataStoreProviderImpl.java
+++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackPrimaryDataStoreProviderImpl.java
@@ -34,15 +34,15 @@ import com.cloud.utils.component.ComponentContext;
 public class CloudStackPrimaryDataStoreProviderImpl implements
         PrimaryDataStoreProvider {
 
-    private final String providerName = "ancient primary data store provider";
+    private final String providerName = "cloudstack primary data store provider";
     protected PrimaryDataStoreDriver driver;
     protected HypervisorHostListener listener;
     protected DataStoreLifeCycle lifecyle;
 
     CloudStackPrimaryDataStoreProviderImpl() {
-        
+
     }
-    
+
     @Override
     public String getName() {
         return providerName;
@@ -70,7 +70,7 @@ public class CloudStackPrimaryDataStoreProviderImpl implements
     public HypervisorHostListener getHostListener() {
         return this.listener;
     }
-    
+
     @Override
     public Set<DataStoreProviderType> getTypes() {
         Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/plugins/storage/volume/sample/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/sample/pom.xml b/plugins/storage/volume/sample/pom.xml
new file mode 100644
index 0000000..2e2fdb5
--- /dev/null
+++ b/plugins/storage/volume/sample/pom.xml
@@ -0,0 +1,56 @@
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
+  license agreements. See the NOTICE file distributed with this work for additional 
+  information regarding copyright ownership. The ASF licenses this file to 
+  you under the Apache License, Version 2.0 (the "License"); you may not use 
+  this file except in compliance with the License. You may obtain a copy of 
+  the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
+  by applicable law or agreed to in writing, software distributed under the 
+  License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
+  OF ANY KIND, either express or implied. See the License for the specific 
+  language governing permissions and limitations under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>cloud-plugin-storage-volume-sample</artifactId>
+  <name>Apache CloudStack Plugin - Storage Volume sample provider</name>
+  <parent>
+    <groupId>org.apache.cloudstack</groupId>
+    <artifactId>cloudstack-plugins</artifactId>
+    <version>4.2.0-SNAPSHOT</version>
+    <relativePath>../../../pom.xml</relativePath>
+  </parent>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-engine-storage-volume</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+      <version>${cs.mysql.version}</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <defaultGoal>install</defaultGoal>
+    <sourceDirectory>src</sourceDirectory>
+    <testSourceDirectory>test</testSourceDirectory>
+    <plugins>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <skipTests>true</skipTests>
+        </configuration>
+        <executions>
+          <execution>
+            <phase>integration-test</phase>
+            <goals>
+              <goal>test</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/driver/SamplePrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/driver/SamplePrimaryDataStoreDriverImpl.java
b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/driver/SamplePrimaryDataStoreDriverImpl.java
new file mode 100644
index 0000000..67e9843
--- /dev/null
+++ b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/driver/SamplePrimaryDataStoreDriverImpl.java
@@ -0,0 +1,249 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.storage.datastore.driver;
+
+import java.net.URISyntaxException;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
+import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.framework.async.AsyncRpcConext;
+import org.apache.cloudstack.storage.command.CreateObjectAnswer;
+import org.apache.cloudstack.storage.command.CreateObjectCommand;
+import org.apache.cloudstack.storage.command.DeleteCommand;
+import org.apache.cloudstack.storage.datastore.DataObjectManager;
+import org.apache.cloudstack.storage.endpoint.EndPointSelector;
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.storage.dao.StoragePoolHostDao;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.storage.encoding.DecodedDataObject;
+import com.cloud.utils.storage.encoding.Decoder;
+
+
+public class SamplePrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver {
+    private static final Logger s_logger = Logger.getLogger(SamplePrimaryDataStoreDriverImpl.class);
+    @Inject
+    EndPointSelector selector;
+    @Inject
+    StoragePoolHostDao storeHostDao;
+    @Inject
+    DataObjectManager dataObjMgr;
+    public SamplePrimaryDataStoreDriverImpl() {
+        
+    }
+    
+    private class CreateVolumeContext<T> extends AsyncRpcConext<T> {
+        private final DataObject volume;
+        /**
+         * @param callback
+         */
+        public CreateVolumeContext(AsyncCompletionCallback<T> callback, DataObject
volume) {
+            super(callback);
+            this.volume = volume;
+        }
+        
+        public DataObject getVolume() {
+            return this.volume;
+        }
+        
+    }
+    
+    public Void createAsyncCallback(AsyncCallbackDispatcher<SamplePrimaryDataStoreDriverImpl,
Answer> callback, CreateVolumeContext<CreateCmdResult> context) {
+        CreateCmdResult result = null;
+        CreateObjectAnswer volAnswer = (CreateObjectAnswer) callback.getResult();
+        if (volAnswer.getResult()) {
+            result = new CreateCmdResult(volAnswer.getPath(), volAnswer.getSize());
+        } else {
+            result = new CreateCmdResult("", null);
+            result.setResult(volAnswer.getDetails());
+        }
+        
+        context.getParentCallback().complete(result);
+        return null;
+    }
+  
+    @Override
+    public void deleteAsync(DataObject vo, AsyncCompletionCallback<CommandResult> callback)
{
+        DeleteCommand cmd = new DeleteCommand(vo.getUri());
+    
+        EndPoint ep = selector.select(vo);
+        AsyncRpcConext<CommandResult> context = new AsyncRpcConext<CommandResult>(callback);
+        AsyncCallbackDispatcher<SamplePrimaryDataStoreDriverImpl, Answer> caller =
AsyncCallbackDispatcher.create(this);
+        caller.setCallback(caller.getTarget().deleteCallback(null, null))
+            .setContext(context);
+        ep.sendMessageAsync(cmd, caller);
+    }
+    
+    public Void deleteCallback(AsyncCallbackDispatcher<SamplePrimaryDataStoreDriverImpl,
Answer> callback, AsyncRpcConext<CommandResult> context) {
+        CommandResult result = new CommandResult();
+        Answer answer = callback.getResult();
+        if (!answer.getResult()) {
+            result.setResult(answer.getDetails());
+        }
+        context.getParentCallback().complete(result);
+        return null;
+    }
+    /*
+    private class CreateVolumeFromBaseImageContext<T> extends AsyncRpcConext<T>
{
+        private final VolumeObject volume;
+      
+        public CreateVolumeFromBaseImageContext(AsyncCompletionCallback<T> callback,
VolumeObject volume) {
+            super(callback);
+            this.volume = volume;
+        }
+        
+        public VolumeObject getVolume() {
+            return this.volume;
+        }
+        
+    }
+
+    @Override
+    public void createVolumeFromBaseImageAsync(VolumeObject volume, TemplateInfo template,
AsyncCompletionCallback<CommandResult> callback) {
+        VolumeTO vol = this.dataStore.getVolumeTO(volume);
+        List<EndPoint> endPoints = this.dataStore.getEndPoints();
+        EndPoint ep = endPoints.get(0);
+        String templateUri = template.getDataStore().grantAccess(template, ep);
+        CreateVolumeFromBaseImageCommand cmd = new CreateVolumeFromBaseImageCommand(vol,
templateUri);
+        
+        CreateVolumeFromBaseImageContext<CommandResult> context = new CreateVolumeFromBaseImageContext<CommandResult>(callback,
volume);
+        AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> caller =
AsyncCallbackDispatcher.create(this);
+        caller.setContext(context)
+            .setCallback(caller.getTarget().createVolumeFromBaseImageAsyncCallback(null,
null));
+
+        ep.sendMessageAsync(cmd, caller);
+    }*/
+    /*
+    public Object createVolumeFromBaseImageAsyncCallback(AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl,
Answer> callback, CreateVolumeFromBaseImageContext<CommandResult> context) {
+        CreateVolumeAnswer answer = (CreateVolumeAnswer)callback.getResult();
+        CommandResult result = new CommandResult();
+        if (answer == null || answer.getDetails() != null) {
+            result.setSucess(false);
+            if (answer != null) {
+                result.setResult(answer.getDetails());
+            }
+        } else {
+            result.setSucess(true);
+            VolumeObject volume = context.getVolume();
+            volume.setPath(answer.getVolumeUuid());
+        }
+        AsyncCompletionCallback<CommandResult> parentCall = context.getParentCallback();
+        parentCall.complete(result);
+        return null;
+    }*/
+
+    @Override
+    public void createAsync(DataObject vol,
+            AsyncCompletionCallback<CreateCmdResult> callback) {
+        EndPoint ep = selector.select(vol);
+        CreateObjectCommand createCmd = new CreateObjectCommand(vol.getUri());
+        
+        CreateVolumeContext<CreateCmdResult> context = new CreateVolumeContext<CreateCmdResult>(callback,
vol);
+        AsyncCallbackDispatcher<SamplePrimaryDataStoreDriverImpl, Answer> caller =
AsyncCallbackDispatcher.create(this);
+        caller.setContext(context)
+            .setCallback(caller.getTarget().createAsyncCallback(null, null));
+
+        ep.sendMessageAsync(createCmd, caller);
+    }
+
+    @Override
+    public String grantAccess(DataObject object, EndPoint ep) {
+        //StoragePoolHostVO poolHost = storeHostDao.findByPoolHost(object.getDataStore().getId(),
ep.getId());
+        
+        String uri = object.getUri();
+        try {
+            DecodedDataObject obj = Decoder.decode(uri);
+            if (obj.getPath() == null) {
+                //create an obj
+                EndPoint newEp = selector.select(object);
+                CreateObjectCommand createCmd = new CreateObjectCommand(uri);
+                CreateObjectAnswer answer = (CreateObjectAnswer)ep.sendMessage(createCmd);
+                if (answer.getResult()) {
+                    dataObjMgr.update(object, answer.getPath(), answer.getSize());
+                } else {
+                    s_logger.debug("failed to create object" + answer.getDetails());
+                    throw new CloudRuntimeException("failed to create object" + answer.getDetails());
+                }
+            }
+            
+            return object.getUri();
+        } catch (URISyntaxException e) {
+           throw new CloudRuntimeException("uri parsed error", e);
+        }
+    }
+
+    @Override
+    public boolean revokeAccess(DataObject vol, EndPoint ep) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public Set<DataObject> listObjects(DataStore store) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void revertSnapshot(SnapshotInfo snapshot,
+            AsyncCompletionCallback<CommandResult> callback) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    
+
+    @Override
+    public boolean canCopy(DataObject srcData, DataObject destData) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public void copyAsync(DataObject srcdata, DataObject destData,
+            AsyncCompletionCallback<CopyCommandResult> callback) {
+        // TODO Auto-generated method stub
+        
+    }
+
+	@Override
+	public void resize(DataObject data,
+			AsyncCompletionCallback<CreateCmdResult> callback) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public void takeSnapshot(SnapshotInfo snapshot,
+			AsyncCompletionCallback<CreateCmdResult> callback) {
+		// TODO Auto-generated method stub
+		
+	}
+   
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java
b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java
new file mode 100644
index 0000000..15bf8c1
--- /dev/null
+++ b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SamplePrimaryDataStoreLifeCycleImpl.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.lifecycle;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
+import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreCmd;
+import org.apache.cloudstack.storage.command.CreatePrimaryDataStoreCmd;
+import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+import org.apache.cloudstack.storage.endpoint.EndPointSelector;
+import org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper;
+
+import com.cloud.agent.api.StoragePoolInfo;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.StoragePoolStatus;
+
+public class SamplePrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLifeCycle {
+    @Inject
+    EndPointSelector selector;
+    @Inject
+    PrimaryDataStoreDao dataStoreDao;
+    @Inject
+    HostDao hostDao;
+    @Inject
+    PrimaryDataStoreHelper primaryStoreHelper;
+    @Inject
+    PrimaryDataStoreProviderManager providerMgr;
+    public SamplePrimaryDataStoreLifeCycleImpl() {
+    }
+    
+    @Override
+    public DataStore initialize(Map<String, Object> dsInfos) {
+        
+        DataStore store = primaryStoreHelper.createPrimaryDataStore(null); 
+        return providerMgr.getPrimaryDataStore(store.getId());
+    }
+
+    protected void attachCluster(DataStore store) {
+        //send down AttachPrimaryDataStoreCmd command to all the hosts in the cluster
+        List<EndPoint> endPoints = selector.selectAll(store);
+        CreatePrimaryDataStoreCmd createCmd = new CreatePrimaryDataStoreCmd(store.getUri());
+        EndPoint ep = endPoints.get(0);
+        HostVO host = hostDao.findById(ep.getId());
+        if (host.getHypervisorType() == HypervisorType.XenServer) {
+            ep.sendMessage(createCmd);
+        }
+        
+        endPoints.get(0).sendMessage(createCmd);
+        AttachPrimaryDataStoreCmd cmd = new AttachPrimaryDataStoreCmd(store.getUri());
+        for (EndPoint endp : endPoints) {
+            endp.sendMessage(cmd);
+        }
+    }
+    
+    @Override
+    public boolean attachCluster(DataStore dataStore, ClusterScope scope) {
+        StoragePoolVO dataStoreVO = dataStoreDao.findById(dataStore.getId());
+        dataStoreVO.setDataCenterId(scope.getZoneId());
+        dataStoreVO.setPodId(scope.getPodId());
+        dataStoreVO.setClusterId(scope.getScopeId());
+        dataStoreVO.setStatus(StoragePoolStatus.Attaching);
+        dataStoreVO.setScope(scope.getScopeType());
+        dataStoreDao.update(dataStoreVO.getId(), dataStoreVO);
+        
+        
+        attachCluster(dataStore);
+        
+        dataStoreVO = dataStoreDao.findById(dataStore.getId());
+        dataStoreVO.setStatus(StoragePoolStatus.Up);
+        dataStoreDao.update(dataStoreVO.getId(), dataStoreVO);
+        
+        return true;
+    }
+
+    @Override
+    public boolean dettach() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean unmanaged() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean attachZone(DataStore dataStore, ZoneScope scope) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean attachHost(DataStore store, HostScope scope,
+            StoragePoolInfo existingInfo) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean maintain(DataStore store) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean cancelMaintain(DataStore store) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean deleteDataStore(DataStore store) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java
b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java
new file mode 100644
index 0000000..8f6cb1b
--- /dev/null
+++ b/plugins/storage/volume/sample/src/org/apache/cloudstack/storage/datastore/provider/SamplePrimaryDatastoreProviderImpl.java
@@ -0,0 +1,83 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.storage.datastore.provider;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
+import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider.DataStoreProviderType;
+import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
+import org.apache.cloudstack.storage.datastore.driver.SamplePrimaryDataStoreDriverImpl;
+import org.apache.cloudstack.storage.datastore.lifecycle.SamplePrimaryDataStoreLifeCycleImpl;
+
+import com.cloud.utils.component.ComponentContext;
+
+
+public class SamplePrimaryDatastoreProviderImpl implements PrimaryDataStoreProvider {
+    private final String providerName = "sample primary data store provider";
+    protected PrimaryDataStoreDriver driver;
+    protected HypervisorHostListener listener;
+    @Inject
+    PrimaryDataStoreProviderManager storeMgr;
+
+    protected DataStoreLifeCycle lifecyle;
+    protected String uuid;
+    protected long id;
+    @Override
+    public String getName() {
+        return providerName;
+    }
+
+    @Override
+    public DataStoreLifeCycle getDataStoreLifeCycle() {
+        return this.lifecyle;
+    }
+
+    @Override
+    public boolean configure(Map<String, Object> params) {
+        lifecyle = ComponentContext.inject(SamplePrimaryDataStoreLifeCycleImpl.class);
+        driver = ComponentContext.inject(SamplePrimaryDataStoreDriverImpl.class);
+        listener = ComponentContext.inject(DefaultHostListener.class);
+        return true;
+    }
+
+    @Override
+    public PrimaryDataStoreDriver getDataStoreDriver() {
+        return this.driver;
+    }
+
+    @Override
+    public HypervisorHostListener getHostListener() {
+        return this.listener;
+    }
+
+    @Override
+    public Set<DataStoreProviderType> getTypes() {
+        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
+        types.add(DataStoreProviderType.PRIMARY);
+        return types;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
index 650cac8..39adf9f 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidfirePrimaryDataStoreProvider.java
@@ -16,24 +16,60 @@
 // under the License.
 package org.apache.cloudstack.storage.datastore.provider;
 
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
 import org.springframework.stereotype.Component;
 
 @Component
-public class SolidfirePrimaryDataStoreProvider extends
-	DefaultPrimaryDatastoreProviderImpl {
-	private final String name = "Solidfre Primary Data Store Provider";
+public class SolidfirePrimaryDataStoreProvider implements PrimaryDataStoreProvider {
+	private final String name = "Solidfire Primary Data Store Provider";
 
 
 	public SolidfirePrimaryDataStoreProvider() {
-	    
-		
+
+
 		// TODO Auto-generated constructor stub
 	}
-	
+
 	@Override
 	public String getName() {
 		return name;
 	}
-	
-	
+
+    @Override
+    public DataStoreLifeCycle getDataStoreLifeCycle() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public DataStoreDriver getDataStoreDriver() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public HypervisorHostListener getHostListener() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public boolean configure(Map<String, Object> params) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public Set<DataStoreProviderType> getTypes() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+
 }


Mime
View raw message