You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mt...@apache.org on 2014/07/11 05:23:53 UTC

git commit: updated refs/heads/master to 8bd9e78

Repository: cloudstack
Updated Branches:
  refs/heads/master ab8036b76 -> 8bd9e7807


Adding SolidFire API plug-in


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8bd9e780
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8bd9e780
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8bd9e780

Branch: refs/heads/master
Commit: 8bd9e780717dad4d2f4451e4b681f701c45f2793
Parents: ab8036b
Author: Vania Xu <vx...@vxu-lt.users.solidfire.net>
Authored: Thu Jul 10 11:36:26 2014 -0600
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Thu Jul 10 21:22:47 2014 -0600

----------------------------------------------------------------------
 client/pom.xml                                  |  5 ++
 .../findbugsExcludeFilter.xml                   | 25 ++++++
 plugins/api/solidfire-intg-test/pom.xml         | 50 ++++++++++++
 .../solidfire-intg-test/module.properties       | 18 +++++
 .../spring-solidfire-intg-test-context.xml      | 32 ++++++++
 .../solidfire/GetSolidFireAccountIdCmd.java     | 83 ++++++++++++++++++++
 .../response/ApiSolidFireAccountIdResponse.java | 37 +++++++++
 .../solidfire/ApiSolidFireService.java          | 29 +++++++
 .../solidfire/ApiSolidFireServiceImpl.java      | 76 ++++++++++++++++++
 plugins/pom.xml                                 |  1 +
 .../storage/datastore/util/SolidFireUtil.java   |  2 +-
 11 files changed, 357 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bd9e780/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index 29fef4f..46933d9 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -331,6 +331,11 @@
       <artifactId>cloud-plugin-host-anti-affinity</artifactId>
       <version>${project.version}</version>
     </dependency>
+    <dependency>
+        <groupId>org.apache.cloudstack</groupId>
+        <artifactId>cloud-plugin-api-solidfire-intg-test</artifactId>
+        <version>${project.version}</version>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bd9e780/plugins/api/solidfire-intg-test/findbugsExcludeFilter.xml
----------------------------------------------------------------------
diff --git a/plugins/api/solidfire-intg-test/findbugsExcludeFilter.xml b/plugins/api/solidfire-intg-test/findbugsExcludeFilter.xml
new file mode 100644
index 0000000..d372850
--- /dev/null
+++ b/plugins/api/solidfire-intg-test/findbugsExcludeFilter.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<FindBugsFilter>
+
+
+</FindBugsFilter>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bd9e780/plugins/api/solidfire-intg-test/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/api/solidfire-intg-test/pom.xml b/plugins/api/solidfire-intg-test/pom.xml
new file mode 100644
index 0000000..0707461
--- /dev/null
+++ b/plugins/api/solidfire-intg-test/pom.xml
@@ -0,0 +1,50 @@
+<!--
+  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-api-solidfire-intg-test</artifactId>
+  <name>Apache CloudStack Plugin - API SolidFire</name>
+  <parent>
+    <groupId>org.apache.cloudstack</groupId>
+    <artifactId>cloudstack-plugins</artifactId>
+    <version>4.5.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+  <dependencies>
+      <dependency>
+          <groupId>org.apache.cloudstack</groupId>
+          <artifactId>cloud-plugin-storage-volume-solidfire</artifactId>
+          <version>${project.version}</version>
+      </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <argLine>-Xmx1024m</argLine>
+          <excludes>
+            <exclude>org/apache/cloudstack/solidfire/integration/*</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bd9e780/plugins/api/solidfire-intg-test/resources/META-INF/cloudstack/solidfire-intg-test/module.properties
----------------------------------------------------------------------
diff --git a/plugins/api/solidfire-intg-test/resources/META-INF/cloudstack/solidfire-intg-test/module.properties b/plugins/api/solidfire-intg-test/resources/META-INF/cloudstack/solidfire-intg-test/module.properties
new file mode 100644
index 0000000..a6460b9
--- /dev/null
+++ b/plugins/api/solidfire-intg-test/resources/META-INF/cloudstack/solidfire-intg-test/module.properties
@@ -0,0 +1,18 @@
+# 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.
+name=solidfire-intg-test
+parent=api
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bd9e780/plugins/api/solidfire-intg-test/resources/META-INF/cloudstack/solidfire-intg-test/spring-solidfire-intg-test-context.xml
----------------------------------------------------------------------
diff --git a/plugins/api/solidfire-intg-test/resources/META-INF/cloudstack/solidfire-intg-test/spring-solidfire-intg-test-context.xml b/plugins/api/solidfire-intg-test/resources/META-INF/cloudstack/solidfire-intg-test/spring-solidfire-intg-test-context.xml
new file mode 100644
index 0000000..1bab734
--- /dev/null
+++ b/plugins/api/solidfire-intg-test/resources/META-INF/cloudstack/solidfire-intg-test/spring-solidfire-intg-test-context.xml
@@ -0,0 +1,32 @@
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+                      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+                      http://www.springframework.org/schema/context
+                      http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+                      >
+
+      <bean id="apiSolidFireServiceImpl" class="org.apache.cloudstack.solidfire.ApiSolidFireServiceImpl"/>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bd9e780/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireAccountIdCmd.java
----------------------------------------------------------------------
diff --git a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireAccountIdCmd.java b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireAccountIdCmd.java
new file mode 100644
index 0000000..f4c0076
--- /dev/null
+++ b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireAccountIdCmd.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.api.command.user.solidfire;
+
+import com.cloud.user.Account;
+import com.cloud.user.dao.AccountDao;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.ApiSolidFireAccountIdResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.solidfire.ApiSolidFireService;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+
+@APICommand(name = "getSolidFireAccountId", responseObject = ApiSolidFireAccountIdResponse.class, description = "Get SolidFire Account ID",
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class GetSolidFireAccountIdCmd extends BaseCmd {
+    private static final Logger s_logger = Logger.getLogger(GetSolidFireAccountIdCmd.class.getName());
+    private static final String s_name = "getsolidfireaccountidresponse";
+
+    @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.STRING, description = "CloudStack Account UUID", required = true)
+    private String accountUuid;
+    @Parameter(name = ApiConstants.STORAGE_ID, type = CommandType.STRING, description = "Storage Pool UUID", required = true)
+    private String storagePoolUuid;
+
+    @Inject private ApiSolidFireService _apiSolidFireService;
+    @Inject private AccountDao _accountDao;
+    @Inject private PrimaryDataStoreDao _storagePoolDao;
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Account account = CallContext.current().getCallingAccount();
+
+        if (account != null) {
+            return account.getId();
+        }
+
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public void execute() {
+        Account account = _accountDao.findByUuid(accountUuid);
+        StoragePoolVO storagePool = _storagePoolDao.findByUuid(storagePoolUuid);
+
+        ApiSolidFireAccountIdResponse response = _apiSolidFireService.getSolidFireAccountId(account.getId(), storagePool.getId());
+
+        response.setResponseName(getCommandName());
+        response.setObjectName("apisolidfireaccountid");
+
+        this.setResponseObject(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bd9e780/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireAccountIdResponse.java
----------------------------------------------------------------------
diff --git a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireAccountIdResponse.java b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireAccountIdResponse.java
new file mode 100644
index 0000000..ad77c74
--- /dev/null
+++ b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireAccountIdResponse.java
@@ -0,0 +1,37 @@
+// 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.api.response;
+
+import com.cloud.serializer.Param;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.apache.cloudstack.api.BaseResponse;
+
+public class ApiSolidFireAccountIdResponse extends BaseResponse {
+    @SerializedName("solidFireAccountId")
+    @Param(description = "SolidFire Account ID")
+    private long solidFireAccountId;
+
+    public ApiSolidFireAccountIdResponse(long sfAccountId) {
+        solidFireAccountId = sfAccountId;
+    }
+
+    public long getSolidFireAccountId() {
+        return solidFireAccountId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bd9e780/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireService.java
----------------------------------------------------------------------
diff --git a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireService.java b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireService.java
new file mode 100644
index 0000000..2f01cfd
--- /dev/null
+++ b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireService.java
@@ -0,0 +1,29 @@
+// 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.solidfire;
+
+import com.cloud.utils.component.PluggableService;
+
+import org.apache.cloudstack.api.response.ApiSolidFireAccountIdResponse;
+
+/**
+ * Provide API for SolidFire integration tests
+ *
+ */
+public interface ApiSolidFireService extends PluggableService {
+    public ApiSolidFireAccountIdResponse getSolidFireAccountId(Long csAccountId, Long storagePoolId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bd9e780/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl.java
----------------------------------------------------------------------
diff --git a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl.java b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl.java
new file mode 100644
index 0000000..bbb485c
--- /dev/null
+++ b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl.java
@@ -0,0 +1,76 @@
+// 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.solidfire;
+
+import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+import org.apache.cloudstack.acl.APIChecker;
+import org.apache.cloudstack.storage.datastore.util.SolidFireUtil;
+import org.apache.cloudstack.api.response.ApiSolidFireAccountIdResponse;
+import org.apache.cloudstack.api.command.user.solidfire.GetSolidFireAccountIdCmd;
+import org.springframework.stereotype.Component;
+
+import com.cloud.exception.PermissionDeniedException;
+import com.cloud.user.AccountDetailsDao;
+import com.cloud.user.AccountDetailVO;
+import com.cloud.user.User;
+import com.cloud.utils.component.AdapterBase;
+
+@Component
+@Local(value = APIChecker.class)
+public class ApiSolidFireServiceImpl extends AdapterBase implements APIChecker, ApiSolidFireService {
+    private static final Logger s_logger = Logger.getLogger(ApiSolidFireServiceImpl.class);
+
+    @Inject
+    private AccountDetailsDao _accountDetailsDao;
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+        super.configure(name, params);
+
+        return true;
+    }
+
+    @Override
+    public ApiSolidFireAccountIdResponse getSolidFireAccountId(Long csAccountId, Long storagePoolId) {
+        AccountDetailVO accountDetail = _accountDetailsDao.findDetail(csAccountId, SolidFireUtil.getAccountKey(storagePoolId));
+        String sfAccountId = accountDetail.getValue();
+
+        return new ApiSolidFireAccountIdResponse(Long.parseLong(sfAccountId));
+    }
+
+    @Override
+    public boolean checkAccess(User user, String apiCommandName) throws PermissionDeniedException {
+        return true;
+    }
+
+    @Override
+    public List<Class<?>> getCommands() {
+        List<Class<?>> cmdList = new ArrayList<Class<?>>();
+
+        cmdList.add(GetSolidFireAccountIdCmd.class);
+
+        return cmdList;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bd9e780/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index b5e6a61..802e2ea 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -38,6 +38,7 @@
   </build>
   <modules>
     <module>api/rate-limit</module>
+    <module>api/solidfire-intg-test</module>
     <module>api/discovery</module>
     <module>acl/static-role-based</module>
     <module>affinity-group-processors/host-anti-affinity</module>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bd9e780/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java
index 7c09d85..307ddbc 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java
@@ -360,7 +360,7 @@ public class SolidFireUtil {
         return "sfVolumeAccessGroup_" + storagePoolId;
     }
 
-    private static String getAccountKey(long storagePoolId) {
+    public static String getAccountKey(long storagePoolId) {
         return SolidFireUtil.ACCOUNT_ID + "_" + storagePoolId;
     }