You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ml...@apache.org on 2014/03/08 01:22:34 UTC

[01/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Repository: cloudstack
Updated Branches:
  refs/heads/resize-root 4a21da6b7 -> 0eb996735


Add hover states for nav icons


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

Branch: refs/heads/resize-root
Commit: 4df897f4abb5d68c73b2b482679eb0dd1f2a76be
Parents: 5a8d165
Author: Brian Federle <br...@citrix.com>
Authored: Tue Mar 4 16:03:38 2014 -0800
Committer: Brian Federle <br...@citrix.com>
Committed: Tue Mar 4 16:04:17 2014 -0800

----------------------------------------------------------------------
 ui/css/cloudstack3.css |  98 +++++++++++++++++++++++++++++++++++++-------
 ui/images/icons.png    | Bin 55332 -> 61164 bytes
 ui/images/sprites.png  | Bin 207785 -> 212515 bytes
 3 files changed, 83 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4df897f4/ui/css/cloudstack3.css
----------------------------------------------------------------------
diff --git a/ui/css/cloudstack3.css b/ui/css/cloudstack3.css
index 9273eba..162f77b 100644
--- a/ui/css/cloudstack3.css
+++ b/ui/css/cloudstack3.css
@@ -2640,63 +2640,127 @@ div.detail-group.actions td {
   margin-right: -14px;
 }
 
-#navigation ul li.last.active,
-#navigation ul li.last:hover {
-}
-
 /*Navigation icons*/
 #navigation ul li.dashboard span.icon,
 #navigation ul li.dashboard-user span.icon {
   background-position: -14px -18px;
 }
 
+#navigation ul li.dashboard:hover span.icon,
+#navigation ul li.dashboard-user:hover span.icon span.icon,
+#navigation ul li.dashboard.active span.icon,
+#navigation ul li.dashboard-user.active span.icon span.icon {
+  background-position: -23px -687px;
+}
+
 #navigation ul li.instances span.icon {
-  background-position: -73px -23px;
+  background-position: -73px -18px;
+}
+
+#navigation ul li.instances.active span.icon,
+#navigation ul li.instances:hover span.icon {
+  background-position: -82px -686px;
 }
 
 #navigation ul li.affinityGroups span.icon {
   background-position: -73px -87px;
 }
 
+#navigation ul li.affinityGroups.active span.icon,
+#navigation ul li.affinityGroups:hover span.icon {
+  background-position: -82px -755px;
+}
+
 #navigation ul li.storage span.icon {
-  background-position: -127px -23px;
+  background-position: -127px -19px;
+}
+
+#navigation ul li.storage.active span.icon,
+#navigation ul li.storage:hover span.icon {
+  background-position: -137px -687px;
 }
 
 #navigation ul li.network span.icon {
-  background-position: -180px -23px;
+  background-position: -180px -20px;
+}
+
+#navigation ul li.network.active span.icon,
+#navigation ul li.network:hover span.icon {
+  background-position: -189px -690px;
 }
 
 #navigation ul li.templates span.icon {
-  background-position: -233px -23px;
+  background-position: -233px -21px;
+}
+
+#navigation ul li.templates.active span.icon,
+#navigation ul li.templates:hover span.icon {
+  background-position: -242px -690px;
 }
 
 #navigation ul li.projects span.icon {
-  background-position: -294px -23px;
+  background-position: -294px -21px;
+}
+
+#navigation ul li.projects.active span.icon,
+#navigation ul li.projects:hover span.icon {
+  background-position: -303px -690px;
 }
 
 #navigation ul li.events span.icon {
   background-position: -351px -23px;
 }
 
+#navigation ul li.events.active span.icon,
+#navigation ul li.events:hover span.icon {
+  background-position: -359px -692px;
+}
+
 #navigation ul li.configuration span.icon {
-  background-position: -400px -24px;
+  background-position: -401px -21px;
+}
+
+#navigation ul li.configuration.active span.icon,
+#navigation ul li.configuration:hover span.icon {
+  background-position: -410px -690px;
 }
 
 #navigation ul li.global-settings span.icon {
   background-image: url(../images/sprites.png);
-  background-position: -141px -241px;
+  background-position: -143px -240px;
+}
+
+#navigation ul li.global-settings.active span.icon,
+#navigation ul li.global-settings:hover span.icon {
+  background-image: url(../images/sprites.png);
+  background-position: -366px -239px;
 }
 
 #navigation ul li.accounts span.icon {
-  background-position: -458px -24px;
+  background-position: -458px -19px;
+}
+
+#navigation ul li.accounts.active span.icon,
+#navigation ul li.accounts:hover span.icon {
+  background-position: -467px -688px;
 }
 
 #navigation ul li.system span.icon {
   background-position: -569px -24px;
 }
 
+#navigation ul li.system.active span.icon,
+#navigation ul li.system:hover span.icon {
+  background-position: -578px -692px;
+}
+
 #navigation ul li.domains span.icon {
-  background-position: -519px -24px;
+  background-position: -520px -21px;
+}
+
+#navigation ul li.domains.active span.icon,
+#navigation ul li.domains:hover span.icon {
+  background-position: -529px -690px;
 }
 
 #navigation ul li.plugins span.icon {
@@ -2704,7 +2768,12 @@ div.detail-group.actions td {
 }
 
 #navigation ul li.regions span.icon {
-  background: url(../images/sprites.png) no-repeat -141px -381px;
+  background: url(../images/sprites.png) no-repeat -141px -379px;
+}
+
+#navigation ul li.regions.active span.icon,
+#navigation ul li.regions:hover span.icon {
+  background: url(../images/sprites.png) no-repeat -365px -377px;
 }
 
 /*Browser*/
@@ -7584,7 +7653,6 @@ label.error {
 }
 
 #navigation ul li.last.active {
-  height: 52px;
 }
 
 .detail-group table tbody {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4df897f4/ui/images/icons.png
----------------------------------------------------------------------
diff --git a/ui/images/icons.png b/ui/images/icons.png
index fe348c7..fd1049d 100644
Binary files a/ui/images/icons.png and b/ui/images/icons.png differ

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4df897f4/ui/images/sprites.png
----------------------------------------------------------------------
diff --git a/ui/images/sprites.png b/ui/images/sprites.png
index 0070bf9..ca7f470 100644
Binary files a/ui/images/sprites.png and b/ui/images/sprites.png differ


[41/50] [abbrv] Dispatcher corrections, refactoring and tests

Posted by ml...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/src/com/cloud/api/dispatch/ParamGenericValidationWorker.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/dispatch/ParamGenericValidationWorker.java b/server/src/com/cloud/api/dispatch/ParamGenericValidationWorker.java
new file mode 100644
index 0000000..0c829e8
--- /dev/null
+++ b/server/src/com/cloud/api/dispatch/ParamGenericValidationWorker.java
@@ -0,0 +1,103 @@
+// 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 com.cloud.api.dispatch;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.log4j.Logger;
+
+/**
+ * This worker validates parameters in a generic way, by using annotated
+ * restrictions without involving the {@Link BaseCmd}. This worker doesn't
+ * know or care about the meaning of the parameters and that's why we can
+ * have it out of the {@Link BaseCmd}
+ *
+ * @author afornie
+ */
+public class ParamGenericValidationWorker implements DispatchWorker {
+
+    protected static Logger s_logger = Logger.getLogger(ParamGenericValidationWorker.class.getName());
+
+    protected static List<String> defaultParamNames = new ArrayList<String>();
+
+    static {
+        defaultParamNames.add(ApiConstants.CTX_START_EVENT_ID);
+        defaultParamNames.add(ApiConstants.COMMAND);
+        defaultParamNames.add(ApiConstants.CMD_EVENT_TYPE);
+        defaultParamNames.add(ApiConstants.USERNAME);
+        defaultParamNames.add(ApiConstants.USER_ID);
+        defaultParamNames.add(ApiConstants.PASSWORD);
+        defaultParamNames.add(ApiConstants.DOMAIN);
+        defaultParamNames.add(ApiConstants.DOMAIN_ID);
+        defaultParamNames.add(ApiConstants.DOMAIN__ID);
+        defaultParamNames.add(ApiConstants.SESSIONKEY);
+        defaultParamNames.add(ApiConstants.RESPONSE);
+        defaultParamNames.add(ApiConstants.PAGE);
+        defaultParamNames.add(ApiConstants.USER_API_KEY);
+        defaultParamNames.add(ApiConstants.API_KEY);
+        defaultParamNames.add(ApiConstants.PAGE_SIZE);
+        defaultParamNames.add(ApiConstants.HTTPMETHOD);
+        defaultParamNames.add(ApiConstants.SIGNATURE);
+        defaultParamNames.add(ApiConstants.CTX_ACCOUNT_ID);
+        defaultParamNames.add(ApiConstants.CTX_START_EVENT_ID);
+        defaultParamNames.add(ApiConstants.CTX_USER_ID);
+        defaultParamNames.add("_");
+    }
+
+    protected static final String ERROR_MSG_PREFIX = "Unknown parameters :";
+
+    @SuppressWarnings("rawtypes")
+    @Override
+    public void handle(final DispatchTask task) {
+        final BaseCmd cmd = task.getCmd();
+        final Map params = task.getParams();
+
+        final List<String> expectedParamNames = getParamNamesForCommand(cmd);
+
+        final StringBuilder errorMsg = new StringBuilder(ERROR_MSG_PREFIX);
+        boolean foundUnknownParam = false;
+        for (final Object paramName : params.keySet()) {
+            if (!expectedParamNames.contains(paramName)) {
+                errorMsg.append(" ").append(paramName);
+                foundUnknownParam= true;
+            }
+        }
+
+        if (foundUnknownParam) {
+            s_logger.warn(String.format("Received unknown parameters for command %s. %s", cmd.getActualCommandName(), errorMsg));
+        }
+    }
+
+    protected List<String> getParamNamesForCommand(final BaseCmd cmd) {
+        final List<String> paramNames = new ArrayList<String>();
+        // The expected param names are all the specific for the current command class ...
+        for (final Field field : cmd.getParamFields()) {
+            final Parameter parameterAnnotation = field.getAnnotation(Parameter.class);
+            paramNames.add(parameterAnnotation.name());
+        }
+        // ... plus the default ones
+        paramNames.addAll(defaultParamNames);
+        return paramNames;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/src/com/cloud/api/dispatch/ParamProcessWorker.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/dispatch/ParamProcessWorker.java b/server/src/com/cloud/api/dispatch/ParamProcessWorker.java
new file mode 100644
index 0000000..e9bdd8b
--- /dev/null
+++ b/server/src/com/cloud/api/dispatch/ParamProcessWorker.java
@@ -0,0 +1,428 @@
+// 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 com.cloud.api.dispatch;
+
+import static org.apache.commons.lang.StringUtils.isNotBlank;
+
+import java.lang.reflect.Field;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.acl.InfrastructureEntity;
+import org.apache.cloudstack.acl.SecurityChecker.AccessType;
+import org.apache.cloudstack.api.ACL;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.EntityReference;
+import org.apache.cloudstack.api.InternalIdentity;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.BaseCmd.CommandType;
+import org.apache.cloudstack.api.command.admin.resource.ArchiveAlertsCmd;
+import org.apache.cloudstack.api.command.admin.resource.DeleteAlertsCmd;
+import org.apache.cloudstack.api.command.user.event.ArchiveEventsCmd;
+import org.apache.cloudstack.api.command.user.event.DeleteEventsCmd;
+import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
+import org.apache.cloudstack.context.CallContext;
+
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.user.Account;
+import com.cloud.user.AccountManager;
+import com.cloud.utils.DateUtil;
+import com.cloud.utils.db.EntityManager;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+public class ParamProcessWorker implements DispatchWorker {
+
+    private static final Logger s_logger = Logger.getLogger(ParamProcessWorker.class.getName());
+
+    @Inject
+    protected AccountManager _accountMgr;
+
+    @Inject
+    protected EntityManager _entityMgr;
+
+    @Override
+    public void handle(final DispatchTask task) {
+        processParameters(task.getCmd(), task.getParams());
+    }
+
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    public void processParameters(final BaseCmd cmd, final Map params) {
+        final Map<Object, AccessType> entitiesToAccess = new HashMap<Object, AccessType>();
+
+        final List<Field> cmdFields = cmd.getParamFields();
+
+        for (final Field field : cmdFields) {
+            final Parameter parameterAnnotation = field.getAnnotation(Parameter.class);
+            final Object paramObj = params.get(parameterAnnotation.name());
+            if (paramObj == null) {
+                if (parameterAnnotation.required()) {
+                    throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to execute API command " +
+                        cmd.getCommandName().substring(0, cmd.getCommandName().length() - 8) +
+                        " due to missing parameter " + parameterAnnotation.name());
+                }
+                continue;
+            }
+
+            // marshall the parameter into the correct type and set the field value
+            try {
+                setFieldValue(field, cmd, paramObj, parameterAnnotation);
+            } catch (final IllegalArgumentException argEx) {
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Unable to execute API command " + cmd.getCommandName() + " due to invalid value " + paramObj + " for parameter " +
+                            parameterAnnotation.name());
+                }
+                throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to execute API command " +
+                    cmd.getCommandName().substring(0, cmd.getCommandName().length() - 8) + " due to invalid value " + paramObj + " for parameter " +
+                    parameterAnnotation.name());
+            } catch (final ParseException parseEx) {
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Invalid date parameter " + paramObj + " passed to command " + cmd.getCommandName().substring(0, cmd.getCommandName().length() - 8));
+                }
+                throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to parse date " + paramObj + " for command " +
+                    cmd.getCommandName().substring(0, cmd.getCommandName().length() - 8) + ", please pass dates in the format mentioned in the api documentation");
+            } catch (final InvalidParameterValueException invEx) {
+                throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to execute API command " +
+                    cmd.getCommandName().substring(0, cmd.getCommandName().length() - 8) + " due to invalid value. " + invEx.getMessage());
+            } catch (final CloudRuntimeException cloudEx) {
+                s_logger.error("CloudRuntimeException", cloudEx);
+                // FIXME: Better error message? This only happens if the API command is not executable, which typically
+                //means
+                // there was
+                // and IllegalAccessException setting one of the parameters.
+                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Internal error executing API command " +
+                    cmd.getCommandName().substring(0, cmd.getCommandName().length() - 8));
+            }
+
+            //check access on the resource this field points to
+            try {
+                final ACL checkAccess = field.getAnnotation(ACL.class);
+                final CommandType fieldType = parameterAnnotation.type();
+
+                if (checkAccess != null) {
+                    // Verify that caller can perform actions in behalf of vm owner
+                    //acumulate all Controlled Entities together.
+
+                    //parse the array of resource types and in case of map check access on key or value or both as specified in @acl
+                    //implement external dao for classes that need findByName
+                    //for maps, specify access to be checkd on key or value.
+
+                    // find the controlled entity DBid by uuid
+                    if (parameterAnnotation.entityType() != null) {
+                        final Class<?>[] entityList = parameterAnnotation.entityType()[0].getAnnotation(EntityReference.class).value();
+
+                        for (final Class entity : entityList) {
+                            // Check if the parameter type is a single
+                            // Id or list of id's/name's
+                            switch (fieldType) {
+                                case LIST:
+                                    final CommandType listType = parameterAnnotation.collectionType();
+                                    switch (listType) {
+                                        case LONG:
+                                        case UUID:
+                                            final List<Long> listParam = (List<Long>)field.get(cmd);
+                                            for (final Long entityId : listParam) {
+                                                final Object entityObj = _entityMgr.findById(entity, entityId);
+                                                entitiesToAccess.put(entityObj, checkAccess.accessType());
+                                            }
+                                            break;
+                                        /*
+                                         * case STRING: List<String> listParam =
+                                         * new ArrayList<String>(); listParam =
+                                         * (List)field.get(cmd); for(String
+                                         * entityName: listParam){
+                                         * ControlledEntity entityObj =
+                                         * (ControlledEntity
+                                         * )daoClassInstance(entityId);
+                                         * entitiesToAccess.add(entityObj); }
+                                         * break;
+                                         */
+                                        default:
+                                            break;
+                                    }
+                                    break;
+                                case LONG:
+                                case UUID:
+                                    final Object entityObj = _entityMgr.findById(entity, (Long)field.get(cmd));
+                                    entitiesToAccess.put(entityObj, checkAccess.accessType());
+                                    break;
+                                default:
+                                    break;
+                            }
+
+                            if (ControlledEntity.class.isAssignableFrom(entity)) {
+                                if (s_logger.isDebugEnabled()) {
+                                    s_logger.debug("ControlledEntity name is:" + entity.getName());
+                                }
+                            }
+
+                            if (InfrastructureEntity.class.isAssignableFrom(entity)) {
+                                if (s_logger.isDebugEnabled()) {
+                                    s_logger.debug("InfrastructureEntity name is:" + entity.getName());
+                                }
+                            }
+                        }
+
+                    }
+
+                }
+
+            } catch (final IllegalArgumentException e) {
+                s_logger.error("Error initializing command " + cmd.getCommandName() + ", field " + field.getName() + " is not accessible.");
+                throw new CloudRuntimeException("Internal error initializing parameters for command " + cmd.getCommandName() + " [field " + field.getName() +
+                    " is not accessible]");
+            } catch (final IllegalAccessException e) {
+                s_logger.error("Error initializing command " + cmd.getCommandName() + ", field " + field.getName() + " is not accessible.");
+                throw new CloudRuntimeException("Internal error initializing parameters for command " + cmd.getCommandName() + " [field " + field.getName() +
+                    " is not accessible]");
+            }
+
+        }
+
+        doAccessChecks(cmd, entitiesToAccess);
+    }
+
+
+    private void doAccessChecks(final BaseCmd cmd, final Map<Object, AccessType> entitiesToAccess) {
+        final Account caller = CallContext.current().getCallingAccount();
+        final Account owner = _accountMgr.getActiveAccountById(cmd.getEntityOwnerId());
+
+        if (cmd instanceof BaseAsyncCreateCmd) {
+            //check that caller can access the owner account.
+            _accountMgr.checkAccess(caller, null, true, owner);
+        }
+
+        if (!entitiesToAccess.isEmpty()) {
+            //check that caller can access the owner account.
+            _accountMgr.checkAccess(caller, null, true, owner);
+            for (final Object entity : entitiesToAccess.keySet()) {
+                if (entity instanceof ControlledEntity) {
+                    _accountMgr.checkAccess(caller, entitiesToAccess.get(entity), true, (ControlledEntity)entity);
+                } else if (entity instanceof InfrastructureEntity) {
+                    //FIXME: Move this code in adapter, remove code from Account manager
+                }
+            }
+        }
+    }
+
+
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    private void setFieldValue(final Field field, final BaseCmd cmdObj, final Object paramObj, final Parameter annotation) throws IllegalArgumentException, ParseException {
+        try {
+            field.setAccessible(true);
+            final CommandType fieldType = annotation.type();
+            switch (fieldType) {
+                case BOOLEAN:
+                    field.set(cmdObj, Boolean.valueOf(paramObj.toString()));
+                    break;
+                case DATE:
+                    // This piece of code is for maintaining backward compatibility
+                    // and support both the date formats(Bug 9724)
+                    // Do the date messaging for ListEventsCmd only
+                    if (cmdObj instanceof ListEventsCmd || cmdObj instanceof DeleteEventsCmd || cmdObj instanceof ArchiveEventsCmd ||
+                        cmdObj instanceof ArchiveAlertsCmd || cmdObj instanceof DeleteAlertsCmd) {
+                        final boolean isObjInNewDateFormat = isObjInNewDateFormat(paramObj.toString());
+                        if (isObjInNewDateFormat) {
+                            final DateFormat newFormat = BaseCmd.NEW_INPUT_FORMAT;
+                            synchronized (newFormat) {
+                                field.set(cmdObj, newFormat.parse(paramObj.toString()));
+                            }
+                        } else {
+                            final DateFormat format = BaseCmd.INPUT_FORMAT;
+                            synchronized (format) {
+                                Date date = format.parse(paramObj.toString());
+                                if (field.getName().equals("startDate")) {
+                                    date = messageDate(date, 0, 0, 0);
+                                } else if (field.getName().equals("endDate")) {
+                                    date = messageDate(date, 23, 59, 59);
+                                }
+                                field.set(cmdObj, date);
+                            }
+                        }
+                    } else {
+                        final DateFormat format = BaseCmd.INPUT_FORMAT;
+                        synchronized (format) {
+                            format.setLenient(false);
+                            field.set(cmdObj, format.parse(paramObj.toString()));
+                        }
+                    }
+                    break;
+                case FLOAT:
+                    // Assuming that the parameters have been checked for required before now,
+                    // we ignore blank or null values and defer to the command to set a default
+                    // value for optional parameters ...
+                    if (paramObj != null && isNotBlank(paramObj.toString())) {
+                        field.set(cmdObj, Float.valueOf(paramObj.toString()));
+                    }
+                    break;
+                case INTEGER:
+                    // Assuming that the parameters have been checked for required before now,
+                    // we ignore blank or null values and defer to the command to set a default
+                    // value for optional parameters ...
+                    if (paramObj != null && isNotBlank(paramObj.toString())) {
+                        field.set(cmdObj, Integer.valueOf(paramObj.toString()));
+                    }
+                    break;
+                case LIST:
+                    final List listParam = new ArrayList();
+                    final StringTokenizer st = new StringTokenizer(paramObj.toString(), ",");
+                    while (st.hasMoreTokens()) {
+                        final String token = st.nextToken();
+                        final CommandType listType = annotation.collectionType();
+                        switch (listType) {
+                            case INTEGER:
+                                listParam.add(Integer.valueOf(token));
+                                break;
+                            case UUID:
+                                if (token.isEmpty())
+                                    break;
+                                final Long internalId = translateUuidToInternalId(token, annotation);
+                                listParam.add(internalId);
+                                break;
+                            case LONG: {
+                                listParam.add(Long.valueOf(token));
+                            }
+                                break;
+                            case SHORT:
+                                listParam.add(Short.valueOf(token));
+                            case STRING:
+                                listParam.add(token);
+                                break;
+                        }
+                    }
+                    field.set(cmdObj, listParam);
+                    break;
+                case UUID:
+                    if (paramObj.toString().isEmpty())
+                        break;
+                    final Long internalId = translateUuidToInternalId(paramObj.toString(), annotation);
+                    field.set(cmdObj, internalId);
+                    break;
+                case LONG:
+                    field.set(cmdObj, Long.valueOf(paramObj.toString()));
+                    break;
+                case SHORT:
+                    field.set(cmdObj, Short.valueOf(paramObj.toString()));
+                    break;
+                case STRING:
+                    if ((paramObj != null) && paramObj.toString().length() > annotation.length()) {
+                        s_logger.error("Value greater than max allowed length " + annotation.length() + " for param: " + field.getName());
+                        throw new InvalidParameterValueException("Value greater than max allowed length " + annotation.length() + " for param: " + field.getName());
+                    }
+                    field.set(cmdObj, paramObj.toString());
+                    break;
+                case TZDATE:
+                    field.set(cmdObj, DateUtil.parseTZDateString(paramObj.toString()));
+                    break;
+                case MAP:
+                default:
+                    field.set(cmdObj, paramObj);
+                    break;
+            }
+        } catch (final IllegalAccessException ex) {
+            s_logger.error("Error initializing command " + cmdObj.getCommandName() + ", field " + field.getName() + " is not accessible.");
+            throw new CloudRuntimeException("Internal error initializing parameters for command " + cmdObj.getCommandName() + " [field " + field.getName() +
+                " is not accessible]");
+        }
+    }
+
+    private boolean isObjInNewDateFormat(final String string) {
+        final Matcher matcher = BaseCmd.newInputDateFormat.matcher(string);
+        return matcher.matches();
+    }
+
+    private Date messageDate(final Date date, final int hourOfDay, final int minute, final int second) {
+        final Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.set(Calendar.HOUR_OF_DAY, hourOfDay);
+        cal.set(Calendar.MINUTE, minute);
+        cal.set(Calendar.SECOND, second);
+        return cal.getTime();
+    }
+
+    private Long translateUuidToInternalId(final String uuid, final Parameter annotation) {
+        if (uuid.equals("-1")) {
+            // FIXME: This is to handle a lot of hardcoded special cases where -1 is sent
+            // APITODO: Find and get rid of all hardcoded params in API Cmds and service layer
+            return -1L;
+        }
+        Long internalId = null;
+        // If annotation's empty, the cmd existed before 3.x try conversion to long
+        final boolean isPre3x = annotation.since().isEmpty();
+        // Match against Java's UUID regex to check if input is uuid string
+        final boolean isUuid = uuid.matches("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$");
+        // Enforce that it's uuid for newly added apis from version 3.x
+        if (!isPre3x && !isUuid)
+            return null;
+        // Allow both uuid and internal id for pre3x apis
+        if (isPre3x && !isUuid) {
+            try {
+                internalId = Long.parseLong(uuid);
+            } catch (final NumberFormatException e) {
+                internalId = null;
+            }
+            if (internalId != null)
+                return internalId;
+        }
+        // There may be multiple entities defined on the @EntityReference of a Response.class
+        // UUID CommandType would expect only one entityType, so use the first entityType
+        final Class<?>[] entities = annotation.entityType()[0].getAnnotation(EntityReference.class).value();
+        // Go through each entity which is an interface to a VO class and get a VO object
+        // Try to getId() for the object using reflection, break on first non-null value
+        for (final Class<?> entity : entities) {
+            // For backward compatibility, we search within removed entities and let service layer deal
+            // with removed ones, return empty response or error
+            final Object objVO = _entityMgr.findByUuidIncludingRemoved(entity, uuid);
+            if (objVO == null) {
+                continue;
+            }
+            // Invoke the getId method, get the internal long ID
+            // If that fails hide exceptions as the uuid may not exist
+            try {
+                internalId = ((InternalIdentity)objVO).getId();
+            } catch (final IllegalArgumentException e) {
+            } catch (final NullPointerException e) {
+            }
+            // Return on first non-null Id for the uuid entity
+            if (internalId != null)
+                break;
+        }
+        if (internalId == null) {
+            if (s_logger.isDebugEnabled())
+                s_logger.debug("Object entity uuid = " + uuid + " does not exist in the database.");
+            throw new InvalidParameterValueException("Invalid parameter " + annotation.name() + " value=" + uuid +
+                " due to incorrect long value format, or entity does not exist or due to incorrect parameter annotation for the field in api cmd class.");
+        }
+        return internalId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/src/com/cloud/api/dispatch/ParamUnpackWorker.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/dispatch/ParamUnpackWorker.java b/server/src/com/cloud/api/dispatch/ParamUnpackWorker.java
new file mode 100644
index 0000000..12e1226
--- /dev/null
+++ b/server/src/com/cloud/api/dispatch/ParamUnpackWorker.java
@@ -0,0 +1,114 @@
+// 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 com.cloud.api.dispatch;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.ServerApiException;
+
+public class ParamUnpackWorker implements DispatchWorker {
+
+    private static final Logger s_logger = Logger.getLogger(ParamUnpackWorker.class);
+
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    @Override
+    public void handle(final DispatchTask task) throws ServerApiException {
+        final Map<String, Object> lowercaseParams = new HashMap<String, Object>();
+        final Map<String, String> params = task.getParams();
+        for (final String key : params.keySet()) {
+            final int arrayStartIndex = key.indexOf('[');
+            final int arrayStartLastIndex = key.lastIndexOf('[');
+            if (arrayStartIndex != arrayStartLastIndex) {
+                throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key +
+                    "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
+            }
+
+            if (arrayStartIndex > 0) {
+                final int arrayEndIndex = key.indexOf(']');
+                final int arrayEndLastIndex = key.lastIndexOf(']');
+                if ((arrayEndIndex < arrayStartIndex) || (arrayEndIndex != arrayEndLastIndex)) {
+                    // malformed parameter
+                    throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key +
+                        "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
+                }
+
+                // Now that we have an array object, check for a field name in the case of a complex object
+                final int fieldIndex = key.indexOf('.');
+                String fieldName = null;
+                if (fieldIndex < arrayEndIndex) {
+                    throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key +
+                        "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
+                } else {
+                    fieldName = key.substring(fieldIndex + 1);
+                }
+
+                // parse the parameter name as the text before the first '[' character
+                String paramName = key.substring(0, arrayStartIndex);
+                paramName = paramName.toLowerCase();
+
+                Map<Integer, Map> mapArray = null;
+                Map<String, Object> mapValue = null;
+                final String indexStr = key.substring(arrayStartIndex + 1, arrayEndIndex);
+                int index = 0;
+                boolean parsedIndex = false;
+                try {
+                    if (indexStr != null) {
+                        index = Integer.parseInt(indexStr);
+                        parsedIndex = true;
+                    }
+                } catch (final NumberFormatException nfe) {
+                    s_logger.warn("Invalid parameter " + key + " received, unable to parse object array, returning an error.");
+                }
+
+                if (!parsedIndex) {
+                    throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key +
+                        "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
+                }
+
+                final Object value = lowercaseParams.get(paramName);
+                if (value == null) {
+                    // for now, assume object array with sub fields
+                    mapArray = new HashMap<Integer, Map>();
+                    mapValue = new HashMap<String, Object>();
+                    mapArray.put(Integer.valueOf(index), mapValue);
+                } else if (value instanceof Map) {
+                    mapArray = (HashMap)value;
+                    mapValue = mapArray.get(Integer.valueOf(index));
+                    if (mapValue == null) {
+                        mapValue = new HashMap<String, Object>();
+                        mapArray.put(Integer.valueOf(index), mapValue);
+                    }
+                }
+
+                // we are ready to store the value for a particular field into the map for this object
+                mapValue.put(fieldName, params.get(key));
+
+                lowercaseParams.put(paramName, mapArray);
+            } else {
+                lowercaseParams.put(key.toLowerCase(), params.get(key));
+            }
+        }
+
+        // The chain continues processing the unpacked parameters
+        task.setParams(lowercaseParams);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/src/com/cloud/api/dispatch/SpecificCmdValidationWorker.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/dispatch/SpecificCmdValidationWorker.java b/server/src/com/cloud/api/dispatch/SpecificCmdValidationWorker.java
new file mode 100644
index 0000000..3566a1a
--- /dev/null
+++ b/server/src/com/cloud/api/dispatch/SpecificCmdValidationWorker.java
@@ -0,0 +1,34 @@
+// 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 com.cloud.api.dispatch;
+
+/**
+ * This worker validates parameters in a semantic way, that is of
+ * course specific for each {@link BaseCmd}, so actually it delegates
+ * the validation on the {@link BaseCmd} itself
+ *
+ */
+public class SpecificCmdValidationWorker implements DispatchWorker {
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public void handle(final DispatchTask task) {
+        task.getCmd().validateSpecificParameters(task.getParams());
+    }
+
+}


[44/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
rats

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

Branch: refs/heads/resize-root
Commit: c257fb0e3efbb6eb3ae1e102397ebdcb989b5b51
Parents: c211f0b
Author: Daan Hoogland <da...@onecht.net>
Authored: Fri Mar 7 19:27:58 2014 +0100
Committer: Daan Hoogland <da...@onecht.net>
Committed: Fri Mar 7 19:27:58 2014 +0100

----------------------------------------------------------------------
 .../src/com/cloud/api/dispatch/DispatchTask.java   | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c257fb0e/server/src/com/cloud/api/dispatch/DispatchTask.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/dispatch/DispatchTask.java b/server/src/com/cloud/api/dispatch/DispatchTask.java
index 2a8a4bd..f6cb183 100644
--- a/server/src/com/cloud/api/dispatch/DispatchTask.java
+++ b/server/src/com/cloud/api/dispatch/DispatchTask.java
@@ -1,3 +1,20 @@
+// 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 com.cloud.api.dispatch;
 
 import java.util.Map;


[31/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-6170


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

Branch: refs/heads/resize-root
Commit: 9b66866dc2085486f465159cbd446ac03e266a2c
Parents: ea0dec7
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Thu Mar 6 00:29:10 2014 -0700
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Thu Mar 6 13:01:11 2014 -0700

----------------------------------------------------------------------
 .../admin/offering/CreateDiskOfferingCmd.java   |  6 +--
 .../api/response/DiskOfferingResponse.java      | 12 +++++
 .../api/response/ServiceOfferingResponse.java   | 48 ++++++++++++++++++++
 .../api/query/dao/DiskOfferingJoinDaoImpl.java  |  1 +
 .../query/dao/ServiceOfferingJoinDaoImpl.java   |  4 ++
 .../cloud/api/query/vo/DiskOfferingJoinVO.java  |  7 ++-
 .../api/query/vo/ServiceOfferingJoinVO.java     | 28 ++++++++++++
 setup/db/db/schema-430to440.sql                 |  5 ++
 ui/scripts/configuration.js                     | 40 ++++++++++++++++
 9 files changed, 146 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b66866d/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java
index 84c2c25..67c9792 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java
@@ -93,9 +93,9 @@ public class CreateDiskOfferingCmd extends BaseCmd {
     private Long maxIops;
 
     @Parameter(name = ApiConstants.HYPERVISOR_SNAPSHOT_RESERVE,
-               type = CommandType.INTEGER,
-               required = false,
-               description = "Hypervisor snapshot reserve space as a percent of a volume (for managed storage using Xen or VMware)")
+            type = CommandType.INTEGER,
+            required = false,
+            description = "Hypervisor snapshot reserve space as a percent of a volume (for managed storage using Xen or VMware)")
     private Integer hypervisorSnapshotReserve;
 
 /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b66866d/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java b/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java
index ebc2242..0894eec 100644
--- a/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java
@@ -73,6 +73,10 @@ public class DiskOfferingResponse extends BaseResponse {
     @Param(description = "the max iops of the disk offering")
     private Long maxIops;
 
+    @SerializedName(ApiConstants.HYPERVISOR_SNAPSHOT_RESERVE)
+    @Param(description = "Hypervisor snapshot reserve space as a percent of a volume (for managed storage using Xen or VMware)")
+    private Integer hypervisorSnapshotReserve;
+
     @SerializedName(ApiConstants.TAGS)
     @Param(description = "the tags for the disk offering")
     private String tags;
@@ -210,6 +214,14 @@ public class DiskOfferingResponse extends BaseResponse {
         this.maxIops = maxIops;
     }
 
+    public Integer getHypervisorSnapshotReserve() {
+        return hypervisorSnapshotReserve;
+    }
+
+    public void setHypervisorSnapshotReserve(Integer hypervisorSnapshotReserve) {
+        this.hypervisorSnapshotReserve = hypervisorSnapshotReserve;
+    }
+
     public String getCacheMode() {
         return cacheMode;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b66866d/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java b/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java
index 526e52b..d371f9a 100644
--- a/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java
@@ -106,6 +106,22 @@ public class ServiceOfferingResponse extends BaseResponse {
     @Param(description = "data transfer rate in megabits per second allowed.")
     private Integer networkRate;
 
+    @SerializedName("iscustomizediops")
+    @Param(description = "true if disk offering uses custom iops, false otherwise")
+    private Boolean customizedIops;
+
+    @SerializedName(ApiConstants.MIN_IOPS)
+    @Param(description = "the min iops of the disk offering")
+    private Long minIops;
+
+    @SerializedName(ApiConstants.MAX_IOPS)
+    @Param(description = "the max iops of the disk offering")
+    private Long maxIops;
+
+    @SerializedName(ApiConstants.HYPERVISOR_SNAPSHOT_RESERVE)
+    @Param(description = "Hypervisor snapshot reserve space as a percent of a volume (for managed storage using Xen or VMware)")
+    private Integer hypervisorSnapshotReserve;
+
     @SerializedName("diskBytesReadRate")
     @Param(description = "bytes read rate of the service offering")
     private Long bytesReadRate;
@@ -293,6 +309,38 @@ public class ServiceOfferingResponse extends BaseResponse {
         this.isVolatile = isVolatile;
     }
 
+    public Boolean isCustomizedIops() {
+        return customizedIops;
+    }
+
+    public void setCustomizedIops(Boolean customizedIops) {
+        this.customizedIops = customizedIops;
+    }
+
+    public Long getMinIops() {
+        return minIops;
+    }
+
+    public void setMinIops(Long minIops) {
+        this.minIops = minIops;
+    }
+
+    public Long getMaxIops() {
+        return maxIops;
+    }
+
+    public void setMaxIops(Long maxIops) {
+        this.maxIops = maxIops;
+    }
+
+    public Integer getHypervisorSnapshotReserve() {
+        return hypervisorSnapshotReserve;
+    }
+
+    public void setHypervisorSnapshotReserve(Integer hypervisorSnapshotReserve) {
+        this.hypervisorSnapshotReserve = hypervisorSnapshotReserve;
+    }
+
     public void setBytesReadRate(Long bytesReadRate) {
         this.bytesReadRate = bytesReadRate;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b66866d/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java
index d153712..bf28c03 100644
--- a/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java
@@ -71,6 +71,7 @@ public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO,
         diskOfferingResponse.setTags(offering.getTags());
         diskOfferingResponse.setCustomized(offering.isCustomized());
         diskOfferingResponse.setCustomizedIops(offering.isCustomizedIops());
+        diskOfferingResponse.setHypervisorSnapshotReserve(offering.getHypervisorSnapshotReserve());
         diskOfferingResponse.setStorageType(offering.isUseLocalStorage() ? ServiceOffering.StorageType.local.toString() : ServiceOffering.StorageType.shared.toString());
         diskOfferingResponse.setBytesReadRate(offering.getBytesReadRate());
         diskOfferingResponse.setBytesWriteRate(offering.getBytesWriteRate());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b66866d/server/src/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java
index 7e113e4..7fcc5c6 100644
--- a/server/src/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java
@@ -73,6 +73,10 @@ public class ServiceOfferingJoinDaoImpl extends GenericDaoBase<ServiceOfferingJo
         offeringResponse.setNetworkRate(offering.getRateMbps());
         offeringResponse.setHostTag(offering.getHostTag());
         offeringResponse.setDeploymentPlanner(offering.getDeploymentPlanner());
+        offeringResponse.setCustomizedIops(offering.isCustomizedIops());
+        offeringResponse.setMinIops(offering.getMinIops());
+        offeringResponse.setMaxIops(offering.getMaxIops());
+        offeringResponse.setHypervisorSnapshotReserve(offering.getHypervisorSnapshotReserve());
         offeringResponse.setBytesReadRate(offering.getBytesReadRate());
         offeringResponse.setBytesWriteRate(offering.getBytesWriteRate());
         offeringResponse.setIopsReadRate(offering.getIopsReadRate());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b66866d/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java b/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java
index 9d81bc4..e3e0a9e 100644
--- a/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java
@@ -70,6 +70,9 @@ public class DiskOfferingJoinVO extends BaseViewVO implements InternalIdentity,
     @Column(name = "max_iops")
     private Long maxIops;
 
+    @Column(name = "hv_ss_reserve")
+    private Integer hypervisorSnapshotReserve;
+
     @Column(name = "sort_key")
     int sortKey;
 
@@ -165,8 +168,8 @@ public class DiskOfferingJoinVO extends BaseViewVO implements InternalIdentity,
         return maxIops;
     }
 
-    public void setMaxIops(Long maxIops) {
-        this.maxIops = maxIops;
+    public Integer getHypervisorSnapshotReserve() {
+        return hypervisorSnapshotReserve;
     }
 
     public String getCacheMode() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b66866d/server/src/com/cloud/api/query/vo/ServiceOfferingJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/ServiceOfferingJoinVO.java b/server/src/com/cloud/api/query/vo/ServiceOfferingJoinVO.java
index 06b9e6b..dbeb530 100644
--- a/server/src/com/cloud/api/query/vo/ServiceOfferingJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/ServiceOfferingJoinVO.java
@@ -87,6 +87,18 @@ public class ServiceOfferingJoinVO extends BaseViewVO implements InternalIdentit
     @Column(name = "vm_type")
     private String vmType;
 
+    @Column(name = "customized_iops")
+    private Boolean customizedIops;
+
+    @Column(name = "min_iops")
+    private Long minIops;
+
+    @Column(name = "max_iops")
+    private Long maxIops;
+
+    @Column(name = "hv_ss_reserve")
+    private Integer hypervisorSnapshotReserve;
+
     @Column(name = "sort_key")
     int sortKey;
 
@@ -180,6 +192,22 @@ public class ServiceOfferingJoinVO extends BaseViewVO implements InternalIdentit
         return domainPath;
     }
 
+    public Boolean isCustomizedIops() {
+        return customizedIops;
+    }
+
+    public Long getMinIops() {
+        return minIops;
+    }
+
+    public Long getMaxIops() {
+        return maxIops;
+    }
+
+    public Integer getHypervisorSnapshotReserve() {
+        return hypervisorSnapshotReserve;
+    }
+
     public int getSortKey() {
         return sortKey;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b66866d/setup/db/db/schema-430to440.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-430to440.sql b/setup/db/db/schema-430to440.sql
index acc7e21..be49b83 100644
--- a/setup/db/db/schema-430to440.sql
+++ b/setup/db/db/schema-430to440.sql
@@ -44,6 +44,7 @@ CREATE VIEW `cloud`.`disk_offering_view` AS
         disk_offering.removed,
         disk_offering.use_local_storage,
         disk_offering.system_use,
+        disk_offering.hv_ss_reserve,
         disk_offering.bytes_read_rate,
         disk_offering.bytes_write_rate,
         disk_offering.iops_read_rate,
@@ -75,6 +76,10 @@ CREATE VIEW `cloud`.`service_offering_view` AS
         disk_offering.removed,
         disk_offering.use_local_storage,
         disk_offering.system_use,
+        disk_offering.customized_iops,
+        disk_offering.min_iops,
+        disk_offering.max_iops,
+        disk_offering.hv_ss_reserve,
         disk_offering.bytes_read_rate,
         disk_offering.bytes_write_rate,
         disk_offering.iops_read_rate,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b66866d/ui/scripts/configuration.js
----------------------------------------------------------------------
diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js
index 401262c..e3c35af 100644
--- a/ui/scripts/configuration.js
+++ b/ui/scripts/configuration.js
@@ -671,6 +671,37 @@
                                     networkrate: {
                                         label: 'label.network.rate'
                                     },
+                                    iscustomizediops: {
+                                        label: 'label.custom.disk.iops',
+                                        converter: cloudStack.converters.toBooleanText
+                                    },
+                                    miniops: {
+                                        label: 'label.disk.iops.min',
+                                        converter: function(args) {
+                                            if (args > 0)
+                                                return args;
+                                            else
+                                                return "N/A";
+                                        }
+                                    },
+                                    maxiops: {
+                                        label: 'label.disk.iops.max',
+                                        converter: function(args) {
+                                            if (args > 0)
+                                                return args;
+                                            else
+                                                return "N/A";
+                                        }
+                                    },
+                                    hypervisorsnapshotreserve: {
+                                        label: 'label.hypervisor.snapshot.reserve',
+                                        converter: function(args) {
+                                            if (args > 0)
+                                                return args;
+                                            else
+                                                return "N/A";
+                                        }
+                                    },
                                     diskBytesReadRate: {
                                         label: 'label.disk.bytes.read.rate'
                                     },
@@ -1783,6 +1814,15 @@
                                                 return "N/A";
                                         }
                                     },
+                                    hypervisorsnapshotreserve: {
+                                        label: 'label.hypervisor.snapshot.reserve',
+                                        converter: function(args) {
+                                            if (args > 0)
+                                                return args;
+                                            else
+                                                return "N/A";
+                                        }
+                                    },
                                     diskBytesReadRate: {
                                         label: 'label.disk.bytes.write.rate'
                                     },


[17/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
UI Dialog: Was passing wrong field data for makeFields event


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

Branch: refs/heads/resize-root
Commit: e1e554277a10a4e881aaf032d906cadcd4bd3afc
Parents: b06e66c
Author: Brian Federle <br...@citrix.com>
Authored: Wed Mar 5 13:34:48 2014 -0800
Committer: Brian Federle <br...@citrix.com>
Committed: Wed Mar 5 13:34:48 2014 -0800

----------------------------------------------------------------------
 ui/scripts/ui/dialog.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1e55427/ui/scripts/ui/dialog.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/dialog.js b/ui/scripts/ui/dialog.js
index 5f0697a..82e7fd4 100644
--- a/ui/scripts/ui/dialog.js
+++ b/ui/scripts/ui/dialog.js
@@ -72,7 +72,7 @@
 
             $(window).trigger('cloudStack.createForm.makeFields', {
                 $form: $form,
-                fields: fields
+                fields: args.form.fields
             });
 
             var ret = function() {


[22/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
Externalized the hardcodedstrings from UI JAVASCRIPT files.


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

Branch: refs/heads/resize-root
Commit: 182c31899bb353eac66a43ca4e81117c4fd06332
Parents: e1e5542
Author: vetrivelc <ve...@citrix.com>
Authored: Wed Mar 5 14:21:23 2014 +0530
Committer: Brian Federle <br...@citrix.com>
Committed: Wed Mar 5 14:11:51 2014 -0800

----------------------------------------------------------------------
 .../classes/resources/messages.properties       | 209 ++++++
 .../classes/resources/messages_ja_JP.properties | 272 +++++++-
 .../classes/resources/messages_zh_CN.properties | 572 +++++++++++------
 tools/ngui/static/js/app/accounts/accounts.js   |  16 +-
 tools/ngui/static/js/app/storage/storage.js     |   2 +-
 ui/dictionary.jsp                               | 220 ++++++-
 .../vnmcNetworkProvider/vnmcNetworkProvider.js  |  50 +-
 ui/scripts/configuration.js                     |  58 +-
 ui/scripts/installWizard.js                     |   6 +-
 ui/scripts/instances.js                         |  20 +-
 ui/scripts/network.js                           |  62 +-
 ui/scripts/sharedFunctions.js                   |  28 +-
 ui/scripts/storage.js                           |   6 +-
 ui/scripts/system.js                            | 634 +++++++++----------
 ui/scripts/templates.js                         |   6 +-
 ui/scripts/ui-custom/zoneChart.js               |  16 +-
 ui/scripts/ui/core.js                           |   2 +-
 ui/scripts/ui/widgets/tagger.js                 |   4 +-
 ui/scripts/vpc.js                               |  16 +-
 ui/scripts/zoneWizard.js                        |  12 +-
 20 files changed, 1519 insertions(+), 692 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/client/WEB-INF/classes/resources/messages.properties
----------------------------------------------------------------------
diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties
index 82ac499..cb4d292 100644
--- a/client/WEB-INF/classes/resources/messages.properties
+++ b/client/WEB-INF/classes/resources/messages.properties
@@ -1291,6 +1291,7 @@ label.add.gslb=Add GSLB
 label.gslb.servicetype=Service Type
 label.gslb.details=GSLB details
 label.gslb.delete=delete GSLB
+label.opendaylight.controller=OpenDaylight Controller
 label.opendaylight.controllers=OpenDaylight Controllers
 label.portable.ip.ranges=Portable IP Ranges
 label.add.portable.ip.range=Add Portable IP Range
@@ -1319,6 +1320,167 @@ label.add.ucs.manager=Add UCS Manager
 label.ovm.traffic.label=OVM traffic label
 label.lxc.traffic.label=LXC Traffic Label
 label.hyperv.traffic.label=HyperV Traffic Label
+label.resource.name=Resource Name
+label.reource.id=Resource ID
+label.vnmc.devices=VNMC Devices
+label.add.vnmc.provider=Add VNMC provider
+label.enable.vnmc.provider=Enable VNMC provider
+label.add.vnmc.device=Add VNMC device
+label.ciscovnmc.resource.details=CiscoVNMC resource details
+label.delete.ciscovnmc.resource=delete CiscoVNMC resource
+label.enable.vnmc.device=Enable VNMC device
+label.disbale.vnmc.device=Disable VNMC device
+label.disable.vnmc.provider=Disable VNMC provider
+label.services=Services
+label.secondary.staging.store=Secondary Staging Store
+label.release.account=Release from Account
+label.release.account.lowercase=release from account
+label.vlan.vni.ranges=VLAN/VNI Range(s)
+label.dedicated.vlan.vni.ranges=Dedicated VLAN/VNI Ranges
+label.dedicate.vlan.vni.range=Dedicate VLAN/VNI Range
+label.vlan.vni.range=VLAN/VNI Range
+label.vlan.range.details=VLAN Range details
+label.release.dedicated.vlan.range=Release dedicated VLAN range
+label.broadcat.uri=broadcast URI
+label.ipv4.cidr=IPv4 CIDR
+label.guest.network.details=Guest network details
+label.ipv4.gateway=IPv4 Gateway
+label.release.dedicated.vlan.range=Release dedicated VLAN range
+label.vlan.ranges=VLAN Range(s)
+label.virtual.appliance.details=Virtual applicance details
+label.start.lb.vm=Start LB VM
+label.stop.lb.vm=Stop LB VM
+label.migrate.lb.vm=Migrate LB VM
+label.vpc.virtual.router=VPC Virtual Router
+label.ovs=OVS
+label.gslb.service=GSLB service
+label.gslb.service.public.ip=GSLB service Public IP
+label.gslb.service.private.ip=GSLB service Private IP
+label.baremetal.dhcp.provider=Baremetal DHCP Provider
+label.add.baremetal.dhcp.device=Add Baremetal DHCP Device
+label.baremetal.pxe.provider=Baremetal PXE Provider
+label.baremetal.pxe.device=Add Baremetal PXE Device
+label.tftp.root.directory=Tftp root directory
+label.add.vmware.datacenter=Add VMware datacenter
+label.remove.vmware.datacenter=Remove VMware datacenter
+label.dc.name=DC Name
+label.vcenter=vcenter
+label.dedicate.zone=Dedicate Zone
+label.zone.dedicated=Zone Dedicated
+label.release.dedicated.zone=Release Dedicated Zone
+label.ipv6.dns1=IPv6 DNS1
+label.ipv6.dns2=IPv6 DNS2
+label.vmware.datacenter.name=VMware datacenter Name
+label.vmware.datacenter.vcenter=VMware datacenter vcenter
+label.vmware.datacenter.id=VMware datacenter ID
+label.system.vm.details=System VM details
+label.system.vm.scaled.up=System VM Scaled Up
+label.console.proxy.vm=Console Proxy VM
+label.settings=Settings
+label.requires.upgrade=Requires Upgrade
+label.upgrade.router.newer.template=Upgrade Router to Use Newer Template
+label.router.vm.scaled.up=Router VM Scaled Up
+label.total.virtual.routers=Total of Virtual Routers
+label.upgrade.required=Upgrade is required
+label.virtual.routers.group.zone=Virtual Routers group by zone
+label.total.virtual.routers.upgrade=Total of Virtual Routers that require upgrade
+label.virtual.routers.group.pod=Virtual Routers group by pod
+label.virtual.routers.group.cluster=Virtual Routers group by cluster
+label.zone.lower=zone
+label.virtual.routers.group.account=Virtual Routers group by account
+label.netscaler.details=NetScaler details
+label.baremetal.dhcp.devices=Baremetal DHCP Devices
+label.baremetal.pxe.devices=Baremetal PXE Devices
+label.addes.new.f5=Added new F5
+label.f5.details=F5 details
+label.srx.details=SRX details
+label.palo.alto.details=Palo Alto details
+label.added.nicira.nvp.controller=Added new Nicira NVP Controller\
+label.nicira.nvp.details=Nicira NVP details
+label.added.new.bigswitch.vns.controller=Added new BigSwitch VNS Controller
+label.bigswitch.vns.details=BigSwitch VNS details
+label.dedicate=Dedicate
+label.dedicate.pod=Dedicate Pod
+label.pod.dedicated=Pod Dedicated
+label.release.dedicated.pod=Release Dedicated Pod
+label.override.public.traffic=Override Public-Traffic
+label.public.traffic.vswitch.type=Public Traffic vSwitch Type
+label.public.traffic.vswitch.name=Public Traffic vSwitch Name
+label.override.guest.traffic=Override Guest-Traffic
+label.guest.traffic.vswitch.type=Guest Traffic vSwitch Type
+label.guest.traffic.vswitch.name=Guest Traffic vSwitch Name
+label.cisco.nexus1000v.ip.address=Nexus 1000v IP Address
+label.cisco.nexus1000v.username=Nexus 1000v Username
+label.cisco.nexus1000v.password=Nexus 1000v Password
+label.dedicate.cluster=Dedicate Cluster
+label.release.dedicated.cluster=Release Dedicated Cluster
+label.dedicate.host=Dedicate Host
+label.release.dedicated.host=Release Dedicated Host
+label.number.of.cpu.sockets=The Number of CPU Sockets
+label.delete.ucs.manager=Delete UCS Manager
+label.blades=Blades
+label.chassis=Chassis
+label.blade.id=Blade ID
+label.associated.profile=Associated Profile
+label.refresh.blades=Refresh Blades
+label.instanciate.template.associate.profile.blade=Instanciate Template and Associate Profile to Blade
+label.select.template=Select Template
+label.profile=Profile
+label.delete.profile=Delete Profile
+label.disassociate.profile.blade=Disassociate Profile from Blade
+label.secondary.storage.details=Secondary storage details
+label.secondary.staging.store.details=Secondary Staging Store details
+label.add.nfs.secondary.staging.store=Add NFS Secondary Staging Store
+label.delete.secondary.staging.store=Delete Secondary Staging Store
+label.ipv4.start.ip=IPv4 Start IP
+label.ipv4.end.ip=IPv4 End IP
+label.ipv6.start.ip=IPv6 Start IP
+label.ipv6.end.ip=IPv6 End IP
+label.vm.password=Password of the VM is
+label.group.by.zone=group by zone
+label.group.by.pod=group by pod
+label.group.by.cluster=group by cluster
+label.group.by.account=group by account
+label.no.grouping=(no grouping)\
+label.create.nfs.secondary.staging.storage=Create NFS Secondary Staging Store
+label.username.lower=username
+label.password.lower=password
+label.email.lower=email
+label.firstname.lower=firstname
+label.lastname.lower=lastname
+label.domain.lower=domain
+label.account.lower=account
+label.type.lower=type
+label.rule.number=Rule Number
+label.action=Action
+label.name.lower=name
+label.ucs=UCS
+label.change.affinity=Change Affinity
+label.persistent=Persistent 
+label.broadcasturi=broadcasturi
+label.network.cidr=Network CIDR
+label.reserved.ip.range=Reserved IP Range
+label.autoscale=AutoScale
+label.health.check=Health Check
+label.public.load.balancer.provider=Public Load Balancer Provider
+label.add.isolated.network=Add Isolated Network
+label.vlan=VLAN
+label.secondary.isolated.vlan.id=Secondary Isolated VLAN ID
+label.ipv4.netmask=IPv4 Netmask
+label.custom=Custom
+label.disable.network.offering=Disable network offering
+label.enable.network.offering=Enable network offering
+label.remove.network.offering=Remove network offering
+label.system.offering.for.router=System Offering for Router
+label.mode=Mode
+label.associate.public.ip=Associate Public IP
+label.acl=ACL
+label.user.data=User Data
+label.virtual.networking=Virtual Networking
+label.allow=Allow
+label.deny=Deny
+label.default.egress.policy=Default egress policy
+label.xenserver.tools.version.61.plus=XenServer Tools Version 6.1\+
 managed.state=Managed State
 message.acquire.new.ip.vpc=Please confirm that you would like to acquire a new IP for this VPC.
 message.acquire.new.ip=Please confirm that you would like to acquire a new IP for this network.
@@ -1669,6 +1831,53 @@ message.tier.required=Tier is required
 message.remove.ldap=Are you sure you want to delete the LDAP configuration?
 message.action.downloading.template=Downloading template.
 message.configure.ldap=Please confirm you would like to configure LDAP.
+message.confirm.delete.ciscovnmc.resource=Please confirm you want to delete CiscoVNMC resource
+message.confirm.add.vnmc.provider=Please confirm you would like to add the VNMC provider.
+message.confirm.enable.vnmc.provider=Please confirm you would like to enable the VNMC provider.
+message.confirm.disable.vnmc.provider=Please confirm you would like to disable the VNMC provider.
+message.vnmc.available.list=VNMC is not available from provider list.
+message.vnmc.not.available.list=VNMC is not available from provider list.
+message.confirm.release.dedicate.vlan.range=Please confirm you want to release dedicated VLAN range
+message.confirm.start.lb.vm=Please confirm you want to start LB VM
+message.confirm.stop.lb.vm=Please confirm you want to stop LB VM
+message.confirm.remove.vmware.datacenter=Please confirm you want to remove VMware datacenter
+message.confirm.dedicate.zone=Do you really want to dedicate this zone to a domain/account?
+message.confirm.release.dedicated.zone=Do you want to release this dedicated zone ? 
+message.dedicated.zone.released=Zone dedication released
+message.read.admin.guide.scaling.up=Please read the dynamic scaling section in the admin guide before scaling up.
+message.confirm.scale.up.system.vm=Do you really want to scale up the system VM ?
+message.confirm.upgrade.router.newer.template=Please confirm that you want to upgrade router to use newer template
+message.confirm.scale.up.router.vm=Do you really want to scale up the Router VM ?
+message.confirm.upgrade.routers.newtemplate=Please confirm that you want to upgrade all routers in this zone to use newer template
+message.confirm.upgrade.routers.pod.newtemplate=Please confirm that you want to upgrade all routers in this pod to use newer template
+message.confirm.upgrade.routers.cluster.newtemplate=Please confirm that you want to upgrade all routers in this cluster to use newer template
+message.confirm.upgrade.routers.account.newtemplate=Please confirm that you want to upgrade all routers in this account to use newer template
+message.confirm.dedicate.pod.domain.account=Do you really want to dedicate this pod to a domain/account? 
+message.confirm.release.dedicated.pod=Do you want to release this dedicated pod ?
+message.pod.dedication.released=Pod dedication released
+message.confirm.dedicate.cluster.domain.account=Do you really want to dedicate this cluster to a domain/account? 
+message.cluster.dedicated=Cluster Dedicated
+message.confirm.release.dedicated.cluster=Do you want to release this dedicated cluster ?
+message.cluster.dedication.released=Cluster dedication released
+message.confirm.dedicate.host.domain.account=Do you really want to dedicate this host to a domain/account? 
+message.host.dedicated=Host Dedicated
+message.confirm.release.dedicated.host=Do you want to release this dedicated host ?
+message.host.dedication.released=Host dedication released
+message.confirm.delete.ucs.manager=Please confirm that you want to delete UCS Manager
+message.confirm.refresh.blades=Please confirm that you want to refresh blades.
+message.confirm.delete.secondary.staging.store=Please confirm you want to delete Secondary Staging Store.
+message.select.tier=Please select a tier
+message.disallowed.characters=Disallowed characters: \<\,\>
+message.waiting.for.builtin.templates.to.load=Waiting for builtin templates to load...
+message.systems.vms.ready=System VMs ready.
+message.your.cloudstack.is.ready=Your CloudStack is ready\!
+message.specifiy.tag.key.value=Please specify a tag key and value
+message.enter.seperated.list.multiple.cidrs=Please enter a comma separated list of CIDRs if more than one
+message.disabling.network.offering=Disabling network offering
+message.confirm.enable.network.offering=Are you sure you want to enable this network offering?
+message.enabling.network.offering=Enabling network offering
+message.confirm.remove.network.offering=Are you sure you want to remove this network offering?
+message.confirm.disable.network.offering=Are you sure you want to disable this network offering?
 mode=Mode
 network.rate=Network Rate
 notification.reboot.instance=Reboot instance

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/client/WEB-INF/classes/resources/messages_ja_JP.properties
----------------------------------------------------------------------
diff --git a/client/WEB-INF/classes/resources/messages_ja_JP.properties b/client/WEB-INF/classes/resources/messages_ja_JP.properties
index 828cf54..da4851a 100644
--- a/client/WEB-INF/classes/resources/messages_ja_JP.properties
+++ b/client/WEB-INF/classes/resources/messages_ja_JP.properties
@@ -29,7 +29,7 @@ label.smb.password=SMB \u30d1\u30b9\u30ef\u30fc\u30c9
 label.smb.domain=SMB \u30c9\u30e1\u30a4\u30f3
 label.hypervisors=\u30cf\u30a4\u30d1\u30fc\u30d0\u30a4\u30b6\u30fc
 label.home=\u30db\u30fc\u30e0
-label.sockets=CPU Sockets
+label.sockets=CPU \u30bd\u30b1\u30c3\u30c8
 label.root.disk.size=\u30eb\u30fc\u30c8 \u30c7\u30a3\u30b9\u30af \u30b5\u30a4\u30ba
 label.s3.nfs.server=S3 NFS \u30b5\u30fc\u30d0\u30fc
 label.s3.nfs.path=S3 NFS \u30d1\u30b9
@@ -63,7 +63,7 @@ message.action.delete.nic=\u3053\u306e NIC \u3092\u524a\u9664\u3057\u3066\u3082\
 changed.item.properties=\u9805\u76ee\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u5909\u66f4
 confirm.enable.s3=S3 \u30d9\u30fc\u30b9\u306e\u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c8\u30ec\u30fc\u30b8\u306e\u30b5\u30dd\u30fc\u30c8\u3092\u6709\u52b9\u306b\u3059\u308b\u306b\u306f\u3001\u6b21\u306e\u60c5\u5831\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
 confirm.enable.swift=Swift \u306e\u30b5\u30dd\u30fc\u30c8\u3092\u6709\u52b9\u306b\u3059\u308b\u306b\u306f\u3001\u6b21\u306e\u60c5\u5831\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
-error.could.not.change.your.password.because.ldap.is.enabled=Error could not change your password because LDAP is enabled.
+error.could.not.change.your.password.because.ldap.is.enabled=\u30a8\u30e9\u30fc\u3002LDAP \u304c\u6709\u52b9\u306a\u305f\u3081\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5909\u66f4\u3067\u304d\u307e\u305b\u3093\u3002
 error.could.not.enable.zone=\u30be\u30fc\u30f3\u3092\u6709\u52b9\u306b\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f
 error.installWizard.message=\u554f\u984c\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002\u623b\u3063\u3066\u30a8\u30e9\u30fc\u3092\u4fee\u6b63\u3067\u304d\u307e\u3059\u3002
 error.invalid.username.password=\u7121\u52b9\u306a\u30e6\u30fc\u30b6\u30fc\u540d\u307e\u305f\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u3067\u3059\u3002
@@ -384,8 +384,8 @@ label.api.key=API \u30ad\u30fc
 label.apply=\u9069\u7528
 label.assign.to.load.balancer=\u8ca0\u8377\u5206\u6563\u88c5\u7f6e\u306b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u5272\u308a\u5f53\u3066\u3066\u3044\u307e\u3059
 label.assign=\u5272\u308a\u5f53\u3066
-label.associated.network.id=\u95a2\u9023\u3065\u3051\u3089\u308c\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af ID
-label.associated.network=\u95a2\u9023\u3065\u3051\u3089\u308c\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af
+label.associated.network.id=\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af ID
+label.associated.network=\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af
 label.attached.iso=\u30a2\u30bf\u30c3\u30c1\u3055\u308c\u305f ISO
 label.author.email=\u4f5c\u6210\u8005\u306e\u96fb\u5b50\u30e1\u30fc\u30eb
 label.author.name=\u4f5c\u6210\u8005\u306e\u540d\u524d
@@ -601,6 +601,7 @@ label.full=\u5b8c\u5168
 label.gateway=\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4
 label.general.alerts=\u4e00\u822c\u30a2\u30e9\u30fc\u30c8
 label.generating.url=URL \u3092\u751f\u6210\u3057\u3066\u3044\u307e\u3059
+label.gluster.volume=\u30dc\u30ea\u30e5\u30fc\u30e0
 label.go.step.2=\u624b\u9806 2 \u306b\u9032\u3080
 label.go.step.3=\u624b\u9806 3 \u306b\u9032\u3080
 label.go.step.4=\u624b\u9806 4 \u306b\u9032\u3080
@@ -704,7 +705,7 @@ label.lang.arabic=\u30a2\u30e9\u30d3\u30a2\u8a9e
 label.lang.brportugese=\u30dd\u30eb\u30c8\u30ac\u30eb\u8a9e (\u30d6\u30e9\u30b8\u30eb)
 label.lang.catalan=\u30ab\u30bf\u30eb\u30cb\u30a2\u8a9e
 label.lang.chinese=\u7c21\u4f53\u5b57\u4e2d\u56fd\u8a9e
-label.lang.dutch=Dutch (Netherlands)
+label.lang.dutch=\u30aa\u30e9\u30f3\u30c0\u8a9e (\u30aa\u30e9\u30f3\u30c0)
 label.lang.english=\u82f1\u8a9e
 label.lang.french=\u30d5\u30e9\u30f3\u30b9\u8a9e
 label.lang.german=\u30c9\u30a4\u30c4\u8a9e
@@ -712,7 +713,7 @@ label.lang.italian=\u30a4\u30bf\u30ea\u30a2\u8a9e
 label.lang.japanese=\u65e5\u672c\u8a9e
 label.lang.korean=\u97d3\u56fd\u8a9e
 label.lang.norwegian=\u30ce\u30eb\u30a6\u30a7\u30fc\u8a9e
-label.lang.polish=Polish
+label.lang.polish=\u30dd\u30fc\u30e9\u30f3\u30c9\u8a9e
 label.lang.russian=\u30ed\u30b7\u30a2\u8a9e
 label.lang.spanish=\u30b9\u30da\u30a4\u30f3\u8a9e
 label.last.disconnected=\u6700\u7d42\u5207\u65ad\u65e5\u6642
@@ -1067,7 +1068,7 @@ label.source=\u9001\u4fe1\u5143
 label.specify.IP.ranges=IP \u30a2\u30c9\u30ec\u30b9\u306e\u7bc4\u56f2\u306e\u6307\u5b9a
 label.specify.vlan=VLAN \u3092\u6307\u5b9a\u3059\u308b
 label.specify.vxlan=VXLAN \u3092\u6307\u5b9a\u3059\u308b
-label.SR.name = SR Name-Label
+label.SR.name=SR \u540d\u30e9\u30d9\u30eb
 label.srx=SRX
 label.PA=Palo Alto
 label.start.IP=\u958b\u59cb IP \u30a2\u30c9\u30ec\u30b9
@@ -1111,7 +1112,7 @@ label.storage.tags=\u30b9\u30c8\u30ec\u30fc\u30b8 \u30bf\u30b0
 label.storage.traffic=\u30b9\u30c8\u30ec\u30fc\u30b8 \u30c8\u30e9\u30d5\u30a3\u30c3\u30af
 label.storage.type=\u30b9\u30c8\u30ec\u30fc\u30b8\u306e\u7a2e\u985e
 label.qos.type=QoS \u306e\u7a2e\u985e
-label.cache.mode=Write-cache Type
+label.cache.mode=\u66f8\u304d\u8fbc\u307f\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u7a2e\u985e
 label.storage=\u30b9\u30c8\u30ec\u30fc\u30b8
 label.subdomain.access=\u30b5\u30d6\u30c9\u30e1\u30a4\u30f3 \u30a2\u30af\u30bb\u30b9
 label.submit=\u9001\u4fe1
@@ -1144,7 +1145,7 @@ label.tier.details=\u968e\u5c64\u306e\u8a73\u7d30
 label.tier=\u968e\u5c64
 label.time.zone=\u30bf\u30a4\u30e0\u30be\u30fc\u30f3
 label.time=\u6642\u523b
-label.timeout.in.second = Timeout(seconds)
+label.timeout.in.second=\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8 (\u79d2)
 label.timeout=\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8
 label.timezone=\u30bf\u30a4\u30e0\u30be\u30fc\u30f3
 label.token=\u30c8\u30fc\u30af\u30f3
@@ -1166,8 +1167,8 @@ label.unavailable=\u4f7f\u7528\u4e0d\u80fd
 label.unlimited=\u7121\u5236\u9650
 label.untagged=\u30bf\u30b0\u306a\u3057
 label.update.project.resources=\u30d7\u30ed\u30b8\u30a7\u30af\u30c8 \u30ea\u30bd\u30fc\u30b9\u306e\u66f4\u65b0
-label.update.ssl.cert= SSL Certificate
-label.update.ssl= SSL Certificate
+label.update.ssl.cert=SSL \u8a3c\u660e\u66f8
+label.update.ssl=SSL \u8a3c\u660e\u66f8
 label.updating=\u66f4\u65b0\u3057\u3066\u3044\u307e\u3059
 label.upload.volume=\u30dc\u30ea\u30e5\u30fc\u30e0\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9
 label.upload=\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9
@@ -1289,11 +1290,12 @@ label.add.gslb=GSLB \u306e\u8ffd\u52a0
 label.gslb.servicetype=\u30b5\u30fc\u30d3\u30b9\u306e\u7a2e\u985e
 label.gslb.details=GSLB \u306e\u8a73\u7d30
 label.gslb.delete=GSLB \u306e\u524a\u9664
-label.opendaylight.controllers=OpenDaylight Controllers
+label.opendaylight.controller=OpenDaylight \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc
+label.opendaylight.controllers=OpenDaylight \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc
 label.portable.ip.ranges=\u30dd\u30fc\u30bf\u30d6\u30eb IP \u30a2\u30c9\u30ec\u30b9\u306e\u7bc4\u56f2
 label.add.portable.ip.range=\u30dd\u30fc\u30bf\u30d6\u30eb IP \u30a2\u30c9\u30ec\u30b9\u306e\u7bc4\u56f2\u306e\u8ffd\u52a0
 label.delete.portable.ip.range=\u30dd\u30fc\u30bf\u30d6\u30eb IP \u30a2\u30c9\u30ec\u30b9\u306e\u7bc4\u56f2\u306e\u524a\u9664
-label.opendaylight.controllerdetail=OpenDaylight Controller Details
+label.opendaylight.controllerdetail=OpenDaylight \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u8a73\u7d30
 label.portable.ip.range.details=\u30dd\u30fc\u30bf\u30d6\u30eb IP \u30a2\u30c9\u30ec\u30b9\u306e\u7bc4\u56f2\u306e\u8a73\u7d30
 label.portable.ips=\u30dd\u30fc\u30bf\u30d6\u30eb IP \u30a2\u30c9\u30ec\u30b9
 label.gslb.assigned.lb=\u5272\u308a\u5f53\u3066\u6e08\u307f\u8ca0\u8377\u5206\u6563
@@ -1305,9 +1307,9 @@ label.enable.autoscale=\u81ea\u52d5\u30b5\u30a4\u30ba\u8a2d\u5b9a\u306e\u6709\u5
 label.disable.autoscale=\u81ea\u52d5\u30b5\u30a4\u30ba\u8a2d\u5b9a\u306e\u7121\u52b9\u5316
 label.min.instances=\u6700\u5c0f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u6570
 label.max.instances=\u6700\u5927\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u6570
-label.add.OpenDaylight.device=Add OpenDaylight Controller
+label.add.OpenDaylight.device=OpenDaylight \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u8ffd\u52a0
 label.show.advanced.settings=\u8a73\u7d30\u8a2d\u5b9a\u306e\u8868\u793a
-label.delete.OpenDaylight.device=Delete OpenDaylight Controller
+label.delete.OpenDaylight.device=OpenDaylight \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u524a\u9664
 label.polling.interval.sec=\u30dd\u30fc\u30ea\u30f3\u30b0\u9593\u9694 (\u79d2)
 label.quiet.time.sec=\u5f85\u3061\u6642\u9593 (\u79d2)
 label.destroy.vm.graceperiod=VM \u7834\u68c4\u306e\u7336\u4e88\u671f\u9593
@@ -1317,6 +1319,167 @@ label.add.ucs.manager=UCS Manager \u306e\u8ffd\u52a0
 label.ovm.traffic.label=OVM \u306e\u30c8\u30e9\u30d5\u30a3\u30c3\u30af \u30e9\u30d9\u30eb
 label.lxc.traffic.label=LXC \u306e\u30c8\u30e9\u30d5\u30a3\u30c3\u30af \u30e9\u30d9\u30eb
 label.hyperv.traffic.label=Hyper-V \u306e\u30c8\u30e9\u30d5\u30a3\u30c3\u30af \u30e9\u30d9\u30eb
+label.resource.name=\u30ea\u30bd\u30fc\u30b9\u540d
+label.reource.id=\u30ea\u30bd\u30fc\u30b9 ID
+label.vnmc.devices=VNMC \u30c7\u30d0\u30a4\u30b9
+label.add.vnmc.provider=VNMC \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u306e\u8ffd\u52a0
+label.enable.vnmc.provider=VNMC \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u306e\u6709\u52b9\u5316
+label.add.vnmc.device=VNMC \u30c7\u30d0\u30a4\u30b9\u306e\u8ffd\u52a0
+label.ciscovnmc.resource.details=Cisco VNMC \u30ea\u30bd\u30fc\u30b9\u306e\u8a73\u7d30
+label.delete.ciscovnmc.resource=Cisco VNMC \u30ea\u30bd\u30fc\u30b9\u306e\u524a\u9664
+label.enable.vnmc.device=VNMC \u30c7\u30d0\u30a4\u30b9\u306e\u6709\u52b9\u5316
+label.disbale.vnmc.device=VNMC \u30c7\u30d0\u30a4\u30b9\u306e\u7121\u52b9\u5316
+label.disable.vnmc.provider=VNMC \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u306e\u7121\u52b9\u5316
+label.services=\u30b5\u30fc\u30d3\u30b9
+label.secondary.staging.store=\u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0 \u30b9\u30c8\u30a2
+label.release.account=\u30a2\u30ab\u30a6\u30f3\u30c8\u304b\u3089\u89e3\u653e
+label.release.account.lowercase=\u30a2\u30ab\u30a6\u30f3\u30c8\u304b\u3089\u89e3\u653e
+label.vlan.vni.ranges=VLAN/VNI \u306e\u7bc4\u56f2
+label.dedicated.vlan.vni.ranges=\u5c02\u7528 VLAN/VNI \u306e\u7bc4\u56f2
+label.dedicate.vlan.vni.range=VLAN/VNI \u306e\u7bc4\u56f2\u3092\u5c02\u7528\u306b\u8a2d\u5b9a
+label.vlan.vni.range=VLAN/VNI \u306e\u7bc4\u56f2
+label.vlan.range.details=VLAN \u306e\u7bc4\u56f2\u306e\u8a73\u7d30
+label.release.dedicated.vlan.range=\u5c02\u7528 VLAN \u306e\u7bc4\u56f2\u306e\u89e3\u653e
+label.broadcat.uri=\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8 URI
+label.ipv4.cidr=IPv4 CIDR
+label.guest.network.details=\u30b2\u30b9\u30c8 \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u8a73\u7d30
+label.ipv4.gateway=IPv4 \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4
+label.release.dedicated.vlan.range=\u5c02\u7528 VLAN \u306e\u7bc4\u56f2\u3092\u89e3\u653e
+label.vlan.ranges=VLAN \u306e\u7bc4\u56f2
+label.virtual.appliance.details=\u4eee\u60f3\u30a2\u30d7\u30e9\u30a4\u30a2\u30f3\u30b9\u306e\u8a73\u7d30
+label.start.lb.vm=LB VM \u306e\u8d77\u52d5
+label.stop.lb.vm=LB VM \u306e\u505c\u6b62
+label.migrate.lb.vm=LB VM \u306e\u79fb\u884c
+label.vpc.virtual.router=VPC \u4eee\u60f3\u30eb\u30fc\u30bf\u30fc
+label.ovs=OVS
+label.gslb.service=GSLB \u30b5\u30fc\u30d3\u30b9
+label.gslb.service.public.ip=GSLB \u30b5\u30fc\u30d3\u30b9\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u30a2\u30c9\u30ec\u30b9
+label.gslb.service.private.ip=GSLB \u30b5\u30fc\u30d3\u30b9\u306e\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8 IP \u30a2\u30c9\u30ec\u30b9
+label.baremetal.dhcp.provider=\u30d9\u30a2\u30e1\u30bf\u30eb DHCP \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc
+label.add.baremetal.dhcp.device=\u30d9\u30a2\u30e1\u30bf\u30eb DHCP \u30c7\u30d0\u30a4\u30b9\u306e\u8ffd\u52a0
+label.baremetal.pxe.provider=\u30d9\u30a2\u30e1\u30bf\u30eb PXE \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc
+label.baremetal.pxe.device=\u30d9\u30a2\u30e1\u30bf\u30eb PXE \u30c7\u30d0\u30a4\u30b9\u306e\u8ffd\u52a0
+label.tftp.root.directory=TFTP \u30eb\u30fc\u30c8 \u30c7\u30a3\u30ec\u30af\u30c8\u30ea
+label.add.vmware.datacenter=VMware \u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc\u306e\u8ffd\u52a0
+label.remove.vmware.datacenter=VMware \u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc\u306e\u524a\u9664
+label.dc.name=DC \u540d
+label.vcenter=vCenter
+label.dedicate.zone=\u30be\u30fc\u30f3\u3092\u5c02\u7528\u306b\u8a2d\u5b9a
+label.zone.dedicated=\u5c02\u7528\u30be\u30fc\u30f3
+label.release.dedicated.zone=\u5c02\u7528\u30be\u30fc\u30f3\u306e\u89e3\u653e
+label.ipv6.dns1=IPv6 DNS 1
+label.ipv6.dns2=IPv6 DNS 2
+label.vmware.datacenter.name=VMware \u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc\u540d
+label.vmware.datacenter.vcenter=VMware \u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc\u306e vCenter
+label.vmware.datacenter.id=VMware \u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc ID
+label.system.vm.details=\u30b7\u30b9\u30c6\u30e0 VM \u306e\u8a73\u7d30
+label.system.vm.scaled.up=\u30b7\u30b9\u30c6\u30e0 VM \u306e\u30b5\u30a4\u30ba\u304c\u62e1\u5927\u3055\u308c\u307e\u3057\u305f
+label.console.proxy.vm=\u30b3\u30f3\u30bd\u30fc\u30eb \u30d7\u30ed\u30ad\u30b7 VM
+label.settings=\u8a2d\u5b9a
+label.requires.upgrade=\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u304c\u5fc5\u8981
+label.upgrade.router.newer.template=\u30eb\u30fc\u30bf\u30fc\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u65b0\u3057\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3059\u308b
+label.router.vm.scaled.up=\u30eb\u30fc\u30bf\u30fc VM \u306e\u30b5\u30a4\u30ba\u304c\u62e1\u5927\u3055\u308c\u307e\u3057\u305f
+label.total.virtual.routers=\u4eee\u60f3\u30eb\u30fc\u30bf\u30fc\u5408\u8a08
+label.upgrade.required=\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u304c\u5fc5\u8981\u3067\u3059
+label.virtual.routers.group.zone=\u30be\u30fc\u30f3\u5225\u306e\u4eee\u60f3\u30eb\u30fc\u30bf\u30fc \u30b0\u30eb\u30fc\u30d7
+label.total.virtual.routers.upgrade=\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u304c\u5fc5\u8981\u306a\u4eee\u60f3\u30eb\u30fc\u30bf\u30fc\u5408\u8a08
+label.virtual.routers.group.pod=\u30dd\u30c3\u30c9\u5225\u306e\u4eee\u60f3\u30eb\u30fc\u30bf\u30fc \u30b0\u30eb\u30fc\u30d7
+label.virtual.routers.group.cluster=\u30af\u30e9\u30b9\u30bf\u30fc\u5225\u306e\u4eee\u60f3\u30eb\u30fc\u30bf\u30fc \u30b0\u30eb\u30fc\u30d7
+label.zone.lower=\u30be\u30fc\u30f3
+label.virtual.routers.group.account=\u30a2\u30ab\u30a6\u30f3\u30c8\u5225\u306e\u4eee\u60f3\u30eb\u30fc\u30bf\u30fc \u30b0\u30eb\u30fc\u30d7
+label.netscaler.details=NetScaler \u306e\u8a73\u7d30
+label.baremetal.dhcp.devices=\u30d9\u30a2\u30e1\u30bf\u30eb DHCP \u30c7\u30d0\u30a4\u30b9
+label.baremetal.pxe.devices=\u30d9\u30a2\u30e1\u30bf\u30eb PXE \u30c7\u30d0\u30a4\u30b9
+label.addes.new.f5=\u65b0\u3057\u3044 F5 \u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f
+label.f5.details=F5 \u306e\u8a73\u7d30
+label.srx.details=SRX \u306e\u8a73\u7d30
+label.palo.alto.details=Palo Alto \u306e\u8a73\u7d30
+label.added.nicira.nvp.controller=\u65b0\u3057\u3044 Nicira NVP Controller \u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f\
+label.nicira.nvp.details=Nicira NVP \u306e\u8a73\u7d30
+label.added.new.bigswitch.vns.controller=\u65b0\u3057\u3044 Big Switch VNS \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f
+label.bigswitch.vns.details=Big Switch VNS \u306e\u8a73\u7d30
+label.dedicate=\u5c02\u7528\u306b\u8a2d\u5b9a
+label.dedicate.pod=\u30dd\u30c3\u30c9\u3092\u5c02\u7528\u306b\u8a2d\u5b9a
+label.pod.dedicated=\u30dd\u30c3\u30c9\u3092\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u307e\u3057\u305f
+label.release.dedicated.pod=\u5c02\u7528\u30dd\u30c3\u30c9\u306e\u89e3\u653e
+label.override.public.traffic=\u30d1\u30d6\u30ea\u30c3\u30af \u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3059\u308b
+label.public.traffic.vswitch.type=\u30d1\u30d6\u30ea\u30c3\u30af \u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u306e vSwitch \u306e\u7a2e\u985e
+label.public.traffic.vswitch.name=\u30d1\u30d6\u30ea\u30c3\u30af \u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u306e vSwitch \u540d
+label.override.guest.traffic=\u30b2\u30b9\u30c8 \u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3059\u308b
+label.guest.traffic.vswitch.type=\u30b2\u30b9\u30c8 \u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u306e vSwitch \u306e\u7a2e\u985e
+label.guest.traffic.vswitch.name=\u30b2\u30b9\u30c8 \u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u306e vSwitch \u540d
+label.cisco.nexus1000v.ip.address=Nexus 1000V \u306e IP \u30a2\u30c9\u30ec\u30b9
+label.cisco.nexus1000v.username=Nexus 1000V \u306e\u30e6\u30fc\u30b6\u30fc\u540d
+label.cisco.nexus1000v.password=Nexus 1000V \u306e\u30d1\u30b9\u30ef\u30fc\u30c9
+label.dedicate.cluster=\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u5c02\u7528\u306b\u8a2d\u5b9a
+label.release.dedicated.cluster=\u5c02\u7528\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u89e3\u653e
+label.dedicate.host=\u30db\u30b9\u30c8\u3092\u5c02\u7528\u306b\u8a2d\u5b9a
+label.release.dedicated.host=\u5c02\u7528\u30db\u30b9\u30c8\u306e\u89e3\u653e
+label.number.of.cpu.sockets=CPU \u30bd\u30b1\u30c3\u30c8\u6570
+label.delete.ucs.manager=UCS Manager \u306e\u524a\u9664
+label.blades=\u30d6\u30ec\u30fc\u30c9
+label.chassis=\u30b7\u30e3\u30fc\u30b7
+label.blade.id=\u30d6\u30ec\u30fc\u30c9 ID
+label.associated.profile=\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb
+label.refresh.blades=\u30d6\u30ec\u30fc\u30c9\u306e\u66f4\u65b0
+label.instanciate.template.associate.profile.blade=\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u4f5c\u6210\u304a\u3088\u3073\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u3068\u30d6\u30ec\u30fc\u30c9\u306e\u95a2\u9023\u4ed8\u3051
+label.select.template=\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u9078\u629e
+label.profile=\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb
+label.delete.profile=\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u306e\u524a\u9664
+label.disassociate.profile.blade=\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u3068\u30d6\u30ec\u30fc\u30c9\u306e\u95a2\u9023\u4ed8\u3051\u306e\u89e3\u9664
+label.secondary.storage.details=\u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c8\u30ec\u30fc\u30b8\u306e\u8a73\u7d30
+label.secondary.staging.store.details=\u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0 \u30b9\u30c8\u30a2\u306e\u8a73\u7d30
+label.add.nfs.secondary.staging.store=NFS \u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0 \u30b9\u30c8\u30a2\u306e\u8ffd\u52a0
+label.delete.secondary.staging.store=\u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0 \u30b9\u30c8\u30a2\u306e\u524a\u9664
+label.ipv4.start.ip=IPv4 \u958b\u59cb IP \u30a2\u30c9\u30ec\u30b9
+label.ipv4.end.ip=IPv4 \u7d42\u4e86 IP \u30a2\u30c9\u30ec\u30b9
+label.ipv6.start.ip=IPv6 \u958b\u59cb IP \u30a2\u30c9\u30ec\u30b9
+label.ipv6.end.ip=IPv6 \u7d42\u4e86 IP \u30a2\u30c9\u30ec\u30b9
+label.vm.password=VM \u306e\u30d1\u30b9\u30ef\u30fc\u30c9:
+label.group.by.zone=\u30be\u30fc\u30f3\u5225\u30b0\u30eb\u30fc\u30d7
+label.group.by.pod=\u30dd\u30c3\u30c9\u5225\u30b0\u30eb\u30fc\u30d7
+label.group.by.cluster=\u30af\u30e9\u30b9\u30bf\u30fc\u5225\u30b0\u30eb\u30fc\u30d7
+label.group.by.account=\u30a2\u30ab\u30a6\u30f3\u30c8\u5225\u30b0\u30eb\u30fc\u30d7
+label.no.grouping=(\u30b0\u30eb\u30fc\u30d7\u306a\u3057)\
+label.create.nfs.secondary.staging.storage=NFS \u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0 \u30b9\u30c8\u30a2\u3092\u4f5c\u6210\u3059\u308b
+label.username.lower=\u30e6\u30fc\u30b6\u30fc\u540d
+label.password.lower=\u30d1\u30b9\u30ef\u30fc\u30c9
+label.email.lower=\u96fb\u5b50\u30e1\u30fc\u30eb
+label.firstname.lower=\u540d
+label.lastname.lower=\u59d3
+label.domain.lower=\u30c9\u30e1\u30a4\u30f3
+label.account.lower=\u30a2\u30ab\u30a6\u30f3\u30c8
+label.type.lower=\u7a2e\u985e
+label.rule.number=\u898f\u5247\u756a\u53f7
+label.action=\u64cd\u4f5c
+label.name.lower=\u540d\u524d
+label.ucs=UCS
+label.change.affinity=\u30a2\u30d5\u30a3\u30cb\u30c6\u30a3\u306e\u5909\u66f4
+label.persistent=\u6c38\u7d9a
+label.broadcasturi=\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8 URI
+label.network.cidr=\u30cd\u30c3\u30c8\u30ef\u30fc\u30af CIDR
+label.reserved.ip.range=\u4e88\u7d04\u6e08\u307f IP \u30a2\u30c9\u30ec\u30b9\u306e\u7bc4\u56f2
+label.autoscale=\u81ea\u52d5\u30b5\u30a4\u30ba\u8a2d\u5b9a
+label.health.check=\u30d8\u30eb\u30b9 \u30c1\u30a7\u30c3\u30af
+label.public.load.balancer.provider=\u30d1\u30d6\u30ea\u30c3\u30af\u8ca0\u8377\u5206\u6563\u88c5\u7f6e\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc
+label.add.isolated.network=\u5206\u96e2\u3055\u308c\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u8ffd\u52a0
+label.vlan=VLAN
+label.secondary.isolated.vlan.id=\u5206\u96e2\u3055\u308c\u305f\u30bb\u30ab\u30f3\u30c0\u30ea VLAN ID
+label.ipv4.netmask=IPv4 \u30cd\u30c3\u30c8\u30de\u30b9\u30af
+label.custom=\u30ab\u30b9\u30bf\u30e0
+label.disable.network.offering=\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u306e\u7121\u52b9\u5316
+label.enable.network.offering=\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u306e\u6709\u52b9\u5316
+label.remove.network.offering=\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u306e\u524a\u9664
+label.system.offering.for.router=\u30eb\u30fc\u30bf\u30fc\u7528\u30b7\u30b9\u30c6\u30e0 \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0
+label.mode=\u30e2\u30fc\u30c9
+label.associate.public.ip=\u30d1\u30d6\u30ea\u30c3\u30af IP \u30a2\u30c9\u30ec\u30b9\u306e\u95a2\u9023\u4ed8\u3051
+label.acl=ACL
+label.user.data=\u30e6\u30fc\u30b6\u30fc \u30c7\u30fc\u30bf
+label.virtual.networking=\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af
+label.allow=\u8a31\u53ef
+label.deny=\u62d2\u5426
+label.default.egress.policy=\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u9001\u4fe1\u30dd\u30ea\u30b7\u30fc
+label.xenserver.tools.version.61.plus=XenServer Tools Version 6.1 \u4ee5\u964d
 managed.state=\u7ba1\u7406\u5bfe\u8c61\u72b6\u614b
 message.acquire.new.ip.vpc=\u3053\u306e VPC \u306e\u65b0\u3057\u3044 IP \u30a2\u30c9\u30ec\u30b9\u3092\u53d6\u5f97\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
 message.acquire.new.ip=\u3053\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u65b0\u3057\u3044 IP \u30a2\u30c9\u30ec\u30b9\u3092\u53d6\u5f97\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
@@ -1460,7 +1623,7 @@ message.creating.primary.storage=\u30d7\u30e9\u30a4\u30de\u30ea \u30b9\u30c8\u30
 message.creating.secondary.storage=\u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c8\u30ec\u30fc\u30b8\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059
 message.creating.zone=\u30be\u30fc\u30f3\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059
 message.decline.invitation=\u3053\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3078\u306e\u62db\u5f85\u3092\u8f9e\u9000\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
-message.dedicate.zone=\u30be\u30fc\u30f3\u3092\u5c02\u7528\u5316\u3057\u3066\u3044\u307e\u3059
+message.dedicate.zone=\u30be\u30fc\u30f3\u3092\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059
 message.delete.account=\u3053\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
 message.delete.affinity.group=\u3053\u306e\u30a2\u30d5\u30a3\u30cb\u30c6\u30a3 \u30b0\u30eb\u30fc\u30d7\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
 message.delete.gateway=\u3053\u306e\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
@@ -1632,21 +1795,21 @@ message.zone.step.3.desc=\u65b0\u3057\u3044\u30dd\u30c3\u30c9\u3092\u8ffd\u52a0\
 message.zoneWizard.enable.local.storage=\u8b66\u544a\: \u3053\u306e\u30be\u30fc\u30f3\u306e\u30ed\u30fc\u30ab\u30eb \u30b9\u30c8\u30ec\u30fc\u30b8\u3092\u6709\u52b9\u306b\u3059\u308b\u5834\u5408\u306f\u3001\u30b7\u30b9\u30c6\u30e0 VM \u306e\u8d77\u52d5\u5834\u6240\u306b\u5fdc\u3058\u3066\u6b21\u306e\u64cd\u4f5c\u304c\u5fc5\u8981\u3067\u3059\u3002<br/><br/>1. \u30b7\u30b9\u30c6\u30e0 VM \u3092\u30d7\u30e9\u30a4\u30de\u30ea \u30b9\u30c8\u30ec\u30fc\u30b8\u3067\u8d77\u52d5\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u30d7\u30e9\u30a4\u30de\u30ea \u30b9\u30c8\u30ec\u30fc\u30b8\u3092\u4f5c\u6210\u3057\u305f\u5f8c\u3067\u30be\u30fc\u30f3\u306b\u8ffd\u52a0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u30be\u30fc\u30f3\u3092\u7121\u52b9\u72b6\u614b\u304b\u3089\u958b\u59cb\u3059\u308b\u5fc5\u8981\u3082\u3042\u308a\u307e\u3059\u3002<br/><br/>2. \u30b7\u30b9\u30c6\u30e0 VM \u3092\u30ed\u30fc\u30ab\u30eb \u30b9\u30c8\u30ec\u30fc\u30b8\u3067\u8d77\u52d5\u3059
 \u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u30be\u30fc\u30f3\u3092\u6709\u52b9\u306b\u3059\u308b\u524d\u306b system.vm.use.local.storage \u3092 true \u306b\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br/><br/><br/>\u7d9a\u884c\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
 message.validate.fieldrequired=\u3053\u308c\u306f\u5fc5\u9808\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3067\u3059\u3002
 message.validate.fixfield=\u3053\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u4fee\u6b63\u3057\u3066\u304f\u3060\u3055\u3044\u3002
-message.validate.email.address=Please enter a valid email address.
-message.validate.URL=Please enter a valid URL.
-message.validate.date=Please enter a valid date.
-message.validate.date.ISO=Please enter a valid date (ISO).
-message.validate.number=Please enter a valid number.
-message.validate.digits=Please enter only digits.
-message.validate.creditcard=Please enter a valid credit card number.
-message.validate.equalto=Please enter the same value again.
-message.validate.accept=Please enter a value with a valid extension.
-message.validate.maxlength=Please enter no more than {0} characters.
-message.validate.minlength=Please enter at least {0} characters.
-message.validate.range.length=Please enter a value between {0} and {1} characters long.
-message.validate.range=Please enter a value between {0} and {1}.
-message.validate.max=Please enter a value less than or equal to {0}.
-messgae.validate.min=Please enter a value greater than or equal to {0}.
+message.validate.email.address=\u30e1\u30fc\u30eb \u30a2\u30c9\u30ec\u30b9\u3092\u6b63\u3057\u304f\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
+message.validate.URL=URL \u3092\u6b63\u3057\u304f\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
+message.validate.date=\u65e5\u4ed8\u3092\u6b63\u3057\u304f\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
+message.validate.date.ISO=\u65e5\u4ed8\u3092\u6b63\u3057\u304f\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044 (ISO)\u3002
+message.validate.number=\u6570\u5024\u3092\u6b63\u3057\u304f\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
+message.validate.digits=\u6570\u5b57\u306e\u307f\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
+message.validate.creditcard=\u30af\u30ec\u30b8\u30c3\u30c8 \u30ab\u30fc\u30c9\u756a\u53f7\u3092\u6b63\u3057\u304f\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
+message.validate.equalto=\u540c\u3058\u5024\u3092\u518d\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
+message.validate.accept=\u6709\u52b9\u306a\u62e1\u5f35\u5b50\u3092\u6301\u3064\u5024\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
+message.validate.maxlength={0} \u6587\u5b57\u4ee5\u4e0b\u3067\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
+message.validate.minlength={0} \u6587\u5b57\u4ee5\u4e0a\u3067\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
+message.validate.range.length={0} \uff5e {1} \u6587\u5b57\u3067\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
+message.validate.range={0} \uff5e {1} \u306e\u5024\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
+message.validate.max={0} \u4ee5\u4e0b\u306e\u5024\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
+messgae.validate.min={0} \u4ee5\u4e0a\u306e\u5024\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
 message.creating.systemVM=\u30b7\u30b9\u30c6\u30e0 VM \u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059 (\u3057\u3070\u3089\u304f\u304a\u5f85\u3061\u304f\u3060\u3055\u3044)
 message.enabling.zone.dots=\u30be\u30fc\u30f3\u3092\u6709\u52b9\u306b\u3057\u3066\u3044\u307e\u3059...
 message.restoreVM=VM \u3092\u5fa9\u5143\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
@@ -1667,6 +1830,53 @@ message.tier.required=\u968e\u5c64\u306f\u5fc5\u9808\u3067\u3059
 message.remove.ldap=LDAP \u69cb\u6210\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
 message.action.downloading.template=\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u3044\u307e\u3059\u3002
 message.configure.ldap=LDAP \u3092\u69cb\u6210\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.delete.ciscovnmc.resource=Cisco VNMC \u30ea\u30bd\u30fc\u30b9\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.add.vnmc.provider=VNMC \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u3092\u8ffd\u52a0\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.enable.vnmc.provider=VNMC \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u3092\u6709\u52b9\u306b\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.disable.vnmc.provider=VNMC \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u3092\u7121\u52b9\u306b\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.vnmc.available.list=\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u4e00\u89a7\u3067 VNMC \u3092\u5229\u7528\u3067\u304d\u307e\u305b\u3093\u3002
+message.vnmc.not.available.list=\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u4e00\u89a7\u3067 VNMC \u3092\u5229\u7528\u3067\u304d\u307e\u305b\u3093\u3002
+message.confirm.release.dedicate.vlan.range=\u5c02\u7528 VLAN \u306e\u7bc4\u56f2\u3092\u89e3\u653e\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.start.lb.vm=LB VM \u3092\u8d77\u52d5\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.stop.lb.vm=LB VM \u3092\u505c\u6b62\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.remove.vmware.datacenter=VMware \u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.dedicate.zone=\u3053\u306e\u30be\u30fc\u30f3\u3092\u30c9\u30e1\u30a4\u30f3/\u30a2\u30ab\u30a6\u30f3\u30c8\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.release.dedicated.zone=\u3053\u306e\u5c02\u7528\u30be\u30fc\u30f3\u3092\u89e3\u653e\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? 
+message.dedicated.zone.released=\u5c02\u7528\u30be\u30fc\u30f3\u304c\u89e3\u653e\u3055\u308c\u307e\u3057\u305f
+message.read.admin.guide.scaling.up=\u30b5\u30a4\u30ba\u3092\u62e1\u5927\u3059\u308b\u524d\u306b\u7ba1\u7406\u8005\u30ac\u30a4\u30c9\u306e\u52d5\u7684\u306a\u30b5\u30a4\u30ba\u5909\u66f4\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3092\u304a\u8aad\u307f\u304f\u3060\u3055\u3044\u3002
+message.confirm.scale.up.system.vm=\u30b7\u30b9\u30c6\u30e0 VM \u306e\u30b5\u30a4\u30ba\u3092\u62e1\u5927\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.upgrade.router.newer.template=\u30eb\u30fc\u30bf\u30fc\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u65b0\u3057\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.scale.up.router.vm=\u30eb\u30fc\u30bf\u30fc VM \u306e\u30b5\u30a4\u30ba\u3092\u62e1\u5927\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.upgrade.routers.newtemplate=\u3053\u306e\u30be\u30fc\u30f3\u306e\u3059\u3079\u3066\u306e\u30eb\u30fc\u30bf\u30fc\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u65b0\u3057\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.upgrade.routers.pod.newtemplate=\u3053\u306e\u30dd\u30c3\u30c9\u306e\u3059\u3079\u3066\u306e\u30eb\u30fc\u30bf\u30fc\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u65b0\u3057\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.upgrade.routers.cluster.newtemplate=\u3053\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u3059\u3079\u3066\u306e\u30eb\u30fc\u30bf\u30fc\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u65b0\u3057\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.upgrade.routers.account.newtemplate=\u3053\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u3059\u3079\u3066\u306e\u30eb\u30fc\u30bf\u30fc\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u65b0\u3057\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.dedicate.pod.domain.account=\u3053\u306e\u30dd\u30c3\u30c9\u3092\u30c9\u30e1\u30a4\u30f3/\u30a2\u30ab\u30a6\u30f3\u30c8\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.release.dedicated.pod=\u3053\u306e\u5c02\u7528\u30dd\u30c3\u30c9\u3092\u89e3\u653e\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? 
+message.pod.dedication.released=\u5c02\u7528\u30dd\u30c3\u30c9\u304c\u89e3\u653e\u3055\u308c\u307e\u3057\u305f
+message.confirm.dedicate.cluster.domain.account=\u3053\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u30c9\u30e1\u30a4\u30f3/\u30a2\u30ab\u30a6\u30f3\u30c8\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.cluster.dedicated=\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u307e\u3057\u305f
+message.confirm.release.dedicated.cluster=\u3053\u306e\u5c02\u7528\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u89e3\u653e\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? 
+message.cluster.dedication.released=\u5c02\u7528\u30af\u30e9\u30b9\u30bf\u30fc\u304c\u89e3\u653e\u3055\u308c\u307e\u3057\u305f
+message.confirm.dedicate.host.domain.account=\u3053\u306e\u30db\u30b9\u30c8\u3092\u30c9\u30e1\u30a4\u30f3/\u30a2\u30ab\u30a6\u30f3\u30c8\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.host.dedicated=\u30db\u30b9\u30c8\u3092\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u307e\u3057\u305f
+message.confirm.release.dedicated.host=\u3053\u306e\u5c02\u7528\u30db\u30b9\u30c8\u3092\u89e3\u653e\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? 
+message.host.dedication.released=\u5c02\u7528\u30db\u30b9\u30c8\u304c\u89e3\u653e\u3055\u308c\u307e\u3057\u305f
+message.confirm.delete.ucs.manager=UCS Manager \u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.refresh.blades=\u30d6\u30ec\u30fc\u30c9\u3092\u66f4\u65b0\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? 
+message.confirm.delete.secondary.staging.store=\u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0 \u30b9\u30c8\u30a2\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.select.tier=\u968e\u5c64\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002
+message.disallowed.characters=\u8a31\u53ef\u3055\u308c\u306a\u3044\u6587\u5b57: \<\,\>
+message.waiting.for.builtin.templates.to.load=\u7d44\u307f\u8fbc\u307f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30ed\u30fc\u30c9\u3092\u5f85\u6a5f\u3057\u3066\u3044\u307e\u3059...
+message.systems.vms.ready=\u30b7\u30b9\u30c6\u30e0 VM \u306e\u6e96\u5099\u304c\u3067\u304d\u307e\u3057\u305f\u3002
+message.your.cloudstack.is.ready=CloudStack \u306e\u6e96\u5099\u304c\u3067\u304d\u307e\u3057\u305f\!
+message.specifiy.tag.key.value=\u30bf\u30b0 \u30ad\u30fc\u304a\u3088\u3073\u5024\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044
+message.enter.seperated.list.multiple.cidrs=CIDR \u304c\u8907\u6570\u3042\u308b\u5834\u5408\u306f\u3001\u30b3\u30f3\u30de\u533a\u5207\u308a\u306e\u4e00\u89a7\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044
+message.disabling.network.offering=\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u3092\u7121\u52b9\u306b\u3057\u3066\u3044\u307e\u3059
+message.confirm.enable.network.offering=\u3053\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u3092\u6709\u52b9\u306b\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.enabling.network.offering=\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u3092\u6709\u52b9\u306b\u3057\u3066\u3044\u307e\u3059
+message.confirm.remove.network.offering=\u3053\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
+message.confirm.disable.network.offering=\u3053\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u3092\u7121\u52b9\u306b\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?
 mode=\u30e2\u30fc\u30c9
 network.rate=\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u901f\u5ea6
 notification.reboot.instance=\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u518d\u8d77\u52d5


[15/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-6203: Correct documentation for KVM migration tuneables


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

Branch: refs/heads/resize-root
Commit: bbaec7bae87fde2c93568a042b8cd085b57bf0d1
Parents: e5449e2
Author: Marcus Sorensen <ma...@betterservers.com>
Authored: Wed Mar 5 12:41:09 2014 -0700
Committer: Marcus Sorensen <ma...@betterservers.com>
Committed: Wed Mar 5 12:41:09 2014 -0700

----------------------------------------------------------------------
 agent/conf/agent.properties | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bbaec7ba/agent/conf/agent.properties
----------------------------------------------------------------------
diff --git a/agent/conf/agent.properties b/agent/conf/agent.properties
index e7e3b9c..b8b7a7c 100644
--- a/agent/conf/agent.properties
+++ b/agent/conf/agent.properties
@@ -77,7 +77,7 @@ domr.scripts.dir=scripts/network/domr/kvm
 
 # Busy VMs may never finish migrating, depending on environment. When its available, we will
 # want to add support for autoconvergence migration flag which should fix this. Set an upper
-# limit in seconds for how long live migration should wait, at which point VM is paused and
+# limit in milliseconds for how long live migration should wait, at which point VM is paused and
 # migration will finish quickly.  Less than 1 means disabled.
 #vm.migrate.pauseafter=0
 


[28/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-6199:  Hide action events for Vm/Volume commands when the resources have display flag=0.
Introduce generic BaseAsync(Vm/Volume)Cmd to make get the flag value for logging action events.
Rename the db field as display rather than display_event in keeping with the convention


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

Branch: refs/heads/resize-root
Commit: 830328b63da3c720712263d792f0393ea547466d
Parents: 38c0dd8
Author: Nitin Mehta <ni...@citrix.com>
Authored: Wed Mar 5 16:40:44 2014 -0800
Committer: Nitin Mehta <ni...@citrix.com>
Committed: Wed Mar 5 16:40:44 2014 -0800

----------------------------------------------------------------------
 api/src/com/cloud/storage/VolumeApiService.java |  2 ++
 api/src/com/cloud/vm/UserVmService.java         |  6 ++++
 .../apache/cloudstack/api/BaseAsyncVMCmd.java   | 30 ++++++++++++++++++++
 .../cloudstack/api/BaseAsyncVolumeCmd.java      | 30 ++++++++++++++++++++
 .../api/command/user/vm/DeployVMCmd.java        | 10 +++++++
 .../api/command/user/vm/DestroyVMCmd.java       |  4 +--
 .../api/command/user/vm/RebootVMCmd.java        |  4 +--
 .../api/command/user/vm/ResetVMPasswordCmd.java |  4 +--
 .../api/command/user/vm/ResetVMSSHKeyCmd.java   |  4 +--
 .../api/command/user/vm/RestoreVMCmd.java       | 10 +++++--
 .../api/command/user/vm/ScaleVMCmd.java         |  4 +--
 .../api/command/user/vm/StartVMCmd.java         |  4 +--
 .../api/command/user/vm/StopVMCmd.java          |  4 +--
 .../api/command/user/vm/UpgradeVMCmd.java       |  5 ++++
 .../command/user/volume/AttachVolumeCmd.java    | 13 ++-------
 .../command/user/volume/CreateVolumeCmd.java    | 12 ++++----
 .../command/user/volume/DeleteVolumeCmd.java    |  5 ++++
 .../command/user/volume/DetachVolumeCmd.java    |  4 +--
 .../command/user/volume/ExtractVolumeCmd.java   |  4 +--
 .../command/user/volume/MigrateVolumeCmd.java   | 10 +++++--
 .../command/user/volume/ResizeVolumeCmd.java    | 10 +++++--
 .../command/user/volume/UpdateVolumeCmd.java    |  5 ++++
 engine/schema/src/com/cloud/event/EventVO.java  | 12 ++++----
 server/src/com/cloud/api/ApiServer.java         |  1 -
 .../com/cloud/api/query/QueryManagerImpl.java   |  2 +-
 .../src/com/cloud/api/query/vo/EventJoinVO.java |  8 +++---
 .../src/com/cloud/event/ActionEventUtils.java   |  2 +-
 .../com/cloud/storage/VolumeApiServiceImpl.java |  9 ++++++
 server/src/com/cloud/vm/UserVmManagerImpl.java  | 10 +++++++
 setup/db/db/schema-430to440.sql                 |  4 +--
 30 files changed, 176 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/com/cloud/storage/VolumeApiService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/VolumeApiService.java b/api/src/com/cloud/storage/VolumeApiService.java
index 310f69e..3560db6 100644
--- a/api/src/com/cloud/storage/VolumeApiService.java
+++ b/api/src/com/cloud/storage/VolumeApiService.java
@@ -94,4 +94,6 @@ public interface VolumeApiService {
      *
      */
     String extractVolume(ExtractVolumeCmd cmd);
+
+    boolean isDisplayResourceEnabled(Long id);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/com/cloud/vm/UserVmService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/UserVmService.java b/api/src/com/cloud/vm/UserVmService.java
index 51a8fdf..af4e1d3 100755
--- a/api/src/com/cloud/vm/UserVmService.java
+++ b/api/src/com/cloud/vm/UserVmService.java
@@ -469,4 +469,10 @@ public interface UserVmService {
      */
     String getVmUserData(long vmId);
 
+    /**
+     * determin whether the uservm should be visible to the end user
+     * @return  value of the display flag
+     */
+    public boolean isDisplayResourceEnabled(Long vmId);
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/BaseAsyncVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseAsyncVMCmd.java b/api/src/org/apache/cloudstack/api/BaseAsyncVMCmd.java
new file mode 100644
index 0000000..abfc953
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/BaseAsyncVMCmd.java
@@ -0,0 +1,30 @@
+// 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;
+
+/**
+ * A generic class for implementing methods common to all async vm commands
+ */
+public abstract class BaseAsyncVMCmd extends BaseAsyncCmd {
+
+    @Override
+    public boolean isDisplayResourceEnabled(){
+        return _userVmService.isDisplayResourceEnabled(getId());
+    }
+
+    public abstract Long getId();
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/BaseAsyncVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseAsyncVolumeCmd.java b/api/src/org/apache/cloudstack/api/BaseAsyncVolumeCmd.java
new file mode 100644
index 0000000..1782e4a
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/BaseAsyncVolumeCmd.java
@@ -0,0 +1,30 @@
+// 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;
+
+/**
+ * A generic class for implementing methods common to all async volume commands
+ */
+public abstract class BaseAsyncVolumeCmd extends BaseAsyncCmd {
+
+    @Override
+    public boolean isDisplayResourceEnabled(){
+        return _volumeService.isDisplayResourceEnabled(getId());
+    }
+
+    public abstract Long getId();
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
index c6f4e19..1cc8380 100755
--- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
@@ -390,6 +390,16 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd {
     }
 
     @Override
+    public boolean isDisplayResourceEnabled(){
+        Boolean display = getDisplayVm();
+        if(display == null){
+            return true;
+        } else {
+            return display;
+        }
+    }
+
+    @Override
     public String getEventType() {
         return EventTypes.EVENT_VM_CREATE;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/vm/DestroyVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DestroyVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DestroyVMCmd.java
index 9bfd611..e9a5213 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/DestroyVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/DestroyVMCmd.java
@@ -18,13 +18,13 @@ package org.apache.cloudstack.api.command.user.vm;
 
 import java.util.List;
 
+import org.apache.cloudstack.api.BaseAsyncVMCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.UserVmResponse;
@@ -41,7 +41,7 @@ import com.cloud.uservm.UserVm;
             responseObject = UserVmResponse.class,
             requestHasSensitiveInfo = false,
             responseHasSensitiveInfo = true)
-public class DestroyVMCmd extends BaseAsyncCmd {
+public class DestroyVMCmd extends BaseAsyncVMCmd {
     public static final Logger s_logger = Logger.getLogger(DestroyVMCmd.class.getName());
 
     private static final String s_name = "destroyvirtualmachineresponse";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/vm/RebootVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/RebootVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/RebootVMCmd.java
index c54d62f..c547d62 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/RebootVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/RebootVMCmd.java
@@ -16,13 +16,13 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.vm;
 
+import org.apache.cloudstack.api.BaseAsyncVMCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.UserVmResponse;
@@ -36,7 +36,7 @@ import com.cloud.uservm.UserVm;
 
 @APICommand(name = "rebootVirtualMachine", description = "Reboots a virtual machine.", responseObject = UserVmResponse.class,
         requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
-public class RebootVMCmd extends BaseAsyncCmd {
+public class RebootVMCmd extends BaseAsyncVMCmd {
     public static final Logger s_logger = Logger.getLogger(RebootVMCmd.class.getName());
     private static final String s_name = "rebootvirtualmachineresponse";
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMPasswordCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMPasswordCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMPasswordCmd.java
index e8d5f73..461ce7f 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMPasswordCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMPasswordCmd.java
@@ -16,13 +16,13 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.vm;
 
+import org.apache.cloudstack.api.BaseAsyncVMCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.UserVmResponse;
@@ -37,7 +37,7 @@ import com.cloud.uservm.UserVm;
 @APICommand(name = "resetPasswordForVirtualMachine", responseObject = UserVmResponse.class, description = "Resets the password for virtual machine. "
     + "The virtual machine must be in a \"Stopped\" state and the template must already " + "support this feature for this command to take effect. [async]",
     requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
-public class ResetVMPasswordCmd extends BaseAsyncCmd {
+public class ResetVMPasswordCmd extends BaseAsyncVMCmd {
     public static final Logger s_logger = Logger.getLogger(ResetVMPasswordCmd.class.getName());
 
     private static final String s_name = "resetpasswordforvirtualmachineresponse";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMSSHKeyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMSSHKeyCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMSSHKeyCmd.java
index 318d3c8..b7ab357 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMSSHKeyCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMSSHKeyCmd.java
@@ -17,13 +17,13 @@
 
 package org.apache.cloudstack.api.command.user.vm;
 
+import org.apache.cloudstack.api.BaseAsyncVMCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainResponse;
@@ -40,7 +40,7 @@ import com.cloud.uservm.UserVm;
 @APICommand(name = "resetSSHKeyForVirtualMachine", responseObject = UserVmResponse.class, description = "Resets the SSH Key for virtual machine. "
     + "The virtual machine must be in a \"Stopped\" state. [async]",
     requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
-public class ResetVMSSHKeyCmd extends BaseAsyncCmd {
+public class ResetVMSSHKeyCmd extends BaseAsyncVMCmd {
 
     public static final Logger s_logger = Logger.getLogger(ResetVMSSHKeyCmd.class.getName());
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/vm/RestoreVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/RestoreVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/RestoreVMCmd.java
index 7c35680..81c40ec 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/RestoreVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/RestoreVMCmd.java
@@ -16,12 +16,12 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.vm;
 
+import org.apache.cloudstack.api.BaseAsyncVMCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.TemplateResponse;
@@ -42,7 +42,7 @@ import com.cloud.uservm.UserVm;
             since = "3.0.0",
             requestHasSensitiveInfo = false,
             responseHasSensitiveInfo = true)
-public class RestoreVMCmd extends BaseAsyncCmd {
+public class RestoreVMCmd extends BaseAsyncVMCmd {
     public static final Logger s_logger = Logger.getLogger(RestoreVMCmd.class);
     private static final String s_name = "restorevmresponse";
 
@@ -101,4 +101,10 @@ public class RestoreVMCmd extends BaseAsyncCmd {
     public Long getTemplateId() {
         return templateId;
     }
+
+    // TODO - Remove vmid param and make it "id" in 5.0 so that we dont have two getters
+    @Override
+    public Long getId() {
+        return getVmId();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java
index fe752cb..07672c0 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java
@@ -26,7 +26,7 @@ import org.apache.cloudstack.api.ACL;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseAsyncVMCmd;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
@@ -45,7 +45,7 @@ import com.cloud.uservm.UserVm;
 
 @APICommand(name = "scaleVirtualMachine", description = "Scales the virtual machine to a new service offering.", responseObject = SuccessResponse.class,
         requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
-public class ScaleVMCmd extends BaseAsyncCmd {
+public class ScaleVMCmd extends BaseAsyncVMCmd {
     public static final Logger s_logger = Logger.getLogger(ScaleVMCmd.class.getName());
     private static final String s_name = "scalevirtualmachineresponse";
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java
index a59dc6e..553b753 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java
@@ -16,13 +16,13 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.vm;
 
+import org.apache.cloudstack.api.BaseAsyncVMCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.HostResponse;
@@ -42,7 +42,7 @@ import com.cloud.utils.exception.ExecutionException;
 
 @APICommand(name = "startVirtualMachine", responseObject = UserVmResponse.class, description = "Starts a virtual machine.",
         requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
-public class StartVMCmd extends BaseAsyncCmd {
+public class StartVMCmd extends BaseAsyncVMCmd {
     public static final Logger s_logger = Logger.getLogger(StartVMCmd.class.getName());
 
     private static final String s_name = "startvirtualmachineresponse";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/vm/StopVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/StopVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/StopVMCmd.java
index b547357..e9fa97b 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/StopVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/StopVMCmd.java
@@ -16,6 +16,7 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.vm;
 
+import org.apache.cloudstack.api.BaseAsyncVMCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.ACL;
@@ -23,7 +24,6 @@ import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.UserVmResponse;
@@ -36,7 +36,7 @@ import com.cloud.uservm.UserVm;
 
 @APICommand(name = "stopVirtualMachine", responseObject = UserVmResponse.class, description = "Stops a virtual machine.",
         requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
-public class StopVMCmd extends BaseAsyncCmd {
+public class StopVMCmd extends BaseAsyncVMCmd {
     public static final Logger s_logger = Logger.getLogger(StopVMCmd.class.getName());
 
     private static final String s_name = "stopvirtualmachineresponse";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
index 46cce80..9fa89d0 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
@@ -109,6 +109,11 @@ public class UpgradeVMCmd extends BaseCmd {
     }
 
     @Override
+    public boolean isDisplayResourceEnabled(){
+        return _userVmService.isDisplayResourceEnabled(getId());
+    }
+
+    @Override
     public void execute() throws ResourceAllocationException {
         CallContext.current().setEventDetails("Vm Id: " + getId());
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java
index 78e1a69..7939edf 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java
@@ -16,13 +16,13 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
+import org.apache.cloudstack.api.BaseAsyncVolumeCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.UserVmResponse;
@@ -35,7 +35,7 @@ import com.cloud.user.Account;
 
 @APICommand(name = "attachVolume", description = "Attaches a disk volume to a virtual machine.", responseObject = VolumeResponse.class,
         requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
-public class AttachVolumeCmd extends BaseAsyncCmd {
+public class AttachVolumeCmd extends BaseAsyncVolumeCmd {
     public static final Logger s_logger = Logger.getLogger(AttachVolumeCmd.class.getName());
     private static final String s_name = "attachvolumeresponse";
 
@@ -108,15 +108,6 @@ public class AttachVolumeCmd extends BaseAsyncCmd {
     }
 
     @Override
-    public boolean isDisplayResourceEnabled(){
-        Volume volume = _responseGenerator.findVolumeById(getId());
-        if (volume == null) {
-            return true; // bad id given, parent this command to true so ERROR events are tracked
-        }
-        return volume.isDisplayVolume();
-    }
-
-    @Override
     public String getEventDescription() {
         return "attaching volume: " + getId() + " to vm: " + getVirtualMachineId();
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
index 555711b..80b49fd 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
@@ -152,10 +152,6 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd {
     }
 
     public Boolean getDisplayVolume() {
-        if(displayVolume == null){
-            return true;
-        }
-
         return displayVolume;
     }
 
@@ -197,7 +193,12 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd {
 
     @Override
     public boolean isDisplayResourceEnabled(){
-        return getDisplayVolume();
+        Boolean display = getDisplayVolume();
+        if(display == null){
+            return true;
+        } else {
+            return display;
+        }
     }
 
     @Override
@@ -220,7 +221,6 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd {
     @Override
     public void execute() {
         CallContext.current().setEventDetails("Volume Id: " + getEntityId() + ((getSnapshotId() == null) ? "" : " from snapshot: " + getSnapshotId()));
-        CallContext.current().setEventDisplayEnabled(getDisplayVolume());
         Volume volume = _volumeService.createVolume(this);
         if (volume != null) {
             VolumeResponse response = _responseGenerator.createVolumeResponse(volume);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java
index 2c66dea..eff7a35 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java
@@ -77,6 +77,11 @@ public class DeleteVolumeCmd extends BaseCmd {
     }
 
     @Override
+    public boolean isDisplayResourceEnabled(){
+        return _volumeService.isDisplayResourceEnabled(getId());
+    }
+
+    @Override
     public void execute() throws ConcurrentOperationException {
         CallContext.current().setEventDetails("Volume Id: " + getId());
         boolean result = this._volumeService.deleteVolume(id, CallContext.current().getCallingAccount());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java
index 2b87ff8..b45ad0b 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java
@@ -16,13 +16,13 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
+import org.apache.cloudstack.api.BaseAsyncVolumeCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.UserVmResponse;
@@ -36,7 +36,7 @@ import com.cloud.uservm.UserVm;
 
 @APICommand(name = "detachVolume", description = "Detaches a disk volume from a virtual machine.", responseObject = VolumeResponse.class,
         requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
-public class DetachVolumeCmd extends BaseAsyncCmd {
+public class DetachVolumeCmd extends BaseAsyncVolumeCmd {
     public static final Logger s_logger = Logger.getLogger(DetachVolumeCmd.class.getName());
     private static final String s_name = "detachvolumeresponse";
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/volume/ExtractVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/ExtractVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/ExtractVolumeCmd.java
index da466fd..7f5cd0d 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/ExtractVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/ExtractVolumeCmd.java
@@ -16,13 +16,13 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
+import org.apache.cloudstack.api.BaseAsyncVolumeCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.ExtractResponse;
@@ -38,7 +38,7 @@ import com.cloud.user.Account;
 
 @APICommand(name = "extractVolume", description = "Extracts volume", responseObject = ExtractResponse.class,
         requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
-public class ExtractVolumeCmd extends BaseAsyncCmd {
+public class ExtractVolumeCmd extends BaseAsyncVolumeCmd {
     public static final Logger s_logger = Logger.getLogger(ExtractVolumeCmd.class.getName());
 
     private static final String s_name = "extractvolumeresponse";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
index 47bf26f..126f1f3 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
@@ -19,7 +19,7 @@ package org.apache.cloudstack.api.command.user.volume;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseAsyncVolumeCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.StoragePoolResponse;
@@ -31,7 +31,7 @@ import com.cloud.user.Account;
 
 @APICommand(name = "migrateVolume", description = "Migrate volume", responseObject = VolumeResponse.class, since = "3.0.0",
         requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
-public class MigrateVolumeCmd extends BaseAsyncCmd {
+public class MigrateVolumeCmd extends BaseAsyncVolumeCmd {
     private static final String s_name = "migratevolumeresponse";
 
     /////////////////////////////////////////////////////
@@ -58,10 +58,16 @@ public class MigrateVolumeCmd extends BaseAsyncCmd {
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
 
+    // TODO remove this in 5.0 and use id as param instead.
     public Long getVolumeId() {
         return volumeId;
     }
 
+    @Override
+    public Long getId() {
+        return getVolumeId();
+    }
+
     public Long getStoragePoolId() {
         return storageId;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
index a95c95b..d51cdc5 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
@@ -20,7 +20,7 @@ import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseAsyncVolumeCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DiskOfferingResponse;
@@ -38,7 +38,7 @@ import com.cloud.user.Account;
 
 @APICommand(name = "resizeVolume", description = "Resizes a volume", responseObject = VolumeResponse.class,
         requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
-public class ResizeVolumeCmd extends BaseAsyncCmd {
+public class ResizeVolumeCmd extends BaseAsyncVolumeCmd {
     public static final Logger s_logger = Logger.getLogger(ResizeVolumeCmd.class.getName());
 
     private static final String s_name = "resizevolumeresponse";
@@ -67,10 +67,16 @@ public class ResizeVolumeCmd extends BaseAsyncCmd {
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
 
+    //TODO use the method getId() instead of this one.
     public Long getEntityId() {
         return id;
     }
 
+    @Override
+    public Long getId() {
+        return getEntityId();
+    }
+
     public Long getSize() {
         return size;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java
index 2d2b215..affb312 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java
@@ -123,6 +123,11 @@ public class UpdateVolumeCmd extends BaseAsyncCustomIdCmd {
     }
 
     @Override
+    public boolean isDisplayResourceEnabled(){
+        return _volumeService.isDisplayResourceEnabled(getId());
+    }
+
+    @Override
     public String getEventType() {
         return EventTypes.EVENT_VOLUME_UPDATE;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/engine/schema/src/com/cloud/event/EventVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/event/EventVO.java b/engine/schema/src/com/cloud/event/EventVO.java
index 6fecaa6..c857f51 100644
--- a/engine/schema/src/com/cloud/event/EventVO.java
+++ b/engine/schema/src/com/cloud/event/EventVO.java
@@ -78,8 +78,8 @@ public class EventVO implements Event {
     @Column(name = "archived")
     private boolean archived;
 
-    @Column(name = "display_event", updatable = true, nullable = false)
-    protected boolean isDisplayEventEnabled = true;
+    @Column(name = "display", updatable = true, nullable = false)
+    protected boolean display = true;
 
     @Transient
     private int totalSize;
@@ -214,12 +214,12 @@ public class EventVO implements Event {
         this.archived = archived;
     }
 
-    public boolean isDisplayEventEnabled() {
-        return isDisplayEventEnabled;
+    public boolean isDisplay() {
+        return display;
     }
 
-    public void setDisplayEventEnabled(boolean displayEventEnabled) {
-        isDisplayEventEnabled = displayEventEnabled;
+    public void setDisplay(boolean display) {
+        this.display = display;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index 05fe6e8..7e29324 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -479,7 +479,6 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         CallContext ctx = CallContext.current();
         Long callerUserId = ctx.getCallingUserId();
         Account caller = ctx.getCallingAccount();
-        ctx.setEventDisplayEnabled(cmdObj.isDisplayResourceEnabled());
 
         // Queue command based on Cmd super class:
         // BaseCmd: cmd is dispatched to ApiDispatcher, executed, serialized and returned.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/server/src/com/cloud/api/query/QueryManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java
index 66794c0..4200799 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -504,7 +504,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
         sb.and("state", sb.entity().getState(), SearchCriteria.Op.NEQ);
         sb.and("startId", sb.entity().getStartId(), SearchCriteria.Op.EQ);
         sb.and("createDate", sb.entity().getCreateDate(), SearchCriteria.Op.BETWEEN);
-        sb.and("displayEvent", sb.entity().getDisplayEvent(), SearchCriteria.Op.EQ);
+        sb.and("displayEvent", sb.entity().getDisplay(), SearchCriteria.Op.EQ);
         sb.and("archived", sb.entity().getArchived(), SearchCriteria.Op.EQ);
 
         SearchCriteria<EventJoinVO> sc = sb.create();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/server/src/com/cloud/api/query/vo/EventJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/EventJoinVO.java b/server/src/com/cloud/api/query/vo/EventJoinVO.java
index 696221d..9e9e73c 100644
--- a/server/src/com/cloud/api/query/vo/EventJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/EventJoinVO.java
@@ -108,8 +108,8 @@ public class EventJoinVO extends BaseViewVO implements ControlledViewEntity {
     @Column(name = "archived")
     private boolean archived;
 
-    @Column(name = "display_event")
-    protected boolean displayEvent = true;
+    @Column(name = "display")
+    protected boolean display = true;
 
     public EventJoinVO() {
     }
@@ -222,8 +222,8 @@ public class EventJoinVO extends BaseViewVO implements ControlledViewEntity {
         return archived;
     }
 
-    public boolean getDisplayEvent() {
-        return displayEvent;
+    public boolean getDisplay() {
+        return display;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/server/src/com/cloud/event/ActionEventUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/event/ActionEventUtils.java b/server/src/com/cloud/event/ActionEventUtils.java
index a9999dc..9724d99 100755
--- a/server/src/com/cloud/event/ActionEventUtils.java
+++ b/server/src/com/cloud/event/ActionEventUtils.java
@@ -159,7 +159,7 @@ public class ActionEventUtils {
         event.setType(type);
         event.setState(state);
         event.setDescription(description);
-        event.setDisplayEventEnabled(eventDisplayEnabled);
+        event.setDisplay(eventDisplayEnabled);
 
         if (domainId != null) {
             event.setDomainId(domainId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 50aa87e..17461c0 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -1820,6 +1820,15 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
         return extractUrl;
     }
 
+    @Override
+    public boolean isDisplayResourceEnabled(Long id) {
+        Volume volume = _volumeDao.findById(id);
+        if (volume == null) {
+            return true; // bad id given, default to true
+        }
+        return volume.isDisplayVolume();
+    }
+
     private String getFormatForPool(StoragePool pool) {
         ClusterVO cluster = ApiDBUtils.findClusterById(pool.getClusterId());
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 9874dc3..9c38430 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -4811,4 +4811,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
         _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, vm);
         return vm.getUserData();
     }
+
+    @Override
+    public boolean isDisplayResourceEnabled(Long vmId) {
+        UserVm vm = _vmDao.findById(vmId);
+        if (vm != null) {
+            return vm.isDisplayVm();
+        }
+
+        return true; // no info then default to true
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/830328b6/setup/db/db/schema-430to440.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-430to440.sql b/setup/db/db/schema-430to440.sql
index f755a08..acc7e21 100644
--- a/setup/db/db/schema-430to440.sql
+++ b/setup/db/db/schema-430to440.sql
@@ -543,7 +543,7 @@ ALTER TABLE `cloud`.`s2s_vpn_gateway` ADD COLUMN `display` tinyint(1) NOT NULL D
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (225, UUID(), 9, 'FreeBSD 10 (32-bit)');
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (226, UUID(), 9, 'FreeBSD 10 (64-bit)');
 
-ALTER TABLE `cloud`.`event` ADD COLUMN `display_event` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the detail can be displayed to the end user';
+ALTER TABLE `cloud`.`event` ADD COLUMN `display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the detail can be displayed to the end user';
 
 DROP VIEW IF EXISTS `cloud`.`event_view`;
 CREATE VIEW `cloud`.`event_view` AS
@@ -560,7 +560,7 @@ CREATE VIEW `cloud`.`event_view` AS
         eve.uuid start_uuid,
         event.user_id,
         event.archived,
-        event.display_event,
+        event.display,
         user.username user_name,
         account.id account_id,
         account.uuid account_uuid,


[10/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-5920: Add some interface methods and constants required by
IAM.


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

Branch: refs/heads/resize-root
Commit: 793becf524520c62fd5df35b22128db13347f6c9
Parents: d0ae4d9
Author: Min Chen <mi...@citrix.com>
Authored: Tue Mar 4 17:34:50 2014 -0800
Committer: Min Chen <mi...@citrix.com>
Committed: Wed Mar 5 09:40:55 2014 -0800

----------------------------------------------------------------------
 api/src/com/cloud/event/EventTypes.java         | 13 ++++
 .../apache/cloudstack/acl/PermissionScope.java  | 25 +++++++
 .../apache/cloudstack/acl/QuerySelector.java    | 72 ++++++++++++++++++++
 .../apache/cloudstack/acl/SecurityChecker.java  | 22 +++++-
 .../org/apache/cloudstack/api/APICommand.java   |  3 +
 .../cloudstack/api/ApiCommandJobType.java       |  4 +-
 .../org/apache/cloudstack/api/ApiConstants.java | 18 +++++
 .../src/com/cloud/template/TemplateManager.java |  3 +
 server/src/com/cloud/acl/DomainChecker.java     |  6 ++
 server/src/com/cloud/api/ApiServer.java         |  3 +-
 server/src/com/cloud/api/ApiServerService.java  |  2 +
 server/src/com/cloud/user/AccountManager.java   |  4 ++
 server/src/com/cloud/user/DomainManager.java    |  3 +
 utils/src/com/cloud/utils/db/EntityManager.java |  6 ++
 14 files changed, 181 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793becf5/api/src/com/cloud/event/EventTypes.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java
index 7dd8772..ec54ea1 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -455,6 +455,19 @@ public class EventTypes {
 
     public static final String EVENT_UCS_ASSOCIATED_PROFILE = "UCS.ASSOCIATEPROFILE";
 
+    // IAM events
+    public static final String EVENT_IAM_POLICY_CREATE = "IAMPOLICY.CREATE";
+    public static final String EVENT_IAM_POLICY_DELETE = "IAMPOLICY.DELETE";
+    public static final String EVENT_IAM_POLICY_GRANT = "IAMPOLICY.GRANT";
+    public static final String EVENT_IAM_POLICY_REVOKE = "IAMPOLICY.REVOKE";
+
+    public static final String EVENT_IAM_GROUP_UPDATE = "IAMGROUP.UPDATE";
+    public static final String EVENT_IAM_GROUP_CREATE = "IAMGROUP.CREATE";
+    public static final String EVENT_IAM_GROUP_DELETE = "IAMGROUP.DELETE";
+    public static final String EVENT_IAM_GROUP_GRANT = "IAMGROUP.GRANT";
+    public static final String EVENT_IAM_GROUP_REVOKE = "IAMGROUP.REVOKE";
+    public static final String EVENT_IAM_ACCOUNT_POLICY_UPDATE = "IAMACCOUNTPOLICY.UPDATE";
+
     // Object store migration
     public static final String EVENT_MIGRATE_PREPARE_SECONDARY_STORAGE = "MIGRATE.PREPARE.SS";
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793becf5/api/src/org/apache/cloudstack/acl/PermissionScope.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/acl/PermissionScope.java b/api/src/org/apache/cloudstack/acl/PermissionScope.java
new file mode 100644
index 0000000..03dbc10
--- /dev/null
+++ b/api/src/org/apache/cloudstack/acl/PermissionScope.java
@@ -0,0 +1,25 @@
+package org.apache.cloudstack.acl;
+
+public enum PermissionScope {
+    RESOURCE(0),
+    ACCOUNT(1),
+    DOMAIN(2),
+ REGION(3), ALL(4);
+
+    private int _scale;
+
+    private PermissionScope(int scale) {
+        _scale = scale;
+    }
+
+    public int getScale() {
+        return _scale;
+    }
+
+    public boolean greaterThan(PermissionScope s) {
+        if (_scale > s.getScale())
+            return true;
+        else
+            return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793becf5/api/src/org/apache/cloudstack/acl/QuerySelector.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/acl/QuerySelector.java b/api/src/org/apache/cloudstack/acl/QuerySelector.java
new file mode 100644
index 0000000..b89aa4e
--- /dev/null
+++ b/api/src/org/apache/cloudstack/acl/QuerySelector.java
@@ -0,0 +1,72 @@
+// 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.acl;
+
+import java.util.List;
+
+import com.cloud.user.Account;
+import com.cloud.utils.component.Adapter;
+
+/**
+ * QueryChecker returns granted access at domain, account or resource level.
+ */
+public interface QuerySelector extends Adapter {
+
+    /**
+    * List granted domains for the caller, given a specific action.
+    *
+    * @param caller account to check against.
+    * @param action action
+    * @return list of domain Ids granted to the caller account.
+    */
+    List<Long> getAuthorizedDomains(Account caller, String action);
+
+    /**
+    * List granted accounts for the caller, given a specific action.
+    *
+    * @param caller account to check against.
+    * @param action action.
+    * @return list of domain Ids granted to the caller account.
+    */
+    List<Long> getAuthorizedAccounts(Account caller, String action);
+
+
+    /**
+    * List granted resources for the caller, given a specific action.
+    *
+    * @param caller account to check against.
+    * @param action action.
+    * @return list of domain Ids granted to the caller account.
+    */
+    List<Long> getAuthorizedResources(Account caller, String action);
+
+    /**
+     * Check if this account is associated with a policy with scope of ALL
+     * @param caller account to check
+     * @param action action.
+     * @return true if this account is attached with a policy for the given action of ALL scope.
+     */
+    boolean isGrantedAll(Account caller, String action);
+
+    /**
+     * List of ACL group the given account belongs to
+     * @param accountId account id.
+     * @return ACL group names
+     */
+    List<String> listAclGroupsByAccount(long accountId);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793becf5/api/src/org/apache/cloudstack/acl/SecurityChecker.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/acl/SecurityChecker.java b/api/src/org/apache/cloudstack/acl/SecurityChecker.java
index ab3f7c5..aab88fe 100644
--- a/api/src/org/apache/cloudstack/acl/SecurityChecker.java
+++ b/api/src/org/apache/cloudstack/acl/SecurityChecker.java
@@ -31,7 +31,7 @@ import com.cloud.utils.component.Adapter;
 public interface SecurityChecker extends Adapter {
 
     public enum AccessType {
-        ListEntry, ModifyEntry, ModifyProject, UseNetwork
+        ListEntry, ModifyEntry, ModifyProject, UseNetwork, OperateEntry, UseEntry
     }
 
     /**
@@ -76,6 +76,26 @@ public interface SecurityChecker extends Adapter {
     boolean checkAccess(Account caller, ControlledEntity entity, AccessType accessType) throws PermissionDeniedException;
 
     /**
+     * Checks if the account can access the object.
+     *
+     * @param caller
+     *            account to check against.
+     * @param entity
+     *            object that the account is trying to access.
+     * @param accessType
+     *            TODO
+     * @param action
+     *            name of the API
+     * @return true if access allowed. false if this adapter cannot provide
+     *         permission.
+     * @throws PermissionDeniedException
+     *             if this adapter is suppose to authenticate ownership and the
+     *             check failed.
+     */
+    boolean checkAccess(Account caller, ControlledEntity entity, AccessType accessType, String action) throws PermissionDeniedException;
+
+
+    /**
      * Checks if the user belongs to an account that can access the object.
      *
      * @param user

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793becf5/api/src/org/apache/cloudstack/api/APICommand.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/APICommand.java b/api/src/org/apache/cloudstack/api/APICommand.java
index f0b46a4..6211afc 100644
--- a/api/src/org/apache/cloudstack/api/APICommand.java
+++ b/api/src/org/apache/cloudstack/api/APICommand.java
@@ -22,6 +22,7 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.acl.RoleType;
 
 @Retention(RetentionPolicy.RUNTIME)
@@ -44,4 +45,6 @@ public @interface APICommand {
     boolean responseHasSensitiveInfo() default true;
 
     RoleType[] authorized() default {};
+
+    IAMEntityType[] entityType() default {};
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793becf5/api/src/org/apache/cloudstack/api/ApiCommandJobType.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiCommandJobType.java b/api/src/org/apache/cloudstack/api/ApiCommandJobType.java
index 3067af8..f27f001 100644
--- a/api/src/org/apache/cloudstack/api/ApiCommandJobType.java
+++ b/api/src/org/apache/cloudstack/api/ApiCommandJobType.java
@@ -49,5 +49,7 @@ public enum ApiCommandJobType {
     LoadBalancerRule,
     AffinityGroup,
     InternalLbVm,
-    DedicatedGuestVlanRange
+    DedicatedGuestVlanRange,
+    IAMPolicy,
+    IAMGroup
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793becf5/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index 7b7f9ca..14df653 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -544,6 +544,24 @@ public class ApiConstants {
     public static final String ROUTING = "isrouting";
     public static final String MAX_CONNECTIONS = "maxconnections";
     public static final String SERVICE_STATE = "servicestate";
+
+    public static final String IAM_ACCOUNT_IDS = "accountids";
+    public static final String IAM_MEMBER_ACCOUNTS = "memberaccounts";
+    public static final String IAM_PARENT_POLICY_ID = "parentpolicyid";
+    public static final String IAM_PARENT_POLICY_NAME = "parentpolicyname";
+    public static final String IAM_POLICY_IDS = "policyids";
+    public static final String IAM_POLICIES = "policies";
+    public static final String IAM_APIS = "apis";
+    public static final String IAM_GROUPS = "groups";
+    public static final String IAM_PERMISSIONS = "permission";
+    public static final String IAM_ACTION = "action";
+    public static final String IAM_SCOPE = "scope";
+    public static final String IAM_SCOPE_ID = "scopeid";
+    public static final String IAM_ALLOW_DENY = "permission";
+    public static final String ENTITY_TYPE = "entitytype";
+    public static final String ENTITY_ID = "entityid";
+    public static final String ACCESS_TYPE = "accesstype";
+
     public static final String RESOURCE_DETAILS = "resourcedetails";
     public static final String EXPUNGE = "expunge";
     public static final String FOR_DISPLAY = "fordisplay";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793becf5/engine/components-api/src/com/cloud/template/TemplateManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/template/TemplateManager.java b/engine/components-api/src/com/cloud/template/TemplateManager.java
index 0557a29..5987ac0 100755
--- a/engine/components-api/src/com/cloud/template/TemplateManager.java
+++ b/engine/components-api/src/com/cloud/template/TemplateManager.java
@@ -122,4 +122,7 @@ public interface TemplateManager {
      */
     void prepareIsoForVmProfile(VirtualMachineProfile profile);
 
+    public static final String MESSAGE_REGISTER_PUBLIC_TEMPLATE_EVENT = "Message.RegisterPublicTemplate.Event";
+    public static final String MESSAGE_RESET_TEMPLATE_PERMISSION_EVENT = "Message.ResetTemplatePermission.Event";
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793becf5/server/src/com/cloud/acl/DomainChecker.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/acl/DomainChecker.java b/server/src/com/cloud/acl/DomainChecker.java
index 31b273f..f8acceb 100755
--- a/server/src/com/cloud/acl/DomainChecker.java
+++ b/server/src/com/cloud/acl/DomainChecker.java
@@ -319,4 +319,10 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
         }
         return false;
     }
+
+    @Override
+    public boolean checkAccess(Account caller, ControlledEntity entity, AccessType accessType, String action)
+            throws PermissionDeniedException {
+        return checkAccess(caller, entity, accessType);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793becf5/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index 3df599e..05fe6e8 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -891,7 +891,8 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         }
     }
 
-    private Class<?> getCmdClass(String cmdName) {
+    @Override
+    public Class<?> getCmdClass(String cmdName) {
         return s_apiNameCmdClassMap.get(cmdName);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793becf5/server/src/com/cloud/api/ApiServerService.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServerService.java b/server/src/com/cloud/api/ApiServerService.java
index 8e078c6..bf0ba23 100644
--- a/server/src/com/cloud/api/ApiServerService.java
+++ b/server/src/com/cloud/api/ApiServerService.java
@@ -41,4 +41,6 @@ public interface ApiServerService {
     public String getSerializedApiError(ServerApiException ex, Map<String, Object[]> apiCommandParams, String responseType);
 
     public String handleRequest(Map params, String responseType, StringBuffer auditTrailSb) throws ServerApiException;
+
+    public Class<?> getCmdClass(String cmdName);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793becf5/server/src/com/cloud/user/AccountManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/AccountManager.java b/server/src/com/cloud/user/AccountManager.java
index 1f191fc..983caf1 100755
--- a/server/src/com/cloud/user/AccountManager.java
+++ b/server/src/com/cloud/user/AccountManager.java
@@ -188,4 +188,8 @@ public interface AccountManager extends AccountService {
      * @return account object
      */
     Account lockAccount(String accountName, Long domainId, Long accountId);
+
+    public static final String MESSAGE_ADD_ACCOUNT_EVENT = "Message.AddAccount.Event";
+
+    public static final String MESSAGE_REMOVE_ACCOUNT_EVENT = "Message.RemoveAccount.Event";
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793becf5/server/src/com/cloud/user/DomainManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/DomainManager.java b/server/src/com/cloud/user/DomainManager.java
index 41d9d34..f72b18a 100644
--- a/server/src/com/cloud/user/DomainManager.java
+++ b/server/src/com/cloud/user/DomainManager.java
@@ -47,4 +47,7 @@ public interface DomainManager extends DomainService {
      * @return Domain object if the command succeeded
      */
     Domain updateDomain(UpdateDomainCmd cmd);
+
+    public static final String MESSAGE_ADD_DOMAIN_EVENT = "Message.AddDomain.Event";
+    public static final String MESSAGE_REMOVE_DOMAIN_EVENT = "Message.RemoveDomain.Event";
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/793becf5/utils/src/com/cloud/utils/db/EntityManager.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/EntityManager.java b/utils/src/com/cloud/utils/db/EntityManager.java
index 7612a75..8f4e385 100644
--- a/utils/src/com/cloud/utils/db/EntityManager.java
+++ b/utils/src/com/cloud/utils/db/EntityManager.java
@@ -75,4 +75,10 @@ public interface EntityManager {
     public <T, K extends Serializable> void remove(Class<T> entityType, K id);
 
     public <T, K extends Serializable> T findByIdIncludingRemoved(Class<T> entityType, K id);
+
+    public static final String MESSAGE_REMOVE_ENTITY_EVENT = "Message.RemoveEntity.Event";
+
+    public static final String MESSAGE_GRANT_ENTITY_EVENT = "Message.GrantEntity.Event";
+    public static final String MESSAGE_REVOKE_ENTITY_EVENT = "Message.RevokeEntity.Event";
+    public static final String MESSAGE_ADD_DOMAIN_WIDE_ENTITY_EVENT = "Message.AddDomainWideEntity.Event";
 }


[38/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
Fixed CLOUDSTACK-6210 LDAP:listLdapUsers api throws exception when we click on "Add LDAP Account" This occurs when ldap basedn is not configured. Throwing an IAE and a proper message is returned from the api call

Signed-off-by: Ian Duffy <ia...@ianduffy.ie>


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

Branch: refs/heads/resize-root
Commit: 4552ec632201e7432afae7770f5854aaa244267c
Parents: 78b148d
Author: Rajani Karuturi <ra...@gmail.com>
Authored: Fri Mar 7 11:13:35 2014 +0530
Committer: Ian Duffy <ia...@ianduffy.ie>
Committed: Fri Mar 7 16:57:13 2014 +0000

----------------------------------------------------------------------
 .../apache/cloudstack/ldap/LdapUserManager.java |   8 +-
 .../cloudstack/ldap/LdapUserManagerSpec.groovy  | 263 ++++++++++---------
 2 files changed, 145 insertions(+), 126 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4552ec63/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapUserManager.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapUserManager.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapUserManager.java
index 2dacafe..afdf975 100644
--- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapUserManager.java
+++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapUserManager.java
@@ -29,6 +29,8 @@ import javax.naming.directory.DirContext;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 
+import org.apache.commons.lang.StringUtils;
+
 public class LdapUserManager {
 
     @Inject
@@ -185,6 +187,10 @@ public class LdapUserManager {
         controls.setSearchScope(_ldapConfiguration.getScope());
         controls.setReturningAttributes(_ldapConfiguration.getReturnAttributes());
 
-        return context.search(_ldapConfiguration.getBaseDn(), generateSearchFilter(username), controls);
+        String basedn = _ldapConfiguration.getBaseDn();
+        if (StringUtils.isBlank(basedn)) {
+            throw new IllegalArgumentException("ldap basedn is not configured");
+        }
+        return context.search(basedn, generateSearchFilter(username), controls);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4552ec63/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserManagerSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserManagerSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserManagerSpec.groovy
index fa735d3..9fbc81f 100644
--- a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserManagerSpec.groovy
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserManagerSpec.groovy
@@ -21,10 +21,9 @@ import org.apache.cloudstack.ldap.LdapUserManager
 import spock.lang.Shared
 
 import javax.naming.NamingException
-import javax.naming.NamingEnumeration
 import javax.naming.directory.Attribute
 import javax.naming.directory.Attributes
-import javax.naming.directory.DirContext
+import javax.naming.directory.InitialDirContext
 import javax.naming.directory.SearchControls
 import javax.naming.directory.SearchResult
 import javax.naming.ldap.LdapContext
@@ -51,83 +50,83 @@ class LdapUserManagerSpec extends spock.lang.Specification {
 
     private def createGroupSearchContext() {
 
-	def umSearchResult = Mock(SearchResult)
-	umSearchResult.getName() >> principal;
-	umSearchResult.getAttributes() >> principal
+        def umSearchResult = Mock(SearchResult)
+        umSearchResult.getName() >> principal;
+        umSearchResult.getAttributes() >> principal
 
-	def uniqueMembers = new BasicNamingEnumerationImpl()
-	uniqueMembers.add(umSearchResult);
-	def attributes = Mock(Attributes)
-	def uniqueMemberAttribute = Mock(Attribute)
-	uniqueMemberAttribute.getId() >> "uniquemember"
-	uniqueMemberAttribute.getAll() >> uniqueMembers
-	attributes.get("uniquemember") >> uniqueMemberAttribute
+        def uniqueMembers = new BasicNamingEnumerationImpl()
+        uniqueMembers.add(umSearchResult);
+        def attributes = Mock(Attributes)
+        def uniqueMemberAttribute = Mock(Attribute)
+        uniqueMemberAttribute.getId() >> "uniquemember"
+        uniqueMemberAttribute.getAll() >> uniqueMembers
+        attributes.get("uniquemember") >> uniqueMemberAttribute
 
-	def groupSearchResult = Mock(SearchResult)
-	groupSearchResult.getName() >> principal;
-	groupSearchResult.getAttributes() >> attributes
+        def groupSearchResult = Mock(SearchResult)
+        groupSearchResult.getName() >> principal;
+        groupSearchResult.getAttributes() >> attributes
 
-	def searchGroupResults = new BasicNamingEnumerationImpl()
-	searchGroupResults.add(groupSearchResult);
+        def searchGroupResults = new BasicNamingEnumerationImpl()
+        searchGroupResults.add(groupSearchResult);
 
-	attributes = createUserAttributes(username, email, firstname, lastname)
-	SearchResult userSearchResult = createSearchResult(attributes)
-	def searchUsersResults = new BasicNamingEnumerationImpl()
-	searchUsersResults.add(userSearchResult);
+        attributes = createUserAttributes(username, email, firstname, lastname)
+        SearchResult userSearchResult = createSearchResult(attributes)
+        def searchUsersResults = new BasicNamingEnumerationImpl()
+        searchUsersResults.add(userSearchResult);
 
-	def context = Mock(LdapContext)
-	context.search(_, _, _) >>> [searchGroupResults, searchUsersResults];
+        def context = Mock(LdapContext)
+        context.search(_, _, _) >>> [searchGroupResults, searchUsersResults];
 
-	return context
+        return context
     }
 
     private def createContext() {
-		Attributes attributes = createUserAttributes(username, email, firstname, lastname)
-		SearchResult searchResults = createSearchResult(attributes)
-		def searchUsersResults = new BasicNamingEnumerationImpl()
-		searchUsersResults.add(searchResults);
+        Attributes attributes = createUserAttributes(username, email, firstname, lastname)
+        SearchResult searchResults = createSearchResult(attributes)
+        def searchUsersResults = new BasicNamingEnumerationImpl()
+        searchUsersResults.add(searchResults);
 
-		def context = Mock(LdapContext)
-		context.search(_, _, _) >> searchUsersResults;
+        def context = Mock(LdapContext)
+        context.search(_, _, _) >> searchUsersResults;
 
-		return context
+        return context
     }
 
     private SearchResult createSearchResult(attributes) {
-		def search = Mock(SearchResult)
+        def search = Mock(SearchResult)
 
-		search.getName() >> "cn=" + attributes.getAt("uid").get();
+        search.getName() >> "cn=" + attributes.getAt("uid").get();
 
-		search.getAttributes() >> attributes
-	search.getNameInNamespace() >> principal
+        search.getAttributes() >> attributes
+        search.getNameInNamespace() >> principal
 
-		return search
+        return search
     }
 
     private Attributes createUserAttributes(String username, String email, String firstname, String lastname) {
-		def attributes = Mock(Attributes)
+        def attributes = Mock(Attributes)
 
-		def nameAttribute = Mock(Attribute)
-		nameAttribute.getId() >> "uid"
-		nameAttribute.get() >> username
-		attributes.get("uid") >> nameAttribute
+        def nameAttribute = Mock(Attribute)
+        nameAttribute.getId() >> "uid"
+        nameAttribute.get() >> username
+        attributes.get("uid") >> nameAttribute
 
-		def mailAttribute = Mock(Attribute)
-		mailAttribute.getId() >> "mail"
-		mailAttribute.get() >> email
-		attributes.get("mail") >> mailAttribute
+        def mailAttribute = Mock(Attribute)
+        mailAttribute.getId() >> "mail"
+        mailAttribute.get() >> email
+        attributes.get("mail") >> mailAttribute
 
-		def givennameAttribute = Mock(Attribute)
-		givennameAttribute.getId() >> "givenname"
-		givennameAttribute.get() >> firstname
-		attributes.get("givenname") >> givennameAttribute
+        def givennameAttribute = Mock(Attribute)
+        givennameAttribute.getId() >> "givenname"
+        givennameAttribute.get() >> firstname
+        attributes.get("givenname") >> givennameAttribute
 
-		def snAttribute = Mock(Attribute)
-		snAttribute.getId() >> "sn"
-		snAttribute.get() >> lastname
-		attributes.get("sn") >> snAttribute
+        def snAttribute = Mock(Attribute)
+        snAttribute.getId() >> "sn"
+        snAttribute.get() >> lastname
+        attributes.get("sn") >> snAttribute
 
-		return attributes
+        return attributes
     }
 
     def setupSpec() {
@@ -140,144 +139,158 @@ class LdapUserManagerSpec extends spock.lang.Specification {
         ldapConfiguration.getFirstnameAttribute() >> "givenname"
         ldapConfiguration.getLastnameAttribute() >> "sn"
         ldapConfiguration.getBaseDn() >> "dc=cloudstack,dc=org"
-	ldapConfiguration.getCommonNameAttribute() >> "cn"
-	ldapConfiguration.getGroupObject() >> "groupOfUniqueNames"
-	ldapConfiguration.getGroupUniqueMemeberAttribute() >> "uniquemember"
+        ldapConfiguration.getCommonNameAttribute() >> "cn"
+        ldapConfiguration.getGroupObject() >> "groupOfUniqueNames"
+        ldapConfiguration.getGroupUniqueMemeberAttribute() >> "uniquemember"
 
         username = "rmurphy"
         email = "rmurphy@test.com"
         firstname = "Ryan"
         lastname = "Murphy"
-		principal = "cn=" + username + "," + ldapConfiguration.getBaseDn()
+        principal = "cn=" + username + "," + ldapConfiguration.getBaseDn()
     }
 
     def "Test successfully creating an Ldap User from Search result"() {
-		given: "We have attributes, a search and a user manager"
-		def attributes = createUserAttributes(username, email, firstname, lastname)
+        given: "We have attributes, a search and a user manager"
+        def attributes = createUserAttributes(username, email, firstname, lastname)
         def search = createSearchResult(attributes)
         def userManager = new LdapUserManager(ldapConfiguration)
         def result = userManager.createUser(search)
 
-		expect: "The crated user the data supplied from LDAP"
+        expect: "The crated user the data supplied from LDAP"
 
         result.username == username
         result.email == email
         result.firstname == firstname
         result.lastname == lastname
-		result.principal == principal
+        result.principal == principal
     }
 
     def "Test successfully returning a list from get users"() {
-		given: "We have a LdapUserManager"
+        given: "We have a LdapUserManager"
 
         def userManager = new LdapUserManager(ldapConfiguration)
 
-		when: "A request for users is made"
+        when: "A request for users is made"
         def result = userManager.getUsers(username, createContext())
 
-		then: "A list of users is returned"
+        then: "A list of users is returned"
         result.size() == 1
     }
 
     def "Test successfully returning a list from get users when no username is given"() {
-		given: "We have a LdapUserManager"
+        given: "We have a LdapUserManager"
 
         def userManager = new LdapUserManager(ldapConfiguration)
 
-		when: "Get users is called without a username"
+        when: "Get users is called without a username"
         def result = userManager.getUsers(createContext())
 
-		then: "All users are returned"
-		result.size() == 1
+        then: "All users are returned"
+        result.size() == 1
     }
 
     def "Test successfully returning a NamingEnumeration from searchUsers"() {
-		given: "We have a LdapUserManager"
-		def userManager = new LdapUserManager(ldapConfiguration)
+        given: "We have a LdapUserManager"
+        def userManager = new LdapUserManager(ldapConfiguration)
 
-		when: "We search for users"
+        when: "We search for users"
         def result = userManager.searchUsers(createContext())
 
-		then: "A list of users are returned."
+        then: "A list of users are returned."
         result.next().getName() + "," + ldapConfiguration.getBaseDn() == principal
     }
 
     def "Test successfully returning an Ldap user from a get user request"() {
-		given: "We have a LdapUserMaanger"
+        given: "We have a LdapUserMaanger"
 
-		def userManager = new LdapUserManager(ldapConfiguration)
+        def userManager = new LdapUserManager(ldapConfiguration)
 
-		when: "A request for a user is made"
-		def result = userManager.getUser(username, createContext())
+        when: "A request for a user is made"
+        def result = userManager.getUser(username, createContext())
 
-		then: "The user is returned"
-		result.username == username
-		result.email == email
-		result.firstname == firstname
-		result.lastname == lastname
-		result.principal == principal
+        then: "The user is returned"
+        result.username == username
+        result.email == email
+        result.firstname == firstname
+        result.lastname == lastname
+        result.principal == principal
     }
 
     def "Test successfully throwing an exception when no users are found with getUser"() {
-		given: "We have a seachResult of users and a User Manager"
+        given: "We have a seachResult of users and a User Manager"
 
-		def searchUsersResults = new BasicNamingEnumerationImpl()
+        def searchUsersResults = new BasicNamingEnumerationImpl()
 
-		def context = Mock(LdapContext)
-		context.search(_, _, _) >> searchUsersResults;
+        def context = Mock(LdapContext)
+        context.search(_, _, _) >> searchUsersResults;
 
-		def userManager = new LdapUserManager(ldapConfiguration)
+        def userManager = new LdapUserManager(ldapConfiguration)
 
-		when: "a get user request is made and no user is found"
-		def result = userManager.getUser(username, context)
+        when: "a get user request is made and no user is found"
+        def result = userManager.getUser(username, context)
 
-		then: "An exception is thrown."
-		thrown NamingException
+        then: "An exception is thrown."
+        thrown NamingException
     }
 
     def "Test that a newly created Ldap User Manager is not null"() {
-		given: "You have created a new Ldap user manager object"
-		def result = new LdapUserManager();
-		expect: "The result is not null"
-		result != null
+        given: "You have created a new Ldap user manager object"
+        def result = new LdapUserManager();
+        expect: "The result is not null"
+        result != null
     }
 
     def "test successful generateGroupSearchFilter"() {
-	given: "ldap user manager and ldap config"
-	def ldapUserManager = new LdapUserManager(ldapConfiguration)
-	def groupName = varGroupName == null ? "*" : varGroupName
-	def expectedResult = "(&(objectClass=groupOfUniqueNames)(cn="+groupName+"))";
-
-	def result = ldapUserManager.generateGroupSearchFilter(varGroupName)
-	expect:
-	result == expectedResult
-	where: "The group name passed is set to "
-	varGroupName << ["", null, "Murphy"]
+        given: "ldap user manager and ldap config"
+        def ldapUserManager = new LdapUserManager(ldapConfiguration)
+        def groupName = varGroupName == null ? "*" : varGroupName
+        def expectedResult = "(&(objectClass=groupOfUniqueNames)(cn=" + groupName + "))";
+
+        def result = ldapUserManager.generateGroupSearchFilter(varGroupName)
+        expect:
+        result == expectedResult
+        where: "The group name passed is set to "
+        varGroupName << ["", null, "Murphy"]
     }
 
-    def "test successful getUsersInGroup"(){
-	given: "ldap user manager and ldap config"
-	def ldapUserManager = new LdapUserManager(ldapConfiguration)
+    def "test successful getUsersInGroup"() {
+        given: "ldap user manager and ldap config"
+        def ldapUserManager = new LdapUserManager(ldapConfiguration)
+
+        when: "A request for users is made"
+        def result = ldapUserManager.getUsersInGroup("engineering", createGroupSearchContext())
+        then: "one user is returned"
+        result.size() == 1
+    }
+
+    def "test successful getUserForDn"() {
+        given: "ldap user manager and ldap config"
+        def ldapUserManager = new LdapUserManager(ldapConfiguration)
+
+        when: "A request for users is made"
+        def result = ldapUserManager.getUserForDn("cn=Ryan Murphy,ou=engineering,dc=cloudstack,dc=org", createContext())
+        then: "A list of users is returned"
+        result != 1
+        result.username == username
+        result.email == email
+        result.firstname == firstname
+        result.lastname == lastname
+        result.principal == principal
 
-	when: "A request for users is made"
-	def result = ldapUserManager.getUsersInGroup("engineering", createGroupSearchContext())
-	then: "one user is returned"
-	result.size() == 1
     }
 
-    def "test successful getUserForDn"(){
-	given: "ldap user manager and ldap config"
-	def ldapUserManager = new LdapUserManager(ldapConfiguration)
+    def "test searchUsers when ldap basedn in not set"() {
+        given: "ldap configuration where basedn is not set"
+        def ldapconfig = Mock(LdapConfiguration)
+        ldapconfig.getBaseDn() >> null
+        def ldapUserManager = new LdapUserManager(ldapconfig)
 
-	when: "A request for users is made"
-	def result = ldapUserManager.getUserForDn("cn=Ryan Murphy,ou=engineering,dc=cloudstack,dc=org",createContext())
-	then: "A list of users is returned"
-	result != 1
-	result.username == username
-	result.email == email
-	result.firstname == firstname
-	result.lastname == lastname
-	result.principal == principal
+        when: "A request for search users is made"
+        def result = ldapUserManager.searchUsers(new InitialDirContext())
 
+        then: "An exception with no basedn defined is returned"
+        def e = thrown(IllegalArgumentException)
+        e.message == "ldap basedn is not configured"
     }
 }


[18/50] [abbrv] Externalized the hardcodedstrings from UI JAVASCRIPT files.

Posted by ml...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/ui/scripts/templates.js
----------------------------------------------------------------------
diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js
index 3551613..7a45463 100644
--- a/ui/scripts/templates.js
+++ b/ui/scripts/templates.js
@@ -237,7 +237,7 @@
                                     },
 
                                     xenserverToolsVersion61plus: {
-                                        label: 'XenServer Tools Version 6.1+',
+                                        label: 'label.xenserver.tools.version.61.plus',
                                         isBoolean: true,
                                         isChecked: function (args) {
                                             var b = false;
@@ -434,7 +434,7 @@
                                     },
 
                                     isdynamicallyscalable: {
-                                        label: "Dynamically Scalable",
+                                        label: "label.dynamically.scalable",
                                         docID: 'helpRegisterTemplateDynamicallyScalable',
                                         isBoolean: true
                                     },
@@ -951,7 +951,7 @@
                                         label: 'label.hypervisor'
                                     },
                                     xenserverToolsVersion61plus: {
-                                        label: 'XenServer Tools Version 6.1+',
+                                        label: 'label.xenserver.tools.version.61.plus',
                                         isBoolean: true,
                                         isEditable: function () {
                                             if (isAdmin())

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/ui/scripts/ui-custom/zoneChart.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/zoneChart.js b/ui/scripts/ui-custom/zoneChart.js
index e847a19..bc30d51 100644
--- a/ui/scripts/ui-custom/zoneChart.js
+++ b/ui/scripts/ui-custom/zoneChart.js
@@ -24,7 +24,7 @@
          */
         var viewAllButton = function(args) {
             var $viewAll = $('<div>').addClass('button view-all');
-            var $label = $('<span>').addClass('view-all-label').html(args.label ? args.label : 'View all');
+            var $label = $('<span>').addClass('view-all-label').html(args.label ? args.label : 'label.view.all');
             var $browser = args.$browser;
             var action = args.action;
             // Launch a list view
@@ -111,46 +111,46 @@
                 // Resource items
                 var computeResources = {
                     zone: {
-                        label: 'Zone'
+                        label: 'label.zone'
                     },
 
                     pods: {
-                        label: 'Pods',
+                        label: 'label.pods',
                         viewAll: {
                             action: actions.listView('pods', context)
                         }
                     },
 
                     clusters: {
-                        label: 'Clusters',
+                        label: 'label.clusters',
                         viewAll: {
                             action: actions.listView('clusters', context)
                         }
                     },
 
                     hosts: {
-                        label: 'Hosts',
+                        label: 'label.hosts',
                         viewAll: {
                             action: actions.listView('hosts', context)
                         }
                     },
 
                     primaryStorage: {
-                        label: 'Primary Storage',
+                        label: 'label.primary.storage',
                         viewAll: {
                             action: actions.listView('primary-storage', context)
                         }
                     },
 
                     ucs: {
-                        label: 'UCS',
+                        label: 'label.ucs',
                         viewAll: {
                             action: actions.listView('ucs', context)
                         }
                     },
 
                     secondaryStorage: {
-                        label: 'Secondary Storage',
+                        label: 'label.secondary.storage',
                         viewAll: {
                             action: actions.listView('secondary-storage', context)
                         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/ui/scripts/ui/core.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/core.js b/ui/scripts/ui/core.js
index 06be12b..add7d06 100644
--- a/ui/scripts/ui/core.js
+++ b/ui/scripts/ui/core.js
@@ -363,7 +363,7 @@
             function(value, element) {
                 return (value.indexOf("<") == -1 && value.indexOf(">") == -1);
             },
-            jQuery.format("Disallowed characters: <, >")
+            jQuery.format('message.disallowed.characters')
         );
 
         // Check for pending project invitations

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/ui/scripts/ui/widgets/tagger.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/tagger.js b/ui/scripts/ui/widgets/tagger.js
index 673bd43..3ffd80b 100644
--- a/ui/scripts/ui/widgets/tagger.js
+++ b/ui/scripts/ui/widgets/tagger.js
@@ -22,7 +22,7 @@
 
         if (!key || !value) {
             cloudStack.dialog.notice({
-                message: 'Please specify a tag key and value'
+                message: 'message.specifiy.tag.key.value'
             });
             return false;
         }
@@ -42,7 +42,7 @@
             var $valueField = $('<div>').addClass('field value');
             var $valueLabel = $('<label>').attr('for', 'value').html(_l('label.value') + ':');
             var $value = $('<input>').addClass('value disallowSpecialCharacters').attr('name', 'value');
-            var $submit = $('<input>').attr('type', 'submit').val('Add');
+            var $submit = $('<input>').attr('type', 'submit').val('label.add');
 
             $keyField.append($keyLabel, $key);
             $valueField.append($valueLabel, $value);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/ui/scripts/vpc.js
----------------------------------------------------------------------
diff --git a/ui/scripts/vpc.js b/ui/scripts/vpc.js
index 770ee9b..73d34df 100644
--- a/ui/scripts/vpc.js
+++ b/ui/scripts/vpc.js
@@ -66,7 +66,7 @@
         fields: {
 
             'number': {
-                label: 'Rule Number',
+                label: 'label.rule.number',
                 edit: true,
                 isEditable: true
 
@@ -78,16 +78,16 @@
                 isEditable: true
             },
             action: {
-                label: 'Action',
+                label: 'label.action',
                 isEditable: true,
                 select: function(args) {
                     args.response.success({
                         data: [{
-                            name: 'Allow',
-                            description: 'Allow'
+                            name: 'label.allow',
+                            description: 'label.allow'
                         }, {
-                            name: 'Deny',
-                            description: 'Deny'
+                            name: 'label.deny',
+                            description: 'label.deny'
                         }]
                     });
                 }
@@ -1926,14 +1926,14 @@
                             docID: 'helpVPCGatewayNetmask'
                         },
                         sourceNat: {
-                            label: 'Source NAT',
+                            label: 'label.source.nat',
                             isBoolean: true,
                             isChecked: false
 
                         },
 
                         aclid: {
-                            label: 'ACL',
+                            label: 'label.acl',
                             select: function(args) {
                                 $.ajax({
                                     url: createURL('listNetworkACLLists'),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/ui/scripts/zoneWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/zoneWizard.js b/ui/scripts/zoneWizard.js
index 1de3646..988e0f9 100755
--- a/ui/scripts/zoneWizard.js
+++ b/ui/scripts/zoneWizard.js
@@ -1569,7 +1569,7 @@
 
                                 var protocol = $(this).val();
 
-                                $form.find('[rel=path]').find(".name").find("label").html('<span class=\"field-required\">*</span>Path:');
+                                $form.find('[rel=path]').find(".name").find("label").html('<span class=\"field-required\">*</span>"label.path":');
 
                                 if (protocol == null)
                                     return;
@@ -1635,7 +1635,7 @@
                                     $form.find('[rel=server]').find(".value").find("input").val("localhost");
                                    
                                     $form.find('[rel=path]').css('display', 'block');                                    
-                                    $form.find('[rel=path]').find(".name").find("label").html("<span class=\"field-required\">*</span>SR Name-Label:");
+                                    $form.find('[rel=path]').find(".name").find("label").html("<span class=\"field-required\">*</span>'label.SR.name':");
                                    
                                     $form.find('[rel=smbUsername]').hide();
                                     $form.find('[rel=smbPassword]').hide();
@@ -2123,20 +2123,20 @@
 
                     //SMB (begin)                                            
                     smbUsername: {
-                    	label: 'SMB Username',
+                    	label: 'label.smb.username',
                     	validation: {
                             required: true
                         }
                     },
                     smbPassword: {
-                    	label: 'SMB Password',
+                    	label: 'label.smb.password',
                     	isPassword: true,
                     	validation: {
                             required: true
                         }
                     },
                     smbDomain: {
-                    	label: 'SMB Domain',
+                    	label: 'label.smb.domain',
                     	validation: {
                             required: true
                         }
@@ -2189,7 +2189,7 @@
                     },
 
                     createNfsCache: {
-                        label: 'Create NFS Secondary Staging Store',
+                        label: 'label.create.nfs.secondary.staging.storage',
                         isBoolean: true,
                         isChecked: true,
                         isHidden: true


[05/50] [abbrv] CLOUDSTACK-5920: IAM service server.

Posted by ml...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDao.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDao.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDao.java
new file mode 100644
index 0000000..6a2df89
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDao.java
@@ -0,0 +1,16 @@
+package org.apache.cloudstack.iam.server.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.iam.server.IAMGroupPolicyMapVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface IAMGroupPolicyMapDao extends GenericDao<IAMGroupPolicyMapVO, Long> {
+
+    List<IAMGroupPolicyMapVO> listByGroupId(long groupId);
+
+    List<IAMGroupPolicyMapVO> listByPolicyId(long policyId);
+
+    IAMGroupPolicyMapVO findByGroupAndPolicy(long groupId, long policyId);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDaoImpl.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDaoImpl.java
new file mode 100644
index 0000000..95b6bac
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDaoImpl.java
@@ -0,0 +1,61 @@
+package org.apache.cloudstack.iam.server.dao;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.ConfigurationException;
+
+import org.apache.cloudstack.iam.server.IAMGroupPolicyMapVO;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+public class IAMGroupPolicyMapDaoImpl extends GenericDaoBase<IAMGroupPolicyMapVO, Long> implements IAMGroupPolicyMapDao {
+
+    private SearchBuilder<IAMGroupPolicyMapVO> ListByGroupId;
+    private SearchBuilder<IAMGroupPolicyMapVO> ListByPolicyId;
+    private SearchBuilder<IAMGroupPolicyMapVO> findByPolicyGroupId;
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+        super.configure(name, params);
+
+        ListByGroupId = createSearchBuilder();
+        ListByGroupId.and("groupId", ListByGroupId.entity().getAclGroupId(), SearchCriteria.Op.EQ);
+        ListByGroupId.done();
+
+        ListByPolicyId = createSearchBuilder();
+        ListByPolicyId.and("policyId", ListByPolicyId.entity().getAclPolicyId(), SearchCriteria.Op.EQ);
+        ListByPolicyId.done();
+
+        findByPolicyGroupId = createSearchBuilder();
+        findByPolicyGroupId.and("policyId", findByPolicyGroupId.entity().getAclPolicyId(), SearchCriteria.Op.EQ);
+        findByPolicyGroupId.and("groupId", findByPolicyGroupId.entity().getAclGroupId(), SearchCriteria.Op.EQ);
+        findByPolicyGroupId.done();
+
+        return true;
+    }
+
+    @Override
+    public List<IAMGroupPolicyMapVO> listByGroupId(long groupId) {
+        SearchCriteria<IAMGroupPolicyMapVO> sc = ListByGroupId.create();
+        sc.setParameters("groupId", groupId);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<IAMGroupPolicyMapVO> listByPolicyId(long policyId) {
+        SearchCriteria<IAMGroupPolicyMapVO> sc = ListByPolicyId.create();
+        sc.setParameters("policyId", policyId);
+        return listBy(sc);
+    }
+
+    @Override
+    public IAMGroupPolicyMapVO findByGroupAndPolicy(long groupId, long policyId) {
+        SearchCriteria<IAMGroupPolicyMapVO> sc = findByPolicyGroupId.create();
+        sc.setParameters("policyId", policyId);
+        sc.setParameters("groupId", groupId);
+        return findOneBy(sc);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyDao.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyDao.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyDao.java
new file mode 100644
index 0000000..ace7d85
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyDao.java
@@ -0,0 +1,28 @@
+// 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.iam.server.dao;
+
+import org.apache.cloudstack.iam.api.IAMPolicy;
+import org.apache.cloudstack.iam.server.IAMPolicyVO;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface IAMPolicyDao extends GenericDao<IAMPolicyVO, Long> {
+
+    IAMPolicy findByName(String policyName);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyDaoImpl.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyDaoImpl.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyDaoImpl.java
new file mode 100644
index 0000000..293cf6f
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyDaoImpl.java
@@ -0,0 +1,57 @@
+// 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.iam.server.dao;
+
+import java.util.Map;
+
+import javax.naming.ConfigurationException;
+
+import org.apache.cloudstack.iam.api.IAMPolicy;
+import org.apache.cloudstack.iam.server.IAMPolicyVO;
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+public class IAMPolicyDaoImpl extends GenericDaoBase<IAMPolicyVO, Long> implements IAMPolicyDao {
+    private SearchBuilder<IAMPolicyVO> nameSearch;
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+        super.configure(name, params);
+
+        nameSearch = createSearchBuilder();
+        nameSearch.and("name", nameSearch.entity().getName(), SearchCriteria.Op.EQ);
+        // nameSearch.and("domainId", nameSearch.entity().getDomainId(),
+        // SearchCriteria.Op.EQ);
+        nameSearch.done();
+
+
+        return true;
+    }
+
+    @Override
+    public IAMPolicy findByName(String name) {
+        SearchCriteria<IAMPolicyVO> sc = nameSearch.create();
+        sc.setParameters("name", name);
+
+        return findOneBy(sc);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyPermissionDao.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyPermissionDao.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyPermissionDao.java
new file mode 100644
index 0000000..cdcb02b
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyPermissionDao.java
@@ -0,0 +1,39 @@
+// 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.iam.server.dao;
+import java.util.List;
+
+import org.apache.cloudstack.iam.api.IAMPolicyPermission.Permission;
+import org.apache.cloudstack.iam.server.IAMPolicyPermissionVO;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface IAMPolicyPermissionDao extends GenericDao<IAMPolicyPermissionVO, Long> {
+
+    List<IAMPolicyPermissionVO> listByPolicy(long policyId);
+
+    IAMPolicyPermissionVO findByPolicyAndEntity(long policyId, String entityType, String scope, Long scopeId,
+            String action, Permission perm);
+
+    List<IAMPolicyPermissionVO> listGrantedByActionAndScope(long policyId, String action, String scope);
+
+    List<IAMPolicyPermissionVO> listByPolicyActionAndEntity(long policyId, String action, String entityType);
+
+    List<IAMPolicyPermissionVO> listByPolicyAccessAndEntity(long policyId, String accessType, String entityType);
+
+    List<IAMPolicyPermissionVO> listByEntity(String entityType, Long entityId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyPermissionDaoImpl.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyPermissionDaoImpl.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyPermissionDaoImpl.java
new file mode 100644
index 0000000..3f976cf
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMPolicyPermissionDaoImpl.java
@@ -0,0 +1,129 @@
+// 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.iam.server.dao;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.ConfigurationException;
+
+import org.apache.cloudstack.iam.api.IAMPolicyPermission.Permission;
+import org.apache.cloudstack.iam.server.IAMPolicyPermissionVO;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+public class IAMPolicyPermissionDaoImpl extends GenericDaoBase<IAMPolicyPermissionVO, Long> implements
+        IAMPolicyPermissionDao {
+
+    private SearchBuilder<IAMPolicyPermissionVO> policyIdSearch;
+    private SearchBuilder<IAMPolicyPermissionVO> fullSearch;
+    private SearchBuilder<IAMPolicyPermissionVO> actionScopeSearch;
+    private SearchBuilder<IAMPolicyPermissionVO> entitySearch;
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+        super.configure(name, params);
+
+        policyIdSearch = createSearchBuilder();
+        policyIdSearch.and("policyId", policyIdSearch.entity().getAclPolicyId(), SearchCriteria.Op.EQ);
+        policyIdSearch.done();
+
+        fullSearch = createSearchBuilder();
+        fullSearch.and("policyId", fullSearch.entity().getAclPolicyId(), SearchCriteria.Op.EQ);
+        fullSearch.and("entityType", fullSearch.entity().getEntityType(), SearchCriteria.Op.EQ);
+        fullSearch.and("scope", fullSearch.entity().getScope(), SearchCriteria.Op.EQ);
+        fullSearch.and("scopeId", fullSearch.entity().getScopeId(), SearchCriteria.Op.EQ);
+        fullSearch.and("action", fullSearch.entity().getAction(), SearchCriteria.Op.EQ);
+        fullSearch.and("permission", fullSearch.entity().getPermission(), SearchCriteria.Op.EQ);
+        fullSearch.and("accessType", fullSearch.entity().getAccessType(), SearchCriteria.Op.EQ);
+        fullSearch.done();
+
+        actionScopeSearch = createSearchBuilder();
+        actionScopeSearch.and("policyId", actionScopeSearch.entity().getAclPolicyId(), SearchCriteria.Op.EQ);
+        actionScopeSearch.and("scope", actionScopeSearch.entity().getScope(), SearchCriteria.Op.EQ);
+        actionScopeSearch.and("action", actionScopeSearch.entity().getAction(), SearchCriteria.Op.EQ);
+        actionScopeSearch.and("permission", actionScopeSearch.entity().getPermission(), SearchCriteria.Op.EQ);
+        actionScopeSearch.done();
+
+        entitySearch = createSearchBuilder();
+        entitySearch.and("entityType", entitySearch.entity().getEntityType(), SearchCriteria.Op.EQ);
+        entitySearch.and("scopeId", entitySearch.entity().getScopeId(), SearchCriteria.Op.EQ);
+        entitySearch.done();
+
+        return true;
+    }
+
+    @Override
+    public List<IAMPolicyPermissionVO> listByPolicy(long policyId) {
+        SearchCriteria<IAMPolicyPermissionVO> sc = policyIdSearch.create();
+        sc.setParameters("policyId", policyId);
+        return listBy(sc);
+    }
+
+    @Override
+    public IAMPolicyPermissionVO findByPolicyAndEntity(long policyId, String entityType, String scope, Long scopeId,
+            String action, Permission perm) {
+        SearchCriteria<IAMPolicyPermissionVO> sc = fullSearch.create();
+        sc.setParameters("policyId", policyId);
+        sc.setParameters("entityType", entityType);
+        sc.setParameters("scope", scope);
+        sc.setParameters("scopeId", scopeId);
+        sc.setParameters("action", action);
+        sc.setParameters("permission", perm);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public List<IAMPolicyPermissionVO> listGrantedByActionAndScope(long policyId, String action, String scope) {
+        SearchCriteria<IAMPolicyPermissionVO> sc = actionScopeSearch.create();
+        sc.setParameters("policyId", policyId);
+        sc.setParameters("action", action);
+        sc.setParameters("scope", scope);
+        sc.setParameters("permission", Permission.Allow);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<IAMPolicyPermissionVO> listByPolicyActionAndEntity(long policyId, String action, String entityType) {
+        SearchCriteria<IAMPolicyPermissionVO> sc = fullSearch.create();
+        sc.setParameters("policyId", policyId);
+        sc.setParameters("entityType", entityType);
+        sc.setParameters("action", action);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<IAMPolicyPermissionVO> listByPolicyAccessAndEntity(long policyId, String accessType,
+            String entityType) {
+        SearchCriteria<IAMPolicyPermissionVO> sc = fullSearch.create();
+        sc.setParameters("policyId", policyId);
+        sc.setParameters("entityType", entityType);
+        sc.setParameters("accessType", accessType);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<IAMPolicyPermissionVO> listByEntity(String entityType, Long entityId) {
+        SearchCriteria<IAMPolicyPermissionVO> sc = fullSearch.create();
+        sc.setParameters("entityType", entityType);
+        sc.setParameters("scopeId", entityId);
+        return listBy(sc);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/test/org/apache/cloudstack/iam/IAMServiceUnitTest.java
----------------------------------------------------------------------
diff --git a/services/iam/server/test/org/apache/cloudstack/iam/IAMServiceUnitTest.java b/services/iam/server/test/org/apache/cloudstack/iam/IAMServiceUnitTest.java
new file mode 100644
index 0000000..53cfc71
--- /dev/null
+++ b/services/iam/server/test/org/apache/cloudstack/iam/IAMServiceUnitTest.java
@@ -0,0 +1,211 @@
+// 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.iam;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.ComponentScan.Filter;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.core.type.classreading.MetadataReader;
+import org.springframework.core.type.classreading.MetadataReaderFactory;
+import org.springframework.core.type.filter.TypeFilter;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.support.AnnotationConfigContextLoader;
+
+import org.apache.cloudstack.iam.api.IAMGroup;
+import org.apache.cloudstack.iam.api.IAMPolicy;
+import org.apache.cloudstack.iam.api.IAMService;
+import org.apache.cloudstack.iam.server.IAMGroupVO;
+import org.apache.cloudstack.iam.server.IAMPolicyVO;
+import org.apache.cloudstack.iam.server.IAMServiceImpl;
+import org.apache.cloudstack.iam.server.dao.IAMAccountPolicyMapDao;
+import org.apache.cloudstack.iam.server.dao.IAMGroupAccountMapDao;
+import org.apache.cloudstack.iam.server.dao.IAMGroupDao;
+import org.apache.cloudstack.iam.server.dao.IAMGroupPolicyMapDao;
+import org.apache.cloudstack.iam.server.dao.IAMPolicyDao;
+import org.apache.cloudstack.iam.server.dao.IAMPolicyPermissionDao;
+import org.apache.cloudstack.test.utils.SpringUtils;
+
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.utils.component.ComponentContext;
+import com.cloud.utils.db.EntityManager;
+import com.cloud.utils.db.SearchCriteria;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
+public class IAMServiceUnitTest {
+
+    @Inject
+    IAMService _iamService;
+
+    @Inject
+    IAMPolicyDao _aclPolicyDao;
+
+    @Inject
+    IAMGroupDao _aclGroupDao;
+
+    @Inject
+    EntityManager _entityMgr;
+
+    @Inject
+    IAMGroupPolicyMapDao _aclGroupPolicyMapDao;
+
+    @Inject
+    IAMGroupAccountMapDao _aclGroupAccountMapDao;
+
+    @Inject
+    IAMPolicyPermissionDao _policyPermissionDao;
+
+    @BeforeClass
+    public static void setUpClass() throws ConfigurationException {
+    }
+
+    @Before
+    public void setUp() {
+        ComponentContext.initComponentsLifeCycle();
+        IAMGroupVO group = new IAMGroupVO("group1", "my first group");
+        Mockito.when(_aclGroupDao.persist(Mockito.any(IAMGroupVO.class))).thenReturn(group);
+        List<IAMGroupVO> groups = new ArrayList<IAMGroupVO>();
+        groups.add(group);
+        when(_aclGroupDao.search(Mockito.any(SearchCriteria.class), Mockito.any(com.cloud.utils.db.Filter.class)))
+                .thenReturn(groups);
+
+        IAMPolicyVO policy = new IAMPolicyVO("policy1", "my first policy");
+        Mockito.when(_aclPolicyDao.persist(Mockito.any(IAMPolicyVO.class))).thenReturn(policy);
+
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    @Test(expected = InvalidParameterValueException.class)
+    public void createAclGroupTest() {
+        IAMGroup group = _iamService.createIAMGroup("group1", "my first group", "/root/mydomain");
+        assertNotNull("Acl group 'group1' failed to create ", group);
+
+        IAMGroupVO group2 = new IAMGroupVO("group1", "my second group");
+        when(_aclGroupDao.findByName(eq("/root/mydomain"), eq("group1"))).thenReturn(group2);
+
+        IAMGroup group3 = _iamService.createIAMGroup("group1", "my first group", "/root/mydomain");
+    }
+
+    @Test(expected = InvalidParameterValueException.class)
+    public void deleteAclGroupInvalidIdTest() {
+        when(_aclGroupDao.findById(20L)).thenReturn(null);
+        _iamService.deleteIAMGroup(20L);
+    }
+
+    @Test
+    public void accountGroupMaptest() {
+        // create group
+        IAMGroupVO group = new IAMGroupVO("group1", "my first group");
+
+        // add account to group
+        List<Long> accountIds = new ArrayList<Long>();
+        accountIds.add(100L);
+        when(_aclGroupDao.findById(20L)).thenReturn(group);
+        _iamService.addAccountsToGroup(accountIds, 20L);
+
+        _iamService.removeAccountsFromGroup(accountIds, 20L);
+    }
+
+    @Test(expected = InvalidParameterValueException.class)
+    public void createAclPolicyTest() {
+        IAMPolicy policy = _iamService.createIAMPolicy("policy1", "my first policy", null, "/root/mydomain");
+        assertNotNull("Acl policy 'policy1' failed to create ", policy);
+
+        IAMPolicyVO rvo = new IAMPolicyVO("policy2", "second policy");
+        when(_aclPolicyDao.findByName(eq("policy2"))).thenReturn(rvo);
+
+        _iamService.createIAMPolicy("policy2", "second policy", null, "/root/mydomain");
+    }
+
+    @Test(expected = InvalidParameterValueException.class)
+    public void deleteAclPolicyInvalidIdTest() {
+        when(_aclPolicyDao.findById(34L)).thenReturn(null);
+        _iamService.deleteIAMPolicy(34L);
+    }
+
+    @Configuration
+    @ComponentScan(basePackageClasses = {IAMServiceImpl.class}, includeFilters = {@Filter(value = TestConfiguration.Library.class, type = FilterType.CUSTOM)}, useDefaultFilters = false)
+    public static class TestConfiguration extends SpringUtils.CloudStackTestConfiguration {
+
+        @Bean
+        public IAMPolicyDao aclPolicyDao() {
+            return Mockito.mock(IAMPolicyDao.class);
+        }
+
+        @Bean
+        public IAMGroupDao aclGroupDao() {
+            return Mockito.mock(IAMGroupDao.class);
+        }
+
+        @Bean
+        public EntityManager entityManager() {
+            return Mockito.mock(EntityManager.class);
+        }
+
+        @Bean
+        public IAMGroupPolicyMapDao aclGroupPolicyMapDao() {
+            return Mockito.mock(IAMGroupPolicyMapDao.class);
+        }
+
+        @Bean
+        public IAMGroupAccountMapDao aclGroupAccountMapDao() {
+            return Mockito.mock(IAMGroupAccountMapDao.class);
+        }
+
+        @Bean
+        public IAMAccountPolicyMapDao aclAccountPolicyMapDao() {
+            return Mockito.mock(IAMAccountPolicyMapDao.class);
+        }
+
+        @Bean
+        public IAMPolicyPermissionDao aclPolicyPermissionDao() {
+            return Mockito.mock(IAMPolicyPermissionDao.class);
+        }
+
+        public static class Library implements TypeFilter {
+
+            @Override
+            public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException {
+                ComponentScan cs = TestConfiguration.class.getAnnotation(ComponentScan.class);
+                return SpringUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/test/resources/db.properties
----------------------------------------------------------------------
diff --git a/services/iam/server/test/resources/db.properties b/services/iam/server/test/resources/db.properties
new file mode 100644
index 0000000..e1b5fe9
--- /dev/null
+++ b/services/iam/server/test/resources/db.properties
@@ -0,0 +1,75 @@
+# 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.
+
+
+# management server clustering parameters, change cluster.node.IP to the machine IP address
+# in which the management server(Tomcat) is running
+cluster.node.IP=127.0.0.1
+cluster.servlet.port=9090
+region.id=1
+
+# CloudStack database settings
+db.cloud.username=cloud
+db.cloud.password=cloud
+db.root.password=
+db.cloud.host=localhost
+db.cloud.port=3306
+db.cloud.name=cloud
+
+# CloudStack database tuning parameters
+db.cloud.maxActive=250
+db.cloud.maxIdle=30
+db.cloud.maxWait=10000
+db.cloud.autoReconnect=true
+db.cloud.validationQuery=SELECT 1
+db.cloud.testOnBorrow=true
+db.cloud.testWhileIdle=true
+db.cloud.timeBetweenEvictionRunsMillis=40000
+db.cloud.minEvictableIdleTimeMillis=240000
+db.cloud.poolPreparedStatements=false
+db.cloud.url.params=prepStmtCacheSize=517&cachePrepStmts=true&prepStmtCacheSqlLimit=4096
+
+# usage database settings
+db.usage.username=cloud
+db.usage.password=cloud
+db.usage.host=localhost
+db.usage.port=3306
+db.usage.name=cloud_usage
+
+# usage database tuning parameters
+db.usage.maxActive=100
+db.usage.maxIdle=30
+db.usage.maxWait=10000
+db.usage.autoReconnect=true
+
+# awsapi database settings
+db.awsapi.username=cloud
+db.awsapi.password=cloud
+db.awsapi.host=localhost
+db.awsapi.port=3306
+db.awsapi.name=cloudbridge
+
+# Simulator database settings
+db.simulator.username=cloud
+db.simulator.password=cloud
+db.simulator.host=localhost
+db.simulator.port=3306
+db.simulator.name=simulator
+db.simulator.maxActive=250
+db.simulator.maxIdle=30
+db.simulator.maxWait=10000
+db.simulator.autoReconnect=true


[02/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
Dialog: Trigger event when createform fields are being drawn

Trigger new event 'cloudStack.createForm.makeFields'
before field params are being passed to createForm for rendering.

This allows plugins to change and intepret fields before they are drawn.


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

Branch: refs/heads/resize-root
Commit: 8b0e04be619ba92e4eb54284da752eec84760bf7
Parents: 4df897f
Author: Brian Federle <br...@citrix.com>
Authored: Tue Mar 4 16:08:35 2014 -0800
Committer: Brian Federle <br...@citrix.com>
Committed: Tue Mar 4 16:11:26 2014 -0800

----------------------------------------------------------------------
 ui/scripts/ui/dialog.js | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8b0e04be/ui/scripts/ui/dialog.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/dialog.js b/ui/scripts/ui/dialog.js
index 035c355..5f0697a 100644
--- a/ui/scripts/ui/dialog.js
+++ b/ui/scripts/ui/dialog.js
@@ -70,6 +70,11 @@
                 return key;
             });
 
+            $(window).trigger('cloudStack.createForm.makeFields', {
+                $form: $form,
+                fields: fields
+            });
+
             var ret = function() {
                 $('.overlay').remove();
 


[49/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
Adding license header

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

Branch: refs/heads/resize-root
Commit: 548c81082b377e87cc6ba18ac21fe297af8996c5
Parents: c427e8d
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Fri Mar 7 16:43:03 2014 -0700
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Fri Mar 7 16:43:03 2014 -0700

----------------------------------------------------------------------
 api/src/com/cloud/offering/DiskOfferingInfo.java | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/548c8108/api/src/com/cloud/offering/DiskOfferingInfo.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/offering/DiskOfferingInfo.java b/api/src/com/cloud/offering/DiskOfferingInfo.java
index e9e7da1..75a520e 100644
--- a/api/src/com/cloud/offering/DiskOfferingInfo.java
+++ b/api/src/com/cloud/offering/DiskOfferingInfo.java
@@ -1,3 +1,21 @@
+/*
+ * 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 com.cloud.offering;
 
 public class DiskOfferingInfo {


[35/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-6047: Add testing for VR aggregation commands


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

Branch: refs/heads/resize-root
Commit: ccea5703df45ef12602421cd45510f5841ddb641
Parents: 60dc254
Author: Sheng Yang <sh...@citrix.com>
Authored: Tue Mar 4 14:28:41 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Thu Mar 6 16:22:23 2014 -0800

----------------------------------------------------------------------
 .../VirtualRoutingResourceTest.java             | 480 +++++++++++++++----
 .../debian/config/opt/cloud/bin/vr_cfg.sh       |   2 +-
 2 files changed, 390 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ccea5703/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
----------------------------------------------------------------------
diff --git a/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java b/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
index c980c9d..9b116dd 100644
--- a/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
+++ b/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
@@ -23,6 +23,7 @@ import com.cloud.agent.api.routing.CreateIpAliasCommand;
 import com.cloud.agent.api.routing.DeleteIpAliasCommand;
 import com.cloud.agent.api.routing.DhcpEntryCommand;
 import com.cloud.agent.api.routing.DnsMasqConfigCommand;
+import com.cloud.agent.api.routing.FinishAggregationCommand;
 import com.cloud.agent.api.routing.GroupAnswer;
 import com.cloud.agent.api.routing.IpAliasTO;
 import com.cloud.agent.api.routing.IpAssocCommand;
@@ -40,6 +41,7 @@ import com.cloud.agent.api.routing.SetSourceNatCommand;
 import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
 import com.cloud.agent.api.routing.SetStaticRouteCommand;
 import com.cloud.agent.api.routing.Site2SiteVpnCfgCommand;
+import com.cloud.agent.api.routing.StartAggregationCommand;
 import com.cloud.agent.api.routing.VmDataCommand;
 import com.cloud.agent.api.routing.VpnUsersCfgCommand;
 import com.cloud.agent.api.to.DhcpTO;
@@ -67,6 +69,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader;
 import javax.naming.ConfigurationException;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.UUID;
 
@@ -81,26 +84,29 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
     NetworkElementCommand _currentCmd;
     int _count;
     String _file;
+    boolean _aggregated = false;
 
-    String ROUTERIP = "10.2.3.4";
+    String ROUTER_IP = "169.254.3.4";
+    String ROUTER_GUEST_IP = "10.200.1.1";
+    String ROUTER_NAME = "r-4-VM";
 
     @Override
     public ExecutionResult executeInVR(String routerIp, String script, String args) {
-        assertEquals(routerIp, ROUTERIP);
+        assertEquals(routerIp, ROUTER_IP);
         verifyCommand(_currentCmd, script, args);
         return new ExecutionResult(true, null);
     }
 
     @Override
     public ExecutionResult createFileInVR(String routerIp, String path, String filename, String content) {
-        assertEquals(routerIp, ROUTERIP);
+        assertEquals(routerIp, ROUTER_IP);
         verifyFile(_currentCmd, path, filename, content);
         return new ExecutionResult(true, null);
     }
 
     @Override
     public ExecutionResult prepareCommand(NetworkElementCommand cmd) {
-        cmd.setRouterAccessIp(ROUTERIP);
+        cmd.setRouterAccessIp(ROUTER_IP);
         _currentCmd = cmd;
         if (cmd instanceof IpAssocVpcCommand) {
             return prepareNetworkElementCommand((IpAssocVpcCommand)cmd);
@@ -131,6 +137,14 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         }
     }
 
+    private void verifyFile(NetworkElementCommand cmd, String path, String filename, String content) {
+        if (cmd instanceof FinishAggregationCommand) {
+            verifyFile((FinishAggregationCommand)cmd, path, filename, content);
+        } else if (cmd instanceof LoadBalancerConfigCommand) {
+            verifyFile((LoadBalancerConfigCommand)cmd, path, filename, content);
+        }
+    }
+
     protected void verifyCommand(NetworkElementCommand cmd, String script, String args) {
         if (cmd instanceof SetPortForwardingRulesVpcCommand) {
             verifyArgs((SetPortForwardingRulesVpcCommand) cmd, script, args);
@@ -175,6 +189,12 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         } else if (cmd instanceof IpAssocCommand) {
             verifyArgs((IpAssocCommand)cmd, script, args);
         }
+
+        if (cmd instanceof StartAggregationCommand) {
+            return;
+        } else if (cmd instanceof FinishAggregationCommand) {
+            verifyArgs((FinishAggregationCommand)cmd, script, args);
+        }
     }
 
     private void verifyArgs(VpnUsersCfgCommand cmd, String script, String args) {
@@ -203,11 +223,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     @Test
     public void testSetPortForwardingRulesVpcCommand() {
-        List<PortForwardingRuleTO> pfRules = new ArrayList<>();
-        pfRules.add(new PortForwardingRuleTO(1, "64.1.1.10", 22, 80, "10.10.1.10", 22, 80, "TCP", false, false));
-        pfRules.add(new PortForwardingRuleTO(2, "64.1.1.11", 8080, 8080, "10.10.1.11", 8080, 8080, "UDP", true, false));
-        SetPortForwardingRulesVpcCommand cmd = new SetPortForwardingRulesVpcCommand(pfRules);
-        assertEquals(cmd.getAnswersCount(), 2);
+        SetPortForwardingRulesVpcCommand cmd = generateSetPortForwardingRulesVpcCommand();
 
         // Reset rule check count
         _count = 0;
@@ -218,6 +234,16 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         assertTrue(answer.getResult());
     }
 
+    protected SetPortForwardingRulesVpcCommand generateSetPortForwardingRulesVpcCommand() {
+        List<PortForwardingRuleTO> pfRules = new ArrayList<>();
+        pfRules.add(new PortForwardingRuleTO(1, "64.1.1.10", 22, 80, "10.10.1.10", 22, 80, "TCP", false, false));
+        pfRules.add(new PortForwardingRuleTO(2, "64.1.1.11", 8080, 8080, "10.10.1.11", 8080, 8080, "UDP", true, false));
+        SetPortForwardingRulesVpcCommand cmd = new SetPortForwardingRulesVpcCommand(pfRules);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        assertEquals(cmd.getAnswersCount(), 2);
+        return cmd;
+    }
+
     private void verifyArgs(SetPortForwardingRulesVpcCommand cmd, String script, String args) {
         assertTrue(script.equals(VRScripts.VPC_PORTFORWARDING));
         _count ++;
@@ -235,12 +261,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     @Test
     public void testSetPortForwardingRulesCommand() {
-        List<PortForwardingRuleTO> pfRules = new ArrayList<>();
-        pfRules.add(new PortForwardingRuleTO(1, "64.1.1.10", 22, 80, "10.10.1.10", 22, 80, "TCP", false, false));
-        pfRules.add(new PortForwardingRuleTO(2, "64.1.1.11", 8080, 8080, "10.10.1.11", 8080, 8080, "UDP", true, false));
-        SetPortForwardingRulesCommand cmd = new SetPortForwardingRulesCommand(pfRules);
-        assertEquals(cmd.getAnswersCount(), 2);
-
+        SetPortForwardingRulesCommand cmd = generateSetPortForwardingRulesCommand();
         // Reset rule check count
         _count = 0;
 
@@ -250,6 +271,16 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         assertTrue(answer.getResult());
     }
 
+    protected SetPortForwardingRulesCommand generateSetPortForwardingRulesCommand() {
+        List<PortForwardingRuleTO> pfRules = new ArrayList<>();
+        pfRules.add(new PortForwardingRuleTO(1, "64.1.1.10", 22, 80, "10.10.1.10", 22, 80, "TCP", false, false));
+        pfRules.add(new PortForwardingRuleTO(2, "64.1.1.11", 8080, 8080, "10.10.1.11", 8080, 8080, "UDP", true, false));
+        SetPortForwardingRulesCommand cmd = new SetPortForwardingRulesCommand(pfRules);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        assertEquals(cmd.getAnswersCount(), 2);
+        return cmd;
+    }
+
     private void verifyArgs(SetPortForwardingRulesCommand cmd, String script, String args) {
         assertTrue(script.equals(VRScripts.FIREWALL_NAT));
         _count ++;
@@ -267,14 +298,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     @Test
     public void testIpAssocCommand() {
-        List<IpAddressTO> ips = new ArrayList<IpAddressTO>();
-        ips.add(new IpAddressTO(1, "64.1.1.10", true, true, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false));
-        ips.add(new IpAddressTO(2, "64.1.1.11", false, false, false, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false));
-        ips.add(new IpAddressTO(3, "65.1.1.11", true, false, false, "vlan://65", "65.1.1.1", "255.255.255.0", "11:23:45:67:89:AB", 1000, false));
-        IpAddressTO[] ipArray = ips.toArray(new IpAddressTO[ips.size()]);
-        IpAssocCommand cmd = new IpAssocCommand(ipArray);
-        assertEquals(cmd.getAnswersCount(), 3);
-
+        IpAssocCommand cmd = generateIpAssocCommand();
         _count = 0;
 
         Answer answer = _resource.executeRequest(cmd);
@@ -292,16 +316,22 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         return new ExecutionResult(true, null);
     }
 
-    @Test
-    public void testIpAssocVpcCommand() {
-        List<IpAddressTO> ips = new ArrayList<IpAddressTO>();
+    protected IpAssocCommand generateIpAssocCommand() {
+        List<IpAddressTO> ips = new ArrayList<>();
         ips.add(new IpAddressTO(1, "64.1.1.10", true, true, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false));
-        ips.add(new IpAddressTO(2, "64.1.1.11", false, false, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false));
+        ips.add(new IpAddressTO(2, "64.1.1.11", false, false, false, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false));
         ips.add(new IpAddressTO(3, "65.1.1.11", true, false, false, "vlan://65", "65.1.1.1", "255.255.255.0", "11:23:45:67:89:AB", 1000, false));
         IpAddressTO[] ipArray = ips.toArray(new IpAddressTO[ips.size()]);
-        IpAssocVpcCommand cmd = new IpAssocVpcCommand(ipArray);
-        assertEquals(cmd.getAnswersCount(), 6);
+        IpAssocCommand cmd = new IpAssocCommand(ipArray);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        assertEquals(cmd.getAnswersCount(), 3);
 
+        return cmd;
+    }
+
+    @Test
+    public void testIpAssocVpcCommand() {
+        IpAssocVpcCommand cmd = generateIpAssocVpcCommand();
         _count = 0;
 
         Answer answer = _resource.executeRequest(cmd);
@@ -319,6 +349,19 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         return new ExecutionResult(true, null);
     }
 
+    protected IpAssocVpcCommand generateIpAssocVpcCommand() {
+        List<IpAddressTO> ips = new ArrayList<IpAddressTO>();
+        ips.add(new IpAddressTO(1, "64.1.1.10", true, true, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false));
+        ips.add(new IpAddressTO(2, "64.1.1.11", false, false, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false));
+        ips.add(new IpAddressTO(3, "65.1.1.11", true, false, false, "vlan://65", "65.1.1.1", "255.255.255.0", "11:23:45:67:89:AB", 1000, false));
+        IpAddressTO[] ipArray = ips.toArray(new IpAddressTO[ips.size()]);
+        IpAssocVpcCommand cmd = new IpAssocVpcCommand(ipArray);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        assertEquals(cmd.getAnswersCount(), 6);
+
+        return cmd;
+    }
+
     private void verifyArgs(IpAssocCommand cmd, String script, String args) {
         if (cmd instanceof IpAssocVpcCommand) {
             _count ++;
@@ -367,8 +410,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     @Test
     public void testSourceNatCommand() {
-        IpAddressTO ip = new IpAddressTO(1, "64.1.1.10", true, true, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false);
-        SetSourceNatCommand cmd = new SetSourceNatCommand(ip, true);
+        SetSourceNatCommand cmd = generateSetSourceNatCommand();
         Answer answer = _resource.executeRequest(cmd);
         assertTrue(answer.getResult());
     }
@@ -379,6 +421,13 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         return new ExecutionResult(true, null);
     }
 
+    protected SetSourceNatCommand generateSetSourceNatCommand() {
+        IpAddressTO ip = new IpAddressTO(1, "64.1.1.10", true, true, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false);
+        SetSourceNatCommand cmd = new SetSourceNatCommand(ip, true);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        return cmd;
+    }
+
     private void verifyArgs(SetSourceNatCommand cmd, String script, String args) {
         assertEquals(script, VRScripts.VPC_SOURCE_NAT);
         assertEquals(args, "-A -l 64.1.1.10 -c eth1");
@@ -386,6 +435,18 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     @Test
     public void testNetworkACLCommand() {
+        SetNetworkACLCommand cmd = generateSetNetworkACLCommand();
+        _count = 0;
+
+        Answer answer = _resource.executeRequest(cmd);
+        assertTrue(answer.getResult());
+
+        cmd.setAccessDetail(NetworkElementCommand.VPC_PRIVATE_GATEWAY, String.valueOf(VpcGateway.Type.Private));
+        answer = _resource.executeRequest(cmd);
+        assertTrue(answer.getResult());
+    }
+
+    protected SetNetworkACLCommand generateSetNetworkACLCommand() {
         List<NetworkACLTO> acls = new ArrayList<>();
         List<String> cidrs = new ArrayList<>();
         cidrs.add("192.168.0.1/24");
@@ -397,16 +458,10 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         nic.setMac("01:23:45:67:89:AB");
         nic.setIp("192.168.1.1");
         nic.setNetmask("255.255.255.0");
-
-        _count = 0;
-
         SetNetworkACLCommand cmd = new SetNetworkACLCommand(acls, nic);
-        Answer answer = _resource.executeRequest(cmd);
-        assertTrue(answer.getResult());
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
 
-        cmd.setAccessDetail(NetworkElementCommand.VPC_PRIVATE_GATEWAY, String.valueOf(VpcGateway.Type.Private));
-        answer = _resource.executeRequest(cmd);
-        assertTrue(answer.getResult());
+        return cmd;
     }
 
     private void verifyArgs(SetNetworkACLCommand cmd, String script, String args) {
@@ -435,6 +490,18 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     @Test
     public void testSetupGuestNetworkCommand() {
+        SetupGuestNetworkCommand cmd = generateSetupGuestNetworkCommand();
+        Answer answer = _resource.executeRequest(cmd);
+        assertTrue(answer.getResult());
+    }
+
+    private ExecutionResult prepareNetworkElementCommand(SetupGuestNetworkCommand cmd) {
+        NicTO nic = cmd.getNic();
+        nic.setDeviceId(4);
+        return new ExecutionResult(true, null);
+    }
+
+    protected SetupGuestNetworkCommand generateSetupGuestNetworkCommand() {
         NicTO nic = new NicTO();
         nic.setMac("01:23:45:67:89:AB");
         nic.setIp("10.1.1.1");
@@ -443,16 +510,9 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         SetupGuestNetworkCommand cmd = new SetupGuestNetworkCommand("10.1.1.10-10.1.1.20", "cloud.test", false, 0, "8.8.8.8", "8.8.4.4", true, nic);
         cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, "10.1.1.2");
         cmd.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY, "10.1.1.1");
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
 
-        Answer answer = _resource.executeRequest(cmd);
-        assertTrue(answer.getResult());
-
-    }
-
-    private ExecutionResult prepareNetworkElementCommand(SetupGuestNetworkCommand cmd) {
-        NicTO nic = cmd.getNic();
-        nic.setDeviceId(4);
-        return new ExecutionResult(true, null);
+        return cmd;
     }
 
     private void verifyArgs(SetupGuestNetworkCommand cmd, String script, String args) {
@@ -462,13 +522,20 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     @Test
     public void testSetMonitorServiceCommand() {
+        SetMonitorServiceCommand cmd = generateSetMonitorServiceCommand();
+        Answer answer = _resource.executeRequest(cmd);
+        assertTrue(answer.getResult());
+    }
+
+    protected SetMonitorServiceCommand generateSetMonitorServiceCommand() {
         List<MonitorServiceTO> services = new ArrayList<>();
         services.add(new MonitorServiceTO("service", "process", "name", "path", "file", true));
         services.add(new MonitorServiceTO("service_2", "process_2", "name_2", "path_2", "file_2", false));
 
         SetMonitorServiceCommand cmd = new SetMonitorServiceCommand(services);
-        Answer answer = _resource.executeRequest(cmd);
-        assertTrue(answer.getResult());
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+
+        return cmd;
     }
 
     private void verifyArgs(SetMonitorServiceCommand cmd, String script, String args) {
@@ -481,14 +548,17 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         _count = 0;
 
         Site2SiteVpnCfgCommand cmd = new Site2SiteVpnCfgCommand(true, "64.10.1.10", "64.10.1.1", "192.168.1.1/16", "124.10.1.10", "192.168.100.1/24", "3des-sha1,aes128-sha1;modp1536", "3des-sha1,aes128-md5", "psk", Long.valueOf(1800), Long.valueOf(1800), true, false);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
         Answer answer = _resource.executeRequest(cmd);
         assertTrue(answer.getResult());
 
         cmd = new Site2SiteVpnCfgCommand(true, "64.10.1.10", "64.10.1.1", "192.168.1.1/16", "124.10.1.10", "192.168.100.1/24", "3des-sha1,aes128-sha1;modp1536", "3des-sha1,aes128-md5", "psk", Long.valueOf(1800), Long.valueOf(1800), false, true);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
         answer = _resource.executeRequest(cmd);
         assertTrue(answer.getResult());
 
         cmd = new Site2SiteVpnCfgCommand(false, "64.10.1.10", "64.10.1.1", "192.168.1.1/16", "124.10.1.10", "192.168.100.1/24", "3des-sha1,aes128-sha1;modp1536", "3des-sha1,aes128-md5", "psk", Long.valueOf(1800), Long.valueOf(1800), false, true);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
         answer = _resource.executeRequest(cmd);
         assertTrue(answer.getResult());
     }
@@ -516,20 +586,35 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
     public void testRemoteAccessVpnCfgCommand() {
         _count = 0;
 
+        Answer answer = _resource.executeRequest(generateRemoteAccessVpnCfgCommand1());
+        assertTrue(answer.getResult());
+
+        answer = _resource.executeRequest(generateRemoteAccessVpnCfgCommand2());
+        assertTrue(answer.getResult());
+
+        answer = _resource.executeRequest(generateRemoteAccessVpnCfgCommand3());
+        assertTrue(answer.getResult());
+    }
+
+    protected RemoteAccessVpnCfgCommand generateRemoteAccessVpnCfgCommand1() {
         RemoteAccessVpnCfgCommand cmd = new RemoteAccessVpnCfgCommand(true, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", false);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
         cmd.setLocalCidr("10.1.1.1/24");
-        Answer answer = _resource.executeRequest(cmd);
-        assertTrue(answer.getResult());
+        return cmd;
+    }
 
-        cmd = new RemoteAccessVpnCfgCommand(false, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", false);
+    protected RemoteAccessVpnCfgCommand generateRemoteAccessVpnCfgCommand2() {
+        RemoteAccessVpnCfgCommand cmd = new RemoteAccessVpnCfgCommand(false, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", false);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
         cmd.setLocalCidr("10.1.1.1/24");
-        answer = _resource.executeRequest(cmd);
-        assertTrue(answer.getResult());
+        return cmd;
+    }
 
-        cmd = new RemoteAccessVpnCfgCommand(true, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", true);
+    protected RemoteAccessVpnCfgCommand generateRemoteAccessVpnCfgCommand3() {
+        RemoteAccessVpnCfgCommand cmd = new RemoteAccessVpnCfgCommand(true, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", true);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
         cmd.setLocalCidr("10.1.1.1/24");
-        answer = _resource.executeRequest(cmd);
-        assertTrue(answer.getResult());
+        return cmd;
     }
 
     private void verifyArgs(RemoteAccessVpnCfgCommand cmd, String script, String args) {
@@ -556,6 +641,15 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
     public void testFirewallRulesCommand() {
         _count = 0;
 
+        Answer answer = _resource.executeRequest(generateSetFirewallRulesCommand());
+        assertTrue(answer.getResult());
+        assertTrue(answer instanceof GroupAnswer);
+        assertEquals(((GroupAnswer) answer).getResults().length, 3);
+
+        //TODO Didn't test egress rule because not able to generate FirewallRuleVO object
+    }
+
+    protected SetFirewallRulesCommand generateSetFirewallRulesCommand() {
         List<FirewallRuleTO> rules = new ArrayList<>();
         List<String> sourceCidrs = new ArrayList<>();
         sourceCidrs.add("10.10.1.1/24");
@@ -564,12 +658,9 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         rules.add(new FirewallRuleTO(2, "64.10.10.10", "ICMP", 0, 0, false, false, Purpose.Firewall, sourceCidrs, -1, -1));
         rules.add(new FirewallRuleTO(3, "64.10.10.10", "ICMP", 0, 0, true, true, Purpose.Firewall, sourceCidrs, -1, -1));
         SetFirewallRulesCommand cmd = new SetFirewallRulesCommand(rules);
-        Answer answer = _resource.executeRequest(cmd);
-        assertTrue(answer.getResult());
-        assertTrue(answer instanceof GroupAnswer);
-        assertEquals(((GroupAnswer) answer).getResults().length, 3);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
 
-        //TODO Didn't test egress rule because not able to generate FirewallRuleVO object
+        return cmd;
     }
 
     private void verifyArgs(SetFirewallRulesCommand cmd, String script, String args) {
@@ -579,6 +670,11 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     @Test
     public void testVmDataCommand() {
+        Answer answer = _resource.executeRequest(generateVmDataCommand());
+        assertTrue(answer.getResult());
+    }
+
+    protected VmDataCommand generateVmDataCommand() {
         VmDataCommand cmd = new VmDataCommand("10.1.10.4", "i-4-VM", true);
         cmd.addVmData("userdata", "user-data", "user-data");
         cmd.addVmData("metadata", "service-offering", "serviceOffering");
@@ -592,8 +688,9 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         cmd.addVmData("metadata", "public-keys", "publickey");
         cmd.addVmData("metadata", "cloud-identifier", "CloudStack-{test}");
 
-        Answer answer = _resource.executeRequest(cmd);
-        assertTrue(answer.getResult());
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+
+        return cmd;
     }
 
     private void verifyArgs(VmDataCommand cmd, String script, String args) {
@@ -608,11 +705,16 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     @Test
     public void testSavePasswordCommand() {
-        SavePasswordCommand cmd = new SavePasswordCommand("123pass", "10.1.10.4", "i-4-VM", true);
-        Answer answer = _resource.executeRequest(cmd);
+        Answer answer = _resource.executeRequest(generateSavePasswordCommand());
         assertTrue(answer.getResult());
     }
 
+    protected SavePasswordCommand generateSavePasswordCommand() {
+        SavePasswordCommand cmd = new SavePasswordCommand("123pass", "10.1.10.4", "i-4-VM", true);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        return cmd;
+    }
+
     private void verifyArgs(SavePasswordCommand cmd, String script, String args) {
         assertEquals(script, VRScripts.PASSWORD);
         assertEquals(args, "-v 10.1.10.4 -p 123pass");
@@ -621,21 +723,37 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
     @Test
     public void testDhcpEntryCommand() {
         _count = 0;
-        DhcpEntryCommand cmd = new DhcpEntryCommand("12:34:56:78:90:AB", "10.1.10.2", "vm1", null, true);
-        Answer answer = _resource.executeRequest(cmd);
+
+        Answer answer = _resource.executeRequest(generateDhcpEntryCommand1());
         assertTrue(answer.getResult());
 
-        cmd = new DhcpEntryCommand("12:34:56:78:90:AB", null, "vm1", "2001:db8:0:0:0:ff00:42:8329", true);
-        cmd.setDuid(NetUtils.getDuidLL(cmd.getVmMac()));
-        answer = _resource.executeRequest(cmd);
+        answer = _resource.executeRequest(generateDhcpEntryCommand2());
         assertTrue(answer.getResult());
 
-        cmd = new DhcpEntryCommand("12:34:56:78:90:AB", "10.1.10.2", "vm1", "2001:db8:0:0:0:ff00:42:8329", true);
-        cmd.setDuid(NetUtils.getDuidLL(cmd.getVmMac()));
-        answer = _resource.executeRequest(cmd);
+        answer = _resource.executeRequest(generateDhcpEntryCommand3());
         assertTrue(answer.getResult());
     }
 
+    protected DhcpEntryCommand generateDhcpEntryCommand1() {
+        DhcpEntryCommand cmd = new DhcpEntryCommand("12:34:56:78:90:AB", "10.1.10.2", "vm1", null, true);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        return cmd;
+    }
+
+    protected DhcpEntryCommand generateDhcpEntryCommand2() {
+        DhcpEntryCommand cmd = new DhcpEntryCommand("12:34:56:78:90:AB", null, "vm1", "2001:db8:0:0:0:ff00:42:8329", true);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setDuid(NetUtils.getDuidLL(cmd.getVmMac()));
+        return cmd;
+    }
+
+    protected DhcpEntryCommand generateDhcpEntryCommand3() {
+        DhcpEntryCommand cmd = new DhcpEntryCommand("12:34:56:78:90:AB", "10.1.10.2", "vm1", "2001:db8:0:0:0:ff00:42:8329", true);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setDuid(NetUtils.getDuidLL(cmd.getVmMac()));
+        return cmd;
+    }
+
     private void verifyArgs(DhcpEntryCommand cmd, String script, String args) {
         _count ++;
         assertEquals(script, VRScripts.DHCP);
@@ -656,13 +774,19 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     @Test
     public void testCreateIpAliasCommand() {
+        Answer answer = _resource.executeRequest(generateCreateIpAliasCommand());
+        assertTrue(answer.getResult());
+    }
+
+    protected CreateIpAliasCommand generateCreateIpAliasCommand() {
         List<IpAliasTO> aliases = new ArrayList<>();
         aliases.add(new IpAliasTO("169.254.3.10", "255.255.255.0", "1"));
         aliases.add(new IpAliasTO("169.254.3.11", "255.255.255.0", "2"));
         aliases.add(new IpAliasTO("169.254.3.12", "255.255.255.0", "3"));
         CreateIpAliasCommand cmd = new CreateIpAliasCommand("169.254.3.10", aliases);
-        Answer answer = _resource.executeRequest(cmd);
-        assertTrue(answer.getResult());
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+
+        return cmd;
     }
 
     private void verifyArgs(CreateIpAliasCommand cmd, String script, String args) {
@@ -672,13 +796,18 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     @Test
     public void testDeleteIpAliasCommand() {
+        Answer answer = _resource.executeRequest(generateDeleteIpAliasCommand());
+        assertTrue(answer.getResult());
+    }
+
+    protected DeleteIpAliasCommand generateDeleteIpAliasCommand() {
         List<IpAliasTO> aliases = new ArrayList<>();
         aliases.add(new IpAliasTO("169.254.3.10", "255.255.255.0", "1"));
         aliases.add(new IpAliasTO("169.254.3.11", "255.255.255.0", "2"));
         aliases.add(new IpAliasTO("169.254.3.12", "255.255.255.0", "3"));
         DeleteIpAliasCommand cmd = new DeleteIpAliasCommand("169.254.10.1", aliases, aliases);
-        Answer answer = _resource.executeRequest(cmd);
-        assertTrue(answer.getResult());
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        return cmd;
     }
 
     private void verifyArgs(DeleteIpAliasCommand cmd, String script, String args) {
@@ -688,12 +817,17 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     @Test
     public void testDnsMasqConfigCommand() {
-        List<DhcpTO> dhcps = new ArrayList<DhcpTO>();
+        Answer answer = _resource.executeRequest(generateDnsMasqConfigCommand());
+        assertTrue(answer.getResult());
+    }
+
+    protected DnsMasqConfigCommand generateDnsMasqConfigCommand() {
+        List<DhcpTO> dhcps = new ArrayList<>();
         dhcps.add(new DhcpTO("10.1.20.2", "10.1.20.1", "255.255.255.0", "10.1.20.5"));
         dhcps.add(new DhcpTO("10.1.21.2", "10.1.21.1", "255.255.255.0", "10.1.21.5"));
         DnsMasqConfigCommand cmd = new DnsMasqConfigCommand(dhcps);
-        Answer answer = _resource.executeRequest(cmd);
-        assertTrue(answer.getResult());
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        return cmd;
     }
 
     private void verifyArgs(DnsMasqConfigCommand cmd, String script, String args) {
@@ -706,6 +840,14 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         _count = 0;
         _file = "";
 
+        Answer answer = _resource.executeRequest(generateLoadBalancerConfigCommand1());
+        assertTrue(answer.getResult());
+
+        answer = _resource.executeRequest(generateLoadBalancerConfigCommand2());
+        assertTrue(answer.getResult());
+    }
+
+    protected LoadBalancerConfigCommand generateLoadBalancerConfigCommand1() {
         List<LoadBalancerTO> lbs = new ArrayList<>();
         List<LbDestination> dests = new ArrayList<>();
         dests.add(new LbDestination(80, 8080, "10.1.10.2", false));
@@ -716,19 +858,27 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         NicTO nic = new NicTO();
         LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(arrayLbs, "64.10.2.10", "10.1.10.2", "192.168.1.2", nic, null, "1000", false);
         cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, "10.1.10.2");
-        Answer answer = _resource.executeRequest(cmd);
-        assertTrue(answer.getResult());
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        return cmd;
+    }
 
+    protected LoadBalancerConfigCommand generateLoadBalancerConfigCommand2() {
+        List<LoadBalancerTO> lbs = new ArrayList<>();
+        List<LbDestination> dests = new ArrayList<>();
+        dests.add(new LbDestination(80, 8080, "10.1.10.2", false));
+        dests.add(new LbDestination(80, 8080, "10.1.10.2", true));
+        lbs.add(new LoadBalancerTO(UUID.randomUUID().toString(), "64.10.1.10", 80, "tcp", "algo", false, false, false, dests));
+        LoadBalancerTO[] arrayLbs = new LoadBalancerTO[lbs.size()];
+        lbs.toArray(arrayLbs);
+        NicTO nic = new NicTO();
         nic.setIp("10.1.10.2");
-        cmd = new LoadBalancerConfigCommand(arrayLbs, "64.10.2.10", "10.1.10.2", "192.168.1.2", nic, Long.valueOf(1), "1000", false);
-        answer = _resource.executeRequest(cmd);
-        assertTrue(answer.getResult());
+        LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(arrayLbs, "64.10.2.10", "10.1.10.2", "192.168.1.2", nic, Long.valueOf(1), "1000", false);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, "10.1.10.2");
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        return cmd;
     }
 
-    private void verifyFile(NetworkElementCommand cmd, String path, String filename, String content) {
-        if (!(cmd instanceof LoadBalancerConfigCommand)) {
-            fail("Only LB command would call this!");
-        }
+    protected void verifyFile(LoadBalancerConfigCommand cmd, String path, String filename, String content) {
         _count ++;
         switch (_count) {
             case 1:
@@ -795,5 +945,153 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         }
     }
 
+    @Test
+    public void testAggregationCommands() {
+        List<NetworkElementCommand> cmds = new LinkedList<>();
+        StartAggregationCommand startCmd = new StartAggregationCommand(ROUTER_NAME, ROUTER_IP, ROUTER_GUEST_IP);
+        cmds.add(startCmd);
+        cmds.add(generateIpAssocCommand());
+        cmds.add(generateIpAssocVpcCommand());
+
+        cmds.add(generateSetFirewallRulesCommand());
+
+        cmds.add(generateSetPortForwardingRulesCommand());
+        cmds.add(generateSetPortForwardingRulesVpcCommand());
+
+        cmds.add(generateCreateIpAliasCommand());
+        cmds.add(generateDeleteIpAliasCommand());
+        cmds.add(generateDnsMasqConfigCommand());
+
+        cmds.add(generateRemoteAccessVpnCfgCommand1());
+        cmds.add(generateRemoteAccessVpnCfgCommand2());
+        cmds.add(generateRemoteAccessVpnCfgCommand3());
+
+        //cmds.add(generateLoadBalancerConfigCommand1());
+        //cmds.add(generateLoadBalancerConfigCommand2());
+
+        cmds.add(generateSetPortForwardingRulesCommand());
+        cmds.add(generateSetPortForwardingRulesVpcCommand());
+
+        cmds.add(generateDhcpEntryCommand1());
+        cmds.add(generateDhcpEntryCommand2());
+        cmds.add(generateDhcpEntryCommand3());
+
+        cmds.add(generateSavePasswordCommand());
+        cmds.add(generateVmDataCommand());
+
+        FinishAggregationCommand finishCmd = new FinishAggregationCommand(ROUTER_NAME, ROUTER_IP, ROUTER_GUEST_IP);
+        cmds.add(finishCmd);
+
+        for (NetworkElementCommand cmd : cmds) {
+            Answer answer = _resource.executeRequest(cmd);
+            if (!(cmd instanceof FinishAggregationCommand)) {
+                assertTrue(answer.getResult());
+            } else {
+
+            }
+        }
+    }
+
+    private void verifyArgs(FinishAggregationCommand cmd, String script, String args) {
+        assertEquals(script, VRScripts.VR_CFG);
+        assertTrue(args.startsWith("-c /var/cache/cloud/VR-"));
+        assertTrue(args.endsWith(".cfg"));
+    }
+
+    protected void verifyFile(FinishAggregationCommand cmd, String path, String filename, String content) {
+        assertEquals(path, "/var/cache/cloud/");
+        assertTrue(filename.startsWith("VR-"));
+        assertTrue(filename.endsWith(".cfg"));
+        assertEquals(content, "#Apache CloudStack Virtual Router Config File\n" +
+                "<version>\n" +
+                "1.0\n" +
+                "</version>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/ipassoc.sh -A -s -f -l 64.1.1.10/24 -c eth2 -g 64.1.1.1\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/ipassoc.sh -D -l 64.1.1.11/24 -c eth2 -g 64.1.1.1\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/ipassoc.sh -A -l 65.1.1.11/24 -c eth2 -g 65.1.1.1\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/vpc_ipassoc.sh  -A  -l 64.1.1.10 -c eth2 -g 64.1.1.1 -m 24 -n 64.1.1.0\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/vpc_privateGateway.sh  -A  -l 64.1.1.10 -c eth2\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/vpc_ipassoc.sh  -D  -l 64.1.1.11 -c eth2 -g 64.1.1.1 -m 24 -n 64.1.1.0\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/vpc_privateGateway.sh  -D  -l 64.1.1.11 -c eth2\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/vpc_ipassoc.sh  -A  -l 65.1.1.11 -c eth2 -g 65.1.1.1 -m 24 -n 65.1.1.0\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/firewall_ingress.sh  -F -a 64.10.10.10:ICMP:0:0:10.10.1.1/24-10.10.1.2/24:,64.10.10.10:TCP:22:80:10.10.1.1/24-10.10.1.2/24:,64.10.10.10:reverted:0:0:0:,\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/firewall_nat.sh -A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22:80\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/firewall_nat.sh -D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080:8080\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/vpc_portforwarding.sh -A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22-80\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/vpc_portforwarding.sh -D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080-8080\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/createipAlias.sh 1:169.254.3.10:255.255.255.0-2:169.254.3.11:255.255.255.0-3:169.254.3.12:255.255.255.0-\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/deleteipAlias.sh 1:169.254.3.10:255.255.255.0-2:169.254.3.11:255.255.255.0-3:169.254.3.12:255.255.255.0-- 1:169.254.3.10:255.255.255.0-2:169.254.3.11:255.255.255.0-3:169.254.3.12:255.255.255.0-\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/dnsmasq.sh 10.1.20.2:10.1.20.1:255.255.255.0:10.1.20.5-10.1.21.2:10.1.21.1:255.255.255.0:10.1.21.5-\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/vpn_l2tp.sh -r 10.10.1.10-10.10.1.20 -p sharedkey -s 124.10.10.10 -l 10.10.1.1 -c  -C 10.1.1.1/24 -i eth2\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/vpn_l2tp.sh -d  -s 124.10.10.10 -C 10.1.1.1/24 -i eth2\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/vpn_l2tp.sh -r 10.10.1.10-10.10.1.20 -p sharedkey -s 124.10.10.10 -l 10.10.1.1 -c  -C 10.1.1.1/24 -i eth1\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/firewall_nat.sh -A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22:80\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/firewall_nat.sh -D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080:8080\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/vpc_portforwarding.sh -A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22-80\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/vpc_portforwarding.sh -D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080-8080\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/edithosts.sh  -m 12:34:56:78:90:AB -4 10.1.10.2 -h vm1\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/edithosts.sh  -m 12:34:56:78:90:AB -h vm1 -6 2001:db8:0:0:0:ff00:42:8329 -u 00:03:00:01:12:34:56:78:90:AB\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/edithosts.sh  -m 12:34:56:78:90:AB -4 10.1.10.2 -h vm1 -6 2001:db8:0:0:0:ff00:42:8329 -u 00:03:00:01:12:34:56:78:90:AB\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/savepassword.sh -v 10.1.10.4 -p 123pass\n" +
+                "</script>\n" +
+                "<script>\n" +
+                "/opt/cloud/bin/vmdata.py -d eyIxMC4xLjEwLjQiOltbInVzZXJkYXRhIiwidXNlci1kYXRhIiwidXNlci1kYXRhIl0sWyJtZXRhZGF0YSIsInNlcnZpY2Utb2ZmZXJpbmciLCJzZXJ2aWNlT2ZmZXJpbmciXSxbIm1ldGFkYXRhIiwiYXZhaWxhYmlsaXR5LXpvbmUiLCJ6b25lTmFtZSJdLFsibWV0YWRhdGEiLCJsb2NhbC1pcHY0IiwiMTAuMS4xMC40Il0sWyJtZXRhZGF0YSIsImxvY2FsLWhvc3RuYW1lIiwidGVzdC12bSJdLFsibWV0YWRhdGEiLCJwdWJsaWMtaXB2NCIsIjExMC4xLjEwLjQiXSxbIm1ldGFkYXRhIiwicHVibGljLWhvc3RuYW1lIiwiaG9zdG5hbWUiXSxbIm1ldGFkYXRhIiwiaW5zdGFuY2UtaWQiLCJpLTQtVk0iXSxbIm1ldGFkYXRhIiwidm0taWQiLCI0Il0sWyJtZXRhZGF0YSIsInB1YmxpYy1rZXlzIiwicHVibGlja2V5Il0sWyJtZXRhZGF0YSIsImNsb3VkLWlkZW50aWZpZXIiLCJDbG91ZFN0YWNrLXt0ZXN0fSJdXX0=\n" +
+                "</script>" +
+                "\n");
+    }
+
 }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ccea5703/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh b/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh
index 8994a06..dffa45a 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh
@@ -62,7 +62,7 @@ do
         then
             log_it "VR config: executing failed: $line"
             # expose error info to mgmt server
-            echo "VR config: execution failed: \"$line\", check $log in VR for details "
+            echo "VR config: execution failed: \"$line\", check $log in VR for details " 1>&2
             exit 1
         fi
         #skip </script>


[34/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-6047: Introduce Aggregated commands queue to VR


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

Branch: refs/heads/resize-root
Commit: 60dc25450a02f070c13a768d832a7a24d2b7b414
Parents: 7cb9132
Author: Sheng Yang <sh...@citrix.com>
Authored: Tue Mar 4 14:28:41 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Thu Mar 6 16:22:01 2014 -0800

----------------------------------------------------------------------
 .../api/routing/FinishAggregationCommand.java   |  31 +++
 .../api/routing/StartAggregationCommand.java    |  31 +++
 .../virtualnetwork/VirtualRoutingResource.java  | 188 ++++++++++++++-----
 .../VirtualNetworkApplianceManagerImpl.java     |   8 +-
 .../debian/config/opt/cloud/bin/vr_cfg.sh       |  96 ++++++++++
 5 files changed, 302 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/60dc2545/core/src/com/cloud/agent/api/routing/FinishAggregationCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/FinishAggregationCommand.java b/core/src/com/cloud/agent/api/routing/FinishAggregationCommand.java
new file mode 100644
index 0000000..bfafccd
--- /dev/null
+++ b/core/src/com/cloud/agent/api/routing/FinishAggregationCommand.java
@@ -0,0 +1,31 @@
+// 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 com.cloud.agent.api.routing;
+
+public class FinishAggregationCommand extends NetworkElementCommand{
+    protected FinishAggregationCommand() {
+        super();
+    }
+
+    public FinishAggregationCommand(String name, String ip, String guestIp) {
+        super();
+        this.setAccessDetail(NetworkElementCommand.ROUTER_NAME, name);
+        this.setAccessDetail(NetworkElementCommand.ROUTER_IP, ip);
+        this.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, guestIp);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/60dc2545/core/src/com/cloud/agent/api/routing/StartAggregationCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/StartAggregationCommand.java b/core/src/com/cloud/agent/api/routing/StartAggregationCommand.java
new file mode 100644
index 0000000..fbf97a8
--- /dev/null
+++ b/core/src/com/cloud/agent/api/routing/StartAggregationCommand.java
@@ -0,0 +1,31 @@
+// 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 com.cloud.agent.api.routing;
+
+public class StartAggregationCommand extends NetworkElementCommand{
+    protected StartAggregationCommand() {
+        super();
+    }
+
+    public StartAggregationCommand(String name, String ip, String guestIp) {
+        super();
+        this.setAccessDetail(NetworkElementCommand.ROUTER_NAME, name);
+        this.setAccessDetail(NetworkElementCommand.ROUTER_IP, ip);
+        this.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, guestIp);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/60dc2545/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index 9bebd4c..49e6812 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -29,6 +29,7 @@ import com.cloud.agent.api.routing.CreateIpAliasCommand;
 import com.cloud.agent.api.routing.DeleteIpAliasCommand;
 import com.cloud.agent.api.routing.DhcpEntryCommand;
 import com.cloud.agent.api.routing.DnsMasqConfigCommand;
+import com.cloud.agent.api.routing.FinishAggregationCommand;
 import com.cloud.agent.api.routing.GroupAnswer;
 import com.cloud.agent.api.routing.IpAliasTO;
 import com.cloud.agent.api.routing.IpAssocCommand;
@@ -46,6 +47,7 @@ import com.cloud.agent.api.routing.SetSourceNatCommand;
 import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
 import com.cloud.agent.api.routing.SetStaticRouteCommand;
 import com.cloud.agent.api.routing.Site2SiteVpnCfgCommand;
+import com.cloud.agent.api.routing.StartAggregationCommand;
 import com.cloud.agent.api.routing.VmDataCommand;
 import com.cloud.agent.api.routing.VpnUsersCfgCommand;
 import com.cloud.agent.api.to.DhcpTO;
@@ -72,6 +74,9 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Queue;
+import java.util.UUID;
+import java.util.concurrent.LinkedBlockingQueue;
 
 /**
  * VirtualNetworkResource controls and configures virtual networking
@@ -111,27 +116,34 @@ public class VirtualRoutingResource {
         protected static final String VPC_STATIC_NAT = "vpc_staticnat.sh";
         protected static final String VPC_STATIC_ROUTE = "vpc_staticroute.sh";
         protected static final String VPN_L2TP = "vpn_l2tp.sh";
+
+        protected static final String VR_CFG = "vr_cfg.sh";
     }
 
     private static final Logger s_logger = Logger.getLogger(VirtualRoutingResource.class);
     private VirtualRouterDeployer _vrDeployer;
+    private Map <String, Queue> _vrAggregateCommandsSet;
 
     private String _name;
     private int _sleep;
     private int _retry;
     private int _port;
 
+    private String _cfgVersion = "1.0";
+
     public VirtualRoutingResource(VirtualRouterDeployer deployer) {
         this._vrDeployer = deployer;
     }
 
     public Answer executeRequest(final NetworkElementCommand cmd) {
+        boolean aggregated = false;
         try {
             ExecutionResult rc = _vrDeployer.prepareCommand(cmd);
             if (!rc.isSuccess()) {
                 s_logger.error("Failed to prepare VR command due to " + rc.getDetails());
                 return new Answer(cmd, false, rc.getDetails());
             }
+            String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
 
             assert cmd.getRouterAccessIp() != null : "Why there is no access IP for VR?";
 
@@ -139,50 +151,22 @@ public class VirtualRoutingResource {
                 return executeQueryCommand(cmd);
             }
 
-            List<ConfigItem> cfg;
-            if (cmd instanceof SetPortForwardingRulesVpcCommand) {
-                cfg = generateConfig((SetPortForwardingRulesVpcCommand)cmd);
-            } else if (cmd instanceof SetPortForwardingRulesCommand) {
-                cfg = generateConfig((SetPortForwardingRulesCommand)cmd);
-            } else if (cmd instanceof SetStaticRouteCommand) {
-                cfg = generateConfig((SetStaticRouteCommand)cmd);
-            } else if (cmd instanceof SetStaticNatRulesCommand) {
-                cfg = generateConfig((SetStaticNatRulesCommand)cmd);
-            } else if (cmd instanceof LoadBalancerConfigCommand) {
-                cfg = generateConfig((LoadBalancerConfigCommand)cmd);
-            } else if (cmd instanceof SavePasswordCommand) {
-                cfg = generateConfig((SavePasswordCommand)cmd);
-            } else if (cmd instanceof DhcpEntryCommand) {
-                cfg = generateConfig((DhcpEntryCommand)cmd);
-            } else if (cmd instanceof CreateIpAliasCommand) {
-                cfg = generateConfig((CreateIpAliasCommand)cmd);
-            } else if (cmd instanceof DnsMasqConfigCommand) {
-                cfg = generateConfig((DnsMasqConfigCommand)cmd);
-            } else if (cmd instanceof DeleteIpAliasCommand) {
-                cfg = generateConfig((DeleteIpAliasCommand)cmd);
-            } else if (cmd instanceof VmDataCommand) {
-                cfg = generateConfig((VmDataCommand)cmd);
-            } else if (cmd instanceof SetFirewallRulesCommand) {
-                cfg = generateConfig((SetFirewallRulesCommand)cmd);
-            } else if (cmd instanceof BumpUpPriorityCommand) {
-                cfg = generateConfig((BumpUpPriorityCommand)cmd);
-            } else if (cmd instanceof RemoteAccessVpnCfgCommand) {
-                cfg = generateConfig((RemoteAccessVpnCfgCommand)cmd);
-            } else if (cmd instanceof VpnUsersCfgCommand) {
-                cfg = generateConfig((VpnUsersCfgCommand)cmd);
-            } else if (cmd instanceof Site2SiteVpnCfgCommand) {
-                cfg = generateConfig((Site2SiteVpnCfgCommand)cmd);
-            } else if (cmd instanceof SetMonitorServiceCommand) {
-                cfg = generateConfig((SetMonitorServiceCommand)cmd);
-            } else if (cmd instanceof SetupGuestNetworkCommand) {
-                cfg = generateConfig((SetupGuestNetworkCommand)cmd);
-            } else if (cmd instanceof SetNetworkACLCommand) {
-                cfg = generateConfig((SetNetworkACLCommand)cmd);
-            } else if (cmd instanceof SetSourceNatCommand) {
-                cfg = generateConfig((SetSourceNatCommand)cmd);
-            } else if (cmd instanceof IpAssocCommand) {
-                cfg = generateConfig((IpAssocCommand)cmd);
-            } else {
+            if (cmd instanceof StartAggregationCommand) {
+                return execute((StartAggregationCommand)cmd);
+            } else if (cmd instanceof FinishAggregationCommand) {
+                return execute((FinishAggregationCommand)cmd);
+            }
+
+            if (_vrAggregateCommandsSet.containsKey(routerName)) {
+                _vrAggregateCommandsSet.get(routerName).add(cmd);
+                aggregated = true;
+                // Clean up would be done after command has been executed
+                //TODO: Deal with group answer as well
+                return new Answer(cmd);
+            }
+
+            List<ConfigItem> cfg = generateCommandCfg(cmd);
+            if (cfg == null) {
                 return Answer.createUnsupportedCommandAnswer(cmd);
             }
 
@@ -190,9 +174,11 @@ public class VirtualRoutingResource {
         } catch (final IllegalArgumentException e) {
             return new Answer(cmd, false, e.getMessage());
         } finally {
-            ExecutionResult rc = _vrDeployer.cleanupCommand(cmd);
-            if (!rc.isSuccess()) {
-                s_logger.error("Failed to cleanup VR command due to " + rc.getDetails());
+            if (!aggregated) {
+                ExecutionResult rc = _vrDeployer.cleanupCommand(cmd);
+                if (!rc.isSuccess()) {
+                    s_logger.error("Failed to cleanup VR command due to " + rc.getDetails());
+                }
             }
         }
     }
@@ -952,6 +938,8 @@ public class VirtualRoutingResource {
         if (_vrDeployer == null) {
             throw new ConfigurationException("Unable to find the resource for VirtualRouterDeployer!");
         }
+
+        _vrAggregateCommandsSet = new HashMap<>();
         return true;
     }
 
@@ -1030,4 +1018,110 @@ public class VirtualRoutingResource {
 
         return false;
     }
+
+    private Answer execute(StartAggregationCommand cmd) {
+        // Access IP would be used as ID for router
+        String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
+        assert routerName != null;
+        Queue<NetworkElementCommand> queue = new LinkedBlockingQueue<>();
+        _vrAggregateCommandsSet.put(routerName, queue);
+        return new Answer(cmd);
+    }
+
+    private List<ConfigItem> generateCommandCfg(NetworkElementCommand cmd) {
+        List<ConfigItem> cfg;
+        if (cmd instanceof SetPortForwardingRulesVpcCommand) {
+            cfg = generateConfig((SetPortForwardingRulesVpcCommand)cmd);
+        } else if (cmd instanceof SetPortForwardingRulesCommand) {
+            cfg = generateConfig((SetPortForwardingRulesCommand)cmd);
+        } else if (cmd instanceof SetStaticRouteCommand) {
+            cfg = generateConfig((SetStaticRouteCommand)cmd);
+        } else if (cmd instanceof SetStaticNatRulesCommand) {
+            cfg = generateConfig((SetStaticNatRulesCommand)cmd);
+        } else if (cmd instanceof LoadBalancerConfigCommand) {
+            cfg = generateConfig((LoadBalancerConfigCommand)cmd);
+        } else if (cmd instanceof SavePasswordCommand) {
+            cfg = generateConfig((SavePasswordCommand)cmd);
+        } else if (cmd instanceof DhcpEntryCommand) {
+            cfg = generateConfig((DhcpEntryCommand)cmd);
+        } else if (cmd instanceof CreateIpAliasCommand) {
+            cfg = generateConfig((CreateIpAliasCommand)cmd);
+        } else if (cmd instanceof DnsMasqConfigCommand) {
+            cfg = generateConfig((DnsMasqConfigCommand)cmd);
+        } else if (cmd instanceof DeleteIpAliasCommand) {
+            cfg = generateConfig((DeleteIpAliasCommand)cmd);
+        } else if (cmd instanceof VmDataCommand) {
+            cfg = generateConfig((VmDataCommand)cmd);
+        } else if (cmd instanceof SetFirewallRulesCommand) {
+            cfg = generateConfig((SetFirewallRulesCommand)cmd);
+        } else if (cmd instanceof BumpUpPriorityCommand) {
+            cfg = generateConfig((BumpUpPriorityCommand)cmd);
+        } else if (cmd instanceof RemoteAccessVpnCfgCommand) {
+            cfg = generateConfig((RemoteAccessVpnCfgCommand)cmd);
+        } else if (cmd instanceof VpnUsersCfgCommand) {
+            cfg = generateConfig((VpnUsersCfgCommand)cmd);
+        } else if (cmd instanceof Site2SiteVpnCfgCommand) {
+            cfg = generateConfig((Site2SiteVpnCfgCommand)cmd);
+        } else if (cmd instanceof SetMonitorServiceCommand) {
+            cfg = generateConfig((SetMonitorServiceCommand)cmd);
+        } else if (cmd instanceof SetupGuestNetworkCommand) {
+            cfg = generateConfig((SetupGuestNetworkCommand)cmd);
+        } else if (cmd instanceof SetNetworkACLCommand) {
+            cfg = generateConfig((SetNetworkACLCommand)cmd);
+        } else if (cmd instanceof SetSourceNatCommand) {
+            cfg = generateConfig((SetSourceNatCommand)cmd);
+        } else if (cmd instanceof IpAssocCommand) {
+            cfg = generateConfig((IpAssocCommand)cmd);
+        } else {
+            return null;
+        }
+        return cfg;
+    }
+
+    private Answer execute(FinishAggregationCommand cmd) {
+        String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
+        assert routerName != null;
+        assert cmd.getRouterAccessIp() != null;
+        Queue<NetworkElementCommand> queue = _vrAggregateCommandsSet.get(routerName);
+        try {
+            StringBuilder sb = new StringBuilder();
+            sb.append("#Apache CloudStack Virtual Router Config File\n");
+            sb.append("<version>\n" + _cfgVersion + "\n</version>\n");
+            for (NetworkElementCommand command : queue) {
+                List<ConfigItem> cfg = generateCommandCfg(command);
+                if (cfg == null) {
+                    s_logger.warn("Unknown commands for VirtualRoutingResource, but continue: " + cmd.toString());
+                }
+
+                for (ConfigItem c : cfg) {
+                    if (c.isFile()) {
+                        sb.append("<file>\n");
+                        sb.append(c.getFilePath() + c.getFileName() + "\n");
+                        sb.append(c.getFileContents() + "\n");
+                        sb.append("</file>\n");
+                    } else {
+                        sb.append("<script>\n");
+                        sb.append("/opt/cloud/bin/" + c.getScript() + " " + c.getArgs() + "\n");
+                        sb.append("</script>\n");
+                    }
+                }
+            }
+            String cfgFilePath = "/var/cache/cloud/";
+            String cfgFileName = "VR-"+ UUID.randomUUID().toString() + ".cfg";
+            ExecutionResult result = _vrDeployer.createFileInVR(cmd.getRouterAccessIp(), cfgFilePath, cfgFileName, sb.toString());
+            if (!result.isSuccess()) {
+                return new Answer(cmd, false, result.getDetails());
+            }
+
+            result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VR_CFG, "-c " + cfgFilePath + cfgFileName);
+            if (!result.isSuccess()) {
+                return new Answer(cmd, false, result.getDetails());
+            }
+            return new Answer(cmd);
+        } finally {
+            queue.clear();
+            _vrAggregateCommandsSet.remove(routerName);
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/60dc2545/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 37171f5..8486f06 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -2736,12 +2736,10 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
             final Commands cmds = new Commands(Command.OnError.Stop);
             createApplyVpnCommands(true, vpn, router, cmds);
 
-            try {
-                _agentMgr.send(router.getHostId(), cmds);
-            } catch (final OperationTimedoutException e) {
-                s_logger.debug("Failed to start remote access VPN: ", e);
-                throw new AgentUnavailableException("Unable to send commands to virtual router ", router.getHostId(), e);
+            if (!sendCommandsToRouter(router, cmds)) {
+                throw new AgentUnavailableException("Unable to send commands to virtual router ", router.getHostId());
             }
+
             Answer answer = cmds.getAnswer("users");
             if (!answer.getResult()) {
                 s_logger.error("Unable to start vpn: unable add users to vpn in zone " + router.getDataCenterId() + " for account " + vpn.getAccountId() + " on domR: " +

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/60dc2545/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh b/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh
new file mode 100755
index 0000000..8994a06
--- /dev/null
+++ b/systemvm/patches/debian/config/opt/cloud/bin/vr_cfg.sh
@@ -0,0 +1,96 @@
+#!/bin/bash
+# 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.
+
+#set -x
+
+cfg=
+version=
+log=/var/log/cloud.log
+
+log_it() {
+    logger -t cloud "$*"
+    echo "$(date) : $*" >> $log
+}
+
+while getopts 'c:' OPTION
+do
+  case $OPTION in
+      c) cfg="$OPTARG"
+          ;;
+  esac
+done
+
+while read line
+do
+    #comment
+    if [[ $line == \#* ]]
+    then
+	    continue
+    fi
+
+    if [ "$line" == "<version>" ]
+    then
+        read line
+        version=$line
+        log_it "VR config: configuation format version $version"
+        #skip </version>
+        read line
+        continue
+    fi
+
+    if [ "$line" == "<script>" ]
+    then
+        read line
+        log_it "VR config: executing: $line"
+        eval $line >> $log 2>&1
+        if [ $? -ne 0 ]
+        then
+            log_it "VR config: executing failed: $line"
+            # expose error info to mgmt server
+            echo "VR config: execution failed: \"$line\", check $log in VR for details "
+            exit 1
+        fi
+        #skip </script>
+        read line
+        log_it "VR config: execution success "
+        continue
+    fi
+
+    if [ "$line" == "<file>" ]
+    then
+        read line
+        file=$line
+        log_it "VR config: creating file: $file"
+        rm -f $file
+        while read line
+        do
+            if [ "$line" == "</file>" ]
+            then
+                break
+            fi
+            echo $line >> $file
+        done
+        log_it "VR config: create file success"
+        continue
+    fi
+done < $cfg
+
+#remove the configuration file, log file should have all the records as well
+rm -f $cfg
+
+exit 0


[45/50] [abbrv] Removed unused methods from BaseCmd class. Moved some helper methods to AccountManagerImpl class

Posted by ml...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/server/test/com/cloud/api/dispatch/ParamGenericValidationWorkerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/api/dispatch/ParamGenericValidationWorkerTest.java b/server/test/com/cloud/api/dispatch/ParamGenericValidationWorkerTest.java
index 867625d..0803a2b 100644
--- a/server/test/com/cloud/api/dispatch/ParamGenericValidationWorkerTest.java
+++ b/server/test/com/cloud/api/dispatch/ParamGenericValidationWorkerTest.java
@@ -16,16 +16,15 @@
 // under the License.
 package com.cloud.api.dispatch;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Test;
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
 import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
@@ -33,6 +32,9 @@ import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.BaseResponse;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
+import org.junit.Test;
 
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
@@ -40,8 +42,9 @@ import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.user.Account;
-
-import org.apache.log4j.Logger;
+import com.cloud.user.AccountVO;
+import com.cloud.user.User;
+import com.cloud.user.UserVO;
 
 public class ParamGenericValidationWorkerTest {
 
@@ -55,9 +58,9 @@ public class ParamGenericValidationWorkerTest {
         final ParamGenericValidationWorker genValidationWorker = new ParamGenericValidationWorker();
 
         // We create a mock logger to verify the result
-        ParamGenericValidationWorker.s_logger = new Logger(""){
+        ParamGenericValidationWorker.s_logger = new Logger("") {
             @Override
-            public void warn(final Object msg){
+            public void warn(final Object msg) {
                 loggerOutput = msg.toString();
             }
         };
@@ -74,8 +77,15 @@ public class ParamGenericValidationWorkerTest {
         params.put(ApiConstants.COMMAND, "");
         params.put("addedParam", "");
 
+        Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid");
+        UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString());
+        CallContext.register(user, account);
         // Execute
-        driveTest(cmd, params);
+        try {
+            driveTest(cmd, params);
+        } finally {
+            CallContext.unregister();
+        }
 
         // Assert
         assertEquals("There should be no errors since there are no unknown parameters for this command class", null, loggerOutput);
@@ -91,8 +101,16 @@ public class ParamGenericValidationWorkerTest {
         params.put("addedParam", "");
         params.put(unknownParamKey, "");
 
+        Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid");
+        UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString());
+        CallContext.register(user, account);
+
         // Execute
-        driveTest(cmd, params);
+        try {
+            driveTest(cmd, params);
+        } finally {
+            CallContext.unregister();
+        }
 
         // Assert
         assertTrue("There should be error msg, since there is one unknown parameter", loggerOutput.contains(unknownParamKey));
@@ -102,6 +120,7 @@ public class ParamGenericValidationWorkerTest {
     @Test
     public void testHandleWithoutAuthorization() throws ResourceAllocationException {
         final short type = Account.ACCOUNT_TYPE_NORMAL;
+
         driveAuthTest(type);
 
         // Assert
@@ -112,25 +131,33 @@ public class ParamGenericValidationWorkerTest {
     @Test
     public void testHandleWithAuthorization() throws ResourceAllocationException {
         final short type = Account.ACCOUNT_TYPE_ADMIN;
-        driveAuthTest(type);
 
+        driveAuthTest(type);
         // Assert
         assertEquals("There should be no errors since parameters have authorization", null, loggerOutput);
     }
 
     protected void driveAuthTest(final short type) {
+
         // Prepare
         final BaseCmd cmd = new FakeCmdWithRoleAdmin();
         final Account account = mock(Account.class);
         ((FakeCmdWithRoleAdmin)cmd).account = account;
         when(account.getType()).thenReturn(type);
+        User user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString());
+        CallContext.register(user, account);
+
         final Map<String, String> params = new HashMap<String, String>();
         params.put(ApiConstants.COMMAND, "");
         params.put("addedParam", "");
         params.put("paramWithRole", "");
 
         // Execute
-        driveTest(cmd, params);
+        try {
+            driveTest(cmd, params);
+        } finally {
+            CallContext.unregister();
+        }
     }
 }
 
@@ -143,11 +170,6 @@ class FakeCmd extends BaseCmd {
 
     public Account account;
 
-    @Override
-    protected Account getCurrentContextAccount() {
-        return account;
-    }
-
     //
     // Dummy methods for mere correct compilation
     //

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/server/test/com/cloud/user/MockAccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/user/MockAccountManagerImpl.java b/server/test/com/cloud/user/MockAccountManagerImpl.java
index 62e7fc8..5a44800 100644
--- a/server/test/com/cloud/user/MockAccountManagerImpl.java
+++ b/server/test/com/cloud/user/MockAccountManagerImpl.java
@@ -22,8 +22,6 @@ import java.util.Map;
 import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
-import org.springframework.stereotype.Component;
-
 import org.apache.cloudstack.acl.ControlledEntity;
 import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
@@ -31,6 +29,7 @@ import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
 import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
 import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
 import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
+import org.springframework.stereotype.Component;
 
 import com.cloud.api.query.vo.ControlledViewEntity;
 import com.cloud.domain.Domain;
@@ -322,4 +321,10 @@ public class MockAccountManagerImpl extends ManagerBase implements Manager, Acco
         return null;
     }
 
+    @Override
+    public Long finalyzeAccountId(String accountName, Long domainId, Long projectId, boolean enabledOnly) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }


[33/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
Removed unused parameter from @Parameter


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

Branch: refs/heads/resize-root
Commit: 7cb913235ab4d8bd61a4994f5ac9312bbeb6352f
Parents: bf8507d
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Thu Mar 6 13:32:44 2014 -0800
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Thu Mar 6 16:06:00 2014 -0800

----------------------------------------------------------------------
 api/src/org/apache/cloudstack/api/Parameter.java | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7cb91323/api/src/org/apache/cloudstack/api/Parameter.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/Parameter.java b/api/src/org/apache/cloudstack/api/Parameter.java
index f1c6e1a..7ee6897 100644
--- a/api/src/org/apache/cloudstack/api/Parameter.java
+++ b/api/src/org/apache/cloudstack/api/Parameter.java
@@ -48,7 +48,5 @@ public @interface Parameter {
 
     String since() default "";
 
-    String retrieveMethod() default "getById";
-
     RoleType[] authorized() default {};
 }


[23/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
Fix unapproved licens issue.


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

Branch: refs/heads/resize-root
Commit: 922cdc0dd11ae92d83a30efd9346caa17a71bc01
Parents: 182c318
Author: Min Chen <mi...@citrix.com>
Authored: Wed Mar 5 14:28:06 2014 -0800
Committer: Min Chen <mi...@citrix.com>
Committed: Wed Mar 5 14:31:28 2014 -0800

----------------------------------------------------------------------
 .../org/apache/cloudstack/acl/IAMEntityType.java   | 16 ++++++++++++++++
 .../org/apache/cloudstack/acl/PermissionScope.java | 16 ++++++++++++++++
 .../cloudstack/iam/test/IAMApiServiceTest.java     | 16 ++++++++++++++++
 .../iam/server/dao/IAMAccountPolicyMapDao.java     | 16 ++++++++++++++++
 .../iam/server/dao/IAMAccountPolicyMapDaoImpl.java | 16 ++++++++++++++++
 .../iam/server/dao/IAMGroupPolicyMapDao.java       | 17 +++++++++++++++++
 .../iam/server/dao/IAMGroupPolicyMapDaoImpl.java   | 16 ++++++++++++++++
 7 files changed, 113 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/922cdc0d/api/src/org/apache/cloudstack/acl/IAMEntityType.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/acl/IAMEntityType.java b/api/src/org/apache/cloudstack/acl/IAMEntityType.java
index 9299ae9..c1703ea 100644
--- a/api/src/org/apache/cloudstack/acl/IAMEntityType.java
+++ b/api/src/org/apache/cloudstack/acl/IAMEntityType.java
@@ -1,3 +1,19 @@
+// 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.acl;
 
 public enum IAMEntityType {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/922cdc0d/api/src/org/apache/cloudstack/acl/PermissionScope.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/acl/PermissionScope.java b/api/src/org/apache/cloudstack/acl/PermissionScope.java
index 03dbc10..6647440 100644
--- a/api/src/org/apache/cloudstack/acl/PermissionScope.java
+++ b/api/src/org/apache/cloudstack/acl/PermissionScope.java
@@ -1,3 +1,19 @@
+// 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.acl;
 
 public enum PermissionScope {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/922cdc0d/services/iam/plugin/test/org/apache/cloudstack/iam/test/IAMApiServiceTest.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/test/org/apache/cloudstack/iam/test/IAMApiServiceTest.java b/services/iam/plugin/test/org/apache/cloudstack/iam/test/IAMApiServiceTest.java
index dc5c168..b825ab2 100644
--- a/services/iam/plugin/test/org/apache/cloudstack/iam/test/IAMApiServiceTest.java
+++ b/services/iam/plugin/test/org/apache/cloudstack/iam/test/IAMApiServiceTest.java
@@ -1,3 +1,19 @@
+// 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.iam.test;
 
 import static org.junit.Assert.assertEquals;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/922cdc0d/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDao.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDao.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDao.java
index 4caf659..0162589 100644
--- a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDao.java
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDao.java
@@ -1,3 +1,19 @@
+// 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.iam.server.dao;
 
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/922cdc0d/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDaoImpl.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDaoImpl.java
index 3ecca3b..d74e86f 100644
--- a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDaoImpl.java
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDaoImpl.java
@@ -1,3 +1,19 @@
+// 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.iam.server.dao;
 
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/922cdc0d/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDao.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDao.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDao.java
index 6a2df89..3f5f232 100644
--- a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDao.java
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDao.java
@@ -1,8 +1,25 @@
+// 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.iam.server.dao;
 
 import java.util.List;
 
 import org.apache.cloudstack.iam.server.IAMGroupPolicyMapVO;
+
 import com.cloud.utils.db.GenericDao;
 
 public interface IAMGroupPolicyMapDao extends GenericDao<IAMGroupPolicyMapVO, Long> {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/922cdc0d/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDaoImpl.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDaoImpl.java
index 95b6bac..ac42f04 100644
--- a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDaoImpl.java
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupPolicyMapDaoImpl.java
@@ -1,3 +1,19 @@
+// 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.iam.server.dao;
 
 import java.util.List;


[50/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
Merge branch 'master' into resize-root


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

Branch: refs/heads/resize-root
Commit: 0eb9967354c7a7f90383fad127290425867035c5
Parents: 4a21da6 548c810
Author: Marcus Sorensen <ma...@betterservers.com>
Authored: Fri Mar 7 17:21:57 2014 -0700
Committer: Marcus Sorensen <ma...@betterservers.com>
Committed: Fri Mar 7 17:21:57 2014 -0700

----------------------------------------------------------------------
 agent/conf/agent.properties                     |  11 +
 .../cloud/agent/api/HostVmStateReportEntry.java |  10 +-
 api/src/com/cloud/event/EventTypes.java         |  13 +
 api/src/com/cloud/network/NetworkProfile.java   |   7 +
 .../cloud/network/vpc/StaticRouteProfile.java   |  28 +-
 .../com/cloud/offering/DiskOfferingInfo.java    |  65 ++
 api/src/com/cloud/server/ManagementService.java |   4 -
 api/src/com/cloud/storage/Volume.java           |   2 +
 api/src/com/cloud/storage/VolumeApiService.java |   2 +
 api/src/com/cloud/user/AccountService.java      |   2 +
 api/src/com/cloud/uservm/UserVm.java            |   1 +
 api/src/com/cloud/vm/UserVmService.java         |   6 +
 .../apache/cloudstack/acl/ControlledEntity.java |   1 +
 .../apache/cloudstack/acl/IAMEntityType.java    |  61 ++
 .../apache/cloudstack/acl/PermissionScope.java  |  41 +
 .../apache/cloudstack/acl/QuerySelector.java    |  72 ++
 .../apache/cloudstack/acl/SecurityChecker.java  |  22 +-
 .../org/apache/cloudstack/api/APICommand.java   |   3 +
 .../cloudstack/api/ApiCommandJobType.java       |   4 +-
 .../org/apache/cloudstack/api/ApiConstants.java |  33 +-
 .../org/apache/cloudstack/api/BaseAsyncCmd.java |  34 -
 .../apache/cloudstack/api/BaseAsyncVMCmd.java   |  30 +
 .../cloudstack/api/BaseAsyncVolumeCmd.java      |  30 +
 api/src/org/apache/cloudstack/api/BaseCmd.java  | 255 +++---
 .../org/apache/cloudstack/api/BaseListCmd.java  |  30 +-
 .../BaseListTemplateOrIsoPermissionsCmd.java    |   5 +-
 .../org/apache/cloudstack/api/Parameter.java    |   2 -
 .../admin/offering/CreateDiskOfferingCmd.java   |   6 +-
 .../offering/CreateServiceOfferingCmd.java      |  32 +
 .../api/command/admin/user/CreateUserCmd.java   |   5 +-
 .../affinitygroup/CreateAffinityGroupCmd.java   |   5 +-
 .../affinitygroup/DeleteAffinityGroupCmd.java   |   5 +-
 .../user/autoscale/CreateConditionCmd.java      |   5 +-
 .../firewall/CreateEgressFirewallRuleCmd.java   |  11 +-
 .../user/firewall/CreateFirewallRuleCmd.java    |  12 +-
 .../firewall/CreatePortForwardingRuleCmd.java   |  10 +-
 .../api/command/user/iso/ListIsosCmd.java       |   5 +-
 .../api/command/user/iso/RegisterIsoCmd.java    |   5 +-
 .../user/nat/CreateIpForwardingRuleCmd.java     |  18 +-
 .../command/user/network/CreateNetworkCmd.java  |   2 +-
 .../gslb/CreateGlobalLoadBalancerRuleCmd.java   |   5 +-
 .../user/resource/ListResourceLimitsCmd.java    |   5 +-
 .../user/resource/UpdateResourceCountCmd.java   |   7 +-
 .../user/resource/UpdateResourceLimitCmd.java   |   7 +-
 .../AuthorizeSecurityGroupEgressCmd.java        |   5 +-
 .../AuthorizeSecurityGroupIngressCmd.java       |   5 +-
 .../securitygroup/CreateSecurityGroupCmd.java   |   5 +-
 .../securitygroup/DeleteSecurityGroupCmd.java   |   5 +-
 .../command/user/ssh/CreateSSHKeyPairCmd.java   |   5 +-
 .../command/user/ssh/DeleteSSHKeyPairCmd.java   |   5 +-
 .../command/user/ssh/RegisterSSHKeyPairCmd.java |   5 +-
 .../command/user/template/ListTemplatesCmd.java |   5 +-
 .../user/template/RegisterTemplateCmd.java      |   5 +-
 .../api/command/user/vm/DeployVMCmd.java        |  62 +-
 .../api/command/user/vm/DestroyVMCmd.java       |   4 +-
 .../api/command/user/vm/RebootVMCmd.java        |   4 +-
 .../api/command/user/vm/ResetVMPasswordCmd.java |   4 +-
 .../api/command/user/vm/ResetVMSSHKeyCmd.java   |   4 +-
 .../api/command/user/vm/RestoreVMCmd.java       |  10 +-
 .../api/command/user/vm/ScaleVMCmd.java         |   4 +-
 .../api/command/user/vm/StartVMCmd.java         |   4 +-
 .../api/command/user/vm/StopVMCmd.java          |   4 +-
 .../api/command/user/vm/UpdateVMCmd.java        |  10 +
 .../api/command/user/vm/UpgradeVMCmd.java       |   5 +
 .../command/user/vmgroup/CreateVMGroupCmd.java  |   5 +-
 .../command/user/volume/AttachVolumeCmd.java    |   4 +-
 .../command/user/volume/CreateVolumeCmd.java    |  12 +-
 .../command/user/volume/DeleteVolumeCmd.java    |   5 +
 .../command/user/volume/DetachVolumeCmd.java    |   4 +-
 .../command/user/volume/ExtractVolumeCmd.java   |   4 +-
 .../command/user/volume/MigrateVolumeCmd.java   |  10 +-
 .../command/user/volume/ResizeVolumeCmd.java    |  10 +-
 .../command/user/volume/UpdateVolumeCmd.java    |   5 +
 .../command/user/volume/UploadVolumeCmd.java    |   5 +-
 .../api/command/user/vpc/CreateVPCCmd.java      |   2 +-
 .../api/command/user/vpn/AddVpnUserCmd.java     |   5 +-
 .../user/vpn/CreateVpnCustomerGatewayCmd.java   |   5 +-
 .../api/command/user/vpn/RemoveVpnUserCmd.java  |   5 +-
 .../command/user/vpn/ResetVpnConnectionCmd.java |   5 +-
 .../user/vpn/UpdateVpnCustomerGatewayCmd.java   |   5 +-
 .../api/response/DiskOfferingResponse.java      |  12 +
 .../api/response/ServiceOfferingResponse.java   |  48 ++
 .../apache/cloudstack/context/CallContext.java  |  13 +
 .../org/apache/cloudstack/api/BaseCmdTest.java  |  69 ++
 .../classes/resources/messages.properties       | 209 +++++
 .../classes/resources/messages_ja_JP.properties | 272 ++++++-
 .../classes/resources/messages_zh_CN.properties | 572 +++++++++----
 .../com/cloud/agent/api/ClusterSyncAnswer.java  |  10 +-
 .../agent/api/ClusterVMMetaDataSyncAnswer.java  |  52 ++
 .../agent/api/ClusterVMMetaDataSyncCommand.java |  47 ++
 .../cloud/agent/api/StartupRoutingCommand.java  |   8 +-
 .../api/routing/FinishAggregationCommand.java   |  31 +
 .../api/routing/StartAggregationCommand.java    |  31 +
 .../virtualnetwork/VirtualRoutingResource.java  | 189 +++--
 .../storage/to/PrimaryDataStoreTO.java          |  18 +
 .../VirtualRoutingResourceTest.java             | 474 +++++++++--
 .../src/com/cloud/vm/VirtualMachineManager.java |   9 +-
 .../service/NetworkOrchestrationService.java    |   2 +-
 .../service/VolumeOrchestrationService.java     |   2 +-
 .../api/storage/DataMotionService.java          |   2 +
 .../api/storage/DataMotionStrategy.java         |   2 +
 .../api/storage/PrimaryDataStoreInfo.java       |  18 +
 .../subsystem/api/storage/VolumeService.java    |   6 +-
 .../src/com/cloud/network/addr/PublicIp.java    |   7 +
 .../cloud/network/rules/StaticNatRuleImpl.java  |  33 +-
 .../src/com/cloud/template/TemplateManager.java |   3 +
 .../cloud/agent/manager/DirectAgentAttache.java |   2 -
 .../com/cloud/vm/VirtualMachineManagerImpl.java | 109 ++-
 .../engine/orchestration/CloudOrchestrator.java |  56 +-
 .../orchestration/NetworkOrchestrator.java      | 101 ++-
 .../orchestration/VolumeOrchestrator.java       |  29 +-
 engine/schema/src/com/cloud/event/EventVO.java  |  23 +-
 .../com/cloud/network/UserIpv6AddressVO.java    |  17 +-
 .../schema/src/com/cloud/network/VpnUserVO.java |  19 +-
 .../com/cloud/network/as/AutoScalePolicyVO.java |   9 +-
 .../cloud/network/as/AutoScaleVmGroupVO.java    |  11 +-
 .../cloud/network/as/AutoScaleVmProfileVO.java  |  11 +-
 .../src/com/cloud/network/as/ConditionVO.java   |  11 +-
 .../src/com/cloud/network/dao/IPAddressVO.java  |  45 +-
 .../cloud/network/dao/MonitoringServiceVO.java  |   7 +
 .../src/com/cloud/network/dao/NetworkVO.java    |  46 +-
 .../cloud/network/dao/RemoteAccessVpnVO.java    |  17 +-
 .../network/dao/Site2SiteCustomerGatewayVO.java |   9 +-
 .../network/dao/Site2SiteVpnConnectionVO.java   |  14 +-
 .../network/dao/Site2SiteVpnGatewayVO.java      |  13 +-
 .../src/com/cloud/network/dao/SslCertVO.java    |  14 +-
 .../com/cloud/network/rules/FirewallRuleVO.java |  24 +-
 .../cloud/network/security/SecurityGroupVO.java |  13 +-
 .../com/cloud/network/vpc/StaticRouteVO.java    |  15 +-
 .../src/com/cloud/network/vpc/VpcGatewayVO.java |  17 +-
 .../schema/src/com/cloud/network/vpc/VpcVO.java |  15 +-
 .../com/cloud/projects/ProjectInvitationVO.java |  17 +-
 .../src/com/cloud/storage/SnapshotVO.java       |  19 +-
 .../src/com/cloud/storage/VMTemplateVO.java     |   6 +
 .../schema/src/com/cloud/storage/VolumeVO.java  | 102 +--
 .../src/com/cloud/tags/ResourceTagVO.java       |  11 +-
 .../cloud/upgrade/dao/DatabaseAccessObject.java |  99 +++
 .../com/cloud/upgrade/dao/DbUpgradeUtils.java   |  76 +-
 engine/schema/src/com/cloud/user/AccountVO.java |  16 +-
 .../schema/src/com/cloud/user/SSHKeyPairVO.java |   6 +
 .../src/com/cloud/vm/InstanceGroupVO.java       |  11 +-
 .../schema/src/com/cloud/vm/VMInstanceVO.java   |  28 +-
 .../src/com/cloud/vm/dao/NicIpAliasVO.java      |  14 +-
 .../src/com/cloud/vm/dao/NicSecondaryIpVO.java  |   9 +-
 .../src/com/cloud/vm/snapshot/VMSnapshotVO.java |  14 +-
 .../cloudstack/affinity/AffinityGroupVO.java    |  12 +-
 .../engine/cloud/entity/api/db/VMEntityVO.java  |  28 +-
 .../region/gslb/GlobalLoadBalancerRuleVO.java   |  15 +-
 .../upgrade/dao/DatabaseAccessObjectTest.java   | 463 +++++++++++
 .../cloud/upgrade/dao/DbUpgradeUtilsTest.java   | 162 ++++
 .../motion/AncientDataMotionStrategy.java       |  25 +-
 .../storage/motion/DataMotionServiceImpl.java   |   9 +-
 .../storage/image/store/TemplateObject.java     |  20 +
 .../storage/test/MockStorageMotionStrategy.java |   5 +
 .../storage/snapshot/SnapshotObject.java        |   6 +
 .../storage/image/TemplateEntityImpl.java       |   5 +
 .../storage/snapshot/SnapshotEntityImpl.java    |   5 +
 .../storage/datastore/PrimaryDataStoreImpl.java |  20 +-
 .../datastore/provider/DefaultHostListener.java |   2 +-
 .../cloudstack/storage/volume/VolumeObject.java | 169 ++--
 .../storage/volume/VolumeServiceImpl.java       | 156 +++-
 .../networkservice/BareMetalResourceBase.java   |   3 +-
 .../resource/HypervDirectConnectResource.java   |   2 +-
 .../kvm/resource/LibvirtComputingResource.java  | 101 ++-
 .../cloud/ovm/hypervisor/OvmResourceBase.java   |   2 +-
 .../cloud/resource/AgentRoutingResource.java    |   2 +-
 .../motion/SimulatorDataMotionStrategy.java     |   5 +
 .../vmware/resource/VmwareResource.java         |   2 +-
 .../motion/VmwareStorageMotionStrategy.java     |   5 +
 .../xen/resource/CitrixResourceBase.java        | 148 ++--
 .../xen/resource/XenServer610Resource.java      |   8 -
 .../xen/resource/XenServerPoolVms.java          |  41 +-
 .../xen/resource/XenServerStorageProcessor.java | 126 ++-
 .../xenserver/XenServerResourceNewBase.java     |  20 +-
 .../motion/XenServerStorageMotionStrategy.java  |   5 +
 .../network/lb/LoadBalanceRuleHandler.java      |   7 +-
 .../lb/InternalLoadBalancerVMManagerImpl.java   |  18 +-
 .../api/command/CreateServiceInstanceCmd.java   |   2 +-
 .../contrail/management/ServiceManagerImpl.java |  16 +-
 .../contrail/management/MockAccountManager.java |   9 +-
 .../apache/cloudstack/ldap/LdapUserManager.java |   8 +-
 .../cloudstack/ldap/LdapUserManagerSpec.groovy  | 263 +++---
 .../core/spring-server-core-misc-context.xml    |  12 +
 server/src/com/cloud/acl/DomainChecker.java     |  14 +-
 server/src/com/cloud/api/ApiDispatcher.java     | 491 +----------
 server/src/com/cloud/api/ApiServer.java         | 438 +++++-----
 server/src/com/cloud/api/ApiServerService.java  |   2 +
 server/src/com/cloud/api/ApiServlet.java        | 133 +--
 .../api/dispatch/CommandCreationWorker.java     |  56 ++
 .../com/cloud/api/dispatch/DispatchChain.java   |  40 +
 .../api/dispatch/DispatchChainFactory.java      |  72 ++
 .../com/cloud/api/dispatch/DispatchTask.java    |  58 ++
 .../com/cloud/api/dispatch/DispatchWorker.java  |  30 +
 .../dispatch/ParamGenericValidationWorker.java  | 103 +++
 .../cloud/api/dispatch/ParamProcessWorker.java  | 428 ++++++++++
 .../cloud/api/dispatch/ParamUnpackWorker.java   | 114 +++
 .../dispatch/SpecificCmdValidationWorker.java   |  34 +
 .../com/cloud/api/query/QueryManagerImpl.java   |   7 +
 .../api/query/dao/DiskOfferingJoinDaoImpl.java  |   1 +
 .../query/dao/ServiceOfferingJoinDaoImpl.java   |   4 +
 .../api/query/dao/TemplateJoinDaoImpl.java      |  13 +-
 .../cloud/api/query/vo/AffinityGroupJoinVO.java |   6 +
 .../cloud/api/query/vo/DiskOfferingJoinVO.java  |   7 +-
 .../cloud/api/query/vo/DomainRouterJoinVO.java  |   8 +
 .../src/com/cloud/api/query/vo/EventJoinVO.java |  15 +
 .../cloud/api/query/vo/InstanceGroupJoinVO.java |   8 +
 .../api/query/vo/ProjectInvitationJoinVO.java   |   8 +
 .../cloud/api/query/vo/ResourceTagJoinVO.java   |   8 +
 .../cloud/api/query/vo/SecurityGroupJoinVO.java |   8 +
 .../api/query/vo/ServiceOfferingJoinVO.java     |  28 +
 .../com/cloud/api/query/vo/TemplateJoinVO.java  |   9 +-
 .../com/cloud/api/query/vo/UserVmJoinVO.java    |   8 +
 .../com/cloud/api/query/vo/VolumeJoinVO.java    |   8 +
 .../api/response/SecurityGroupResultObject.java |   8 +-
 .../configuration/ConfigurationManagerImpl.java |  51 +-
 .../consoleproxy/ConsoleProxyManagerImpl.java   |   7 +-
 .../com/cloud/event/ActionEventInterceptor.java |  19 +-
 .../src/com/cloud/event/ActionEventUtils.java   |  34 +-
 .../cloud/network/as/AutoScaleManagerImpl.java  | 466 +++++------
 .../VirtualNetworkApplianceManagerImpl.java     |  40 +-
 .../VpcVirtualNetworkApplianceManagerImpl.java  |  62 +-
 .../network/vpc/PrivateGatewayProfile.java      |   6 +
 .../com/cloud/server/ManagementServerImpl.java  |  10 -
 .../com/cloud/storage/VolumeApiServiceImpl.java |   9 +
 .../storage/snapshot/SnapshotSchedulerImpl.java | 107 +--
 server/src/com/cloud/user/AccountManager.java   |   4 +
 .../src/com/cloud/user/AccountManagerImpl.java  |  48 ++
 server/src/com/cloud/user/DomainManager.java    |   3 +
 server/src/com/cloud/vm/UserVmManagerImpl.java  |  19 +-
 .../test/com/cloud/api/ApiDispatcherTest.java   | 106 ---
 .../api/dispatch/CommandCreationWorkerTest.java |  48 ++
 .../api/dispatch/DispatchChainFactoryTest.java  |  55 ++
 .../ParamGenericValidationWorkerTest.java       | 195 +++++
 .../api/dispatch/ParamProcessWorkerTest.java    | 107 +++
 .../SpecificCmdValidationWorkerTest.java        |  48 ++
 .../com/cloud/user/MockAccountManagerImpl.java  |   9 +-
 .../com/cloud/vpc/MockNetworkManagerImpl.java   |   5 +-
 services/iam/plugin/pom.xml                     |  58 ++
 .../iam-access-checkers/module.properties       |  18 +
 .../spring-iam-access-checkers-context.xml      |  35 +
 .../command/iam/AddAccountToIAMGroupCmd.java    | 127 +++
 .../iam/AddIAMPermissionToIAMPolicyCmd.java     | 155 ++++
 .../iam/AttachIAMPolicyToAccountCmd.java        | 122 +++
 .../iam/AttachIAMPolicyToIAMGroupCmd.java       | 127 +++
 .../api/command/iam/CreateIAMGroupCmd.java      | 168 ++++
 .../api/command/iam/CreateIAMPolicyCmd.java     | 175 ++++
 .../api/command/iam/DeleteIAMGroupCmd.java      | 102 +++
 .../api/command/iam/DeleteIAMPolicyCmd.java     | 102 +++
 .../api/command/iam/ListIAMGroupsCmd.java       |  88 ++
 .../api/command/iam/ListIAMPoliciesCmd.java     |  88 ++
 .../iam/RemoveAccountFromIAMGroupCmd.java       | 127 +++
 .../RemoveIAMPermissionFromIAMPolicyCmd.java    | 148 ++++
 .../iam/RemoveIAMPolicyFromAccountCmd.java      | 122 +++
 .../iam/RemoveIAMPolicyFromIAMGroupCmd.java     | 127 +++
 .../api/response/iam/IAMGroupResponse.java      | 193 +++++
 .../api/response/iam/IAMPermissionResponse.java | 125 +++
 .../api/response/iam/IAMPolicyResponse.java     | 177 ++++
 .../apache/cloudstack/iam/IAMApiService.java    |  87 ++
 .../cloudstack/iam/IAMApiServiceImpl.java       | 800 ++++++++++++++++++
 .../iam/RoleBasedAPIAccessChecker.java          | 273 +++++++
 .../iam/RoleBasedEntityAccessChecker.java       | 186 +++++
 .../iam/RoleBasedEntityQuerySelector.java       | 147 ++++
 .../cloudstack/iam/test/IAMApiServiceTest.java  | 385 +++++++++
 .../iam/plugin/test/resources/db.properties     |  75 ++
 services/iam/pom.xml                            |  59 ++
 services/iam/server/pom.xml                     |  52 ++
 .../core/spring-iam-server-context.xml          |  40 +
 .../org/apache/cloudstack/iam/api/IAMGroup.java |  37 +
 .../apache/cloudstack/iam/api/IAMPolicy.java    |  41 +
 .../cloudstack/iam/api/IAMPolicyPermission.java |  53 ++
 .../apache/cloudstack/iam/api/IAMService.java   |  92 +++
 .../iam/server/IAMAccountPolicyMapVO.java       |  77 ++
 .../iam/server/IAMGroupAccountMapVO.java        |  78 ++
 .../iam/server/IAMGroupPolicyMapVO.java         |  79 ++
 .../cloudstack/iam/server/IAMGroupVO.java       | 122 +++
 .../iam/server/IAMPolicyPermissionVO.java       | 181 ++++
 .../cloudstack/iam/server/IAMPolicyVO.java      | 138 ++++
 .../cloudstack/iam/server/IAMServiceImpl.java   | 815 +++++++++++++++++++
 .../iam/server/dao/IAMAccountPolicyMapDao.java  |  33 +
 .../server/dao/IAMAccountPolicyMapDaoImpl.java  |  77 ++
 .../iam/server/dao/IAMGroupAccountMapDao.java   |  40 +
 .../server/dao/IAMGroupAccountMapDaoImpl.java   | 119 +++
 .../cloudstack/iam/server/dao/IAMGroupDao.java  |  28 +
 .../iam/server/dao/IAMGroupDaoImpl.java         |  59 ++
 .../iam/server/dao/IAMGroupPolicyMapDao.java    |  33 +
 .../server/dao/IAMGroupPolicyMapDaoImpl.java    |  77 ++
 .../cloudstack/iam/server/dao/IAMPolicyDao.java |  28 +
 .../iam/server/dao/IAMPolicyDaoImpl.java        |  57 ++
 .../iam/server/dao/IAMPolicyPermissionDao.java  |  39 +
 .../server/dao/IAMPolicyPermissionDaoImpl.java  | 129 +++
 .../cloudstack/iam/IAMServiceUnitTest.java      | 211 +++++
 .../iam/server/test/resources/db.properties     |  75 ++
 services/pom.xml                                |   1 +
 .../SecondaryStorageManagerImpl.java            |  10 +-
 setup/db/db/schema-430to440.sql                 |  51 ++
 .../debian/config/opt/cloud/bin/vr_cfg.sh       |  96 +++
 tools/ngui/static/js/app/accounts/accounts.js   |  16 +-
 tools/ngui/static/js/app/storage/storage.js     |   2 +-
 ui/css/cloudstack3.css                          | 141 +++-
 ui/dictionary.jsp                               | 220 ++++-
 ui/images/icons.png                             | Bin 50052 -> 61164 bytes
 ui/images/sprites.png                           | Bin 210353 -> 211543 bytes
 ui/index.jsp                                    |  11 +
 .../vnmcNetworkProvider/vnmcNetworkProvider.js  |  50 +-
 ui/scripts/configuration.js                     | 272 +++++--
 ui/scripts/installWizard.js                     |   6 +-
 ui/scripts/instanceWizard.js                    |  16 +-
 ui/scripts/instances.js                         |  20 +-
 ui/scripts/network.js                           |  62 +-
 ui/scripts/sharedFunctions.js                   |  28 +-
 ui/scripts/storage.js                           |   6 +-
 ui/scripts/system.js                            | 634 +++++++--------
 ui/scripts/templates.js                         |   6 +-
 ui/scripts/ui-custom/instanceWizard.js          |   8 +
 ui/scripts/ui-custom/zoneChart.js               |  16 +-
 ui/scripts/ui/core.js                           |   2 +-
 ui/scripts/ui/dialog.js                         |   5 +
 ui/scripts/ui/widgets/tagger.js                 |   4 +-
 ui/scripts/vpc.js                               |  16 +-
 ui/scripts/zoneWizard.js                        |  12 +-
 utils/src/com/cloud/utils/db/EntityManager.java |   6 +
 321 files changed, 15605 insertions(+), 3234 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0eb99673/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
----------------------------------------------------------------------
diff --cc engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
index 2232d69,f3753a7..b6d62e1
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@@ -608,17 -609,15 +609,21 @@@ public class VolumeOrchestrator extend
          assert (template.getFormat() != ImageFormat.ISO) : "ISO is not a template really....";
  
          Long size = _tmpltMgr.getTemplateSize(template.getId(), vm.getDataCenterId());
 -        if (rootDisksize != null) {
 -            size = (rootDisksize * 1024 * 1024 * 1024);
 +        if (rootDisksize != null ) {
 +            rootDisksize = rootDisksize * 1024 * 1024 * 1024;
 +            if (rootDisksize > size) {
 +                s_logger.debug("Using root disk size of " + rootDisksize + " for volume " + name);
 +                size = rootDisksize;
 +            } else {
 +                s_logger.debug("Using root disk size of " + size + " for volume " + name + "since specified root disk size of " + rootDisksize + " is smaller than template");
 +            }
          }
-         VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(), owner.getDomainId(), owner.getId(), offering.getId(), size, offering.getMinIops(), offering.getMaxIops(),
-                 null);
+ 
+         minIops = minIops != null ? minIops : offering.getMinIops();
+         maxIops = maxIops != null ? maxIops : offering.getMaxIops();
+ 
+         VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(), owner.getDomainId(), owner.getId(), offering.getId(), size, minIops, maxIops, null);
+ 
          vol.setFormat(getSupportedImageFormatForCluster(template.getHypervisorType()));
          if (vm != null) {
              vol.setInstanceId(vm.getId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0eb99673/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0eb99673/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0eb99673/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------


[36/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-6047: Fix checkstyle build issue


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

Branch: refs/heads/resize-root
Commit: 2de67dff423be1fd81992302ae9ec38f6d619c09
Parents: ccea570
Author: Sheng Yang <sh...@citrix.com>
Authored: Thu Mar 6 16:49:07 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Thu Mar 6 16:49:07 2014 -0800

----------------------------------------------------------------------
 .../VirtualRoutingResourceTest.java             | 66 ++++++++++----------
 1 file changed, 33 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2de67dff/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
----------------------------------------------------------------------
diff --git a/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java b/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
index 9b116dd..4737019 100644
--- a/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
+++ b/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
@@ -86,27 +86,27 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
     String _file;
     boolean _aggregated = false;
 
-    String ROUTER_IP = "169.254.3.4";
-    String ROUTER_GUEST_IP = "10.200.1.1";
-    String ROUTER_NAME = "r-4-VM";
+    String ROUTERIP = "169.254.3.4";
+    String ROUTERGUESTIP = "10.200.1.1";
+    String ROUTERNAME = "r-4-VM";
 
     @Override
     public ExecutionResult executeInVR(String routerIp, String script, String args) {
-        assertEquals(routerIp, ROUTER_IP);
+        assertEquals(routerIp, ROUTERIP);
         verifyCommand(_currentCmd, script, args);
         return new ExecutionResult(true, null);
     }
 
     @Override
     public ExecutionResult createFileInVR(String routerIp, String path, String filename, String content) {
-        assertEquals(routerIp, ROUTER_IP);
+        assertEquals(routerIp, ROUTERIP);
         verifyFile(_currentCmd, path, filename, content);
         return new ExecutionResult(true, null);
     }
 
     @Override
     public ExecutionResult prepareCommand(NetworkElementCommand cmd) {
-        cmd.setRouterAccessIp(ROUTER_IP);
+        cmd.setRouterAccessIp(ROUTERIP);
         _currentCmd = cmd;
         if (cmd instanceof IpAssocVpcCommand) {
             return prepareNetworkElementCommand((IpAssocVpcCommand)cmd);
@@ -239,7 +239,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         pfRules.add(new PortForwardingRuleTO(1, "64.1.1.10", 22, 80, "10.10.1.10", 22, 80, "TCP", false, false));
         pfRules.add(new PortForwardingRuleTO(2, "64.1.1.11", 8080, 8080, "10.10.1.11", 8080, 8080, "UDP", true, false));
         SetPortForwardingRulesVpcCommand cmd = new SetPortForwardingRulesVpcCommand(pfRules);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         assertEquals(cmd.getAnswersCount(), 2);
         return cmd;
     }
@@ -276,7 +276,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         pfRules.add(new PortForwardingRuleTO(1, "64.1.1.10", 22, 80, "10.10.1.10", 22, 80, "TCP", false, false));
         pfRules.add(new PortForwardingRuleTO(2, "64.1.1.11", 8080, 8080, "10.10.1.11", 8080, 8080, "UDP", true, false));
         SetPortForwardingRulesCommand cmd = new SetPortForwardingRulesCommand(pfRules);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         assertEquals(cmd.getAnswersCount(), 2);
         return cmd;
     }
@@ -323,7 +323,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         ips.add(new IpAddressTO(3, "65.1.1.11", true, false, false, "vlan://65", "65.1.1.1", "255.255.255.0", "11:23:45:67:89:AB", 1000, false));
         IpAddressTO[] ipArray = ips.toArray(new IpAddressTO[ips.size()]);
         IpAssocCommand cmd = new IpAssocCommand(ipArray);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         assertEquals(cmd.getAnswersCount(), 3);
 
         return cmd;
@@ -356,7 +356,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         ips.add(new IpAddressTO(3, "65.1.1.11", true, false, false, "vlan://65", "65.1.1.1", "255.255.255.0", "11:23:45:67:89:AB", 1000, false));
         IpAddressTO[] ipArray = ips.toArray(new IpAddressTO[ips.size()]);
         IpAssocVpcCommand cmd = new IpAssocVpcCommand(ipArray);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         assertEquals(cmd.getAnswersCount(), 6);
 
         return cmd;
@@ -424,7 +424,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
     protected SetSourceNatCommand generateSetSourceNatCommand() {
         IpAddressTO ip = new IpAddressTO(1, "64.1.1.10", true, true, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false);
         SetSourceNatCommand cmd = new SetSourceNatCommand(ip, true);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         return cmd;
     }
 
@@ -459,7 +459,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         nic.setIp("192.168.1.1");
         nic.setNetmask("255.255.255.0");
         SetNetworkACLCommand cmd = new SetNetworkACLCommand(acls, nic);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
 
         return cmd;
     }
@@ -510,7 +510,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         SetupGuestNetworkCommand cmd = new SetupGuestNetworkCommand("10.1.1.10-10.1.1.20", "cloud.test", false, 0, "8.8.8.8", "8.8.4.4", true, nic);
         cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, "10.1.1.2");
         cmd.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY, "10.1.1.1");
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
 
         return cmd;
     }
@@ -533,7 +533,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         services.add(new MonitorServiceTO("service_2", "process_2", "name_2", "path_2", "file_2", false));
 
         SetMonitorServiceCommand cmd = new SetMonitorServiceCommand(services);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
 
         return cmd;
     }
@@ -548,17 +548,17 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         _count = 0;
 
         Site2SiteVpnCfgCommand cmd = new Site2SiteVpnCfgCommand(true, "64.10.1.10", "64.10.1.1", "192.168.1.1/16", "124.10.1.10", "192.168.100.1/24", "3des-sha1,aes128-sha1;modp1536", "3des-sha1,aes128-md5", "psk", Long.valueOf(1800), Long.valueOf(1800), true, false);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         Answer answer = _resource.executeRequest(cmd);
         assertTrue(answer.getResult());
 
         cmd = new Site2SiteVpnCfgCommand(true, "64.10.1.10", "64.10.1.1", "192.168.1.1/16", "124.10.1.10", "192.168.100.1/24", "3des-sha1,aes128-sha1;modp1536", "3des-sha1,aes128-md5", "psk", Long.valueOf(1800), Long.valueOf(1800), false, true);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         answer = _resource.executeRequest(cmd);
         assertTrue(answer.getResult());
 
         cmd = new Site2SiteVpnCfgCommand(false, "64.10.1.10", "64.10.1.1", "192.168.1.1/16", "124.10.1.10", "192.168.100.1/24", "3des-sha1,aes128-sha1;modp1536", "3des-sha1,aes128-md5", "psk", Long.valueOf(1800), Long.valueOf(1800), false, true);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         answer = _resource.executeRequest(cmd);
         assertTrue(answer.getResult());
     }
@@ -598,21 +598,21 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     protected RemoteAccessVpnCfgCommand generateRemoteAccessVpnCfgCommand1() {
         RemoteAccessVpnCfgCommand cmd = new RemoteAccessVpnCfgCommand(true, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", false);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         cmd.setLocalCidr("10.1.1.1/24");
         return cmd;
     }
 
     protected RemoteAccessVpnCfgCommand generateRemoteAccessVpnCfgCommand2() {
         RemoteAccessVpnCfgCommand cmd = new RemoteAccessVpnCfgCommand(false, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", false);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         cmd.setLocalCidr("10.1.1.1/24");
         return cmd;
     }
 
     protected RemoteAccessVpnCfgCommand generateRemoteAccessVpnCfgCommand3() {
         RemoteAccessVpnCfgCommand cmd = new RemoteAccessVpnCfgCommand(true, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", true);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         cmd.setLocalCidr("10.1.1.1/24");
         return cmd;
     }
@@ -658,7 +658,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         rules.add(new FirewallRuleTO(2, "64.10.10.10", "ICMP", 0, 0, false, false, Purpose.Firewall, sourceCidrs, -1, -1));
         rules.add(new FirewallRuleTO(3, "64.10.10.10", "ICMP", 0, 0, true, true, Purpose.Firewall, sourceCidrs, -1, -1));
         SetFirewallRulesCommand cmd = new SetFirewallRulesCommand(rules);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
 
         return cmd;
     }
@@ -688,7 +688,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         cmd.addVmData("metadata", "public-keys", "publickey");
         cmd.addVmData("metadata", "cloud-identifier", "CloudStack-{test}");
 
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
 
         return cmd;
     }
@@ -711,7 +711,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     protected SavePasswordCommand generateSavePasswordCommand() {
         SavePasswordCommand cmd = new SavePasswordCommand("123pass", "10.1.10.4", "i-4-VM", true);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         return cmd;
     }
 
@@ -736,20 +736,20 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     protected DhcpEntryCommand generateDhcpEntryCommand1() {
         DhcpEntryCommand cmd = new DhcpEntryCommand("12:34:56:78:90:AB", "10.1.10.2", "vm1", null, true);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         return cmd;
     }
 
     protected DhcpEntryCommand generateDhcpEntryCommand2() {
         DhcpEntryCommand cmd = new DhcpEntryCommand("12:34:56:78:90:AB", null, "vm1", "2001:db8:0:0:0:ff00:42:8329", true);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         cmd.setDuid(NetUtils.getDuidLL(cmd.getVmMac()));
         return cmd;
     }
 
     protected DhcpEntryCommand generateDhcpEntryCommand3() {
         DhcpEntryCommand cmd = new DhcpEntryCommand("12:34:56:78:90:AB", "10.1.10.2", "vm1", "2001:db8:0:0:0:ff00:42:8329", true);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         cmd.setDuid(NetUtils.getDuidLL(cmd.getVmMac()));
         return cmd;
     }
@@ -784,7 +784,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         aliases.add(new IpAliasTO("169.254.3.11", "255.255.255.0", "2"));
         aliases.add(new IpAliasTO("169.254.3.12", "255.255.255.0", "3"));
         CreateIpAliasCommand cmd = new CreateIpAliasCommand("169.254.3.10", aliases);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
 
         return cmd;
     }
@@ -806,7 +806,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         aliases.add(new IpAliasTO("169.254.3.11", "255.255.255.0", "2"));
         aliases.add(new IpAliasTO("169.254.3.12", "255.255.255.0", "3"));
         DeleteIpAliasCommand cmd = new DeleteIpAliasCommand("169.254.10.1", aliases, aliases);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         return cmd;
     }
 
@@ -826,7 +826,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         dhcps.add(new DhcpTO("10.1.20.2", "10.1.20.1", "255.255.255.0", "10.1.20.5"));
         dhcps.add(new DhcpTO("10.1.21.2", "10.1.21.1", "255.255.255.0", "10.1.21.5"));
         DnsMasqConfigCommand cmd = new DnsMasqConfigCommand(dhcps);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         return cmd;
     }
 
@@ -858,7 +858,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         NicTO nic = new NicTO();
         LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(arrayLbs, "64.10.2.10", "10.1.10.2", "192.168.1.2", nic, null, "1000", false);
         cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, "10.1.10.2");
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         return cmd;
     }
 
@@ -874,7 +874,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         nic.setIp("10.1.10.2");
         LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(arrayLbs, "64.10.2.10", "10.1.10.2", "192.168.1.2", nic, Long.valueOf(1), "1000", false);
         cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, "10.1.10.2");
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTER_NAME);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
         return cmd;
     }
 
@@ -948,7 +948,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
     @Test
     public void testAggregationCommands() {
         List<NetworkElementCommand> cmds = new LinkedList<>();
-        StartAggregationCommand startCmd = new StartAggregationCommand(ROUTER_NAME, ROUTER_IP, ROUTER_GUEST_IP);
+        StartAggregationCommand startCmd = new StartAggregationCommand(ROUTERNAME, ROUTERIP, ROUTERGUESTIP);
         cmds.add(startCmd);
         cmds.add(generateIpAssocCommand());
         cmds.add(generateIpAssocVpcCommand());
@@ -979,7 +979,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         cmds.add(generateSavePasswordCommand());
         cmds.add(generateVmDataCommand());
 
-        FinishAggregationCommand finishCmd = new FinishAggregationCommand(ROUTER_NAME, ROUTER_IP, ROUTER_GUEST_IP);
+        FinishAggregationCommand finishCmd = new FinishAggregationCommand(ROUTERNAME, ROUTERIP, ROUTERGUESTIP);
         cmds.add(finishCmd);
 
         for (NetworkElementCommand cmd : cmds) {


[16/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-6170


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

Branch: refs/heads/resize-root
Commit: b06e66c50a43337d28c4157c396e39adb488902f
Parents: bbaec7b
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Thu Feb 27 13:20:56 2014 -0700
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Wed Mar 5 13:55:12 2014 -0700

----------------------------------------------------------------------
 .../offering/CreateServiceOfferingCmd.java      |  32 ++++
 .../storage/to/PrimaryDataStoreTO.java          |  18 ++
 .../api/storage/DataMotionService.java          |   2 +
 .../api/storage/DataMotionStrategy.java         |   2 +
 .../api/storage/PrimaryDataStoreInfo.java       |  18 ++
 .../subsystem/api/storage/VolumeService.java    |   6 +-
 .../orchestration/VolumeOrchestrator.java       |  19 +-
 .../motion/AncientDataMotionStrategy.java       |  25 ++-
 .../storage/motion/DataMotionServiceImpl.java   |   9 +-
 .../storage/image/store/TemplateObject.java     |  15 ++
 .../storage/test/MockStorageMotionStrategy.java |   5 +
 .../storage/datastore/PrimaryDataStoreImpl.java |  20 ++-
 .../datastore/provider/DefaultHostListener.java |   2 +-
 .../storage/volume/VolumeServiceImpl.java       | 156 ++++++++++++++++-
 .../motion/SimulatorDataMotionStrategy.java     |   5 +
 .../motion/VmwareStorageMotionStrategy.java     |   5 +
 .../xen/resource/CitrixResourceBase.java        |  11 +-
 .../xen/resource/XenServerStorageProcessor.java | 126 ++++++++++----
 .../motion/XenServerStorageMotionStrategy.java  |   5 +
 .../configuration/ConfigurationManagerImpl.java |  49 +++++-
 ui/scripts/configuration.js                     | 174 +++++++++++++++++--
 21 files changed, 638 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java
index 1d8cbff..4143c2e 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java
@@ -27,6 +27,7 @@ import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.BaseCmd.CommandType;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.ServiceOfferingResponse;
 
@@ -117,6 +118,21 @@ public class CreateServiceOfferingCmd extends BaseCmd {
     @Parameter(name = ApiConstants.IOPS_WRITE_RATE, type = CommandType.LONG, required = false, description = "io requests write rate of the disk offering")
     private Long iopsWriteRate;
 
+    @Parameter(name = ApiConstants.CUSTOMIZED_IOPS, type = CommandType.BOOLEAN, required = false, description = "whether compute offering iops is custom or not")
+    private Boolean customizedIops;
+
+    @Parameter(name = ApiConstants.MIN_IOPS, type = CommandType.LONG, required = false, description = "min iops of the compute offering")
+    private Long minIops;
+
+    @Parameter(name = ApiConstants.MAX_IOPS, type = CommandType.LONG, required = false, description = "max iops of the compute offering")
+    private Long maxIops;
+
+    @Parameter(name = ApiConstants.HYPERVISOR_SNAPSHOT_RESERVE,
+            type = CommandType.INTEGER,
+            required = false,
+            description = "Hypervisor snapshot reserve space as a percent of a volume (for managed storage using Xen or VMware)")
+    private Integer hypervisorSnapshotReserve;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -215,6 +231,22 @@ public class CreateServiceOfferingCmd extends BaseCmd {
         return iopsWriteRate;
     }
 
+    public Boolean isCustomizedIops() {
+        return customizedIops;
+    }
+
+    public Long getMinIops() {
+        return minIops;
+    }
+
+    public Long getMaxIops() {
+        return maxIops;
+    }
+
+    public Integer getHypervisorSnapshotReserve() {
+        return hypervisorSnapshotReserve;
+    }
+
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/core/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java b/core/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
index 01c05f0..6a5d679 100644
--- a/core/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
+++ b/core/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java
@@ -16,6 +16,8 @@
 // under the License.
 package org.apache.cloudstack.storage.to;
 
+import java.util.Map;
+
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
 
 import com.cloud.agent.api.to.DataStoreTO;
@@ -23,6 +25,16 @@ import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.Storage.StoragePoolType;
 
 public class PrimaryDataStoreTO implements DataStoreTO {
+    public static final String MANAGED = PrimaryDataStore.MANAGED;
+    public static final String STORAGE_HOST = PrimaryDataStore.STORAGE_HOST;
+    public static final String MANAGED_STORE_TARGET = PrimaryDataStore.MANAGED_STORE_TARGET;
+    public static final String MANAGED_STORE_TARGET_ROOT_VOLUME = PrimaryDataStore.MANAGED_STORE_TARGET_ROOT_VOLUME;
+    public static final String CHAP_INITIATOR_USERNAME = PrimaryDataStore.CHAP_INITIATOR_USERNAME;
+    public static final String CHAP_INITIATOR_SECRET = PrimaryDataStore.CHAP_INITIATOR_SECRET;
+    public static final String CHAP_TARGET_USERNAME = PrimaryDataStore.CHAP_TARGET_USERNAME;
+    public static final String CHAP_TARGET_SECRET = PrimaryDataStore.CHAP_TARGET_SECRET;
+    public static final String VOLUME_SIZE = PrimaryDataStore.VOLUME_SIZE;
+
     private final String uuid;
     private final String name;
     private String type;
@@ -32,6 +44,7 @@ public class PrimaryDataStoreTO implements DataStoreTO {
     private String path;
     private int port;
     private final String url;
+    private Map<String, String> details;
 
     public PrimaryDataStoreTO(PrimaryDataStore dataStore) {
         this.uuid = dataStore.getUuid();
@@ -42,6 +55,7 @@ public class PrimaryDataStoreTO implements DataStoreTO {
         this.setPath(dataStore.getPath());
         this.setPort(dataStore.getPort());
         this.url = dataStore.getUri();
+        this.details = dataStore.getDetails();
     }
 
     public long getId() {
@@ -58,6 +72,10 @@ public class PrimaryDataStoreTO implements DataStoreTO {
         return this.url;
     }
 
+    public Map<String, String> getDetails() {
+        return this.details;
+    }
+
     public String getName() {
         return this.name;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionService.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionService.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionService.java
index f20e188..a8f8b30 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionService.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionService.java
@@ -26,6 +26,8 @@ import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.host.Host;
 
 public interface DataMotionService {
+    void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback);
+
     void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
 
     void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java
index 39a257d..b5601e9 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java
@@ -30,6 +30,8 @@ public interface DataMotionStrategy {
 
     StrategyPriority canHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost);
 
+    Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback);
+
     Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
 
     Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
index 19893d0..bb9f2da 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java
@@ -18,6 +18,8 @@
  */
 package org.apache.cloudstack.engine.subsystem.api.storage;
 
+import java.util.Map;
+
 import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
 
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
@@ -25,6 +27,16 @@ import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.StoragePool;
 
 public interface PrimaryDataStoreInfo extends StoragePool {
+    static final String MANAGED = "managed";
+    static final String STORAGE_HOST= "storageHost";
+    static final String MANAGED_STORE_TARGET = "managedStoreTarget";
+    static final String MANAGED_STORE_TARGET_ROOT_VOLUME = "managedStoreTargetRootVolume";
+    static final String CHAP_INITIATOR_USERNAME = "chapInitiatorUsername";
+    static final String CHAP_INITIATOR_SECRET = "chapInitiatorSecret";
+    static final String CHAP_TARGET_USERNAME = "chapTargetUsername";
+    static final String CHAP_TARGET_SECRET = "chapTargetSecret";
+    static final String VOLUME_SIZE = "volumeSize";
+
     boolean isHypervisorSupported(HypervisorType hypervisor);
 
     boolean isLocalStorageSupported();
@@ -37,5 +49,11 @@ public interface PrimaryDataStoreInfo extends StoragePool {
     @Override
     StoragePoolType getPoolType();
 
+    boolean isManaged();
+
+    void setDetails(Map<String, String> details);
+
+    Map<String, String> getDetails();
+
     PrimaryDataStoreLifeCycle getLifeCycle();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java
index 3f676ae..b6e6106 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java
@@ -78,7 +78,11 @@ public interface VolumeService {
 
     VolumeEntity getVolumeEntity(long volumeId);
 
-    AsyncCallFuture<VolumeApiResult> createVolumeFromTemplateAsync(VolumeInfo volume, long dataStoreId, TemplateInfo template);
+    AsyncCallFuture<VolumeApiResult> createManagedStorageAndVolumeFromTemplateAsync(VolumeInfo volumeInfo, long destDataStoreId,
+            TemplateInfo srcTemplateInfo, long destHostId);
+
+    AsyncCallFuture<VolumeApiResult> createVolumeFromTemplateAsync(VolumeInfo volume, long dataStoreId,
+            TemplateInfo template);
 
     AsyncCallFuture<VolumeApiResult> copyVolume(VolumeInfo srcVolume, DataStore destStore);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
index d3eda8a..4d0c787 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@ -36,6 +36,7 @@ import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationSer
 import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotService;
@@ -1113,7 +1114,23 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
                 future = volService.createVolumeAsync(volume, destPool);
             } else {
                 TemplateInfo templ = tmplFactory.getTemplate(templateId, DataStoreRole.Image);
-                future = volService.createVolumeFromTemplateAsync(volume, destPool.getId(), templ);
+
+                PrimaryDataStore primaryDataStore = (PrimaryDataStore)destPool;
+
+                if (primaryDataStore.isManaged()) {
+                    DiskOffering diskOffering = _entityMgr.findById(DiskOffering.class, volume.getDiskOfferingId());
+                    HypervisorType hyperType = vm.getVirtualMachine().getHypervisorType();
+
+                    // update the volume's hypervisor_ss_reserve from its disk offering (used for managed storage)
+                    updateHypervisorSnapshotReserveForVolume(diskOffering, volume, hyperType);
+
+                    long hostId = vm.getVirtualMachine().getHostId();
+
+                    future = volService.createManagedStorageAndVolumeFromTemplateAsync(volume, destPool.getId(), templ, hostId);
+                }
+                else {
+                    future = volService.createVolumeFromTemplateAsync(volume, destPool.getId(), templ);
+                }
             }
             VolumeApiResult result = null;
             try {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
index 0556479..df81199 100644
--- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
+++ b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
@@ -46,6 +46,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
 import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.storage.RemoteHostEndPoint;
 import org.apache.cloudstack.storage.command.CopyCommand;
 import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
 
@@ -94,15 +95,17 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
 
     protected boolean needCacheStorage(DataObject srcData, DataObject destData) {
         DataTO srcTO = srcData.getTO();
-        DataTO destTO = destData.getTO();
         DataStoreTO srcStoreTO = srcTO.getDataStore();
-        DataStoreTO destStoreTO = destTO.getDataStore();
+
         if (srcStoreTO instanceof NfsTO || srcStoreTO.getRole() == DataStoreRole.ImageCache) {
             //||
             //    (srcStoreTO instanceof PrimaryDataStoreTO && ((PrimaryDataStoreTO)srcStoreTO).getPoolType() == StoragePoolType.NetworkFilesystem)) {
             return false;
         }
 
+        DataTO destTO = destData.getTO();
+        DataStoreTO destStoreTO = destTO.getDataStore();
+
         if (destStoreTO instanceof NfsTO || destStoreTO.getRole() == DataStoreRole.ImageCache) {
             return false;
         }
@@ -147,7 +150,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
         return selectedScope;
     }
 
-    protected Answer copyObject(DataObject srcData, DataObject destData) {
+    protected Answer copyObject(DataObject srcData, DataObject destData, Host destHost) {
         String value = configDao.getValue(Config.PrimaryStorageDownloadWait.toString());
         int _primaryStorageDownloadWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.PrimaryStorageDownloadWait.getDefaultValue()));
         Answer answer = null;
@@ -160,7 +163,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
             }
 
             CopyCommand cmd = new CopyCommand(srcForCopy.getTO(), destData.getTO(), _primaryStorageDownloadWait, VirtualMachineManager.ExecuteInSequence.value());
-            EndPoint ep = selector.select(srcForCopy, destData);
+            EndPoint ep = destHost != null ? RemoteHostEndPoint.getHypervisorHostEndPoint(destHost) : selector.select(srcForCopy, destData);
             if (ep == null) {
                 String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
                 s_logger.error(errMsg);
@@ -193,6 +196,10 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
         }
     }
 
+    protected Answer copyObject(DataObject srcData, DataObject destData) {
+        return copyObject(srcData, destData, null);
+    }
+
     protected DataObject cacheSnapshotChain(SnapshotInfo snapshot, Scope scope) {
         DataObject leafData = null;
         DataStore store = cacheMgr.getCacheStorage(snapshot, scope);
@@ -392,8 +399,9 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
         return answer;
     }
 
+    // Note: destHost is currently only used if the copyObject method is invoked
     @Override
-    public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
+    public Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
         Answer answer = null;
         String errMsg = null;
         try {
@@ -416,7 +424,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
             } else if (srcData.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.SNAPSHOT) {
                 answer = copySnapshot(srcData, destData);
             } else {
-                answer = copyObject(srcData, destData);
+                answer = copyObject(srcData, destData, destHost);
             }
 
             if (answer != null && !answer.getResult()) {
@@ -432,6 +440,11 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
         return null;
     }
 
+    @Override
+    public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
+        return copyAsync(srcData, destData, null, callback);
+    }
+
     @DB
     protected Answer createTemplateFromSnapshot(DataObject srcData, DataObject destData) {
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/DataMotionServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/DataMotionServiceImpl.java b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/DataMotionServiceImpl.java
index 37e8baa..eed1e08 100644
--- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/DataMotionServiceImpl.java
+++ b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/DataMotionServiceImpl.java
@@ -46,7 +46,7 @@ public class DataMotionServiceImpl implements DataMotionService {
     StorageStrategyFactory storageStrategyFactory;
 
     @Override
-    public void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
+    public void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
         if (srcData.getDataStore() == null || destData.getDataStore() == null) {
             throw new CloudRuntimeException("can't find data store");
         }
@@ -65,7 +65,12 @@ public class DataMotionServiceImpl implements DataMotionService {
                 destData.getType().name() + " '" + destData.getUuid() + "'");
         }
 
-        strategy.copyAsync(srcData, destData, callback);
+        strategy.copyAsync(srcData, destData, destHost, callback);
+    }
+
+    @Override
+    public void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
+        copyAsync(srcData, destData, null, callback);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
index 8db21cc..34db481 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
@@ -30,6 +30,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
 import org.apache.cloudstack.storage.command.CopyCmdAnswer;
 import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
@@ -299,6 +300,20 @@ public class TemplateObject implements TemplateInfo {
         if (dataStore == null) {
             return null;
         }
+
+        // managed primary data stores should not have an install path
+        if (dataStore instanceof PrimaryDataStore) {
+            PrimaryDataStore primaryDataStore = (PrimaryDataStore)dataStore;
+
+            Map<String, String> details = primaryDataStore.getDetails();
+
+            boolean managed = details != null && Boolean.parseBoolean(details.get(PrimaryDataStore.MANAGED));
+
+            if (managed) {
+                return null;
+            }
+        }
+
         DataObjectInStore obj = objectInStoreMgr.findObject(this, dataStore);
         return obj.getInstallPath();
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java
index 2a11e13..accfeb5 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java
@@ -58,6 +58,11 @@ public class MockStorageMotionStrategy implements DataMotionStrategy {
     }
 
     @Override
+    public Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
     public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
         CopyCmdAnswer answer = null;
         DataTO data = null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
index 649e689..4fb37e2 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
@@ -20,6 +20,7 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 import javax.inject.Inject;
 
@@ -67,6 +68,7 @@ import com.cloud.utils.storage.encoding.EncodingType;
 
 public class PrimaryDataStoreImpl implements PrimaryDataStore {
     private static final Logger s_logger = Logger.getLogger(PrimaryDataStoreImpl.class);
+
     protected PrimaryDataStoreDriver driver;
     protected StoragePoolVO pdsv;
     @Inject
@@ -86,6 +88,7 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore {
 
     @Inject
     private VolumeDao volumeDao;
+    private Map<String, String> _details;
 
     public PrimaryDataStoreImpl() {
 
@@ -136,6 +139,16 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore {
     }
 
     @Override
+    public void setDetails(Map<String, String> details) {
+        _details = details;
+    }
+
+    @Override
+    public Map<String, String> getDetails() {
+        return _details;
+    }
+
+    @Override
     public String getUri() {
         String path = pdsv.getPath().replaceFirst("/*", "");
         StringBuilder builder = new StringBuilder();
@@ -223,9 +236,14 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore {
     }
 
     @Override
+    public boolean isManaged() {
+        return pdsv.isManaged();
+    }
+
+    @Override
     public DataObject create(DataObject obj) {
         // create template on primary storage
-        if (obj.getType() == DataObjectType.TEMPLATE) {
+        if (obj.getType() == DataObjectType.TEMPLATE && !isManaged()) {
             try {
                 String templateIdPoolIdString = "templateId:" + obj.getId() + "poolId:" + getId();
                 VMTemplateStoragePoolVO templateStoragePoolRef;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
index 4838bf6..fffd1e8 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
@@ -85,7 +85,7 @@ public class DefaultHostListener implements HypervisorHostListener {
         poolVO.setCapacityBytes(mspAnswer.getPoolInfo().getCapacityBytes());
         primaryStoreDao.update(pool.getId(), poolVO);
 
-        s_logger.info("Connection established between " + pool + " host + " + hostId);
+        s_logger.info("Connection established between storage pool " + pool + " and host " + hostId);
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index fa0fd95..d47ee27 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -20,6 +20,7 @@ package org.apache.cloudstack.storage.volume;
 
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -40,6 +41,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
 import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
@@ -60,6 +62,7 @@ import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
 import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
 import org.apache.cloudstack.storage.to.VolumeObjectTO;
+import org.apache.cloudstack.storage.to.TemplateObjectTO;
 
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.storage.ListVolumeAnswer;
@@ -72,6 +75,7 @@ import com.cloud.event.EventTypes;
 import com.cloud.event.UsageEventUtils;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.ResourceAllocationException;
+import com.cloud.host.dao.HostDao;
 import com.cloud.host.Host;
 import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.ScopeType;
@@ -122,6 +126,8 @@ public class VolumeServiceImpl implements VolumeService {
     VolumeDao _volumeDao;
     @Inject
     EndPointSelector _epSelector;
+    @Inject
+    HostDao _hostDao;
 
     public VolumeServiceImpl() {
     }
@@ -349,6 +355,39 @@ public class VolumeServiceImpl implements VolumeService {
         return null;
     }
 
+    private class ManagedCreateBaseImageContext<T> extends AsyncRpcContext<T> {
+        private final VolumeInfo _volumeInfo;
+        private final PrimaryDataStore _primaryDataStore;
+        private final TemplateInfo _templateInfo;
+        private final AsyncCallFuture<VolumeApiResult> _future;
+
+        public ManagedCreateBaseImageContext(AsyncCompletionCallback<T> callback, VolumeInfo volumeInfo,
+                PrimaryDataStore primaryDatastore, TemplateInfo templateInfo, AsyncCallFuture<VolumeApiResult> future) {
+            super(callback);
+
+            _volumeInfo = volumeInfo;
+            _primaryDataStore = primaryDatastore;
+            _templateInfo = templateInfo;
+            _future = future;
+        }
+
+        public VolumeInfo getVolumeInfo() {
+            return _volumeInfo;
+        }
+
+        public PrimaryDataStore getPrimaryDataStore() {
+            return _primaryDataStore;
+        }
+
+        public TemplateInfo getTemplateInfo() {
+            return _templateInfo;
+        }
+
+        public AsyncCallFuture<VolumeApiResult> getFuture() {
+            return _future;
+        }
+    }
+
     class CreateBaseImageContext<T> extends AsyncRpcContext<T> {
         private final VolumeInfo volume;
         private final PrimaryDataStore dataStore;
@@ -411,7 +450,6 @@ public class VolumeServiceImpl implements VolumeService {
 
     @DB
     protected void createBaseImageAsync(VolumeInfo volume, PrimaryDataStore dataStore, TemplateInfo template, AsyncCallFuture<VolumeApiResult> future) {
-
         DataObject templateOnPrimaryStoreObj = dataStore.create(template);
 
         VMTemplateStoragePoolVO templatePoolRef = _tmpltPoolDao.findByPoolTemplate(dataStore.getId(), template.getId());
@@ -476,6 +514,37 @@ public class VolumeServiceImpl implements VolumeService {
         return;
     }
 
+    protected Void managedCopyBaseImageCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback,
+            ManagedCreateBaseImageContext<VolumeApiResult> context) {
+        CopyCommandResult result = callback.getResult();
+        VolumeInfo volumeInfo = context.getVolumeInfo();
+        VolumeApiResult res = new VolumeApiResult(volumeInfo);
+
+        if (result.isSuccess()) {
+            // volumeInfo.processEvent(Event.OperationSuccessed, result.getAnswer());
+
+            VolumeVO volume = volDao.findById(volumeInfo.getId());
+            CopyCmdAnswer answer = (CopyCmdAnswer)result.getAnswer();
+            TemplateObjectTO templateObjectTo = (TemplateObjectTO)answer.getNewData();
+
+            volume.setPath(templateObjectTo.getPath());
+            volume.setFormat(templateObjectTo.getFormat());
+
+            volDao.update(volume.getId(), volume);
+        }
+        else {
+            volumeInfo.processEvent(Event.DestroyRequested);
+
+            res.setResult(result.getResult());
+        }
+
+        AsyncCallFuture<VolumeApiResult> future = context.getFuture();
+
+        future.complete(res);
+
+        return null;
+    }
+
     @DB
     protected Void copyBaseImageCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback, CreateBaseImageContext<VolumeApiResult> context) {
         CopyCommandResult result = callback.getResult();
@@ -577,6 +646,91 @@ public class VolumeServiceImpl implements VolumeService {
         return null;
     }
 
+    @Override
+    public AsyncCallFuture<VolumeApiResult> createManagedStorageAndVolumeFromTemplateAsync(VolumeInfo volumeInfo, long destDataStoreId,
+            TemplateInfo srcTemplateInfo, long destHostId) {
+        PrimaryDataStore destPrimaryDataStore = dataStoreMgr.getPrimaryDataStore(destDataStoreId);
+        TemplateInfo destTemplateInfo = (TemplateInfo)destPrimaryDataStore.create(srcTemplateInfo);
+        Host destHost = _hostDao.findById(destHostId);
+
+        if (destHost == null) {
+            throw new CloudRuntimeException("Destinatin host should not be null.");
+        }
+
+        AsyncCallFuture<VolumeApiResult> future = new AsyncCallFuture<VolumeApiResult>();
+
+        try {
+            // must call driver to have a volume created
+            AsyncCallFuture<VolumeApiResult> createVolumeFuture = createVolumeAsync(volumeInfo, destPrimaryDataStore);
+
+            VolumeApiResult createVolumeResult = createVolumeFuture.get();
+
+            if (createVolumeResult.isFailed()) {
+                throw new CloudRuntimeException("Creation of a volume failed: " + createVolumeResult.getResult());
+            }
+
+            // refresh the volume from the DB
+            volumeInfo = volFactory.getVolume(volumeInfo.getId(), destPrimaryDataStore);
+
+            connectVolumeToHost(volumeInfo, destHost, destPrimaryDataStore);
+
+            ManagedCreateBaseImageContext<CreateCmdResult> context = new ManagedCreateBaseImageContext<CreateCmdResult>(null, volumeInfo,
+                    destPrimaryDataStore, srcTemplateInfo, future);
+            AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
+            caller.setCallback(caller.getTarget().managedCopyBaseImageCallback(null, null)).setContext(context);
+
+            Map<String, String> details = new HashMap<String, String>();
+
+            details.put(PrimaryDataStore.MANAGED, Boolean.TRUE.toString());
+            details.put(PrimaryDataStore.STORAGE_HOST, destPrimaryDataStore.getHostAddress());
+            // for managed storage, the storage repository (XenServer) or datastore (ESX) name is based off of the iScsiName property of a volume
+            details.put(PrimaryDataStore.MANAGED_STORE_TARGET, volumeInfo.get_iScsiName());
+            details.put(PrimaryDataStore.MANAGED_STORE_TARGET_ROOT_VOLUME, volumeInfo.getName());
+            details.put(PrimaryDataStore.VOLUME_SIZE, String.valueOf(volumeInfo.getSize()));
+
+            ChapInfo chapInfo = getChapInfo(volumeInfo, destPrimaryDataStore);
+
+            if (chapInfo != null) {
+                details.put(PrimaryDataStore.CHAP_INITIATOR_USERNAME, chapInfo.getInitiatorUsername());
+                details.put(PrimaryDataStore.CHAP_INITIATOR_SECRET, chapInfo.getInitiatorSecret());
+                details.put(PrimaryDataStore.CHAP_TARGET_USERNAME, chapInfo.getTargetUsername());
+                details.put(PrimaryDataStore.CHAP_TARGET_SECRET, chapInfo.getTargetSecret());
+            }
+
+            destPrimaryDataStore.setDetails(details);
+
+            motionSrv.copyAsync(srcTemplateInfo, destTemplateInfo, destHost, caller);
+        }
+        catch (Throwable t) {
+            String errMsg = t.toString();
+
+            volumeInfo.processEvent(Event.DestroyRequested);
+
+            disconnectVolumeFromHost(volumeInfo, destHost, destPrimaryDataStore);
+
+            try {
+                AsyncCallFuture<VolumeApiResult> expungeVolumeFuture = expungeVolumeAsync(volumeInfo);
+
+                VolumeApiResult expungeVolumeResult = expungeVolumeFuture.get();
+
+                if (expungeVolumeResult.isFailed()) {
+                    errMsg += " : Failed to expunge a volume that was created";
+                }
+            }
+            catch (Exception ex) {
+                errMsg += " : " + ex.getMessage();
+            }
+
+            VolumeApiResult result = new VolumeApiResult(volumeInfo);
+
+            result.setResult(errMsg);
+
+            future.complete(result);
+        }
+
+        return future;
+    }
+
     @DB
     @Override
     public AsyncCallFuture<VolumeApiResult> createVolumeFromTemplateAsync(VolumeInfo volume, long dataStoreId, TemplateInfo template) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/motion/SimulatorDataMotionStrategy.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/motion/SimulatorDataMotionStrategy.java b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/motion/SimulatorDataMotionStrategy.java
index 3eb2cf6..4090962 100644
--- a/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/motion/SimulatorDataMotionStrategy.java
+++ b/plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/motion/SimulatorDataMotionStrategy.java
@@ -43,6 +43,11 @@ public class SimulatorDataMotionStrategy implements DataMotionStrategy {
     }
 
     @Override
+    public Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
     public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
         CopyCommandResult result = new CopyCommandResult("something", null);
         callback.complete(result);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/plugins/hypervisors/vmware/src/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java b/plugins/hypervisors/vmware/src/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java
index 09f1068..24efde7 100644
--- a/plugins/hypervisors/vmware/src/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java
+++ b/plugins/hypervisors/vmware/src/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java
@@ -86,6 +86,11 @@ public class VmwareStorageMotionStrategy implements DataMotionStrategy {
     }
 
     @Override
+    public Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
     public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
         CopyCommandResult result = new CopyCommandResult(null, null);
         result.setResult("Unsupported operation requested for copying data.");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index c0d691a..2b441e5 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -1869,18 +1869,23 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         return prepareManagedStorage(conn, details, null, vdiNameLabel);
     }
 
-    protected VDI prepareManagedStorage(Connection conn, Map<String, String> details, String path, String vdiNameLabel) throws Exception {
+    protected SR prepareManagedSr(Connection conn, Map<String, String> details) {
         String iScsiName = details.get(DiskTO.IQN);
         String storageHost = details.get(DiskTO.STORAGE_HOST);
         String chapInitiatorUsername = details.get(DiskTO.CHAP_INITIATOR_USERNAME);
         String chapInitiatorSecret = details.get(DiskTO.CHAP_INITIATOR_SECRET);
-        Long volumeSize = Long.parseLong(details.get(DiskTO.VOLUME_SIZE));
 
-        SR sr = getIscsiSR(conn, iScsiName, storageHost, iScsiName, chapInitiatorUsername, chapInitiatorSecret, true);
+        return getIscsiSR(conn, iScsiName, storageHost, iScsiName, chapInitiatorUsername, chapInitiatorSecret, true);
+    }
+
+    protected VDI prepareManagedStorage(Connection conn, Map<String, String> details, String path, String vdiNameLabel) throws Exception {
+        SR sr = prepareManagedSr(conn, details);
 
         VDI vdi = getVDIbyUuid(conn, path, false);
 
         if (vdi == null) {
+            Long volumeSize = Long.parseLong(details.get(DiskTO.VOLUME_SIZE));
+
             vdi = createVdi(sr, vdiNameLabel, volumeSize);
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java
index f2abff7..e512046 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java
@@ -59,6 +59,7 @@ import org.apache.cloudstack.storage.command.ForgetObjectCmd;
 import org.apache.cloudstack.storage.command.IntroduceObjectAnswer;
 import org.apache.cloudstack.storage.command.IntroduceObjectCmd;
 import org.apache.cloudstack.storage.datastore.protocol.DataStoreProtocol;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
 import org.apache.cloudstack.storage.to.SnapshotObjectTO;
 import org.apache.cloudstack.storage.to.TemplateObjectTO;
 import org.apache.cloudstack.storage.to.VolumeObjectTO;
@@ -887,58 +888,121 @@ public class XenServerStorageProcessor implements StorageProcessor {
 
     @Override
     public Answer copyTemplateToPrimaryStorage(CopyCommand cmd) {
-        DataTO srcData = cmd.getSrcTO();
-        DataTO destData = cmd.getDestTO();
+        DataTO srcDataTo = cmd.getSrcTO();
+        DataTO destDataTo = cmd.getDestTO();
         int wait = cmd.getWait();
-        DataStoreTO srcStore = srcData.getDataStore();
+        DataStoreTO srcDataStoreTo = srcDataTo.getDataStore();
+
         try {
-            if ((srcStore instanceof NfsTO) && (srcData.getObjectType() == DataObjectType.TEMPLATE)) {
-                NfsTO srcImageStore = (NfsTO)srcStore;
-                TemplateObjectTO srcTemplate = (TemplateObjectTO)srcData;
+            if ((srcDataStoreTo instanceof NfsTO) && (srcDataTo.getObjectType() == DataObjectType.TEMPLATE)) {
+                NfsTO srcImageStore = (NfsTO)srcDataStoreTo;
+                TemplateObjectTO srcTemplateObjectTo = (TemplateObjectTO)srcDataTo;
                 String storeUrl = srcImageStore.getUrl();
-
                 URI uri = new URI(storeUrl);
-                String tmplpath = uri.getHost() + ":" + uri.getPath() + "/" + srcData.getPath();
-                String poolName = destData.getDataStore().getUuid();
+                String tmplPath = uri.getHost() + ":" + uri.getPath() + "/" + srcDataTo.getPath();
+                DataStoreTO destDataStoreTo = destDataTo.getDataStore();
+
+                boolean managed = false;
+                String storageHost = null;
+                String managedStoragePoolName = null;
+                String managedStoragePoolRootVolumeName = null;
+                String managedStoragePoolRootVolumeSize = null;
+                String chapInitiatorUsername = null;
+                String chapInitiatorSecret = null;
+
+                if (destDataStoreTo instanceof PrimaryDataStoreTO) {
+                    PrimaryDataStoreTO destPrimaryDataStoreTo = (PrimaryDataStoreTO)destDataStoreTo;
+
+                    Map<String, String> details = destPrimaryDataStoreTo.getDetails();
+
+                    if (details != null) {
+                        managed = Boolean.parseBoolean(details.get(PrimaryDataStoreTO.MANAGED));
+
+                        if (managed) {
+                            storageHost = details.get(PrimaryDataStoreTO.STORAGE_HOST);
+                            managedStoragePoolName = details.get(PrimaryDataStoreTO.MANAGED_STORE_TARGET);
+                            managedStoragePoolRootVolumeName = details.get(PrimaryDataStoreTO.MANAGED_STORE_TARGET_ROOT_VOLUME);
+                            managedStoragePoolRootVolumeSize = details.get(PrimaryDataStoreTO.VOLUME_SIZE);
+                            chapInitiatorUsername = details.get(PrimaryDataStoreTO.CHAP_INITIATOR_USERNAME);
+                            chapInitiatorSecret = details.get(PrimaryDataStoreTO.CHAP_INITIATOR_SECRET);
+                        }
+                    }
+                }
+
                 Connection conn = hypervisorResource.getConnection();
 
-                SR poolsr = null;
-                Set<SR> srs = SR.getByNameLabel(conn, poolName);
-                if (srs.size() != 1) {
-                    String msg = "There are " + srs.size() + " SRs with same name: " + poolName;
-                    s_logger.warn(msg);
-                    return new CopyCmdAnswer(msg);
-                } else {
-                    poolsr = srs.iterator().next();
+                final SR sr;
+
+                if (managed) {
+                    Map<String, String> details = new HashMap<String, String>();
+
+                    details.put(DiskTO.STORAGE_HOST, storageHost);
+                    details.put(DiskTO.IQN, managedStoragePoolName);
+                    details.put(DiskTO.VOLUME_SIZE, managedStoragePoolRootVolumeSize);
+                    details.put(DiskTO.CHAP_INITIATOR_USERNAME, chapInitiatorUsername);
+                    details.put(DiskTO.CHAP_INITIATOR_SECRET, chapInitiatorSecret);
+
+                    sr = hypervisorResource.prepareManagedSr(conn, details);
+                }
+                else {
+                    String srName = destDataStoreTo.getUuid();
+                    Set<SR> srs = SR.getByNameLabel(conn, srName);
+
+                    if (srs.size() != 1) {
+                        String msg = "There are " + srs.size() + " SRs with same name: " + srName;
+
+                        s_logger.warn(msg);
+
+                        return new CopyCmdAnswer(msg);
+                    } else {
+                        sr = srs.iterator().next();
+                    }
+                }
+
+                String srUuid = sr.getUuid(conn);
+                String tmplUuid = copy_vhd_from_secondarystorage(conn, tmplPath, srUuid, wait);
+                VDI tmplVdi = getVDIbyUuid(conn, tmplUuid);
+
+                final String uuidToReturn;
+
+                if (managed) {
+                    uuidToReturn = tmplUuid;
+
+                    tmplVdi.setNameLabel(conn, managedStoragePoolRootVolumeName);
+                }
+                else {
+                    VDI snapshotVdi = tmplVdi.snapshot(conn, new HashMap<String, String>());
+
+                    uuidToReturn = snapshotVdi.getUuid(conn);
+
+                    snapshotVdi.setNameLabel(conn, "Template " + srcTemplateObjectTo.getName());
+
+                    tmplVdi.destroy(conn);
                 }
-                String pUuid = poolsr.getUuid(conn);
-                boolean isISCSI = IsISCSI(poolsr.getType(conn));
-                String uuid = copy_vhd_from_secondarystorage(conn, tmplpath, pUuid, wait);
-                VDI tmpl = getVDIbyUuid(conn, uuid);
-                VDI snapshotvdi = tmpl.snapshot(conn, new HashMap<String, String>());
-                String snapshotUuid = snapshotvdi.getUuid(conn);
-                snapshotvdi.setNameLabel(conn, "Template " + srcTemplate.getName());
-                String parentuuid = getVhdParent(conn, pUuid, snapshotUuid, isISCSI);
-                VDI parent = getVDIbyUuid(conn, parentuuid);
-                Long phySize = parent.getPhysicalUtilisation(conn);
-                tmpl.destroy(conn);
-                poolsr.scan(conn);
+
+                sr.scan(conn);
+
                 try {
                     Thread.sleep(5000);
                 } catch (Exception e) {
                 }
 
                 TemplateObjectTO newVol = new TemplateObjectTO();
-                newVol.setUuid(snapshotvdi.getUuid(conn));
-                newVol.setPath(newVol.getUuid());
+
+                newVol.setUuid(uuidToReturn);
+                newVol.setPath(uuidToReturn);
                 newVol.setFormat(ImageFormat.VHD);
+
                 return new CopyCmdAnswer(newVol);
             }
         } catch (Exception e) {
             String msg = "Catch Exception " + e.getClass().getName() + " for template + " + " due to " + e.toString();
+
             s_logger.warn(msg, e);
+
             return new CopyCmdAnswer(msg);
         }
+
         return new CopyCmdAnswer("not implemented yet");
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/plugins/hypervisors/xen/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java b/plugins/hypervisors/xen/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java
index e8217f7..975deec 100644
--- a/plugins/hypervisors/xen/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java
+++ b/plugins/hypervisors/xen/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java
@@ -91,6 +91,11 @@ public class XenServerStorageMotionStrategy implements DataMotionStrategy {
     }
 
     @Override
+    public Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
     public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
         CopyCommandResult result = new CopyCommandResult(null, null);
         result.setResult("Unsupported operation requested for copying data.");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 283aeea..08cc5a6 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -2016,15 +2016,54 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
 
         return createServiceOffering(userId, cmd.getIsSystem(), vmType, cmd.getServiceOfferingName(), cpuNumber, memory, cpuSpeed, cmd.getDisplayText(), localStorageRequired,
                 offerHA, limitCpuUse, volatileVm, cmd.getTags(), cmd.getDomainId(), cmd.getHostTag(), cmd.getNetworkRate(), cmd.getDeploymentPlanner(), cmd.getDetails(),
-                cmd.getBytesReadRate(), cmd.getBytesWriteRate(), cmd.getIopsReadRate(), cmd.getIopsWriteRate());
+                cmd.isCustomizedIops(), cmd.getMinIops(), cmd.getMaxIops(), cmd.getBytesReadRate(), cmd.getBytesWriteRate(), cmd.getIopsReadRate(), cmd.getIopsWriteRate(),
+                cmd.getHypervisorSnapshotReserve());
     }
 
     protected ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMachine.Type vmType, String name, Integer cpu, Integer ramSize, Integer speed,
             String displayText, boolean localStorageRequired, boolean offerHA, boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag,
-            Integer networkRate, String deploymentPlanner, Map<String, String> details, Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate) {
+            Integer networkRate, String deploymentPlanner, Map<String, String> details, Boolean isCustomizedIops, Long minIops, Long maxIops,
+            Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate, Integer hypervisorSnapshotReserve) {
         tags = StringUtils.cleanupTags(tags);
         ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, null, offerHA, limitResourceUse, volatileVm, displayText, localStorageRequired,
                 false, tags, isSystem, vmType, domainId, hostTag, deploymentPlanner);
+
+        if (isCustomizedIops != null) {
+            bytesReadRate = null;
+            bytesWriteRate = null;
+            iopsReadRate = null;
+            iopsWriteRate = null;
+
+            if (isCustomizedIops) {
+                minIops = null;
+                maxIops = null;
+            } else {
+                if (minIops == null && maxIops == null) {
+                    minIops = 0L;
+                    maxIops = 0L;
+                } else {
+                    if (minIops == null || minIops <= 0) {
+                        throw new InvalidParameterValueException("The min IOPS must be greater than 0.");
+                    }
+
+                    if (maxIops == null) {
+                        maxIops = 0L;
+                    }
+
+                    if (minIops > maxIops) {
+                        throw new InvalidParameterValueException("The min IOPS must be less than or equal to the max IOPS.");
+                    }
+                }
+            }
+        } else {
+            minIops = null;
+            maxIops = null;
+        }
+
+        offering.setCustomizedIops(isCustomizedIops);
+        offering.setMinIops(minIops);
+        offering.setMaxIops(maxIops);
+
         if ((bytesReadRate != null) && (bytesReadRate > 0))
             offering.setBytesReadRate(bytesReadRate);
         if ((bytesWriteRate != null) && (bytesWriteRate > 0))
@@ -2034,6 +2073,12 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         if ((iopsWriteRate != null) && (iopsWriteRate > 0))
             offering.setIopsWriteRate(iopsWriteRate);
 
+        if (hypervisorSnapshotReserve != null && hypervisorSnapshotReserve < 0) {
+            throw new InvalidParameterValueException("If provided, Hypervisor Snapshot Reserve must be greater than or equal to 0.");
+        }
+
+        offering.setHypervisorSnapshotReserve(hypervisorSnapshotReserve);
+
         if ((offering = _serviceOfferingDao.persist(offering)) != null) {
             if (details != null) {
                 List<ServiceOfferingDetailsVO> detailsVO = new ArrayList<ServiceOfferingDetailsVO>();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b06e66c5/ui/scripts/configuration.js
----------------------------------------------------------------------
diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js
index 869b876..cb54c31 100644
--- a/ui/scripts/configuration.js
+++ b/ui/scripts/configuration.js
@@ -136,6 +136,113 @@
                                             number: true
                                         }
                                     },
+                                    qosType: {
+                                        label: 'label.qos.type',
+                                        docID: 'helpDiskOfferingQoSType',
+                                        select: function(args) {
+                                            var items = [];
+                                            items.push({
+                                                id: '',
+                                                description: ''
+                                            });
+                                            items.push({
+                                                id: 'hypervisor',
+                                                description: 'hypervisor'
+                                            });
+                                            items.push({
+                                                id: 'storage',
+                                                description: 'storage'
+                                            });
+                                            args.response.success({
+                                                data: items
+                                            });
+
+                                            args.$select.change(function() {
+                                                var $form = $(this).closest('form');
+                                                var $isCustomizedIops = $form.find('.form-item[rel=isCustomizedIops]');
+                                                var $minIops = $form.find('.form-item[rel=minIops]');
+                                                var $maxIops = $form.find('.form-item[rel=maxIops]');
+                                                var $hypervisorSnapshotReserve = $form.find('.form-item[rel=hypervisorSnapshotReserve]');
+                                                var $diskBytesReadRate = $form.find('.form-item[rel=diskBytesReadRate]');
+                                                var $diskBytesWriteRate = $form.find('.form-item[rel=diskBytesWriteRate]');
+                                                var $diskIopsReadRate = $form.find('.form-item[rel=diskIopsReadRate]');
+                                                var $diskIopsWriteRate = $form.find('.form-item[rel=diskIopsWriteRate]');
+
+                                                var qosId = $(this).val();
+
+                                                if (qosId == 'storage') { // Storage QoS
+                                                    $diskBytesReadRate.hide();
+                                                    $diskBytesWriteRate.hide();
+                                                    $diskIopsReadRate.hide();
+                                                    $diskIopsWriteRate.hide();
+
+                                                    $isCustomizedIops.css('display', 'inline-block');
+
+                                                    if ($isCustomizedIops.find('input[type=checkbox]').is(':checked')) {
+                                                        $minIops.hide();
+                                                        $maxIops.hide();
+                                                    } else {
+                                                        $minIops.css('display', 'inline-block');
+                                                        $maxIops.css('display', 'inline-block');
+                                                    }
+
+                                                    $hypervisorSnapshotReserve.css('display', 'inline-block');
+                                                } else if (qosId == 'hypervisor') { // Hypervisor Qos
+                                                    $isCustomizedIops.hide();
+                                                    $minIops.hide();
+                                                    $maxIops.hide();
+                                                    $hypervisorSnapshotReserve.hide();
+
+                                                    $diskBytesReadRate.css('display', 'inline-block');
+                                                    $diskBytesWriteRate.css('display', 'inline-block');
+                                                    $diskIopsReadRate.css('display', 'inline-block');
+                                                    $diskIopsWriteRate.css('display', 'inline-block');
+                                                } else { // No Qos
+                                                    $diskBytesReadRate.hide();
+                                                    $diskBytesWriteRate.hide();
+                                                    $diskIopsReadRate.hide();
+                                                    $diskIopsWriteRate.hide();
+                                                    $isCustomizedIops.hide();
+                                                    $minIops.hide();
+                                                    $maxIops.hide();
+                                                    $hypervisorSnapshotReserve.hide();
+                                                }
+                                            });
+                                        }
+                                    },
+                                    isCustomizedIops: {
+                                        label: 'label.custom.disk.iops',
+                                        docID: 'helpDiskOfferingCustomDiskIops',
+                                        isBoolean: true,
+                                        isReverse: true,
+                                        isChecked: false
+                                    },
+                                    minIops: {
+                                        label: 'label.disk.iops.min',
+                                        docID: 'helpDiskOfferingDiskIopsMin',
+                                        dependsOn: 'isCustomizedIops',
+                                        validation: {
+                                            required: false,
+                                            number: true
+                                        }
+                                    },
+                                    maxIops: {
+                                        label: 'label.disk.iops.max',
+                                        docID: 'helpDiskOfferingDiskIopsMax',
+                                        dependsOn: 'isCustomizedIops',
+                                        validation: {
+                                            required: false,
+                                            number: true
+                                        }
+                                    },
+                                    hypervisorSnapshotReserve: {
+                                        label: 'label.hypervisor.snapshot.reserve',
+                                        docID: 'helpDiskOfferingHypervisorSnapshotReserve',
+                                        validation: {
+                                            required: false,
+                                            number: true
+                                        }
+                                    },
                                     diskBytesReadRate: {
                                         label: 'label.disk.bytes.read.rate',
                                         docID: 'helpComputeOfferingDiskBytesReadRate',
@@ -326,26 +433,59 @@
                                         networkrate: args.data.networkRate
                                     });
                                 }
-                                if (args.data.diskBytesReadRate != null && args.data.diskBytesReadRate.length > 0) {
-                                    $.extend(data, {
-                                        bytesreadrate: args.data.diskBytesReadRate
-                                    });
-                                }
-                                if (args.data.diskBytesWriteRate != null && args.data.diskBytesWriteRate.length > 0) {
-                                    $.extend(data, {
-                                        byteswriterate: args.data.diskBytesWriteRate
-                                    });
-                                }
-                                if (args.data.diskIopsReadRate != null && args.data.diskIopsReadRate.length > 0) {
-                                    $.extend(data, {
-                                        iopsreadrate: args.data.diskIopsReadRate
-                                    });
-                                }
-                                if (args.data.diskIopsWriteRate != null && args.data.diskIopsWriteRate.length > 0) {
+
+                                if (args.data.qosType == 'storage') {
+                                    var customIops = args.data.isCustomizedIops == "on";
+
                                     $.extend(data, {
-                                        iopswriterate: args.data.diskIopsWriteRate
+                                        customizediops: customIops
                                     });
+
+                                    if (!customIops) {
+                                        if (args.data.minIops != null && args.data.minIops.length > 0) {
+                                            $.extend(data, {
+                                                miniops: args.data.minIops
+                                            });
+                                        }
+
+                                        if (args.data.maxIops != null && args.data.maxIops.length > 0) {
+                                            $.extend(data, {
+                                                maxiops: args.data.maxIops
+                                            });
+                                        }
+                                    }
+
+                                    if (args.data.hypervisorSnapshotReserve != null && args.data.hypervisorSnapshotReserve.length > 0) {
+                                        $.extend(data, {
+                                            hypervisorsnapshotreserve: args.data.hypervisorSnapshotReserve
+                                        });
+                                    }
+                                } else if (args.data.qosType == 'hypervisor') {
+                                    if (args.data.diskBytesReadRate != null && args.data.diskBytesReadRate.length > 0) {
+                                        $.extend(data, {
+                                            bytesreadrate: args.data.diskBytesReadRate
+                                        });
+                                    }
+
+                                    if (args.data.diskBytesWriteRate != null && args.data.diskBytesWriteRate.length > 0) {
+                                        $.extend(data, {
+                                            byteswriterate: args.data.diskBytesWriteRate
+                                        });
+                                    }
+
+                                    if (args.data.diskIopsReadRate != null && args.data.diskIopsReadRate.length > 0) {
+                                        $.extend(data, {
+                                            iopsreadrate: args.data.diskIopsReadRate
+                                        });
+                                    }
+
+                                    if (args.data.diskIopsWriteRate != null && args.data.diskIopsWriteRate.length > 0) {
+                                        $.extend(data, {
+                                            iopswriterate: args.data.diskIopsWriteRate
+                                        });
+                                    }
                                 }
+
                                 $.extend(data, {
                                     offerha: (args.data.offerHA == "on")
                                 });


[09/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-5920: IAM service plugin.


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

Branch: refs/heads/resize-root
Commit: c28450c1cdb51fba035f8f8f864dd0450ea1e099
Parents: adb29b2
Author: Min Chen <mi...@citrix.com>
Authored: Tue Mar 4 17:52:19 2014 -0800
Committer: Min Chen <mi...@citrix.com>
Committed: Wed Mar 5 09:40:55 2014 -0800

----------------------------------------------------------------------
 services/iam/plugin/pom.xml                     |  58 ++
 .../iam-access-checkers/module.properties       |  18 +
 .../spring-iam-access-checkers-context.xml      |  35 +
 .../command/iam/AddAccountToIAMGroupCmd.java    | 127 +++
 .../iam/AddIAMPermissionToIAMPolicyCmd.java     | 155 ++++
 .../iam/AttachIAMPolicyToAccountCmd.java        | 122 +++
 .../iam/AttachIAMPolicyToIAMGroupCmd.java       | 127 +++
 .../api/command/iam/CreateIAMGroupCmd.java      | 168 ++++
 .../api/command/iam/CreateIAMPolicyCmd.java     | 175 ++++
 .../api/command/iam/DeleteIAMGroupCmd.java      | 102 +++
 .../api/command/iam/DeleteIAMPolicyCmd.java     | 102 +++
 .../api/command/iam/ListIAMGroupsCmd.java       |  88 ++
 .../api/command/iam/ListIAMPoliciesCmd.java     |  88 ++
 .../iam/RemoveAccountFromIAMGroupCmd.java       | 127 +++
 .../RemoveIAMPermissionFromIAMPolicyCmd.java    | 148 ++++
 .../iam/RemoveIAMPolicyFromAccountCmd.java      | 122 +++
 .../iam/RemoveIAMPolicyFromIAMGroupCmd.java     | 127 +++
 .../api/response/iam/IAMGroupResponse.java      | 193 +++++
 .../api/response/iam/IAMPermissionResponse.java | 125 +++
 .../api/response/iam/IAMPolicyResponse.java     | 177 ++++
 .../apache/cloudstack/iam/IAMApiService.java    |  87 ++
 .../cloudstack/iam/IAMApiServiceImpl.java       | 800 +++++++++++++++++++
 .../iam/RoleBasedAPIAccessChecker.java          | 273 +++++++
 .../iam/RoleBasedEntityAccessChecker.java       | 186 +++++
 .../iam/RoleBasedEntityQuerySelector.java       | 147 ++++
 .../cloudstack/iam/test/IAMApiServiceTest.java  | 369 +++++++++
 .../iam/plugin/test/resources/db.properties     |  75 ++
 27 files changed, 4321 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/pom.xml
----------------------------------------------------------------------
diff --git a/services/iam/plugin/pom.xml b/services/iam/plugin/pom.xml
new file mode 100644
index 0000000..0650e43
--- /dev/null
+++ b/services/iam/plugin/pom.xml
@@ -0,0 +1,58 @@
+<!--
+  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-iam</artifactId>
+  <name>Apache CloudStack IAM - Plugin</name>
+  <parent>
+    <groupId>org.apache.cloudstack</groupId>
+    <artifactId>cloudstack-service-iam</artifactId>
+    <version>4.4.0-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-api</artifactId>
+      <version>${project.version}</version>    
+    </dependency> 
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-engine-schema</artifactId>
+      <version>${project.version}</version>    
+    </dependency> 
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-server</artifactId>
+      <version>${project.version}</version>    
+    </dependency>  
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-iam</artifactId>
+      <version>${project.version}</version>    
+    </dependency>  
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-api</artifactId>
+      <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>              
+  </dependencies> 
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/resources/META-INF/cloudstack/iam-access-checkers/module.properties
----------------------------------------------------------------------
diff --git a/services/iam/plugin/resources/META-INF/cloudstack/iam-access-checkers/module.properties b/services/iam/plugin/resources/META-INF/cloudstack/iam-access-checkers/module.properties
new file mode 100644
index 0000000..c87480d
--- /dev/null
+++ b/services/iam/plugin/resources/META-INF/cloudstack/iam-access-checkers/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=iam-access-checkers
+parent=api
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/resources/META-INF/cloudstack/iam-access-checkers/spring-iam-access-checkers-context.xml
----------------------------------------------------------------------
diff --git a/services/iam/plugin/resources/META-INF/cloudstack/iam-access-checkers/spring-iam-access-checkers-context.xml b/services/iam/plugin/resources/META-INF/cloudstack/iam-access-checkers/spring-iam-access-checkers-context.xml
new file mode 100644
index 0000000..983bf08
--- /dev/null
+++ b/services/iam/plugin/resources/META-INF/cloudstack/iam-access-checkers/spring-iam-access-checkers-context.xml
@@ -0,0 +1,35 @@
+<!--
+  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="RoleBasedAPIAccessChecker" class="org.apache.cloudstack.iam.RoleBasedAPIAccessChecker" />
+    <bean id="RoleBasedEntityAccessChecker" class="org.apache.cloudstack.iam.RoleBasedEntityAccessChecker" />
+    <bean id="RoleBasedEntityQuerySelector" class="org.apache.cloudstack.iam.RoleBasedEntityQuerySelector" />
+    <bean id="IAMApiServiceImpl" class="org.apache.cloudstack.iam.IAMApiServiceImpl" />
+
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AddAccountToIAMGroupCmd.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AddAccountToIAMGroupCmd.java b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AddAccountToIAMGroupCmd.java
new file mode 100644
index 0000000..bea3fc9
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AddAccountToIAMGroupCmd.java
@@ -0,0 +1,127 @@
+// 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.iam;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.iam.IAMApiService;
+import org.apache.cloudstack.api.ACL;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.AccountResponse;
+import org.apache.cloudstack.api.response.iam.IAMGroupResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.iam.api.IAMGroup;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+
+
+@APICommand(name = "addAccountToIAMGroup", description = "add account to an iam group", responseObject = IAMGroupResponse.class)
+public class AddAccountToIAMGroupCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(AddAccountToIAMGroupCmd.class.getName());
+    private static final String s_name = "addaccounttoiamgroupresponse";
+
+    @Inject
+    public IAMApiService _iamApiSrv;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+
+    @ACL
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = IAMGroupResponse.class,
+ required = true, description = "The ID of the iam group")
+    private Long id;
+
+    @ACL
+    @Parameter(name = ApiConstants.ACCOUNTS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = AccountResponse.class, description = "comma separated list of account id that are going to be assigned to the iam group.")
+    private List<Long> accountIdList;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+
+    public Long getId() {
+        return id;
+    }
+
+
+    public List<Long> getAccountIdList() {
+        return accountIdList;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public void execute() throws ResourceUnavailableException,
+            InsufficientCapacityException, ServerApiException {
+        CallContext.current().setEventDetails("IAM group Id: " + getId());
+        IAMGroup result = _iamApiSrv.addAccountsToGroup(accountIdList, id);
+        if (result != null){
+            IAMGroupResponse response = _iamApiSrv.createIAMGroupResponse(result);
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add accounts to iam group");
+        }
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_IAM_GROUP_UPDATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "adding accounts to iam group";
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.IAMGroup;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AddIAMPermissionToIAMPolicyCmd.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AddIAMPermissionToIAMPolicyCmd.java b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AddIAMPermissionToIAMPolicyCmd.java
new file mode 100644
index 0000000..e991537
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AddIAMPermissionToIAMPolicyCmd.java
@@ -0,0 +1,155 @@
+// 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.iam;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.acl.PermissionScope;
+import org.apache.cloudstack.api.ACL;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.iam.IAMPolicyResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.iam.IAMApiService;
+import org.apache.cloudstack.iam.api.IAMPolicy;
+import org.apache.cloudstack.iam.api.IAMPolicyPermission.Permission;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+import com.cloud.utils.db.EntityManager;
+
+
+@APICommand(name = "addIAMPermissionToIAMPolicy", description = "Add IAM permission to an iam policy", responseObject = IAMPolicyResponse.class)
+public class AddIAMPermissionToIAMPolicyCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(AddIAMPermissionToIAMPolicyCmd.class.getName());
+    private static final String s_name = "addiampermissiontoiampolicyresponse";
+
+    @Inject
+    public IAMApiService _iamApiSrv;
+    @Inject
+    public EntityManager _entityMgr;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+
+    @ACL
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = IAMPolicyResponse.class,
+ required = true, description = "The ID of the iam policy")
+    private Long id;
+
+    @Parameter(name = ApiConstants.IAM_ACTION, type = CommandType.STRING, required = true, description = "action api name.")
+    private String action;
+
+    @Parameter(name = ApiConstants.ENTITY_TYPE, type = CommandType.STRING, required = false, description = "entity class simple name.")
+    private String entityType;
+
+    @Parameter(name = ApiConstants.IAM_SCOPE, type = CommandType.STRING,
+ required = false, description = "iam permission scope")
+    private String scope;
+
+    @Parameter(name = ApiConstants.IAM_SCOPE_ID, type = CommandType.STRING, required = false, description = "The UUID of the permission scope id")
+    private String scopeId;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+
+    public Long getId() {
+        return id;
+    }
+
+
+    public String getAction() {
+        return action;
+    }
+
+    public String getEntityType() {
+        return entityType;
+    }
+
+    public String getScope() {
+        return scope;
+    }
+
+    public Long getScopeId() {
+        // here we will convert the passed String UUID to Long ID since internally we store it as entity internal ID.
+        return _iamApiSrv.getPermissionScopeId(scope, entityType, scopeId);
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public void execute() throws ResourceUnavailableException,
+            InsufficientCapacityException, ServerApiException {
+        CallContext.current().setEventDetails("IAM policy Id: " + getId());
+        // Only explicit ALLOW is supported for this release, no explicit deny
+        IAMPolicy result = _iamApiSrv.addIAMPermissionToIAMPolicy(id, entityType, PermissionScope.valueOf(scope),
+                getScopeId(), action, Permission.Allow, false);
+        if (result != null) {
+            IAMPolicyResponse response = _iamApiSrv.createIAMPolicyResponse(result);
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to grant permission to iam policy "
+                    + getId());
+        }
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_IAM_POLICY_GRANT;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "granting permission to iam policy";
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.IAMPolicy;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AttachIAMPolicyToAccountCmd.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AttachIAMPolicyToAccountCmd.java b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AttachIAMPolicyToAccountCmd.java
new file mode 100644
index 0000000..fc174cf
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AttachIAMPolicyToAccountCmd.java
@@ -0,0 +1,122 @@
+// 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.iam;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.iam.IAMApiService;
+import org.apache.cloudstack.api.ACL;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.AccountResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.iam.IAMPolicyResponse;
+import org.apache.cloudstack.context.CallContext;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+
+
+@APICommand(name = "attachIAMPolicyToAccount", description = "attach iam policy to accounts", responseObject = SuccessResponse.class)
+public class AttachIAMPolicyToAccountCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(AttachIAMPolicyToAccountCmd.class.getName());
+    private static final String s_name = "attachiampolicytoaccountresponse";
+
+    @Inject
+    public IAMApiService _iamApiSrv;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+
+    @ACL
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = IAMPolicyResponse.class,
+ required = true, description = "The ID of the iam policy")
+    private Long id;
+
+    @ACL
+    @Parameter(name = ApiConstants.ACCOUNTS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = AccountResponse.class, description = "comma separated list of account id that the policy will attach to.")
+    private List<Long> accountIdList;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+
+    public Long getId() {
+        return id;
+    }
+
+
+    public List<Long> getAccountIdList() {
+        return accountIdList;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public void execute() throws ResourceUnavailableException,
+            InsufficientCapacityException, ServerApiException {
+        CallContext.current().setEventDetails("IAM policy Id: " + getId());
+        _iamApiSrv.attachIAMPolicyToAccounts(id, accountIdList);
+        SuccessResponse response = new SuccessResponse();
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_IAM_ACCOUNT_POLICY_UPDATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "adding IAM policy to accounts";
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.Account;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AttachIAMPolicyToIAMGroupCmd.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AttachIAMPolicyToIAMGroupCmd.java b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AttachIAMPolicyToIAMGroupCmd.java
new file mode 100644
index 0000000..1705c4a
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/AttachIAMPolicyToIAMGroupCmd.java
@@ -0,0 +1,127 @@
+// 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.iam;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.iam.IAMApiService;
+import org.apache.cloudstack.api.ACL;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.iam.IAMGroupResponse;
+import org.apache.cloudstack.api.response.iam.IAMPolicyResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.iam.api.IAMGroup;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+
+
+@APICommand(name = "attachIAMPolicyToIAMGroup", description = "attach iam policy to an iam group", responseObject = IAMGroupResponse.class)
+public class AttachIAMPolicyToIAMGroupCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(AttachIAMPolicyToIAMGroupCmd.class.getName());
+    private static final String s_name = "attachiampolicytoiamgroupresponse";
+
+    @Inject
+    public IAMApiService _iamApiSrv;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+
+    @ACL
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = IAMGroupResponse.class,
+ required = true, description = "The ID of the iam group")
+    private Long id;
+
+    @ACL
+    @Parameter(name = ApiConstants.IAM_POLICIES, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = IAMPolicyResponse.class, description = "comma separated list of iam policy id that are going to be applied to the iam group.")
+    private List<Long> policyIdList;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+
+    public Long getId() {
+        return id;
+    }
+
+
+    public List<Long> getPolicyIdList() {
+        return policyIdList;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public void execute() throws ResourceUnavailableException,
+            InsufficientCapacityException, ServerApiException {
+        CallContext.current().setEventDetails("IAM group Id: " + getId());
+        IAMGroup result = _iamApiSrv.attachIAMPoliciesToGroup(policyIdList, id);
+        if (result != null){
+            IAMGroupResponse response = _iamApiSrv.createIAMGroupResponse(result);
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add roles to iam group");
+        }
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_IAM_GROUP_UPDATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "adding iam roles to iam group";
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.IAMGroup;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/CreateIAMGroupCmd.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/CreateIAMGroupCmd.java b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/CreateIAMGroupCmd.java
new file mode 100644
index 0000000..d0b9bc6
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/CreateIAMGroupCmd.java
@@ -0,0 +1,168 @@
+// 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.iam;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.iam.IAMApiService;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.iam.IAMGroupResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.iam.api.IAMGroup;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.user.Account;
+
+@APICommand(name = "createIAMGroup", responseObject = IAMGroupResponse.class, description = "Creates an IAM group")
+public class CreateIAMGroupCmd extends BaseAsyncCreateCmd {
+    public static final Logger s_logger = Logger.getLogger(CreateIAMGroupCmd.class.getName());
+
+    private static final String s_name = "createiamgroupresponse";
+
+    @Inject
+    public IAMApiService _iamApiSrv;
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an account for the iam group. Must be used with domainId.")
+    private String accountName;
+
+    @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, description = "domainId of the account owning the iam group", entityType = DomainResponse.class)
+    private Long domainId;
+
+    @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "optional description of the iam group")
+    private String description;
+
+    @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the iam group")
+    private String name;
+
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Account account = CallContext.current().getCallingAccount();
+        if ((account == null) || _accountService.isAdmin(account.getType())) {
+            if ((domainId != null) && (accountName != null)) {
+                Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
+                if (userAccount != null) {
+                    return userAccount.getId();
+                }
+            }
+        }
+
+        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() {
+        IAMGroup grp = _entityMgr.findById(IAMGroup.class, getEntityId());
+        if (grp != null) {
+            IAMGroupResponse response = _iamApiSrv.createIAMGroupResponse(grp);
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create iam group:" + name);
+        }
+    }
+
+    @Override
+    public void create() throws ResourceAllocationException {
+        Account account = CallContext.current().getCallingAccount();
+        IAMGroup result = _iamApiSrv.createIAMGroup(account, name, description);
+        if (result != null) {
+            setEntityId(result.getId());
+            setEntityUuid(result.getUuid());
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create iam group entity" + name);
+        }
+
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_IAM_GROUP_CREATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "creating IAM group";
+    }
+
+    @Override
+    public String getCreateEventType() {
+        return EventTypes.EVENT_IAM_GROUP_CREATE;
+    }
+
+    @Override
+    public String getCreateEventDescription() {
+        return "creating IAM group";
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.IAMGroup;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/CreateIAMPolicyCmd.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/CreateIAMPolicyCmd.java b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/CreateIAMPolicyCmd.java
new file mode 100644
index 0000000..be863de
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/CreateIAMPolicyCmd.java
@@ -0,0 +1,175 @@
+// 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.iam;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.iam.IAMApiService;
+import org.apache.cloudstack.api.ACL;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.iam.IAMPolicyResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.iam.api.IAMPolicy;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.user.Account;
+
+@APICommand(name = "createIAMPolicy", responseObject = IAMPolicyResponse.class, description = "Creates an iam policy")
+public class CreateIAMPolicyCmd extends BaseAsyncCreateCmd {
+    public static final Logger s_logger = Logger.getLogger(CreateIAMPolicyCmd.class.getName());
+
+    private static final String s_name = "createiampolicyresponse";
+
+    @Inject
+    public IAMApiService _iamApiSrv;
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an account for the iam policy. Must be used with domainId.")
+    private String accountName;
+
+    @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, description = "domainId of the account owning the iam policy", entityType = DomainResponse.class)
+    private Long domainId;
+
+    @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "optional description of the iam policy")
+    private String description;
+
+    @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the iam policy")
+    private String name;
+
+    @ACL
+    @Parameter(name = ApiConstants.IAM_PARENT_POLICY_ID, type = CommandType.UUID, description = "The ID of parent iam policy.", entityType = IAMPolicyResponse.class)
+    private Long parentPolicyId;
+
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public Long getParentPolicyId() {
+        return parentPolicyId;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Account account = CallContext.current().getCallingAccount();
+        if ((account == null) || _accountService.isAdmin(account.getType())) {
+            if ((domainId != null) && (accountName != null)) {
+                Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
+                if (userAccount != null) {
+                    return userAccount.getId();
+                }
+            }
+        }
+
+        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() {
+        IAMPolicy policy = _entityMgr.findById(IAMPolicy.class, getEntityId());
+        if (policy != null) {
+            IAMPolicyResponse response = _iamApiSrv.createIAMPolicyResponse(policy);
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create iam policy:" + name);
+        }
+    }
+
+    @Override
+    public void create() throws ResourceAllocationException {
+        Account account = CallContext.current().getCallingAccount();
+        IAMPolicy result = _iamApiSrv.createIAMPolicy(account, name, description, parentPolicyId);
+        if (result != null) {
+            setEntityId(result.getId());
+            setEntityUuid(result.getUuid());
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create iam policy entity" + name);
+        }
+
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_IAM_POLICY_CREATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "creating IAM policy";
+    }
+
+    @Override
+    public String getCreateEventType() {
+        return EventTypes.EVENT_IAM_POLICY_CREATE;
+    }
+
+    @Override
+    public String getCreateEventDescription() {
+        return "creating IAM policy";
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.IAMPolicy;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/DeleteIAMGroupCmd.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/DeleteIAMGroupCmd.java b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/DeleteIAMGroupCmd.java
new file mode 100644
index 0000000..60b1e24
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/DeleteIAMGroupCmd.java
@@ -0,0 +1,102 @@
+// 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.iam;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ACL;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.iam.IAMGroupResponse;
+import org.apache.cloudstack.iam.IAMApiService;
+
+import com.cloud.event.EventTypes;
+import com.cloud.user.Account;
+
+@APICommand(name = "deleteIAMGroup", description = "Deletes acl group", responseObject = SuccessResponse.class)
+public class DeleteIAMGroupCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(DeleteIAMGroupCmd.class.getName());
+    private static final String s_name = "deleteaclgroupresponse";
+
+    @Inject
+    public IAMApiService _aclApiSrv;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @ACL
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "The ID of the acl group.", required = true, entityType = IAMGroupResponse.class)
+    private Long id;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        boolean result = _aclApiSrv.deleteIAMGroup(id);
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete acl group");
+        }
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_IAM_GROUP_DELETE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Deleting Acl group";
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.IAMGroup;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/DeleteIAMPolicyCmd.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/DeleteIAMPolicyCmd.java b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/DeleteIAMPolicyCmd.java
new file mode 100644
index 0000000..037f4cd
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/DeleteIAMPolicyCmd.java
@@ -0,0 +1,102 @@
+// 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.iam;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.iam.IAMApiService;
+import org.apache.cloudstack.api.ACL;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.iam.IAMPolicyResponse;
+
+import com.cloud.event.EventTypes;
+import com.cloud.user.Account;
+
+@APICommand(name = "deleteIAMPolicy", description = "Deletes iam policy", responseObject = SuccessResponse.class)
+public class DeleteIAMPolicyCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(DeleteIAMPolicyCmd.class.getName());
+    private static final String s_name = "deleteiampolicyresponse";
+
+    @Inject
+    public IAMApiService _iamApiSrv;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @ACL
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "The ID of the iam policy.", required = true, entityType = IAMPolicyResponse.class)
+    private Long id;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        boolean result = _iamApiSrv.deleteIAMPolicy(id);
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete iam policy");
+        }
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_IAM_POLICY_DELETE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Deleting IAM policy";
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.IAMPolicy;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/ListIAMGroupsCmd.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/ListIAMGroupsCmd.java b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/ListIAMGroupsCmd.java
new file mode 100644
index 0000000..ece87fa
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/ListIAMGroupsCmd.java
@@ -0,0 +1,88 @@
+// 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.iam;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.iam.IAMApiService;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListDomainResourcesCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.iam.IAMGroupResponse;
+
+
+@APICommand(name = "listIAMGroups", description = "Lists iam groups", responseObject = IAMGroupResponse.class)
+public class ListIAMGroupsCmd extends BaseListDomainResourcesCmd {
+    public static final Logger s_logger = Logger.getLogger(ListIAMGroupsCmd.class.getName());
+
+    private static final String s_name = "listiamgroupsresponse";
+
+    @Inject
+    public IAMApiService _iamApiSrv;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "lists iam groups by name")
+    private String iamGroupName;
+
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "list the iam group by the id provided", entityType = IAMGroupResponse.class)
+    private Long id;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+    public String getIAMGroupName() {
+        return iamGroupName;
+    }
+
+
+    public Long getId(){
+        return id;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute(){
+
+        ListResponse<IAMGroupResponse> response = _iamApiSrv.listIAMGroups(id, iamGroupName, getDomainId(),
+                getStartIndex(), getPageSizeVal());
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.IAMGroup;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/ListIAMPoliciesCmd.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/ListIAMPoliciesCmd.java b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/ListIAMPoliciesCmd.java
new file mode 100644
index 0000000..096cc3b
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/ListIAMPoliciesCmd.java
@@ -0,0 +1,88 @@
+// 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.iam;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.iam.IAMApiService;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListDomainResourcesCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.iam.IAMPolicyResponse;
+
+
+@APICommand(name = "listIAMPolicies", description = "Lists IAM policies", responseObject = IAMPolicyResponse.class)
+public class ListIAMPoliciesCmd extends BaseListDomainResourcesCmd {
+    public static final Logger s_logger = Logger.getLogger(ListIAMPoliciesCmd.class.getName());
+
+    private static final String s_name = "listiampoliciesresponse";
+
+    @Inject
+    public IAMApiService _iamApiSrv;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "lists iam policies by name")
+    private String iamPolicyName;
+
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "list the iam policy by the id provided", entityType = IAMPolicyResponse.class)
+    private Long id;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+    public String getIAMPolicyName() {
+        return iamPolicyName;
+    }
+
+
+    public Long getId(){
+        return id;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute(){
+
+        ListResponse<IAMPolicyResponse> response = _iamApiSrv.listIAMPolicies(id, iamPolicyName, getDomainId(),
+                getStartIndex(), getPageSizeVal());
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.IAMPolicy;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveAccountFromIAMGroupCmd.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveAccountFromIAMGroupCmd.java b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveAccountFromIAMGroupCmd.java
new file mode 100644
index 0000000..5ff5039
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveAccountFromIAMGroupCmd.java
@@ -0,0 +1,127 @@
+// 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.iam;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.iam.IAMApiService;
+import org.apache.cloudstack.api.ACL;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.AccountResponse;
+import org.apache.cloudstack.api.response.iam.IAMGroupResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.iam.api.IAMGroup;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+
+
+@APICommand(name = "removeAccountFromIAMGroup", description = "remove accounts from an iam group", responseObject = IAMGroupResponse.class)
+public class RemoveAccountFromIAMGroupCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(RemoveAccountFromIAMGroupCmd.class.getName());
+    private static final String s_name = "removeaccountfromiamgroupresponse";
+
+    @Inject
+    public IAMApiService _iamApiSrv;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+
+    @ACL
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = IAMGroupResponse.class,
+ required = true, description = "The ID of the iam group")
+    private Long id;
+
+    @ACL
+    @Parameter(name = ApiConstants.ACCOUNTS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = AccountResponse.class, description = "comma separated list of account id that are going to be assigned to the iam group.")
+    private List<Long> accountIdList;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+
+    public Long getId() {
+        return id;
+    }
+
+
+    public List<Long> getAccountIdList() {
+        return accountIdList;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public void execute() throws ResourceUnavailableException,
+            InsufficientCapacityException, ServerApiException {
+        CallContext.current().setEventDetails("IAM group Id: " + getId());
+        IAMGroup result = _iamApiSrv.removeAccountsFromGroup(accountIdList, id);
+        if (result != null){
+            IAMGroupResponse response = _iamApiSrv.createIAMGroupResponse(result);
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove accounts from iam group");
+        }
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_IAM_GROUP_UPDATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "removing accounts from iam group";
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.IAMGroup;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveIAMPermissionFromIAMPolicyCmd.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveIAMPermissionFromIAMPolicyCmd.java b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveIAMPermissionFromIAMPolicyCmd.java
new file mode 100644
index 0000000..bf065a0
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveIAMPermissionFromIAMPolicyCmd.java
@@ -0,0 +1,148 @@
+// 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.iam;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.acl.PermissionScope;
+import org.apache.cloudstack.api.ACL;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.iam.IAMPolicyResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.iam.IAMApiService;
+import org.apache.cloudstack.iam.api.IAMPolicy;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+
+
+@APICommand(name = "removeIAMPermissionFromIAMPolicy", description = "Remove iam permission from an iam policy", responseObject = IAMPolicyResponse.class)
+public class RemoveIAMPermissionFromIAMPolicyCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(RemoveIAMPermissionFromIAMPolicyCmd.class.getName());
+    private static final String s_name = "removeiampermissionfromiampolicyresponse";
+
+    @Inject
+    public IAMApiService _iamApiSrv;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+
+    @ACL
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = IAMPolicyResponse.class,
+            required = true, description = "The ID of the iam policy")
+    private Long id;
+
+    @Parameter(name = ApiConstants.IAM_ACTION, type = CommandType.STRING, required = true, description = "action api name.")
+    private String action;
+
+    @Parameter(name = ApiConstants.ENTITY_TYPE, type = CommandType.STRING, required = false, description = "entity class simple name.")
+    private String entityType;
+
+    @Parameter(name = ApiConstants.IAM_SCOPE, type = CommandType.STRING,
+            required = false, description = "iam permission scope")
+    private String scope;
+
+    @Parameter(name = ApiConstants.IAM_SCOPE_ID, type = CommandType.STRING, required = false, description = "The ID of the permission scope id")
+    private String scopeId;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+
+    public Long getId() {
+        return id;
+    }
+
+
+    public String getAction() {
+        return action;
+    }
+
+    public String getEntityType() {
+        return entityType;
+    }
+
+    public String getScope() {
+        return scope;
+    }
+
+    public Long getScopeId() {
+        // here we will convert the passed String UUID to Long ID since internally we store it as entity internal ID.
+        return _iamApiSrv.getPermissionScopeId(scope, entityType, scopeId);
+    }
+
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public void execute() throws ResourceUnavailableException,
+            InsufficientCapacityException, ServerApiException {
+        CallContext.current().setEventDetails("IAM policy Id: " + getId());
+        IAMPolicy result = _iamApiSrv.removeIAMPermissionFromIAMPolicy(id, entityType, PermissionScope.valueOf(scope), getScopeId(), action);
+        if (result != null) {
+            IAMPolicyResponse response = _iamApiSrv.createIAMPolicyResponse(result);
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove permission from iam policy " + getId());
+        }
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_IAM_POLICY_REVOKE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "removing permission from iam policy";
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.IAMPolicy;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveIAMPolicyFromAccountCmd.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveIAMPolicyFromAccountCmd.java b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveIAMPolicyFromAccountCmd.java
new file mode 100644
index 0000000..48c2a73
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveIAMPolicyFromAccountCmd.java
@@ -0,0 +1,122 @@
+// 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.iam;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ACL;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.AccountResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.iam.IAMPolicyResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.iam.IAMApiService;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+
+
+@APICommand(name = "removeIAMPolicyFromAccount", description = "remove iam policy from accounts", responseObject = SuccessResponse.class)
+public class RemoveIAMPolicyFromAccountCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(RemoveIAMPolicyFromAccountCmd.class.getName());
+    private static final String s_name = "removeiampolicyfromaccountresponse";
+
+    @Inject
+    public IAMApiService _iamApiSrv;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+
+    @ACL
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = IAMPolicyResponse.class,
+ required = true, description = "The ID of the iam group")
+    private Long id;
+
+    @ACL
+    @Parameter(name = ApiConstants.ACCOUNTS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = AccountResponse.class, description = "comma separated list of iam policy id that are going to be applied to the iam group.")
+    private List<Long> accountIdList;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+
+    public Long getId() {
+        return id;
+    }
+
+
+    public List<Long> getAccountIdList() {
+        return accountIdList;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public void execute() throws ResourceUnavailableException,
+            InsufficientCapacityException, ServerApiException {
+        CallContext.current().setEventDetails("IAM policy Id: " + getId());
+        _iamApiSrv.removeIAMPolicyFromAccounts(id, accountIdList);
+        SuccessResponse response = new SuccessResponse();
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_IAM_ACCOUNT_POLICY_UPDATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "removing iam policy from accounts";
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.Account;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveIAMPolicyFromIAMGroupCmd.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveIAMPolicyFromIAMGroupCmd.java b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveIAMPolicyFromIAMGroupCmd.java
new file mode 100644
index 0000000..a99143d
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/command/iam/RemoveIAMPolicyFromIAMGroupCmd.java
@@ -0,0 +1,127 @@
+// 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.iam;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.iam.IAMApiService;
+import org.apache.cloudstack.api.ACL;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.iam.IAMGroupResponse;
+import org.apache.cloudstack.api.response.iam.IAMPolicyResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.iam.api.IAMGroup;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+
+
+@APICommand(name = "removeIAMPolicyFromIAMGroup", description = "remove iam policy from an iam group", responseObject = IAMGroupResponse.class)
+public class RemoveIAMPolicyFromIAMGroupCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(RemoveIAMPolicyFromIAMGroupCmd.class.getName());
+    private static final String s_name = "removeiampolicyfromiamgroupresponse";
+
+    @Inject
+    public IAMApiService _iamApiSrv;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+
+    @ACL
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = IAMGroupResponse.class,
+ required = true, description = "The ID of the iam group")
+    private Long id;
+
+    @ACL
+    @Parameter(name = ApiConstants.IAM_POLICIES, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = IAMPolicyResponse.class, description = "comma separated list of iam policy id that are going to be applied to the iam group.")
+    private List<Long> policyIdList;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+
+    public Long getId() {
+        return id;
+    }
+
+
+    public List<Long> getRoleIdList() {
+        return policyIdList;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public void execute() throws ResourceUnavailableException,
+            InsufficientCapacityException, ServerApiException {
+        CallContext.current().setEventDetails("IAM group Id: " + getId());
+        IAMGroup result = _iamApiSrv.removeIAMPoliciesFromGroup(policyIdList, id);
+        if (result != null){
+            IAMGroupResponse response = _iamApiSrv.createIAMGroupResponse(result);
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add roles to iam group");
+        }
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_IAM_GROUP_UPDATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "removing IAM roles from IAM group";
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.IAMGroup;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/response/iam/IAMGroupResponse.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/response/iam/IAMGroupResponse.java b/services/iam/plugin/src/org/apache/cloudstack/api/response/iam/IAMGroupResponse.java
new file mode 100644
index 0000000..af28d53
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/response/iam/IAMGroupResponse.java
@@ -0,0 +1,193 @@
+// 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.iam;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
+import org.apache.cloudstack.api.response.ControlledViewEntityResponse;
+import org.apache.cloudstack.iam.api.IAMGroup;
+
+import com.cloud.serializer.Param;
+
+@SuppressWarnings("unused")
+@EntityReference(value = IAMGroup.class)
+public class IAMGroupResponse extends BaseResponse implements ControlledViewEntityResponse {
+
+    @SerializedName(ApiConstants.ID)
+    @Param(description = "the ID of the iam group")
+    private String id;
+
+    @SerializedName(ApiConstants.NAME)
+    @Param(description = "the name of the iam group")
+    private String name;
+
+    @SerializedName(ApiConstants.DESCRIPTION)
+    @Param(description = "the description of the iam group")
+    private String description;
+
+    @SerializedName(ApiConstants.DOMAIN_ID)
+    @Param(description = "the domain ID of the iam group")
+    private String domainId;
+
+    @SerializedName(ApiConstants.DOMAIN)
+    @Param(description = "the domain name of the iam role")
+    private String domainName;
+
+    @SerializedName(ApiConstants.ACCOUNT)
+    @Param(description = "the account owning the policy")
+    private String accountName;
+
+    @SerializedName(ApiConstants.IAM_MEMBER_ACCOUNTS)
+    @Param(description = "account names assigned to this iam group ")
+    private Set<String> accountNameList;
+
+    @SerializedName(ApiConstants.IAM_POLICIES)
+    @Param(description = "iam policies attached to this iam group ")
+    private Set<String> policyNameList;
+
+    public IAMGroupResponse() {
+        accountNameList = new LinkedHashSet<String>();
+        policyNameList = new LinkedHashSet<String>();
+    }
+
+    @Override
+    public String getObjectId() {
+        return getId();
+    }
+
+
+    public String getId() {
+        return id;
+     }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Override
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Override
+    public void setDomainName(String domainName) {
+        this.domainName = domainName;
+    }
+
+    @Override
+    public void setAccountName(String accountName) {
+        this.accountName = accountName;
+
+    }
+
+    @Override
+    public void setProjectId(String projectId) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setProjectName(String projectName) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public String getDomainName() {
+        return domainName;
+    }
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    public Set<String> getAccountNameList() {
+        return accountNameList;
+    }
+
+    public void setMemberAccounts(Set<String> accts) {
+        accountNameList = accts;
+    }
+
+    public void addMemberAccount(String acct) {
+        accountNameList.add(acct);
+    }
+
+    public void setPolicyList(Set<String> policies) {
+        policyNameList = policies;
+    }
+
+    public void addPolicy(String policy) {
+        policyNameList.add(policy);
+    }
+
+    public Set<String> getPolicyList() {
+        return policyNameList;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((id == null) ? 0 : id.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        IAMGroupResponse other = (IAMGroupResponse)obj;
+        if (id == null) {
+            if (other.id != null)
+                return false;
+        } else if (!id.equals(other.id))
+            return false;
+        return true;
+    }
+
+}


[39/50] [abbrv] Dispatcher corrections, refactoring and tests

Posted by ml...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/test/com/cloud/api/ApiDispatcherTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/api/ApiDispatcherTest.java b/server/test/com/cloud/api/ApiDispatcherTest.java
deleted file mode 100644
index 7314a57..0000000
--- a/server/test/com/cloud/api/ApiDispatcherTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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 com.cloud.api;
-
-import java.util.HashMap;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.context.CallContext;
-
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.user.Account;
-import com.cloud.user.AccountManager;
-import com.cloud.user.User;
-
-@RunWith(MockitoJUnitRunner.class)
-public class ApiDispatcherTest {
-
-    @Mock
-    AccountManager accountManager;
-
-    public static class TestCmd extends BaseCmd {
-
-        @Parameter(name = "strparam1")
-        String strparam1;
-
-        @Parameter(name = "intparam1", type = CommandType.INTEGER)
-        int intparam1;
-
-        @Parameter(name = "boolparam1", type = CommandType.BOOLEAN)
-        boolean boolparam1;
-
-        @Override
-        public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
-            ResourceAllocationException, NetworkRuleConflictException {
-            // well documented nothing
-        }
-
-        @Override
-        public String getCommandName() {
-            return "test";
-        }
-
-        @Override
-        public long getEntityOwnerId() {
-            return 0;
-        }
-
-    }
-
-    @Before
-    public void setup() {
-        CallContext.register(Mockito.mock(User.class), Mockito.mock(Account.class));
-        new ApiDispatcher().init();
-        ApiDispatcher.getInstance()._accountMgr = accountManager;
-    }
-
-    @After
-    public void cleanup() {
-        CallContext.unregister();
-    }
-
-    @Test
-    public void processParameters() {
-        HashMap<String, String> params = new HashMap<String, String>();
-        params.put("strparam1", "foo");
-        params.put("intparam1", "100");
-        params.put("boolparam1", "true");
-        TestCmd cmd = new TestCmd();
-        //how lucky that field is not protected, this test would be impossible
-        ApiDispatcher.processParameters(cmd, params);
-        Assert.assertEquals("foo", cmd.strparam1);
-        Assert.assertEquals(100, cmd.intparam1);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/test/com/cloud/api/dispatch/CommandCreationWorkerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/api/dispatch/CommandCreationWorkerTest.java b/server/test/com/cloud/api/dispatch/CommandCreationWorkerTest.java
new file mode 100644
index 0000000..34d64fc
--- /dev/null
+++ b/server/test/com/cloud/api/dispatch/CommandCreationWorkerTest.java
@@ -0,0 +1,48 @@
+// 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 com.cloud.api.dispatch;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+
+import com.cloud.exception.ResourceAllocationException;
+
+public class CommandCreationWorkerTest {
+
+    @Test
+    public void testHandle() throws ResourceAllocationException {
+        // Prepare
+        final BaseAsyncCreateCmd asyncCreateCmd = mock(BaseAsyncCreateCmd.class);
+        final Map<String, String> params = new HashMap<String, String>();
+
+        // Execute
+        final CommandCreationWorker creationWorker = new CommandCreationWorker();
+
+        creationWorker.handle(new DispatchTask(asyncCreateCmd, params));
+
+        // Assert
+        verify(asyncCreateCmd, times(1)).create();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/test/com/cloud/api/dispatch/DispatchChainFactoryTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/api/dispatch/DispatchChainFactoryTest.java b/server/test/com/cloud/api/dispatch/DispatchChainFactoryTest.java
new file mode 100644
index 0000000..f54caae
--- /dev/null
+++ b/server/test/com/cloud/api/dispatch/DispatchChainFactoryTest.java
@@ -0,0 +1,55 @@
+// 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 com.cloud.api.dispatch;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+public class DispatchChainFactoryTest {
+
+    protected static final String STANDARD_CHAIN_ERROR = "Expecting worker of class %s at index %s of StandardChain";
+    protected static final String ASYNC_CHAIN_ERROR = "Expecting worker of class %s at index %s of StandardChain";
+
+    @Test
+    public void testAllChainCreation() {
+        // Prepare
+        final DispatchChainFactory dispatchChainFactory = new DispatchChainFactory();
+        dispatchChainFactory.paramGenericValidationWorker = new ParamGenericValidationWorker();
+        dispatchChainFactory.specificCmdValidationWorker = new SpecificCmdValidationWorker();
+        dispatchChainFactory.paramProcessWorker = new ParamProcessWorker();
+        dispatchChainFactory.commandCreationWorker = new CommandCreationWorker();
+        dispatchChainFactory.paramUnpackWorker = new ParamUnpackWorker();
+
+        final Class<?>[] standardClasses = {ParamUnpackWorker.class, ParamProcessWorker.class,
+                ParamGenericValidationWorker.class, SpecificCmdValidationWorker.class};
+        final Class<?>[] asyncClasses = {ParamUnpackWorker.class, ParamProcessWorker.class,
+                ParamGenericValidationWorker.class, SpecificCmdValidationWorker.class, CommandCreationWorker.class};
+
+        // Execute
+        dispatchChainFactory.setup();
+        final DispatchChain standardChain = dispatchChainFactory.getStandardDispatchChain();
+        final DispatchChain asyncChain = dispatchChainFactory.getAsyncCreationDispatchChain();
+        for (int i = 0; i < standardClasses.length; i++) {
+            assertEquals(String.format(STANDARD_CHAIN_ERROR, standardClasses[i], i),
+                    standardClasses[i], standardChain.workers.get(i).getClass());
+        }
+        for (int i = 0; i < asyncClasses.length; i++) {
+            assertEquals(String.format(ASYNC_CHAIN_ERROR, asyncClasses[i], i),
+                    asyncClasses[i], asyncChain.workers.get(i).getClass());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/test/com/cloud/api/dispatch/ParamGenericValidationWorkerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/api/dispatch/ParamGenericValidationWorkerTest.java b/server/test/com/cloud/api/dispatch/ParamGenericValidationWorkerTest.java
new file mode 100644
index 0000000..867625d
--- /dev/null
+++ b/server/test/com/cloud/api/dispatch/ParamGenericValidationWorkerTest.java
@@ -0,0 +1,173 @@
+// 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 com.cloud.api.dispatch;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+
+import org.apache.log4j.Logger;
+
+public class ParamGenericValidationWorkerTest {
+
+    protected static final String FAKE_CMD_NAME = "fakecmdname";
+
+    protected static final String FAKE_CMD_ROLE_NAME = "fakecmdrolename";
+
+    protected String loggerOutput;
+
+    protected void driveTest(final BaseCmd cmd, final Map<String, String> params) {
+        final ParamGenericValidationWorker genValidationWorker = new ParamGenericValidationWorker();
+
+        // We create a mock logger to verify the result
+        ParamGenericValidationWorker.s_logger = new Logger(""){
+            @Override
+            public void warn(final Object msg){
+                loggerOutput = msg.toString();
+            }
+        };
+
+        // Execute
+        genValidationWorker.handle(new DispatchTask(cmd, params));
+    }
+
+    @Test
+    public void testHandle() throws ResourceAllocationException {
+        // Prepare
+        final BaseCmd cmd = new FakeCmd();
+        final Map<String, String> params = new HashMap<String, String>();
+        params.put(ApiConstants.COMMAND, "");
+        params.put("addedParam", "");
+
+        // Execute
+        driveTest(cmd, params);
+
+        // Assert
+        assertEquals("There should be no errors since there are no unknown parameters for this command class", null, loggerOutput);
+    }
+
+    @Test
+    public void testHandleWithUnknownParams() throws ResourceAllocationException {
+        // Prepare
+        final String unknownParamKey = "unknownParam";
+        final BaseCmd cmd = new FakeCmd();
+        final Map<String, String> params = new HashMap<String, String>();
+        params.put(ApiConstants.COMMAND, "");
+        params.put("addedParam", "");
+        params.put(unknownParamKey, "");
+
+        // Execute
+        driveTest(cmd, params);
+
+        // Assert
+        assertTrue("There should be error msg, since there is one unknown parameter", loggerOutput.contains(unknownParamKey));
+        assertTrue("There should be error msg containing the correct command name", loggerOutput.contains(FAKE_CMD_NAME));
+    }
+
+    @Test
+    public void testHandleWithoutAuthorization() throws ResourceAllocationException {
+        final short type = Account.ACCOUNT_TYPE_NORMAL;
+        driveAuthTest(type);
+
+        // Assert
+        assertTrue("There should be error msg, since there is one unauthorized parameter", loggerOutput.contains("paramWithRole"));
+        assertTrue("There should be error msg containing the correct command name", loggerOutput.contains(FAKE_CMD_ROLE_NAME));
+    }
+
+    @Test
+    public void testHandleWithAuthorization() throws ResourceAllocationException {
+        final short type = Account.ACCOUNT_TYPE_ADMIN;
+        driveAuthTest(type);
+
+        // Assert
+        assertEquals("There should be no errors since parameters have authorization", null, loggerOutput);
+    }
+
+    protected void driveAuthTest(final short type) {
+        // Prepare
+        final BaseCmd cmd = new FakeCmdWithRoleAdmin();
+        final Account account = mock(Account.class);
+        ((FakeCmdWithRoleAdmin)cmd).account = account;
+        when(account.getType()).thenReturn(type);
+        final Map<String, String> params = new HashMap<String, String>();
+        params.put(ApiConstants.COMMAND, "");
+        params.put("addedParam", "");
+        params.put("paramWithRole", "");
+
+        // Execute
+        driveTest(cmd, params);
+    }
+}
+
+
+@APICommand(name=ParamGenericValidationWorkerTest.FAKE_CMD_NAME, responseObject=BaseResponse.class)
+class FakeCmd extends BaseCmd {
+
+    @Parameter(name = "addedParam")
+    private String addedParam;
+
+    public Account account;
+
+    @Override
+    protected Account getCurrentContextAccount() {
+        return account;
+    }
+
+    //
+    // Dummy methods for mere correct compilation
+    //
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException,
+            NetworkRuleConflictException {
+    }
+    @Override
+    public String getCommandName() {
+        return null;
+    }
+    @Override
+    public long getEntityOwnerId() {
+        return 0;
+    }
+}
+
+@APICommand(name=ParamGenericValidationWorkerTest.FAKE_CMD_ROLE_NAME, responseObject=BaseResponse.class)
+class FakeCmdWithRoleAdmin extends FakeCmd {
+
+    @Parameter(name = "paramWithRole", authorized = {RoleType.Admin})
+    private String paramWithRole;
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/test/com/cloud/api/dispatch/ParamProcessWorkerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/api/dispatch/ParamProcessWorkerTest.java b/server/test/com/cloud/api/dispatch/ParamProcessWorkerTest.java
new file mode 100644
index 0000000..12051a6
--- /dev/null
+++ b/server/test/com/cloud/api/dispatch/ParamProcessWorkerTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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 com.cloud.api.dispatch;
+
+import java.util.HashMap;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.context.CallContext;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+import com.cloud.user.AccountManager;
+import com.cloud.user.User;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ParamProcessWorkerTest {
+
+    @Mock
+    protected AccountManager accountManager;
+
+    protected ParamProcessWorker paramProcessWorker;
+
+    public static class TestCmd extends BaseCmd {
+
+        @Parameter(name = "strparam1")
+        String strparam1;
+
+        @Parameter(name = "intparam1", type = CommandType.INTEGER)
+        int intparam1;
+
+        @Parameter(name = "boolparam1", type = CommandType.BOOLEAN)
+        boolean boolparam1;
+
+        @Override
+        public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+            ResourceAllocationException, NetworkRuleConflictException {
+            // well documented nothing
+        }
+
+        @Override
+        public String getCommandName() {
+            return "test";
+        }
+
+        @Override
+        public long getEntityOwnerId() {
+            return 0;
+        }
+
+    }
+
+    @Before
+    public void setup() {
+        CallContext.register(Mockito.mock(User.class), Mockito.mock(Account.class));
+        paramProcessWorker = new ParamProcessWorker();
+        paramProcessWorker._accountMgr = accountManager;
+    }
+
+    @After
+    public void cleanup() {
+        CallContext.unregister();
+    }
+
+    @Test
+    public void processParameters() {
+        final HashMap<String, String> params = new HashMap<String, String>();
+        params.put("strparam1", "foo");
+        params.put("intparam1", "100");
+        params.put("boolparam1", "true");
+        final TestCmd cmd = new TestCmd();
+        paramProcessWorker.processParameters(cmd, params);
+        Assert.assertEquals("foo", cmd.strparam1);
+        Assert.assertEquals(100, cmd.intparam1);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/test/com/cloud/api/dispatch/SpecificCmdValidationWorkerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/api/dispatch/SpecificCmdValidationWorkerTest.java b/server/test/com/cloud/api/dispatch/SpecificCmdValidationWorkerTest.java
new file mode 100644
index 0000000..4ae7200
--- /dev/null
+++ b/server/test/com/cloud/api/dispatch/SpecificCmdValidationWorkerTest.java
@@ -0,0 +1,48 @@
+// 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 com.cloud.api.dispatch;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import org.apache.cloudstack.api.BaseCmd;
+
+import com.cloud.exception.ResourceAllocationException;
+
+public class SpecificCmdValidationWorkerTest {
+
+    @Test
+    public void testHandle() throws ResourceAllocationException {
+        // Prepare
+        final BaseCmd cmd = mock(BaseCmd.class);
+        final Map<String, String> params = new HashMap<String, String>();
+
+        // Execute
+        final SpecificCmdValidationWorker worker = new SpecificCmdValidationWorker();
+
+        worker.handle(new DispatchTask(cmd, params));
+
+        // Assert
+        verify(cmd, times(1)).validateSpecificParameters(params);
+    }
+}


[04/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-6194: Failed to increase Shared network IP Range

Submitted-by:Saksham Srivastava <sa...@citrix.com>


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

Branch: refs/heads/resize-root
Commit: b8413b9413eb39053c378309195469a4d5d4fec0
Parents: f291951
Author: Marcus Sorensen <ma...@betterservers.com>
Authored: Tue Mar 4 22:19:08 2014 -0700
Committer: Marcus Sorensen <ma...@betterservers.com>
Committed: Tue Mar 4 22:19:08 2014 -0700

----------------------------------------------------------------------
 server/src/com/cloud/configuration/ConfigurationManagerImpl.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8413b94/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 1c1da1f..283aeea 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -2555,7 +2555,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
                 List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(network.getId());
                 if (vlans != null && vlans.size() > 0) {
                     VlanVO vlan = vlans.get(0);
-                    if (vlanId == null) {
+                    if (vlanId == null || vlanId.contains(Vlan.UNTAGGED)) {
                         vlanId = vlan.getVlanTag();
                     } else if (!NetUtils.isSameIsolationId(vlan.getVlanTag(), vlanId)) {
                         throw new InvalidParameterValueException("there is already one vlan " + vlan.getVlanTag() + " on network :" + +network.getId()


[11/50] [abbrv] CLOUDSTACK-5920:Add interface to ControlledEntity to return IAM entity type.

Posted by ml...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotVO.java b/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotVO.java
index 79fd274..042b276 100644
--- a/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotVO.java
+++ b/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotVO.java
@@ -33,6 +33,7 @@ import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotOptions;
 
 import com.cloud.utils.db.GenericDao;
@@ -133,10 +134,10 @@ public class VMSnapshotVO implements VMSnapshot {
         this.accountId = accountId;
         this.domainId = domainId;
         this.vmId = vmId;
-        this.state = State.Allocated;
+        state = State.Allocated;
         this.description = description;
-        this.name = vmSnapshotName;
-        this.displayName = vsDisplayName;
+        name = vmSnapshotName;
+        displayName = vsDisplayName;
         this.type = type;
         this.current = current;
     }
@@ -227,7 +228,7 @@ public class VMSnapshotVO implements VMSnapshot {
 
     @Override
     public void incrUpdatedCount() {
-        this.updatedCount++;
+        updatedCount++;
     }
 
     @Override
@@ -243,4 +244,9 @@ public class VMSnapshotVO implements VMSnapshot {
     public void setRemoved(Date removed) {
         this.removed = removed;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.VMSnapshot;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/org/apache/cloudstack/affinity/AffinityGroupVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/affinity/AffinityGroupVO.java b/engine/schema/src/org/apache/cloudstack/affinity/AffinityGroupVO.java
index 86a2e6a..b9fda8e 100644
--- a/engine/schema/src/org/apache/cloudstack/affinity/AffinityGroupVO.java
+++ b/engine/schema/src/org/apache/cloudstack/affinity/AffinityGroupVO.java
@@ -28,6 +28,7 @@ import javax.persistence.Id;
 import javax.persistence.Table;
 
 import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.acl.IAMEntityType;
 
 @Entity
 @Table(name = ("affinity_group"))
@@ -60,7 +61,7 @@ public class AffinityGroupVO implements AffinityGroup {
     ControlledEntity.ACLType aclType;
 
     public AffinityGroupVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public AffinityGroupVO(String name, String type, String description, long domainId, long accountId, ACLType aclType) {
@@ -68,7 +69,7 @@ public class AffinityGroupVO implements AffinityGroup {
         this.description = description;
         this.domainId = domainId;
         this.accountId = accountId;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
         this.type = type;
         this.aclType = aclType;
     }
@@ -100,7 +101,7 @@ public class AffinityGroupVO implements AffinityGroup {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
@@ -124,4 +125,9 @@ public class AffinityGroupVO implements AffinityGroup {
         return buf.toString();
     }
 
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.AffinityGroup;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java
index 19d608b..7403d62 100644
--- a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java
+++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java
@@ -37,6 +37,8 @@ import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.utils.db.Encrypt;
 import com.cloud.utils.db.GenericDao;
@@ -179,28 +181,28 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
     public VMEntityVO(long id, long serviceOfferingId, String name, String instanceName, Type type, Long vmTemplateId, HypervisorType hypervisorType, long guestOSId,
             long domainId, long accountId, boolean haEnabled, Long diskOfferingId) {
         this.id = id;
-        this.hostName = name != null ? name : this.uuid;
+        hostName = name != null ? name : uuid;
         if (vmTemplateId != null) {
-            this.templateId = vmTemplateId;
+            templateId = vmTemplateId;
         }
         this.instanceName = instanceName;
         this.type = type;
         this.guestOSId = guestOSId;
         this.haEnabled = haEnabled;
-        this.vncPassword = Long.toHexString(new Random().nextLong());
-        this.state = State.Stopped;
+        vncPassword = Long.toHexString(new Random().nextLong());
+        state = State.Stopped;
         this.accountId = accountId;
         this.domainId = domainId;
         this.serviceOfferingId = serviceOfferingId;
         this.hypervisorType = hypervisorType;
-        this.limitCpuUse = false;
+        limitCpuUse = false;
         this.diskOfferingId = diskOfferingId;
     }
 
     public VMEntityVO(long id, long serviceOfferingId, String name, String instanceName, Type type, Long vmTemplateId, HypervisorType hypervisorType, long guestOSId,
             long domainId, long accountId, boolean haEnabled, boolean limitResourceUse) {
         this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, haEnabled, null);
-        this.limitCpuUse = limitResourceUse;
+        limitCpuUse = limitResourceUse;
     }
 
     protected VMEntityVO() {
@@ -316,11 +318,11 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
     }
 
     public Date getProxyAssignTime() {
-        return this.proxyAssignTime;
+        return proxyAssignTime;
     }
 
     public void setProxyAssignTime(Date time) {
-        this.proxyAssignTime = time;
+        proxyAssignTime = time;
     }
 
     @Override
@@ -396,7 +398,7 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
     }
 
     public void setPodId(long podId) {
-        this.podIdToDeployIn = podId;
+        podIdToDeployIn = podId;
     }
 
     public void setPrivateMacAddress(String privateMacAddress) {
@@ -404,7 +406,7 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
     }
 
     public void setDataCenterId(long dataCenterId) {
-        this.dataCenterIdToDeployIn = dataCenterId;
+        dataCenterIdToDeployIn = dataCenterId;
     }
 
     public boolean isRemoved() {
@@ -420,7 +422,7 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
     }
 
     public String getReservationId() {
-        return this.reservationId;
+        return reservationId;
     }
 
     @Override
@@ -535,4 +537,8 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
         this.vmReservation = vmReservation;
     }
 
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.VirtualMachine;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleVO.java b/engine/schema/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleVO.java
index b7b720d..a37fec2 100644
--- a/engine/schema/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleVO.java
+++ b/engine/schema/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleVO.java
@@ -28,6 +28,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.region.ha.GlobalLoadBalancerRule;
 
 @Entity
@@ -74,21 +76,21 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule {
     GlobalLoadBalancerRule.State state;
 
     public GlobalLoadBalancerRuleVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public GlobalLoadBalancerRuleVO(String name, String description, String gslbDomain, String algorithm, String persistence, String serviceType, int regionId,
             long accountId, long domainId, State state) {
         this.name = name;
         this.description = description;
-        this.region = regionId;
+        region = regionId;
         this.algorithm = algorithm;
         this.gslbDomain = gslbDomain;
         this.persistence = persistence;
         this.accountId = accountId;
         this.domainId = domainId;
         this.serviceType = serviceType;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
         this.state = state;
     }
 
@@ -163,7 +165,7 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
@@ -187,4 +189,9 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule {
     public GlobalLoadBalancerRule.State getState() {
         return state;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.GlobalLoadBalancerRule;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
index 503d372..8db21cc 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
@@ -25,6 +25,7 @@ import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
@@ -436,4 +437,8 @@ public class TemplateObject implements TemplateInfo {
         return true;
     }
 
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.VirtualMachineTemplate;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
index 669a075..2ff24ca 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
@@ -24,6 +24,7 @@ import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
@@ -380,4 +381,9 @@ public class SnapshotObject implements SnapshotInfo {
         }
         return true;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Snapshot;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java
index ed6b509..fd90ac9 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java
@@ -23,6 +23,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
 import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
 import org.apache.cloudstack.storage.image.datastore.ImageStoreInfo;
@@ -285,4 +286,8 @@ public class TemplateEntityImpl implements TemplateEntity {
         return 0;
     }
 
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.VirtualMachineTemplate;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotEntityImpl.java b/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotEntityImpl.java
index fb3ec48..848b165 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotEntityImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotEntityImpl.java
@@ -21,6 +21,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.engine.cloud.entity.api.SnapshotEntity;
 
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
@@ -183,4 +184,8 @@ public class SnapshotEntityImpl implements SnapshotEntity {
         return null;
     }
 
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Snapshot;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
index 1653dcb..1f05be2 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
@@ -22,9 +22,7 @@ import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 
-import com.cloud.storage.DiskOfferingVO;
-import com.cloud.storage.dao.DiskOfferingDao;
-import com.cloud.vm.VirtualMachine;
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
@@ -43,9 +41,11 @@ import com.cloud.agent.api.to.DataTO;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.offering.DiskOffering.DiskCacheMode;
 import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.storage.Volume;
 import com.cloud.storage.VolumeVO;
+import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.utils.component.ComponentContext;
 import com.cloud.utils.exception.CloudRuntimeException;
@@ -53,6 +53,7 @@ import com.cloud.utils.fsm.NoTransitionException;
 import com.cloud.utils.fsm.StateMachine2;
 import com.cloud.utils.storage.encoding.EncodingType;
 import com.cloud.vm.VMInstanceVO;
+import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.dao.VMInstanceDao;
 
 public class VolumeObject implements VolumeInfo {
@@ -89,7 +90,7 @@ public class VolumeObject implements VolumeInfo {
 
     @Override
     public String getAttachedVmName() {
-        Long vmId = this.volumeVO.getInstanceId();
+        Long vmId = volumeVO.getInstanceId();
         if (vmId != null) {
             VMInstanceVO vm = vmInstanceDao.findById(vmId);
 
@@ -103,7 +104,7 @@ public class VolumeObject implements VolumeInfo {
 
     @Override
     public VirtualMachine getAttachedVM() {
-        Long vmId = this.volumeVO.getInstanceId();
+        Long vmId = volumeVO.getInstanceId();
         if (vmId != null) {
             VMInstanceVO vm = vmInstanceDao.findById(vmId);
             return vm;
@@ -179,7 +180,7 @@ public class VolumeObject implements VolumeInfo {
             result = _volStateMachine.transitTo(volumeVO, event, null, volumeDao);
             volumeVO = volumeDao.findById(volumeVO.getId());
         } catch (NoTransitionException e) {
-            String errorMessage = "Failed to transit volume: " + this.getVolumeId() + ", due to: " + e.toString();
+            String errorMessage = "Failed to transit volume: " + getVolumeId() + ", due to: " + e.toString();
             s_logger.debug(errorMessage);
             throw new CloudRuntimeException(errorMessage);
         }
@@ -246,25 +247,25 @@ public class VolumeObject implements VolumeInfo {
 
     @Override
     public long getId() {
-        return this.volumeVO.getId();
+        return volumeVO.getId();
     }
 
     @Override
     public boolean isAttachedVM() {
-        return (this.volumeVO.getInstanceId() == null) ? false : true;
+        return (volumeVO.getInstanceId() == null) ? false : true;
     }
 
     @Override
     public String getUri() {
-        if (this.dataStore == null) {
+        if (dataStore == null) {
             throw new CloudRuntimeException("datastore must be set before using this object");
         }
-        DataObjectInStore obj = objectInStoreMgr.findObject(this.volumeVO.getId(), DataObjectType.VOLUME, this.dataStore.getId(), this.dataStore.getRole());
+        DataObjectInStore obj = objectInStoreMgr.findObject(volumeVO.getId(), DataObjectType.VOLUME, dataStore.getId(), dataStore.getRole());
         if (obj.getState() != ObjectInDataStoreStateMachine.State.Ready) {
-            return this.dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.SIZE + "=" + this.volumeVO.getSize() + "&" +
-                EncodingType.NAME + "=" + this.volumeVO.getName();
+            return dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.SIZE + "=" + volumeVO.getSize() + "&" +
+                EncodingType.NAME + "=" + volumeVO.getName();
         } else {
-            return this.dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.PATH + "=" + obj.getInstallPath();
+            return dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.PATH + "=" + obj.getInstallPath();
         }
     }
 
@@ -275,19 +276,19 @@ public class VolumeObject implements VolumeInfo {
 
     @Override
     public void processEvent(ObjectInDataStoreStateMachine.Event event) {
-        if (this.dataStore == null) {
+        if (dataStore == null) {
             return;
         }
         try {
             Volume.Event volEvent = null;
-            if (this.dataStore.getRole() == DataStoreRole.ImageCache) {
+            if (dataStore.getRole() == DataStoreRole.ImageCache) {
                 objectInStoreMgr.update(this, event);
                 return;
             }
-            if (this.dataStore.getRole() == DataStoreRole.Image) {
+            if (dataStore.getRole() == DataStoreRole.Image) {
                 objectInStoreMgr.update(this, event);
-                if (this.volumeVO.getState() == Volume.State.Migrating || this.volumeVO.getState() == Volume.State.Copying ||
-                    this.volumeVO.getState() == Volume.State.Uploaded || this.volumeVO.getState() == Volume.State.Expunged) {
+                if (volumeVO.getState() == Volume.State.Migrating || volumeVO.getState() == Volume.State.Copying ||
+                    volumeVO.getState() == Volume.State.Uploaded || volumeVO.getState() == Volume.State.Expunged) {
                     return;
                 }
                 if (event == ObjectInDataStoreStateMachine.Event.CreateOnlyRequested) {
@@ -316,14 +317,14 @@ public class VolumeObject implements VolumeInfo {
             } else if (event == ObjectInDataStoreStateMachine.Event.ResizeRequested) {
                 volEvent = Volume.Event.ResizeRequested;
             }
-            this.stateTransit(volEvent);
+            stateTransit(volEvent);
         } catch (Exception e) {
             s_logger.debug("Failed to update state", e);
             throw new CloudRuntimeException("Failed to update state:" + e.toString());
         } finally {
             // in case of OperationFailed, expunge the entry
             if (event == ObjectInDataStoreStateMachine.Event.OperationFailed &&
-                (this.volumeVO.getState() != Volume.State.Copying && this.volumeVO.getState() != Volume.State.Uploaded)) {
+                (volumeVO.getState() != Volume.State.Copying && volumeVO.getState() != Volume.State.Uploaded)) {
                 objectInStoreMgr.deleteIfNotReady(this);
             }
         }
@@ -347,25 +348,25 @@ public class VolumeObject implements VolumeInfo {
 
     @Override
     public String getName() {
-        return this.volumeVO.getName();
+        return volumeVO.getName();
     }
 
     @Override
     public Long getInstanceId() {
-        return this.volumeVO.getInstanceId();
+        return volumeVO.getInstanceId();
     }
 
     @Override
     public String getFolder() {
-        return this.volumeVO.getFolder();
+        return volumeVO.getFolder();
     }
 
     @Override
     public String getPath() {
-        if (this.dataStore.getRole() == DataStoreRole.Primary) {
-            return this.volumeVO.getPath();
+        if (dataStore.getRole() == DataStoreRole.Primary) {
+            return volumeVO.getPath();
         } else {
-            DataObjectInStore objInStore = this.objectInStoreMgr.findObject(this, dataStore);
+            DataObjectInStore objInStore = objectInStoreMgr.findObject(this, dataStore);
             if (objInStore != null) {
                 return objInStore.getInstallPath();
             } else {
@@ -376,121 +377,121 @@ public class VolumeObject implements VolumeInfo {
 
     @Override
     public Long getPodId() {
-        return this.volumeVO.getPodId();
+        return volumeVO.getPodId();
     }
 
     @Override
     public long getDataCenterId() {
-        return this.volumeVO.getDataCenterId();
+        return volumeVO.getDataCenterId();
     }
 
     @Override
     public Type getVolumeType() {
-        return this.volumeVO.getVolumeType();
+        return volumeVO.getVolumeType();
     }
 
     @Override
     public Long getPoolId() {
-        return this.volumeVO.getPoolId();
+        return volumeVO.getPoolId();
     }
 
     @Override
     public Date getAttached() {
-        return this.volumeVO.getAttached();
+        return volumeVO.getAttached();
     }
 
     @Override
     public Long getDeviceId() {
-        return this.volumeVO.getDeviceId();
+        return volumeVO.getDeviceId();
     }
 
     @Override
     public Date getCreated() {
-        return this.volumeVO.getCreated();
+        return volumeVO.getCreated();
     }
 
     @Override
     public Long getDiskOfferingId() {
-        return this.volumeVO.getDiskOfferingId();
+        return volumeVO.getDiskOfferingId();
     }
 
     @Override
     public String getChainInfo() {
-        return this.volumeVO.getChainInfo();
+        return volumeVO.getChainInfo();
     }
 
     @Override
     public boolean isRecreatable() {
-        return this.volumeVO.isRecreatable();
+        return volumeVO.isRecreatable();
     }
 
     @Override
     public long getUpdatedCount() {
-        return this.volumeVO.getUpdatedCount();
+        return volumeVO.getUpdatedCount();
     }
 
     @Override
     public void incrUpdatedCount() {
-        this.volumeVO.incrUpdatedCount();
+        volumeVO.incrUpdatedCount();
     }
 
     @Override
     public Date getUpdated() {
-        return this.volumeVO.getUpdated();
+        return volumeVO.getUpdated();
     }
 
     @Override
     public String getReservationId() {
-        return this.volumeVO.getReservationId();
+        return volumeVO.getReservationId();
     }
 
     @Override
     public void setReservationId(String reserv) {
-        this.volumeVO.setReservationId(reserv);
+        volumeVO.setReservationId(reserv);
     }
 
     @Override
     public long getAccountId() {
-        return this.volumeVO.getAccountId();
+        return volumeVO.getAccountId();
     }
 
     @Override
     public long getDomainId() {
-        return this.volumeVO.getDomainId();
+        return volumeVO.getDomainId();
     }
 
     @Override
     public Long getTemplateId() {
-        return this.volumeVO.getTemplateId();
+        return volumeVO.getTemplateId();
     }
 
     @Override
     public void addPayload(Object data) {
-        this.payload = data;
+        payload = data;
     }
 
     @Override
     public Object getpayload() {
-        return this.payload;
+        return payload;
     }
 
     public VolumeVO getVolume() {
-        return this.volumeVO;
+        return volumeVO;
     }
 
     @Override
     public HypervisorType getHypervisorType() {
-        return this.volumeDao.getHypervisorType(this.volumeVO.getId());
+        return volumeDao.getHypervisorType(volumeVO.getId());
     }
 
     @Override
     public Long getLastPoolId() {
-        return this.volumeVO.getLastPoolId();
+        return volumeVO.getLastPoolId();
     }
 
     @Override
     public DataTO getTO() {
-        DataTO to = this.getDataStore().getDriver().getTO(this);
+        DataTO to = getDataStore().getDriver().getTO(this);
         if (to == null) {
             to = new VolumeObjectTO(this);
         }
@@ -500,10 +501,10 @@ public class VolumeObject implements VolumeInfo {
     @Override
     public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer) {
         try {
-            if (this.dataStore.getRole() == DataStoreRole.Primary) {
+            if (dataStore.getRole() == DataStoreRole.Primary) {
                 if (answer instanceof CopyCmdAnswer) {
                     CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer;
-                    VolumeVO vol = this.volumeDao.findById(this.getId());
+                    VolumeVO vol = volumeDao.findById(getId());
                     VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData();
                     vol.setPath(newVol.getPath());
                     if (newVol.getSize() != null) {
@@ -512,17 +513,17 @@ public class VolumeObject implements VolumeInfo {
                     if (newVol.getFormat() != null) {
                         vol.setFormat(newVol.getFormat());
                     }
-                    vol.setPoolId(this.getDataStore().getId());
+                    vol.setPoolId(getDataStore().getId());
                     volumeDao.update(vol.getId(), vol);
                 } else if (answer instanceof CreateObjectAnswer) {
                     CreateObjectAnswer createAnswer = (CreateObjectAnswer)answer;
                     VolumeObjectTO newVol = (VolumeObjectTO)createAnswer.getData();
-                    VolumeVO vol = this.volumeDao.findById(this.getId());
+                    VolumeVO vol = volumeDao.findById(getId());
                     vol.setPath(newVol.getPath());
                     if (newVol.getSize() != null) {
                         vol.setSize(newVol.getSize());
                     }
-                    vol.setPoolId(this.getDataStore().getId());
+                    vol.setPoolId(getDataStore().getId());
                     if (newVol.getFormat() != null) {
                         vol.setFormat(newVol.getFormat());
                     }
@@ -532,19 +533,19 @@ public class VolumeObject implements VolumeInfo {
                 // image store or imageCache store
                 if (answer instanceof DownloadAnswer) {
                     DownloadAnswer dwdAnswer = (DownloadAnswer)answer;
-                    VolumeDataStoreVO volStore = this.volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId());
+                    VolumeDataStoreVO volStore = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
                     volStore.setInstallPath(dwdAnswer.getInstallPath());
                     volStore.setChecksum(dwdAnswer.getCheckSum());
-                    this.volumeStoreDao.update(volStore.getId(), volStore);
+                    volumeStoreDao.update(volStore.getId(), volStore);
                 } else if (answer instanceof CopyCmdAnswer) {
                     CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer;
-                    VolumeDataStoreVO volStore = this.volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId());
+                    VolumeDataStoreVO volStore = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
                     VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData();
                     volStore.setInstallPath(newVol.getPath());
                     if (newVol.getSize() != null) {
                         volStore.setSize(newVol.getSize());
                     }
-                    this.volumeStoreDao.update(volStore.getId(), volStore);
+                    volumeStoreDao.update(volStore.getId(), volStore);
                 }
             }
         } catch (RuntimeException ex) {
@@ -559,12 +560,12 @@ public class VolumeObject implements VolumeInfo {
 
     @Override
     public void incRefCount() {
-        if (this.dataStore == null) {
+        if (dataStore == null) {
             return;
         }
 
-        if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) {
-            VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId());
+        if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
+            VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
             store.incrRefCnt();
             store.setLastUpdated(new Date());
             volumeStoreDao.update(store.getId(), store);
@@ -573,11 +574,11 @@ public class VolumeObject implements VolumeInfo {
 
     @Override
     public void decRefCount() {
-        if (this.dataStore == null) {
+        if (dataStore == null) {
             return;
         }
-        if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) {
-            VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId());
+        if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
+            VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
             store.decrRefCnt();
             store.setLastUpdated(new Date());
             volumeStoreDao.update(store.getId(), store);
@@ -586,11 +587,11 @@ public class VolumeObject implements VolumeInfo {
 
     @Override
     public Long getRefCount() {
-        if (this.dataStore == null) {
+        if (dataStore == null) {
             return null;
         }
-        if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) {
-            VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId());
+        if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
+            VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
             return store.getRefCnt();
         }
         return null;
@@ -599,45 +600,45 @@ public class VolumeObject implements VolumeInfo {
     @Override
     public void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer answer) {
         try {
-            if (this.dataStore.getRole() == DataStoreRole.Primary) {
+            if (dataStore.getRole() == DataStoreRole.Primary) {
                 if (answer instanceof CopyCmdAnswer) {
                     CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer;
-                    VolumeVO vol = this.volumeDao.findById(this.getId());
+                    VolumeVO vol = volumeDao.findById(getId());
                     VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData();
                     vol.setPath(newVol.getPath());
                     if (newVol.getSize() != null) {
                         vol.setSize(newVol.getSize());
                     }
-                    vol.setPoolId(this.getDataStore().getId());
+                    vol.setPoolId(getDataStore().getId());
                     volumeDao.update(vol.getId(), vol);
                 } else if (answer instanceof CreateObjectAnswer) {
                     CreateObjectAnswer createAnswer = (CreateObjectAnswer)answer;
                     VolumeObjectTO newVol = (VolumeObjectTO)createAnswer.getData();
-                    VolumeVO vol = this.volumeDao.findById(this.getId());
+                    VolumeVO vol = volumeDao.findById(getId());
                     vol.setPath(newVol.getPath());
                     if (newVol.getSize() != null) {
                         vol.setSize(newVol.getSize());
                     }
-                    vol.setPoolId(this.getDataStore().getId());
+                    vol.setPoolId(getDataStore().getId());
                     volumeDao.update(vol.getId(), vol);
                 }
             } else {
                 // image store or imageCache store
                 if (answer instanceof DownloadAnswer) {
                     DownloadAnswer dwdAnswer = (DownloadAnswer)answer;
-                    VolumeDataStoreVO volStore = this.volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId());
+                    VolumeDataStoreVO volStore = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
                     volStore.setInstallPath(dwdAnswer.getInstallPath());
                     volStore.setChecksum(dwdAnswer.getCheckSum());
-                    this.volumeStoreDao.update(volStore.getId(), volStore);
+                    volumeStoreDao.update(volStore.getId(), volStore);
                 } else if (answer instanceof CopyCmdAnswer) {
                     CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer;
-                    VolumeDataStoreVO volStore = this.volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId());
+                    VolumeDataStoreVO volStore = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
                     VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData();
                     volStore.setInstallPath(newVol.getPath());
                     if (newVol.getSize() != null) {
                         volStore.setSize(newVol.getSize());
                     }
-                    this.volumeStoreDao.update(volStore.getId(), volStore);
+                    volumeStoreDao.update(volStore.getId(), volStore);
                 }
             }
         } catch (RuntimeException ex) {
@@ -652,7 +653,7 @@ public class VolumeObject implements VolumeInfo {
 
     @Override
     public ImageFormat getFormat() {
-        return this.volumeVO.getFormat();
+        return volumeVO.getFormat();
     }
 
     @Override
@@ -665,6 +666,11 @@ public class VolumeObject implements VolumeInfo {
 
     @Override
     public Long getVmSnapshotChainSize() {
-        return this.volumeVO.getVmSnapshotChainSize();
+        return volumeVO.getVmSnapshotChainSize();
+    }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Volume;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/server/src/com/cloud/api/query/vo/AffinityGroupJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/AffinityGroupJoinVO.java b/server/src/com/cloud/api/query/vo/AffinityGroupJoinVO.java
index 047d1b3..f659ed9 100644
--- a/server/src/com/cloud/api/query/vo/AffinityGroupJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/AffinityGroupJoinVO.java
@@ -24,6 +24,7 @@ import javax.persistence.Id;
 import javax.persistence.Table;
 
 import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.acl.IAMEntityType;
 
 import com.cloud.vm.VirtualMachine;
 
@@ -192,4 +193,9 @@ public class AffinityGroupJoinVO extends BaseViewVO implements ControlledViewEnt
         return aclType;
     }
 
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.AffinityGroup;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/server/src/com/cloud/api/query/vo/DomainRouterJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/DomainRouterJoinVO.java b/server/src/com/cloud/api/query/vo/DomainRouterJoinVO.java
index 72c7222..c0c07eb 100644
--- a/server/src/com/cloud/api/query/vo/DomainRouterJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/DomainRouterJoinVO.java
@@ -26,6 +26,8 @@ import javax.persistence.Enumerated;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.network.Network.GuestType;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.router.VirtualRouter;
@@ -510,4 +512,10 @@ public class DomainRouterJoinVO extends BaseViewVO implements ControlledViewEnti
     public VirtualRouter.Role getRole() {
         return role;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.VirtualMachine;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/server/src/com/cloud/api/query/vo/EventJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/EventJoinVO.java b/server/src/com/cloud/api/query/vo/EventJoinVO.java
index 6571269..696221d 100644
--- a/server/src/com/cloud/api/query/vo/EventJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/EventJoinVO.java
@@ -25,6 +25,8 @@ import javax.persistence.Enumerated;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.event.Event.State;
 import com.cloud.utils.db.GenericDao;
 
@@ -223,4 +225,10 @@ public class EventJoinVO extends BaseViewVO implements ControlledViewEntity {
     public boolean getDisplayEvent() {
         return displayEvent;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Event;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/server/src/com/cloud/api/query/vo/InstanceGroupJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/InstanceGroupJoinVO.java b/server/src/com/cloud/api/query/vo/InstanceGroupJoinVO.java
index cd1ba12..38b7229 100644
--- a/server/src/com/cloud/api/query/vo/InstanceGroupJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/InstanceGroupJoinVO.java
@@ -23,6 +23,8 @@ import javax.persistence.Entity;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.utils.db.GenericDao;
 
 @Entity
@@ -156,4 +158,10 @@ public class InstanceGroupJoinVO extends BaseViewVO implements ControlledViewEnt
     public Date getCreated() {
         return created;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.InstanceGroup;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/server/src/com/cloud/api/query/vo/ProjectInvitationJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/ProjectInvitationJoinVO.java b/server/src/com/cloud/api/query/vo/ProjectInvitationJoinVO.java
index 34f3929..7ff1779 100644
--- a/server/src/com/cloud/api/query/vo/ProjectInvitationJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/ProjectInvitationJoinVO.java
@@ -25,6 +25,8 @@ import javax.persistence.Enumerated;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.projects.ProjectInvitation.State;
 import com.cloud.utils.db.GenericDao;
 
@@ -160,4 +162,10 @@ public class ProjectInvitationJoinVO extends BaseViewVO implements ControlledVie
     public String getDomainPath() {
         return domainPath;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.ProjectInvitation;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/server/src/com/cloud/api/query/vo/ResourceTagJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/ResourceTagJoinVO.java b/server/src/com/cloud/api/query/vo/ResourceTagJoinVO.java
index 72f9b77..1dca46b 100644
--- a/server/src/com/cloud/api/query/vo/ResourceTagJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/ResourceTagJoinVO.java
@@ -23,6 +23,8 @@ import javax.persistence.Enumerated;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.server.ResourceTag.ResourceObjectType;
 
 @Entity
@@ -178,4 +180,10 @@ public class ResourceTagJoinVO extends BaseViewVO implements ControlledViewEntit
     public String getCustomer() {
         return customer;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.ResourceTag;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/server/src/com/cloud/api/query/vo/SecurityGroupJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/SecurityGroupJoinVO.java b/server/src/com/cloud/api/query/vo/SecurityGroupJoinVO.java
index d51d111..cf2df98 100644
--- a/server/src/com/cloud/api/query/vo/SecurityGroupJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/SecurityGroupJoinVO.java
@@ -23,6 +23,8 @@ import javax.persistence.Enumerated;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.network.security.SecurityRule.SecurityRuleType;
 import com.cloud.server.ResourceTag.ResourceObjectType;
 
@@ -302,4 +304,10 @@ public class SecurityGroupJoinVO extends BaseViewVO implements ControlledViewEnt
     public String getTagCustomer() {
         return tagCustomer;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.SecurityGroup;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/server/src/com/cloud/api/query/vo/TemplateJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/TemplateJoinVO.java b/server/src/com/cloud/api/query/vo/TemplateJoinVO.java
index c096279..21c0a2e 100644
--- a/server/src/com/cloud/api/query/vo/TemplateJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/TemplateJoinVO.java
@@ -27,7 +27,7 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 
-import com.cloud.template.VirtualMachineTemplate.State;
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
@@ -35,6 +35,7 @@ import com.cloud.server.ResourceTag.ResourceObjectType;
 import com.cloud.storage.ScopeType;
 import com.cloud.storage.Storage;
 import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
+import com.cloud.template.VirtualMachineTemplate.State;
 import com.cloud.utils.db.GenericDao;
 
 @Entity
@@ -539,4 +540,10 @@ public class TemplateJoinVO extends BaseViewVO implements ControlledViewEntity {
     }
 
     public State getTemplateState() { return templateState; }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.VirtualMachineTemplate;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/UserVmJoinVO.java b/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
index 2df49ec..302b4ec 100644
--- a/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
@@ -28,6 +28,8 @@ import javax.persistence.Id;
 import javax.persistence.Table;
 import javax.persistence.Transient;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.network.Network.GuestType;
 import com.cloud.network.Networks.TrafficType;
@@ -909,4 +911,10 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity {
     public String getDetailValue() {
         return detailValue;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.VirtualMachine;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/server/src/com/cloud/api/query/vo/VolumeJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/VolumeJoinVO.java b/server/src/com/cloud/api/query/vo/VolumeJoinVO.java
index 1d1b37d..ce26c1f 100644
--- a/server/src/com/cloud/api/query/vo/VolumeJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/VolumeJoinVO.java
@@ -27,6 +27,8 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.server.ResourceTag.ResourceObjectType;
 import com.cloud.storage.Storage;
@@ -573,4 +575,10 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity {
     public String getChainInfo() {
         return chainInfo;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Volume;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/server/src/com/cloud/api/response/SecurityGroupResultObject.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/response/SecurityGroupResultObject.java b/server/src/com/cloud/api/response/SecurityGroupResultObject.java
index 9697495..66ba487 100644
--- a/server/src/com/cloud/api/response/SecurityGroupResultObject.java
+++ b/server/src/com/cloud/api/response/SecurityGroupResultObject.java
@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.api.InternalIdentity;
 
 import com.cloud.api.ApiDBUtils;
@@ -63,7 +64,7 @@ public class SecurityGroupResultObject implements ControlledEntity, InternalIden
         this.domainId = domainId;
         this.accountId = accountId;
         this.accountName = accountName;
-        this.securityGroupRules = ingressRules;
+        securityGroupRules = ingressRules;
     }
 
     @Override
@@ -209,4 +210,9 @@ public class SecurityGroupResultObject implements ControlledEntity, InternalIden
         }
         return resultObjects;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.SecurityGroup;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/server/src/com/cloud/network/vpc/PrivateGatewayProfile.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/PrivateGatewayProfile.java b/server/src/com/cloud/network/vpc/PrivateGatewayProfile.java
index e183cdb..b912e22 100644
--- a/server/src/com/cloud/network/vpc/PrivateGatewayProfile.java
+++ b/server/src/com/cloud/network/vpc/PrivateGatewayProfile.java
@@ -16,6 +16,8 @@
 // under the License.
 package com.cloud.network.vpc;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 public class PrivateGatewayProfile implements PrivateGateway {
     VpcGateway vpcGateway;
     long physicalNetworkId;
@@ -110,4 +112,8 @@ public class PrivateGatewayProfile implements PrivateGateway {
         return vpcGateway.getNetworkACLId();
     }
 
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.VpcGateway;
+    }
 }


[12/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-5920:Add interface to ControlledEntity to return IAM
entity type.


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

Branch: refs/heads/resize-root
Commit: d0ae4d9a9f7dc2ef39ee24f09c36f67ccb7502d7
Parents: b8413b9
Author: Min Chen <mi...@citrix.com>
Authored: Tue Mar 4 17:14:25 2014 -0800
Committer: Min Chen <mi...@citrix.com>
Committed: Wed Mar 5 09:40:55 2014 -0800

----------------------------------------------------------------------
 api/src/com/cloud/network/NetworkProfile.java   |   7 +
 .../cloud/network/vpc/StaticRouteProfile.java   |  28 ++--
 .../apache/cloudstack/acl/ControlledEntity.java |   1 +
 .../apache/cloudstack/acl/IAMEntityType.java    |  45 +++++
 .../firewall/CreateEgressFirewallRuleCmd.java   |  11 +-
 .../user/firewall/CreateFirewallRuleCmd.java    |  12 +-
 .../firewall/CreatePortForwardingRuleCmd.java   |  10 +-
 .../user/nat/CreateIpForwardingRuleCmd.java     |  18 +-
 .../src/com/cloud/network/addr/PublicIp.java    |   7 +
 .../cloud/network/rules/StaticNatRuleImpl.java  |  33 ++--
 engine/schema/src/com/cloud/event/EventVO.java  |  12 +-
 .../com/cloud/network/UserIpv6AddressVO.java    |  17 +-
 .../schema/src/com/cloud/network/VpnUserVO.java |  19 ++-
 .../com/cloud/network/as/AutoScalePolicyVO.java |   9 +-
 .../cloud/network/as/AutoScaleVmGroupVO.java    |  11 +-
 .../cloud/network/as/AutoScaleVmProfileVO.java  |  11 +-
 .../src/com/cloud/network/as/ConditionVO.java   |  11 +-
 .../src/com/cloud/network/dao/IPAddressVO.java  |  45 ++---
 .../cloud/network/dao/MonitoringServiceVO.java  |   7 +
 .../src/com/cloud/network/dao/NetworkVO.java    |  46 +++---
 .../cloud/network/dao/RemoteAccessVpnVO.java    |  17 +-
 .../network/dao/Site2SiteCustomerGatewayVO.java |   9 +-
 .../network/dao/Site2SiteVpnConnectionVO.java   |  14 +-
 .../network/dao/Site2SiteVpnGatewayVO.java      |  13 +-
 .../src/com/cloud/network/dao/SslCertVO.java    |  14 +-
 .../com/cloud/network/rules/FirewallRuleVO.java |  24 ++-
 .../cloud/network/security/SecurityGroupVO.java |  13 +-
 .../com/cloud/network/vpc/StaticRouteVO.java    |  15 +-
 .../src/com/cloud/network/vpc/VpcGatewayVO.java |  17 +-
 .../schema/src/com/cloud/network/vpc/VpcVO.java |  15 +-
 .../com/cloud/projects/ProjectInvitationVO.java |  17 +-
 .../src/com/cloud/storage/SnapshotVO.java       |  19 ++-
 .../src/com/cloud/storage/VMTemplateVO.java     |   6 +
 .../schema/src/com/cloud/storage/VolumeVO.java  | 101 ++++++------
 .../src/com/cloud/tags/ResourceTagVO.java       |  11 +-
 engine/schema/src/com/cloud/user/AccountVO.java |  16 +-
 .../schema/src/com/cloud/user/SSHKeyPairVO.java |   6 +
 .../src/com/cloud/vm/InstanceGroupVO.java       |  11 +-
 .../schema/src/com/cloud/vm/VMInstanceVO.java   |  28 ++--
 .../src/com/cloud/vm/dao/NicIpAliasVO.java      |  14 +-
 .../src/com/cloud/vm/dao/NicSecondaryIpVO.java  |   9 +-
 .../src/com/cloud/vm/snapshot/VMSnapshotVO.java |  14 +-
 .../cloudstack/affinity/AffinityGroupVO.java    |  12 +-
 .../engine/cloud/entity/api/db/VMEntityVO.java  |  28 ++--
 .../region/gslb/GlobalLoadBalancerRuleVO.java   |  15 +-
 .../storage/image/store/TemplateObject.java     |   5 +
 .../storage/snapshot/SnapshotObject.java        |   6 +
 .../storage/image/TemplateEntityImpl.java       |   5 +
 .../storage/snapshot/SnapshotEntityImpl.java    |   5 +
 .../cloudstack/storage/volume/VolumeObject.java | 164 ++++++++++---------
 .../cloud/api/query/vo/AffinityGroupJoinVO.java |   6 +
 .../cloud/api/query/vo/DomainRouterJoinVO.java  |   8 +
 .../src/com/cloud/api/query/vo/EventJoinVO.java |   8 +
 .../cloud/api/query/vo/InstanceGroupJoinVO.java |   8 +
 .../api/query/vo/ProjectInvitationJoinVO.java   |   8 +
 .../cloud/api/query/vo/ResourceTagJoinVO.java   |   8 +
 .../cloud/api/query/vo/SecurityGroupJoinVO.java |   8 +
 .../com/cloud/api/query/vo/TemplateJoinVO.java  |   9 +-
 .../com/cloud/api/query/vo/UserVmJoinVO.java    |   8 +
 .../com/cloud/api/query/vo/VolumeJoinVO.java    |   8 +
 .../api/response/SecurityGroupResultObject.java |   8 +-
 .../network/vpc/PrivateGatewayProfile.java      |   6 +
 62 files changed, 778 insertions(+), 318 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/api/src/com/cloud/network/NetworkProfile.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/NetworkProfile.java b/api/src/com/cloud/network/NetworkProfile.java
index 1b66c7c..3f57694 100644
--- a/api/src/com/cloud/network/NetworkProfile.java
+++ b/api/src/com/cloud/network/NetworkProfile.java
@@ -18,6 +18,8 @@ package com.cloud.network;
 
 import java.net.URI;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.Mode;
 import com.cloud.network.Networks.TrafficType;
@@ -275,4 +277,9 @@ public class NetworkProfile implements Network {
     public String getIp6Cidr() {
         return ip6Cidr;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Network;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/api/src/com/cloud/network/vpc/StaticRouteProfile.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpc/StaticRouteProfile.java b/api/src/com/cloud/network/vpc/StaticRouteProfile.java
index 05cff49..b38d5ea 100644
--- a/api/src/com/cloud/network/vpc/StaticRouteProfile.java
+++ b/api/src/com/cloud/network/vpc/StaticRouteProfile.java
@@ -16,6 +16,8 @@
 // under the License.
 package com.cloud.network.vpc;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 public class StaticRouteProfile implements StaticRoute {
     private long id;
     private String uuid;
@@ -31,18 +33,18 @@ public class StaticRouteProfile implements StaticRoute {
     String ipAddress;
 
     public StaticRouteProfile(StaticRoute staticRoute, VpcGateway gateway) {
-        this.id = staticRoute.getId();
-        this.uuid = staticRoute.getUuid();
-        this.targetCidr = staticRoute.getCidr();
-        this.accountId = staticRoute.getAccountId();
-        this.domainId = staticRoute.getDomainId();
-        this.gatewayId = staticRoute.getVpcGatewayId();
-        this.state = staticRoute.getState();
-        this.vpcId = staticRoute.getVpcId();
-        this.vlanTag = gateway.getBroadcastUri();
+        id = staticRoute.getId();
+        uuid = staticRoute.getUuid();
+        targetCidr = staticRoute.getCidr();
+        accountId = staticRoute.getAccountId();
+        domainId = staticRoute.getDomainId();
+        gatewayId = staticRoute.getVpcGatewayId();
+        state = staticRoute.getState();
+        vpcId = staticRoute.getVpcId();
+        vlanTag = gateway.getBroadcastUri();
         this.gateway = gateway.getGateway();
-        this.netmask = gateway.getNetmask();
-        this.ipAddress = gateway.getIp4Address();
+        netmask = gateway.getNetmask();
+        ipAddress = gateway.getIp4Address();
     }
 
     @Override
@@ -101,4 +103,8 @@ public class StaticRouteProfile implements StaticRoute {
         return netmask;
     }
 
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.StaticRoute;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/api/src/org/apache/cloudstack/acl/ControlledEntity.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/acl/ControlledEntity.java b/api/src/org/apache/cloudstack/acl/ControlledEntity.java
index 5957576..2572705 100644
--- a/api/src/org/apache/cloudstack/acl/ControlledEntity.java
+++ b/api/src/org/apache/cloudstack/acl/ControlledEntity.java
@@ -29,4 +29,5 @@ public interface ControlledEntity extends OwnedBy, PartOf {
         Account, Domain
     }
 
+    IAMEntityType getEntityType();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/api/src/org/apache/cloudstack/acl/IAMEntityType.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/acl/IAMEntityType.java b/api/src/org/apache/cloudstack/acl/IAMEntityType.java
new file mode 100644
index 0000000..9299ae9
--- /dev/null
+++ b/api/src/org/apache/cloudstack/acl/IAMEntityType.java
@@ -0,0 +1,45 @@
+package org.apache.cloudstack.acl;
+
+public enum IAMEntityType {
+    // currently supported entity, to be added one by one after we support acl on the entity
+    VirtualMachine,
+    Volume,
+    ResourceTag,
+    Account,
+    AffinityGroup,
+    AutoScalePolicy,
+    AutoScaleVmGroup,
+    AutoScaleVmProfile,
+    Condition,
+    Vpc,
+    VpcGateway,
+    PrivateGateway,
+    VpnUser,
+    VMSnapshot,
+    VirtualMachineTemplate,
+    UserIpv6Address,
+    StaticRoute,
+    SSHKeyPair,
+    Snapshot,
+    Site2SiteVpnGateway,
+    Site2SiteVpnConnection,
+    Site2SiteCustomerGateway,
+    SecurityGroup,
+    RemoteAccessVpn,
+    PublicIpAddress,
+    ProjectInvitation,
+    NicSecondaryIp,
+    NicIpAlias,
+    Network,
+    IpAddress,
+    InstanceGroup,
+    GlobalLoadBalancerRule,
+    FirewallRule,
+    PortForwardingRule,
+    Event,
+    AsyncJob,
+    IAMPolicy,
+    IAMGroup,
+    MonitorService,
+    SSLCert
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java
index ca78755..d15ea4b 100644
--- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java
@@ -20,6 +20,9 @@ package org.apache.cloudstack.api.command.user.firewall;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
@@ -32,7 +35,6 @@ import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.FirewallResponse;
 import org.apache.cloudstack.api.response.NetworkResponse;
 import org.apache.cloudstack.context.CallContext;
-import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.InvalidParameterValueException;
@@ -275,7 +277,7 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F
     @Override
     public String getEventDescription() {
         Network network = _networkService.getNetwork(networkId);
-        return ("Creating firewall rule for network: " + network + " for protocol:" + this.getProtocol());
+        return ("Creating firewall rule for network: " + network + " for protocol:" + getProtocol());
     }
 
     @Override
@@ -354,4 +356,9 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F
         }
     }
 
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.FirewallRule;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java
index 0b342f2..76c6e74 100644
--- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java
@@ -19,6 +19,9 @@ package org.apache.cloudstack.api.command.user.firewall;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
@@ -31,7 +34,6 @@ import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.FirewallResponse;
 import org.apache.cloudstack.api.response.IPAddressResponse;
 import org.apache.cloudstack.context.CallContext;
-import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.InvalidParameterValueException;
@@ -266,7 +268,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
     @Override
     public String getEventDescription() {
         IpAddress ip = _networkService.getIp(ipAddressId);
-        return ("Creating firewall rule for Ip: " + ip.getAddress() + " for protocol:" + this.getProtocol());
+        return ("Creating firewall rule for Ip: " + ip.getAddress() + " for protocol:" + getProtocol());
     }
 
     @Override
@@ -346,4 +348,10 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
             return true;
         }
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.FirewallRule;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java
index 61d5856..53945a6 100644
--- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java
@@ -18,6 +18,9 @@ package org.apache.cloudstack.api.command.user.firewall;
 
 import java.util.List;
 
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
@@ -32,7 +35,6 @@ import org.apache.cloudstack.api.response.IPAddressResponse;
 import org.apache.cloudstack.api.response.NetworkResponse;
 import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.cloudstack.context.CallContext;
-import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.InvalidParameterValueException;
@@ -428,4 +430,10 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
             return true;
         }
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.FirewallRule;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java
index 70be167..77edbfc 100644
--- a/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java
@@ -18,6 +18,9 @@ package org.apache.cloudstack.api.command.user.nat;
 
 import java.util.List;
 
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
@@ -30,7 +33,6 @@ import org.apache.cloudstack.api.response.FirewallRuleResponse;
 import org.apache.cloudstack.api.response.IPAddressResponse;
 import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
 import org.apache.cloudstack.context.CallContext;
-import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.InvalidParameterValueException;
@@ -126,7 +128,7 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
             StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false);
             IpForwardingRuleResponse fwResponse = _responseGenerator.createIpForwardingRuleResponse(staticNatRule);
             fwResponse.setResponseName(getCommandName());
-            this.setResponseObject(fwResponse);
+            setResponseObject(fwResponse);
         } finally {
             if (!result || rule == null) {
 
@@ -152,8 +154,8 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
 
         try {
             StaticNatRule rule = _rulesService.createStaticNatRule(this, getOpenFirewall());
-            this.setEntityId(rule.getId());
-            this.setEntityUuid(rule.getUuid());
+            setEntityId(rule.getId());
+            setEntityUuid(rule.getUuid());
         } catch (NetworkRuleConflictException e) {
             s_logger.info("Unable to create Static Nat Rule due to ", e);
             throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
@@ -179,7 +181,7 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
     @Override
     public String getEventDescription() {
         IpAddress ip = _networkService.getIp(ipAddressId);
-        return ("Applying an ipforwarding 1:1 NAT rule for Ip: " + ip.getAddress() + " with virtual machine:" + this.getVirtualMachineId());
+        return ("Applying an ipforwarding 1:1 NAT rule for Ip: " + ip.getAddress() + " with virtual machine:" + getVirtualMachineId());
     }
 
     private long getVirtualMachineId() {
@@ -321,4 +323,10 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
     public boolean isDisplay() {
         return true;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.FirewallRule;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/components-api/src/com/cloud/network/addr/PublicIp.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/network/addr/PublicIp.java b/engine/components-api/src/com/cloud/network/addr/PublicIp.java
index 9a1b663..12e4d34 100644
--- a/engine/components-api/src/com/cloud/network/addr/PublicIp.java
+++ b/engine/components-api/src/com/cloud/network/addr/PublicIp.java
@@ -18,6 +18,8 @@ package com.cloud.network.addr;
 
 import java.util.Date;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.dc.VlanVO;
 import com.cloud.network.PublicIpAddress;
 import com.cloud.network.dao.IPAddressVO;
@@ -236,4 +238,9 @@ public class PublicIp implements PublicIpAddress {
     public boolean isDisplay() {
         return _addr.isDisplay();
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.PublicIpAddress;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/components-api/src/com/cloud/network/rules/StaticNatRuleImpl.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/network/rules/StaticNatRuleImpl.java b/engine/components-api/src/com/cloud/network/rules/StaticNatRuleImpl.java
index 7104715..bdaf2bc 100644
--- a/engine/components-api/src/com/cloud/network/rules/StaticNatRuleImpl.java
+++ b/engine/components-api/src/com/cloud/network/rules/StaticNatRuleImpl.java
@@ -18,6 +18,8 @@ package com.cloud.network.rules;
 
 import java.util.List;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 public class StaticNatRuleImpl implements StaticNatRule {
     long id;
     String xid;
@@ -34,19 +36,19 @@ public class StaticNatRuleImpl implements StaticNatRule {
     boolean forDisplay;
 
     public StaticNatRuleImpl(FirewallRuleVO rule, String dstIp) {
-        this.id = rule.getId();
-        this.xid = rule.getXid();
-        this.uuid = rule.getUuid();
-        this.protocol = rule.getProtocol();
-        this.portStart = rule.getSourcePortStart();
-        this.portEnd = rule.getSourcePortEnd();
-        this.state = rule.getState();
-        this.accountId = rule.getAccountId();
-        this.domainId = rule.getDomainId();
-        this.networkId = rule.getNetworkId();
-        this.sourceIpAddressId = rule.getSourceIpAddressId();
-        this.destIpAddress = dstIp;
-        this.forDisplay = rule.isDisplay();
+        id = rule.getId();
+        xid = rule.getXid();
+        uuid = rule.getUuid();
+        protocol = rule.getProtocol();
+        portStart = rule.getSourcePortStart();
+        portEnd = rule.getSourcePortEnd();
+        state = rule.getState();
+        accountId = rule.getAccountId();
+        domainId = rule.getDomainId();
+        networkId = rule.getNetworkId();
+        sourceIpAddressId = rule.getSourceIpAddressId();
+        destIpAddress = dstIp;
+        forDisplay = rule.isDisplay();
     }
 
     @Override
@@ -148,4 +150,9 @@ public class StaticNatRuleImpl implements StaticNatRule {
     public boolean isDisplay() {
         return forDisplay;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.FirewallRule;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/event/EventVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/event/EventVO.java b/engine/schema/src/com/cloud/event/EventVO.java
index 91174fc..6fecaa6 100644
--- a/engine/schema/src/com/cloud/event/EventVO.java
+++ b/engine/schema/src/com/cloud/event/EventVO.java
@@ -29,6 +29,8 @@ import javax.persistence.Id;
 import javax.persistence.Table;
 import javax.persistence.Transient;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.utils.db.GenericDao;
 
 @Entity
@@ -87,7 +89,7 @@ public class EventVO implements Event {
     public static final String LEVEL_ERROR = "ERROR";
 
     public EventVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     @Override
@@ -196,7 +198,7 @@ public class EventVO implements Event {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
@@ -219,4 +221,10 @@ public class EventVO implements Event {
     public void setDisplayEventEnabled(boolean displayEventEnabled) {
         isDisplayEventEnabled = displayEventEnabled;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Event;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java b/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java
index 3098a68..9314993 100644
--- a/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java
+++ b/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java
@@ -28,6 +28,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.utils.db.GenericDao;
 
 @Entity
@@ -76,16 +78,16 @@ public class UserIpv6AddressVO implements UserIpv6Address {
     Date created;
 
     protected UserIpv6AddressVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public UserIpv6AddressVO(String address, long dataCenterId, String macAddress, long vlanDbId) {
         this.address = address;
         this.dataCenterId = dataCenterId;
-        this.vlanId = vlanDbId;
-        this.state = State.Free;
-        this.setMacAddress(macAddress);
-        this.uuid = UUID.randomUUID().toString();
+        vlanId = vlanDbId;
+        state = State.Free;
+        setMacAddress(macAddress);
+        uuid = UUID.randomUUID().toString();
     }
 
     @Override
@@ -184,4 +186,9 @@ public class UserIpv6AddressVO implements UserIpv6Address {
     public void setCreated(Date created) {
         this.created = created;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.UserIpv6Address;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/VpnUserVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/VpnUserVO.java b/engine/schema/src/com/cloud/network/VpnUserVO.java
index 07b6326..695aac0 100644
--- a/engine/schema/src/com/cloud/network/VpnUserVO.java
+++ b/engine/schema/src/com/cloud/network/VpnUserVO.java
@@ -27,6 +27,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.utils.db.Encrypt;
 
 @Entity
@@ -58,16 +60,16 @@ public class VpnUserVO implements VpnUser {
     private String uuid;
 
     public VpnUserVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public VpnUserVO(long accountId, long domainId, String userName, String password) {
         this.accountId = accountId;
         this.domainId = domainId;
-        this.username = userName;
+        username = userName;
         this.password = password;
-        this.state = State.Add;
-        this.uuid = UUID.randomUUID().toString();
+        state = State.Add;
+        uuid = UUID.randomUUID().toString();
     }
 
     @Override
@@ -86,7 +88,7 @@ public class VpnUserVO implements VpnUser {
     }
 
     public void setUsername(String userName) {
-        this.username = userName;
+        username = userName;
     }
 
     @Override
@@ -119,10 +121,15 @@ public class VpnUserVO implements VpnUser {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
         this.uuid = uuid;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.VpnUser;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java b/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java
index b69907c..bde38f8 100644
--- a/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java
+++ b/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java
@@ -30,6 +30,7 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.api.InternalIdentity;
 
 import com.cloud.utils.db.GenericDao;
@@ -77,7 +78,7 @@ public class AutoScalePolicyVO implements AutoScalePolicy, InternalIdentity {
 
     public AutoScalePolicyVO(long domainId, long accountId, int duration,
             int quietTime, Date lastQuiteTime, String action) {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
         this.domainId = domainId;
         this.accountId = accountId;
         this.duration = duration;
@@ -150,4 +151,10 @@ public class AutoScalePolicyVO implements AutoScalePolicy, InternalIdentity {
     public void setLastQuiteTime(Date lastQuiteTime) {
         this.lastQuiteTime = lastQuiteTime;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.AutoScalePolicy;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java b/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java
index 6694f64..89d079d 100644
--- a/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java
+++ b/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java
@@ -30,6 +30,7 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.api.InternalIdentity;
 
 import com.cloud.utils.db.GenericDao;
@@ -97,8 +98,8 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup, InternalIdentity {
             long accountId, int minMembers, int maxMembers, int memberPort,
             int interval, Date lastInterval, long profileId, String state) {
 
-        this.uuid = UUID.randomUUID().toString();
-        this.loadBalancerId = lbRuleId;
+        uuid = UUID.randomUUID().toString();
+        loadBalancerId = lbRuleId;
         this.minMembers = minMembers;
         this.maxMembers = maxMembers;
         this.memberPort = memberPort;
@@ -224,4 +225,10 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup, InternalIdentity {
     public boolean isDisplay() {
         return display;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.AutoScaleVmGroup;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java b/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java
index 40dbe90..0b59394 100644
--- a/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java
+++ b/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java
@@ -33,6 +33,7 @@ import javax.persistence.Inheritance;
 import javax.persistence.InheritanceType;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.api.Identity;
 import org.apache.cloudstack.api.InternalIdentity;
 
@@ -94,7 +95,7 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter
 
     public AutoScaleVmProfileVO(long zoneId, long domainId, long accountId, long serviceOfferingId, long templateId, String otherDeployParams, Map counterParamList,
             Integer destroyVmGraceperiod, long autoscaleUserId) {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
         this.zoneId = zoneId;
         this.domainId = domainId;
         this.accountId = accountId;
@@ -149,7 +150,7 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter
     }
 
     public void setCounterParams(String counterParam) {
-        this.counterParams = counterParam;
+        counterParams = counterParam;
     }
 
     public void setCounterParamsForUpdate(Map counterParamList) {
@@ -232,4 +233,10 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter
     public boolean isDisplay() {
         return display;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.AutoScaleVmProfile;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/as/ConditionVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/ConditionVO.java b/engine/schema/src/com/cloud/network/as/ConditionVO.java
index 8d7e776..e8c1d0b 100644
--- a/engine/schema/src/com/cloud/network/as/ConditionVO.java
+++ b/engine/schema/src/com/cloud/network/as/ConditionVO.java
@@ -29,6 +29,7 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.api.Identity;
 import org.apache.cloudstack.api.InternalIdentity;
 
@@ -77,7 +78,7 @@ public class ConditionVO implements Condition, Identity, InternalIdentity {
         this.relationalOperator = relationalOperator;
         this.accountId = accountId;
         this.domainId = domainId;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public Date getCreated() {
@@ -121,10 +122,16 @@ public class ConditionVO implements Condition, Identity, InternalIdentity {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public Date getRemoved() {
         return removed;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Condition;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java
index 9abecbe..d06b8c5 100644
--- a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java
+++ b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java
@@ -31,6 +31,8 @@ import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.network.IpAddress;
 import com.cloud.utils.net.Ip;
 
@@ -118,7 +120,7 @@ public class IPAddressVO implements IpAddress {
     protected boolean display = true;
 
     protected IPAddressVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     @Override
@@ -129,26 +131,26 @@ public class IPAddressVO implements IpAddress {
     public IPAddressVO(Ip address, long dataCenterId, long macAddress, long vlanDbId, boolean sourceNat) {
         this.address = address;
         this.dataCenterId = dataCenterId;
-        this.vlanId = vlanDbId;
+        vlanId = vlanDbId;
         this.sourceNat = sourceNat;
-        this.allocatedInDomainId = null;
-        this.allocatedToAccountId = null;
-        this.allocatedTime = null;
-        this.state = State.Free;
+        allocatedInDomainId = null;
+        allocatedToAccountId = null;
+        allocatedTime = null;
+        state = State.Free;
         this.macAddress = macAddress;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public IPAddressVO(Ip address, long dataCenterId, Long networkId, Long vpcId, long physicalNetworkId, long sourceNetworkId, long vlanDbId, boolean portable) {
         this.address = address;
         this.dataCenterId = dataCenterId;
-        this.associatedWithNetworkId = networkId;
+        associatedWithNetworkId = networkId;
         this.vpcId = vpcId;
         this.physicalNetworkId = physicalNetworkId;
         this.sourceNetworkId = sourceNetworkId;
-        this.vlanId = vlanDbId;
+        vlanId = vlanDbId;
         this.portable = portable;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public long getMacAddress() {
@@ -161,7 +163,7 @@ public class IPAddressVO implements IpAddress {
     }
 
     public void setDataCenterId(long dcId) {
-        this.dataCenterId = dcId;
+        dataCenterId = dcId;
     }
 
     @Override
@@ -185,7 +187,7 @@ public class IPAddressVO implements IpAddress {
     }
 
     public void setAssociatedWithNetworkId(Long networkId) {
-        this.associatedWithNetworkId = networkId;
+        associatedWithNetworkId = networkId;
     }
 
     @Override
@@ -203,11 +205,11 @@ public class IPAddressVO implements IpAddress {
     }
 
     public void setAllocatedToAccountId(Long accountId) {
-        this.allocatedToAccountId = accountId;
+        allocatedToAccountId = accountId;
     }
 
     public void setAllocatedInDomainId(Long domainId) {
-        this.allocatedInDomainId = domainId;
+        allocatedInDomainId = domainId;
     }
 
     public void setSourceNat(boolean sourceNat) {
@@ -220,16 +222,16 @@ public class IPAddressVO implements IpAddress {
     }
 
     public void setAllocatedTime(Date allocated) {
-        this.allocatedTime = allocated;
+        allocatedTime = allocated;
     }
 
     @Override
     public long getVlanId() {
-        return this.vlanId;
+        return vlanId;
     }
 
     public void setVlanId(long vlanDbId) {
-        this.vlanId = vlanDbId;
+        vlanId = vlanDbId;
     }
 
     @Override
@@ -281,7 +283,7 @@ public class IPAddressVO implements IpAddress {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
@@ -303,7 +305,7 @@ public class IPAddressVO implements IpAddress {
     }
 
     public void setSystem(boolean isSystem) {
-        this.system = isSystem;
+        system = isSystem;
     }
 
     @Override
@@ -346,4 +348,9 @@ public class IPAddressVO implements IpAddress {
     public void setDisplay(boolean display) {
         this.display = display;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.IpAddress;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/dao/MonitoringServiceVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/MonitoringServiceVO.java b/engine/schema/src/com/cloud/network/dao/MonitoringServiceVO.java
index f9967ec..999fdfc 100644
--- a/engine/schema/src/com/cloud/network/dao/MonitoringServiceVO.java
+++ b/engine/schema/src/com/cloud/network/dao/MonitoringServiceVO.java
@@ -25,6 +25,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.network.MonitoringService;
 
 @Entity
@@ -116,4 +118,9 @@ public class MonitoringServiceVO implements MonitoringService {
     public String getProcessName() {
         return processName;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.MonitorService;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/dao/NetworkVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkVO.java b/engine/schema/src/com/cloud/network/dao/NetworkVO.java
index f3776df..13e8dbf 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkVO.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkVO.java
@@ -30,6 +30,7 @@ import javax.persistence.TableGenerator;
 import javax.persistence.Transient;
 
 import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.acl.IAMEntityType;
 
 import com.cloud.network.Network;
 import com.cloud.network.Networks.BroadcastDomainType;
@@ -167,7 +168,7 @@ public class NetworkVO implements Network {
     Long networkACLId;
 
     public NetworkVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     /**
@@ -193,8 +194,8 @@ public class NetworkVO implements Network {
         } else {
             this.state = state;
         }
-        this.id = -1;
-        this.uuid = UUID.randomUUID().toString();
+        id = -1;
+        uuid = UUID.randomUUID().toString();
     }
 
     public NetworkVO(long id, Network that, long offeringId, String guruName, long domainId, long accountId, long related, String name, String displayText,
@@ -216,19 +217,19 @@ public class NetworkVO implements Network {
             aclType,
             specifyIpRanges,
             vpcId);
-        this.gateway = that.getGateway();
-        this.cidr = that.getCidr();
-        this.networkCidr = that.getNetworkCidr();
-        this.broadcastUri = that.getBroadcastUri();
-        this.broadcastDomainType = that.getBroadcastDomainType();
+        gateway = that.getGateway();
+        cidr = that.getCidr();
+        networkCidr = that.getNetworkCidr();
+        broadcastUri = that.getBroadcastUri();
+        broadcastDomainType = that.getBroadcastDomainType();
         this.guruName = guruName;
-        this.state = that.getState();
+        state = that.getState();
         if (state == null) {
             state = State.Allocated;
         }
-        this.uuid = UUID.randomUUID().toString();
-        this.ip6Gateway = that.getIp6Gateway();
-        this.ip6Cidr = that.getIp6Cidr();
+        uuid = UUID.randomUUID().toString();
+        ip6Gateway = that.getIp6Gateway();
+        ip6Cidr = that.getIp6Cidr();
     }
 
     /**
@@ -260,7 +261,7 @@ public class NetworkVO implements Network {
         this.displayText = displayText;
         this.aclType = aclType;
         this.networkDomain = networkDomain;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
         this.guestType = guestType;
         this.specifyIpRanges = specifyIpRanges;
         this.vpcId = vpcId;
@@ -436,7 +437,7 @@ public class NetworkVO implements Network {
     }
 
     public void setDns1(String dns) {
-        this.dns1 = dns;
+        dns1 = dns;
     }
 
     public String getDns2() {
@@ -444,7 +445,7 @@ public class NetworkVO implements Network {
     }
 
     public void setDns2(String dns) {
-        this.dns2 = dns;
+        dns2 = dns;
     }
 
     @Override
@@ -492,19 +493,19 @@ public class NetworkVO implements Network {
             return false;
         }
         NetworkVO that = (NetworkVO)obj;
-        if (this.trafficType != that.trafficType) {
+        if (trafficType != that.trafficType) {
             return false;
         }
 
-        if ((this.cidr == null && that.cidr != null) || (this.cidr != null && that.cidr == null)) {
+        if ((cidr == null && that.cidr != null) || (cidr != null && that.cidr == null)) {
             return false;
         }
 
-        if (this.cidr == null && that.cidr == null) {
+        if (cidr == null && that.cidr == null) {
             return true;
         }
 
-        return NetUtils.isNetworkAWithinNetworkB(this.cidr, that.cidr);
+        return NetUtils.isNetworkAWithinNetworkB(cidr, that.cidr);
     }
 
     @Override
@@ -516,7 +517,7 @@ public class NetworkVO implements Network {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
@@ -583,4 +584,9 @@ public class NetworkVO implements Network {
     public Long getNetworkACLId() {
         return networkACLId;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Network;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java b/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java
index 3d416f2..827b59b 100644
--- a/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java
+++ b/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java
@@ -25,6 +25,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.network.RemoteAccessVpn;
 
 @Entity
@@ -69,19 +71,19 @@ public class RemoteAccessVpnVO implements RemoteAccessVpn {
     protected boolean display = true;
 
     public RemoteAccessVpnVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public RemoteAccessVpnVO(long accountId, long domainId, Long networkId, long publicIpId, Long vpcId, String localIp, String ipRange, String presharedKey) {
         this.accountId = accountId;
-        this.serverAddressId = publicIpId;
+        serverAddressId = publicIpId;
         this.ipRange = ipRange;
-        this.ipsecPresharedKey = presharedKey;
+        ipsecPresharedKey = presharedKey;
         this.localIp = localIp;
         this.domainId = domainId;
         this.networkId = networkId;
-        this.state = State.Added;
-        this.uuid = UUID.randomUUID().toString();
+        state = State.Added;
+        uuid = UUID.randomUUID().toString();
         this.vpcId = vpcId;
     }
 
@@ -164,4 +166,9 @@ public class RemoteAccessVpnVO implements RemoteAccessVpn {
     public boolean isDisplay() {
         return display;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.RemoteAccessVpn;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java b/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java
index c922855..4a32b31 100644
--- a/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java
+++ b/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java
@@ -26,6 +26,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.network.Site2SiteCustomerGateway;
 import com.cloud.utils.db.Encrypt;
 import com.cloud.utils.db.GenericDao;
@@ -92,7 +94,7 @@ public class Site2SiteCustomerGatewayVO implements Site2SiteCustomerGateway {
         this.ikeLifetime = ikeLifetime;
         this.espLifetime = espLifetime;
         this.dpd = dpd;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
         this.accountId = accountId;
         this.domainId = domainId;
     }
@@ -206,4 +208,9 @@ public class Site2SiteCustomerGatewayVO implements Site2SiteCustomerGateway {
     public long getAccountId() {
         return accountId;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Site2SiteCustomerGateway;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionVO.java b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionVO.java
index beba999..c515fc2 100644
--- a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionVO.java
+++ b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionVO.java
@@ -28,6 +28,7 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
 import org.apache.cloudstack.api.InternalIdentity;
 
 import com.cloud.network.Site2SiteVpnConnection;
@@ -76,10 +77,10 @@ public class Site2SiteVpnConnectionVO implements Site2SiteVpnConnection, Interna
     }
 
     public Site2SiteVpnConnectionVO(long accountId, long domainId, long vpnGatewayId, long customerGatewayId, boolean passive) {
-        this.uuid = UUID.randomUUID().toString();
-        this.setVpnGatewayId(vpnGatewayId);
-        this.setCustomerGatewayId(customerGatewayId);
-        this.setState(State.Pending);
+        uuid = UUID.randomUUID().toString();
+        setVpnGatewayId(vpnGatewayId);
+        setCustomerGatewayId(customerGatewayId);
+        setState(State.Pending);
         this.accountId = accountId;
         this.domainId = domainId;
         this.passive = passive;
@@ -171,4 +172,9 @@ public class Site2SiteVpnConnectionVO implements Site2SiteVpnConnection, Interna
     public boolean isDisplay() {
         return display;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Site2SiteVpnConnection;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnGatewayVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnGatewayVO.java b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnGatewayVO.java
index 226f608..c465334 100644
--- a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnGatewayVO.java
+++ b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnGatewayVO.java
@@ -26,6 +26,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.network.Site2SiteVpnGateway;
 import com.cloud.utils.db.GenericDao;
 
@@ -62,9 +64,9 @@ public class Site2SiteVpnGatewayVO implements Site2SiteVpnGateway {
     }
 
     public Site2SiteVpnGatewayVO(long accountId, long domainId, long addrId, long vpcId) {
-        this.uuid = UUID.randomUUID().toString();
-        this.setAddrId(addrId);
-        this.setVpcId(vpcId);
+        uuid = UUID.randomUUID().toString();
+        setAddrId(addrId);
+        setVpcId(vpcId);
         this.accountId = accountId;
         this.domainId = domainId;
     }
@@ -128,4 +130,9 @@ public class Site2SiteVpnGatewayVO implements Site2SiteVpnGateway {
     public boolean isDisplay() {
         return display;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Site2SiteVpnGateway;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/dao/SslCertVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/SslCertVO.java b/engine/schema/src/com/cloud/network/dao/SslCertVO.java
index 7d73f49..6ef7afd 100644
--- a/engine/schema/src/com/cloud/network/dao/SslCertVO.java
+++ b/engine/schema/src/com/cloud/network/dao/SslCertVO.java
@@ -23,6 +23,8 @@ import javax.persistence.Entity;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.network.lb.SslCert;
 import com.cloud.utils.db.Encrypt;
 
@@ -61,18 +63,18 @@ public class SslCertVO implements SslCert {
     String fingerPrint;
 
     public SslCertVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public SslCertVO(String cert, String key, String password, String chain, Long accountId, Long domainId, String fingerPrint) {
-        this.certificate = cert;
+        certificate = cert;
         this.key = key;
         this.chain = chain;
         this.password = password;
         this.accountId = accountId;
         this.domainId = domainId;
         this.fingerPrint = fingerPrint;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     // Getters
@@ -120,4 +122,10 @@ public class SslCertVO implements SslCert {
     public String getFingerPrint() {
         return fingerPrint;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.SSLCert;
+    }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java b/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java
index 4fa751d..0acc24a 100644
--- a/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java
+++ b/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java
@@ -34,6 +34,8 @@ import javax.persistence.InheritanceType;
 import javax.persistence.Table;
 import javax.persistence.Transient;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.utils.db.GenericDao;
 import com.cloud.utils.net.NetUtils;
 
@@ -191,7 +193,7 @@ public class FirewallRuleVO implements FirewallRule {
     }
 
     protected FirewallRuleVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public FirewallRuleVO(String xId, Long ipAddressId, Integer portStart, Integer portEnd, String protocol, long networkId, long accountId, long domainId,
@@ -202,13 +204,13 @@ public class FirewallRuleVO implements FirewallRule {
         }
         this.accountId = accountId;
         this.domainId = domainId;
-        this.sourceIpAddressId = ipAddressId;
-        this.sourcePortStart = portStart;
-        this.sourcePortEnd = portEnd;
+        sourceIpAddressId = ipAddressId;
+        sourcePortStart = portStart;
+        sourcePortEnd = portEnd;
         this.protocol = protocol;
         this.purpose = purpose;
         this.networkId = networkId;
-        this.state = State.Staged;
+        state = State.Staged;
         this.icmpCode = icmpCode;
         this.icmpType = icmpType;
         this.sourceCidrs = sourceCidrs;
@@ -218,8 +220,8 @@ public class FirewallRuleVO implements FirewallRule {
         }
 
         this.related = related;
-        this.uuid = UUID.randomUUID().toString();
-        this.type = FirewallRuleType.User;
+        uuid = UUID.randomUUID().toString();
+        type = FirewallRuleType.User;
         this.trafficType = trafficType;
     }
 
@@ -256,7 +258,7 @@ public class FirewallRuleVO implements FirewallRule {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
@@ -280,4 +282,10 @@ public class FirewallRuleVO implements FirewallRule {
     public boolean isDisplay() {
         return display;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.FirewallRule;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/security/SecurityGroupVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/security/SecurityGroupVO.java b/engine/schema/src/com/cloud/network/security/SecurityGroupVO.java
index df8427c..26859f7 100644
--- a/engine/schema/src/com/cloud/network/security/SecurityGroupVO.java
+++ b/engine/schema/src/com/cloud/network/security/SecurityGroupVO.java
@@ -25,6 +25,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 @Entity
 @Table(name = ("security_group"))
 public class SecurityGroupVO implements SecurityGroup {
@@ -49,7 +51,7 @@ public class SecurityGroupVO implements SecurityGroup {
     private String uuid;
 
     public SecurityGroupVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public SecurityGroupVO(String name, String description, long domainId, long accountId) {
@@ -57,7 +59,7 @@ public class SecurityGroupVO implements SecurityGroup {
         this.description = description;
         this.domainId = domainId;
         this.accountId = accountId;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     @Override
@@ -87,10 +89,15 @@ public class SecurityGroupVO implements SecurityGroup {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
         this.uuid = uuid;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.SecurityGroup;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/vpc/StaticRouteVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/StaticRouteVO.java b/engine/schema/src/com/cloud/network/vpc/StaticRouteVO.java
index 08e3965..a9ba051 100644
--- a/engine/schema/src/com/cloud/network/vpc/StaticRouteVO.java
+++ b/engine/schema/src/com/cloud/network/vpc/StaticRouteVO.java
@@ -28,6 +28,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.utils.db.GenericDao;
 
 @Entity
@@ -64,7 +66,7 @@ public class StaticRouteVO implements StaticRoute {
     Date created;
 
     protected StaticRouteVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     /**
@@ -78,11 +80,11 @@ public class StaticRouteVO implements StaticRoute {
         super();
         this.vpcGatewayId = vpcGatewayId;
         this.cidr = cidr;
-        this.state = State.Staged;
+        state = State.Staged;
         this.vpcId = vpcId;
         this.accountId = accountId;
         this.domainId = domainId;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     @Override
@@ -107,7 +109,7 @@ public class StaticRouteVO implements StaticRoute {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     @Override
@@ -135,4 +137,9 @@ public class StaticRouteVO implements StaticRoute {
         buf.append(uuid).append("|").append(cidr).append("|").append(vpcGatewayId).append("]");
         return buf.toString();
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.StaticRoute;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java b/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java
index 5f15660..48238b1 100644
--- a/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java
+++ b/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java
@@ -28,6 +28,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.utils.db.GenericDao;
 
 @Entity
@@ -90,7 +92,7 @@ public class VpcGatewayVO implements VpcGateway {
     long networkACLId;
 
     protected VpcGatewayVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     /**
@@ -117,10 +119,10 @@ public class VpcGatewayVO implements VpcGateway {
         this.broadcastUri = broadcastUri;
         this.gateway = gateway;
         this.netmask = netmask;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
         this.accountId = accountId;
         this.domainId = domainId;
-        this.state = State.Creating;
+        state = State.Creating;
         this.sourceNat = sourceNat;
         this.networkACLId = networkACLId;
 
@@ -128,7 +130,7 @@ public class VpcGatewayVO implements VpcGateway {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     @Override
@@ -204,7 +206,7 @@ public class VpcGatewayVO implements VpcGateway {
 
     @Override
     public boolean getSourceNat() {
-        return this.sourceNat;
+        return sourceNat;
     }
 
     public void setNetworkACLId(long networkACLId) {
@@ -215,4 +217,9 @@ public class VpcGatewayVO implements VpcGateway {
     public long getNetworkACLId() {
         return networkACLId;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.VpcGateway;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/network/vpc/VpcVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/VpcVO.java b/engine/schema/src/com/cloud/network/vpc/VpcVO.java
index 7d1933a..d1cfd7c 100644
--- a/engine/schema/src/com/cloud/network/vpc/VpcVO.java
+++ b/engine/schema/src/com/cloud/network/vpc/VpcVO.java
@@ -26,6 +26,8 @@ import javax.persistence.Enumerated;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.utils.db.GenericDao;
 
 @Entity
@@ -80,7 +82,7 @@ public class VpcVO implements Vpc {
     protected boolean display = true;
 
     public VpcVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public VpcVO(long zoneId, String name, String displayText, long accountId, long domainId, long vpcOffId, String cidr, String networkDomain) {
@@ -90,10 +92,10 @@ public class VpcVO implements Vpc {
         this.accountId = accountId;
         this.domainId = domainId;
         this.cidr = cidr;
-        this.uuid = UUID.randomUUID().toString();
-        this.state = State.Enabled;
+        uuid = UUID.randomUUID().toString();
+        state = State.Enabled;
         this.networkDomain = networkDomain;
-        this.vpcOfferingId = vpcOffId;
+        vpcOfferingId = vpcOffId;
     }
 
     @Override
@@ -194,4 +196,9 @@ public class VpcVO implements Vpc {
     public boolean isDisplay() {
         return display;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Vpc;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/projects/ProjectInvitationVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/projects/ProjectInvitationVO.java b/engine/schema/src/com/cloud/projects/ProjectInvitationVO.java
index 6136862..885c148 100644
--- a/engine/schema/src/com/cloud/projects/ProjectInvitationVO.java
+++ b/engine/schema/src/com/cloud/projects/ProjectInvitationVO.java
@@ -28,6 +28,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.utils.db.GenericDao;
 
 @Entity
@@ -64,16 +66,16 @@ public class ProjectInvitationVO implements ProjectInvitation {
     private String uuid;
 
     protected ProjectInvitationVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public ProjectInvitationVO(long projectId, Long accountId, Long domainId, String email, String token) {
-        this.forAccountId = accountId;
-        this.inDomainId = domainId;
+        forAccountId = accountId;
+        inDomainId = domainId;
         this.projectId = projectId;
         this.email = email;
         this.token = token;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     @Override
@@ -129,7 +131,7 @@ public class ProjectInvitationVO implements ProjectInvitation {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
@@ -145,4 +147,9 @@ public class ProjectInvitationVO implements ProjectInvitation {
     public long getAccountId() {
         return forAccountId == null ? -1 : forAccountId;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.ProjectInvitation;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/storage/SnapshotVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/SnapshotVO.java b/engine/schema/src/com/cloud/storage/SnapshotVO.java
index 8521636..4c8ceb7 100644
--- a/engine/schema/src/com/cloud/storage/SnapshotVO.java
+++ b/engine/schema/src/com/cloud/storage/SnapshotVO.java
@@ -30,6 +30,8 @@ import javax.persistence.Table;
 
 import com.google.gson.annotations.Expose;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.utils.db.GenericDao;
 
@@ -93,12 +95,12 @@ public class SnapshotVO implements Snapshot {
     String uuid;
 
     public SnapshotVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public SnapshotVO(long dcId, long accountId, long domainId, Long volumeId, Long diskOfferingId, String name, short snapshotType, String typeDescription, long size,
             HypervisorType hypervisorType) {
-        this.dataCenterId = dcId;
+        dataCenterId = dcId;
         this.accountId = accountId;
         this.domainId = domainId;
         this.volumeId = volumeId;
@@ -107,10 +109,10 @@ public class SnapshotVO implements Snapshot {
         this.snapshotType = snapshotType;
         this.typeDescription = typeDescription;
         this.size = size;
-        this.state = State.Allocated;
+        state = State.Allocated;
         this.hypervisorType = hypervisorType;
-        this.version = "2.2";
-        this.uuid = UUID.randomUUID().toString();
+        version = "2.2";
+        uuid = UUID.randomUUID().toString();
     }
 
     @Override
@@ -229,10 +231,15 @@ public class SnapshotVO implements Snapshot {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
         this.uuid = uuid;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Snapshot;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/storage/VMTemplateVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/VMTemplateVO.java b/engine/schema/src/com/cloud/storage/VMTemplateVO.java
index da93735..e619f68 100755
--- a/engine/schema/src/com/cloud/storage/VMTemplateVO.java
+++ b/engine/schema/src/com/cloud/storage/VMTemplateVO.java
@@ -31,6 +31,8 @@ import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.storage.Storage.TemplateType;
@@ -632,4 +634,8 @@ public class VMTemplateVO implements VirtualMachineTemplate {
         this.updated = updated;
     }
 
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.VirtualMachineTemplate;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/storage/VolumeVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/VolumeVO.java b/engine/schema/src/com/cloud/storage/VolumeVO.java
index fb79c13..82f47d4 100755
--- a/engine/schema/src/com/cloud/storage/VolumeVO.java
+++ b/engine/schema/src/com/cloud/storage/VolumeVO.java
@@ -32,6 +32,8 @@ import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.db.GenericDao;
@@ -164,18 +166,18 @@ public class VolumeVO implements Volume {
 
     // Real Constructor
     public VolumeVO(Type type, String name, long dcId, long domainId, long accountId, long diskOfferingId, long size, Long minIops, Long maxIops, String iScsiName) {
-        this.volumeType = type;
+        volumeType = type;
         this.name = name;
-        this.dataCenterId = dcId;
+        dataCenterId = dcId;
         this.accountId = accountId;
         this.domainId = domainId;
         this.size = size;
         this.minIops = minIops;
         this.maxIops = maxIops;
-        this._iScsiName = iScsiName;
+        _iScsiName = iScsiName;
         this.diskOfferingId = diskOfferingId;
-        this.state = State.Allocated;
-        this.uuid = UUID.randomUUID().toString();
+        state = State.Allocated;
+        uuid = UUID.randomUUID().toString();
     }
 
     public VolumeVO(String name, long dcId, Long podId, long accountId, long domainId, Long instanceId, String folder, String path, long size, Long minIops,
@@ -189,13 +191,13 @@ public class VolumeVO implements Volume {
         this.size = size;
         this.minIops = minIops;
         this.maxIops = maxIops;
-        this._iScsiName = iScsiName;
+        _iScsiName = iScsiName;
         this.podId = podId;
-        this.dataCenterId = dcId;
-        this.volumeType = vType;
-        this.state = Volume.State.Allocated;
-        this.recreatable = false;
-        this.uuid = UUID.randomUUID().toString();
+        dataCenterId = dcId;
+        volumeType = vType;
+        state = Volume.State.Allocated;
+        recreatable = false;
+        uuid = UUID.randomUUID().toString();
     }
 
     public VolumeVO(String name, long dcId, long podId, long accountId, long domainId, Long instanceId, String folder, String path, long size, Volume.Type vType) {
@@ -206,15 +208,15 @@ public class VolumeVO implements Volume {
         this.folder = folder;
         this.path = path;
         this.size = size;
-        this.minIops = null;
-        this.maxIops = null;
-        this._iScsiName = null;
+        minIops = null;
+        maxIops = null;
+        _iScsiName = null;
         this.podId = podId;
-        this.dataCenterId = dcId;
-        this.volumeType = vType;
-        this.state = Volume.State.Allocated;
-        this.recreatable = false;
-        this.uuid = UUID.randomUUID().toString();
+        dataCenterId = dcId;
+        volumeType = vType;
+        state = Volume.State.Allocated;
+        recreatable = false;
+        uuid = UUID.randomUUID().toString();
     }
 
     // Copy Constructor
@@ -232,34 +234,34 @@ public class VolumeVO implements Volume {
             that.getMaxIops(),
             that.get_iScsiName(),
             that.getVolumeType());
-        this.recreatable = that.isRecreatable();
-        this.state = that.getState();
-        this.size = that.getSize();
-        this.minIops = that.getMinIops();
-        this.maxIops = that.getMaxIops();
-        this._iScsiName = that.get_iScsiName();
-        this.diskOfferingId = that.getDiskOfferingId();
-        this.poolId = that.getPoolId();
-        this.attached = that.getAttached();
-        this.chainInfo = that.getChainInfo();
-        this.templateId = that.getTemplateId();
-        this.deviceId = that.getDeviceId();
-        this.format = that.getFormat();
-        this.uuid = UUID.randomUUID().toString();
+        recreatable = that.isRecreatable();
+        state = that.getState();
+        size = that.getSize();
+        minIops = that.getMinIops();
+        maxIops = that.getMaxIops();
+        _iScsiName = that.get_iScsiName();
+        diskOfferingId = that.getDiskOfferingId();
+        poolId = that.getPoolId();
+        attached = that.getAttached();
+        chainInfo = that.getChainInfo();
+        templateId = that.getTemplateId();
+        deviceId = that.getDeviceId();
+        format = that.getFormat();
+        uuid = UUID.randomUUID().toString();
     }
 
     @Override
     public long getUpdatedCount() {
-        return this.updatedCount;
+        return updatedCount;
     }
 
     @Override
     public void incrUpdatedCount() {
-        this.updatedCount++;
+        updatedCount++;
     }
 
     public void decrUpdatedCount() {
-        this.updatedCount--;
+        updatedCount--;
     }
 
     @Override
@@ -481,7 +483,7 @@ public class VolumeVO implements Volume {
 
     @Override
     public Date getAttached() {
-        return this.attached;
+        return attached;
     }
 
     public void setAttached(Date attached) {
@@ -490,7 +492,7 @@ public class VolumeVO implements Volume {
 
     @Override
     public String getChainInfo() {
-        return this.chainInfo;
+        return chainInfo;
     }
 
     public void setChainInfo(String chainInfo) {
@@ -498,11 +500,11 @@ public class VolumeVO implements Volume {
     }
 
     public Long getLastPoolId() {
-        return this.lastPoolId;
+        return lastPoolId;
     }
 
     public void setLastPoolId(Long poolId) {
-        this.lastPoolId = poolId;
+        lastPoolId = poolId;
     }
 
     @Override
@@ -521,17 +523,17 @@ public class VolumeVO implements Volume {
 
     @Override
     public String getReservationId() {
-        return this.reservationId;
+        return reservationId;
     }
 
     @Override
     public void setReservationId(String reserv) {
-        this.reservationId = reserv;
+        reservationId = reserv;
     }
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
@@ -540,11 +542,11 @@ public class VolumeVO implements Volume {
 
     @Override
     public String get_iScsiName() {
-        return this._iScsiName;
+        return _iScsiName;
     }
 
     public void set_iScsiName(String iScsiName) {
-        this._iScsiName = iScsiName;
+        _iScsiName = iScsiName;
     }
 
     @Override
@@ -571,11 +573,11 @@ public class VolumeVO implements Volume {
 
     @Override
     public Long getVmSnapshotChainSize() {
-        return this.vmSnapshotChainSize;
+        return vmSnapshotChainSize;
     }
 
     public Long getIsoId() {
-        return this.isoId;
+        return isoId;
     }
 
     public void setIsoId(Long isoId) {
@@ -596,4 +598,9 @@ public class VolumeVO implements Volume {
     public Integer getHypervisorSnapshotReserve() {
         return hypervisorSnapshotReserve;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Volume;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/tags/ResourceTagVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/tags/ResourceTagVO.java b/engine/schema/src/com/cloud/tags/ResourceTagVO.java
index ca790bd..45e7b27 100644
--- a/engine/schema/src/com/cloud/tags/ResourceTagVO.java
+++ b/engine/schema/src/com/cloud/tags/ResourceTagVO.java
@@ -27,6 +27,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.server.ResourceTag;
 
 @Entity
@@ -67,7 +69,7 @@ public class ResourceTagVO implements ResourceTag {
     String customer;
 
     protected ResourceTagVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     /**
@@ -88,7 +90,7 @@ public class ResourceTagVO implements ResourceTag {
         this.accountId = accountId;
         this.resourceId = resourceId;
         this.resourceType = resourceType;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
         this.customer = customer;
         this.resourceUuid = resourceUuid;
     }
@@ -161,4 +163,9 @@ public class ResourceTagVO implements ResourceTag {
     public String getResourceUuid() {
         return resourceUuid;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.ResourceTag;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/user/AccountVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/user/AccountVO.java b/engine/schema/src/com/cloud/user/AccountVO.java
index 7fa9fe2..fb1b58a 100644
--- a/engine/schema/src/com/cloud/user/AccountVO.java
+++ b/engine/schema/src/com/cloud/user/AccountVO.java
@@ -28,6 +28,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.utils.db.GenericDao;
 
 @Entity
@@ -70,12 +72,12 @@ public class AccountVO implements Account {
     boolean isDefault;
 
     public AccountVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public AccountVO(long id) {
         this.id = id;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public AccountVO(String accountName, long domainId, String networkDomain, short type, String uuid) {
@@ -83,7 +85,7 @@ public class AccountVO implements Account {
         this.domainId = domainId;
         this.networkDomain = networkDomain;
         this.type = type;
-        this.state = State.enabled;
+        state = State.enabled;
         this.uuid = uuid;
     }
 
@@ -175,7 +177,7 @@ public class AccountVO implements Account {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
@@ -186,4 +188,10 @@ public class AccountVO implements Account {
     public boolean isDefault() {
         return isDefault;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.Account;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/user/SSHKeyPairVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/user/SSHKeyPairVO.java b/engine/schema/src/com/cloud/user/SSHKeyPairVO.java
index 9fb035d..4dc03c4 100644
--- a/engine/schema/src/com/cloud/user/SSHKeyPairVO.java
+++ b/engine/schema/src/com/cloud/user/SSHKeyPairVO.java
@@ -24,6 +24,8 @@ import javax.persistence.Id;
 import javax.persistence.Table;
 import javax.persistence.Transient;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 @Entity
 @Table(name = "ssh_keypairs")
 public class SSHKeyPairVO implements SSHKeyPair {
@@ -114,4 +116,8 @@ public class SSHKeyPairVO implements SSHKeyPair {
         this.privateKey = privateKey;
     }
 
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.SSHKeyPair;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/vm/InstanceGroupVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/InstanceGroupVO.java b/engine/schema/src/com/cloud/vm/InstanceGroupVO.java
index 1089017..9b463d3 100644
--- a/engine/schema/src/com/cloud/vm/InstanceGroupVO.java
+++ b/engine/schema/src/com/cloud/vm/InstanceGroupVO.java
@@ -28,6 +28,8 @@ import javax.persistence.PrimaryKeyJoinColumn;
 import javax.persistence.SecondaryTable;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.utils.db.GenericDao;
 
 @Entity
@@ -63,7 +65,7 @@ public class InstanceGroupVO implements InstanceGroup {
     public InstanceGroupVO(String name, long accountId) {
         this.name = name;
         this.accountId = accountId;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     protected InstanceGroupVO() {
@@ -105,7 +107,7 @@ public class InstanceGroupVO implements InstanceGroup {
 
     @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
@@ -116,4 +118,9 @@ public class InstanceGroupVO implements InstanceGroup {
     public Short getAccountType() {
         return accountType;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.InstanceGroup;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/vm/VMInstanceVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/VMInstanceVO.java b/engine/schema/src/com/cloud/vm/VMInstanceVO.java
index 30ef60f..437db54 100644
--- a/engine/schema/src/com/cloud/vm/VMInstanceVO.java
+++ b/engine/schema/src/com/cloud/vm/VMInstanceVO.java
@@ -36,6 +36,8 @@ import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.utils.db.Encrypt;
 import com.cloud.utils.db.GenericDao;
@@ -183,27 +185,27 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
     public VMInstanceVO(long id, long serviceOfferingId, String name, String instanceName, Type type, Long vmTemplateId, HypervisorType hypervisorType, long guestOSId,
             long domainId, long accountId, boolean haEnabled) {
         this.id = id;
-        this.hostName = name != null ? name : this.uuid;
+        hostName = name != null ? name : uuid;
         if (vmTemplateId != null) {
-            this.templateId = vmTemplateId;
+            templateId = vmTemplateId;
         }
         this.instanceName = instanceName;
         this.type = type;
         this.guestOSId = guestOSId;
         this.haEnabled = haEnabled;
-        this.vncPassword = Long.toHexString(new Random().nextLong());
-        this.state = State.Stopped;
+        vncPassword = Long.toHexString(new Random().nextLong());
+        state = State.Stopped;
         this.accountId = accountId;
         this.domainId = domainId;
         this.serviceOfferingId = serviceOfferingId;
         this.hypervisorType = hypervisorType;
-        this.limitCpuUse = false;
+        limitCpuUse = false;
     }
 
     public VMInstanceVO(long id, long serviceOfferingId, String name, String instanceName, Type type, Long vmTemplateId, HypervisorType hypervisorType, long guestOSId,
             long domainId, long accountId, boolean haEnabled, boolean limitResourceUse, Long diskOfferingId) {
         this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
-        this.limitCpuUse = limitResourceUse;
+        limitCpuUse = limitResourceUse;
         this.diskOfferingId = diskOfferingId;
     }
 
@@ -324,11 +326,11 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
     }
 
     public Date getProxyAssignTime() {
-        return this.proxyAssignTime;
+        return proxyAssignTime;
     }
 
     public void setProxyAssignTime(Date time) {
-        this.proxyAssignTime = time;
+        proxyAssignTime = time;
     }
 
     @Override
@@ -412,7 +414,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
     }
 
     public void setPodId(long podId) {
-        this.podIdToDeployIn = podId;
+        podIdToDeployIn = podId;
     }
 
     public void setPrivateMacAddress(String privateMacAddress) {
@@ -436,7 +438,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
     }
 
     public String getReservationId() {
-        return this.reservationId;
+        return reservationId;
     }
 
     @Override
@@ -500,7 +502,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
     }
 
     public Boolean isDynamicallyScalable() {
-        return this.dynamicallyScalable;
+        return dynamicallyScalable;
     }
 
     public VirtualMachine.PowerState getPowerState() {
@@ -535,4 +537,8 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
         powerHostId = hostId;
     }
 
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.VirtualMachine;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/vm/dao/NicIpAliasVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/NicIpAliasVO.java b/engine/schema/src/com/cloud/vm/dao/NicIpAliasVO.java
index 37aa0e3..b03492a 100644
--- a/engine/schema/src/com/cloud/vm/dao/NicIpAliasVO.java
+++ b/engine/schema/src/com/cloud/vm/dao/NicIpAliasVO.java
@@ -28,6 +28,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.utils.db.GenericDao;
 import com.cloud.utils.net.NetUtils;
 import com.cloud.vm.NicIpAlias;
@@ -39,18 +41,18 @@ public class NicIpAliasVO implements NicIpAlias {
     public NicIpAliasVO(Long nicId, String ipaddr, Long vmId, Long accountId, Long domainId, Long networkId, String gateway, String netmask) {
         this.nicId = nicId;
         this.vmId = vmId;
-        this.ip4Address = ipaddr;
+        ip4Address = ipaddr;
         this.accountId = accountId;
         this.domainId = domainId;
         this.networkId = networkId;
         this.netmask = netmask;
         this.gateway = gateway;
-        this.state = NicIpAlias.state.active;
+        state = NicIpAlias.state.active;
         String cidr = NetUtils.getCidrFromGatewayAndNetmask(gateway, netmask);
         String[] cidrPair = cidr.split("\\/");
         String cidrAddress = cidrPair[0];
         long cidrSize = Long.parseLong(cidrPair[1]);
-        this.startIpOfSubnet = NetUtils.getIpRangeStartIpFromCidr(cidrAddress, cidrSize);
+        startIpOfSubnet = NetUtils.getIpRangeStartIpFromCidr(cidrAddress, cidrSize);
     }
 
     protected NicIpAliasVO() {
@@ -199,7 +201,7 @@ public class NicIpAliasVO implements NicIpAlias {
     }
 
     public void setAliasCount(long count) {
-        this.aliasCount = count;
+        aliasCount = count;
     }
 
     public void setNetmask(String netmask) {
@@ -232,4 +234,8 @@ public class NicIpAliasVO implements NicIpAlias {
         return startIpOfSubnet;
     }
 
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.NicIpAlias;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0ae4d9a/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpVO.java b/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpVO.java
index 142de8a..995da17 100644
--- a/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpVO.java
+++ b/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpVO.java
@@ -26,6 +26,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.acl.IAMEntityType;
+
 import com.cloud.utils.db.GenericDao;
 import com.cloud.vm.NicSecondaryIp;
 
@@ -36,7 +38,7 @@ public class NicSecondaryIpVO implements NicSecondaryIp {
     public NicSecondaryIpVO(long nicId, String ipaddr, long vmId, long accountId, long domainId, long networkId) {
         this.nicId = nicId;
         this.vmId = vmId;
-        this.ip4Address = ipaddr;
+        ip4Address = ipaddr;
         this.accountId = accountId;
         this.domainId = domainId;
         this.networkId = networkId;
@@ -124,4 +126,9 @@ public class NicSecondaryIpVO implements NicSecondaryIp {
     public long getVmId() {
         return vmId;
     }
+
+    @Override
+    public IAMEntityType getEntityType() {
+        return IAMEntityType.NicSecondaryIp;
+    }
 }


[48/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-6170


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

Branch: refs/heads/resize-root
Commit: c427e8db1c4294bec93aa9295052950888c0fecf
Parents: e37a6cd
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Thu Mar 6 14:00:56 2014 -0700
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Fri Mar 7 15:38:50 2014 -0700

----------------------------------------------------------------------
 .../com/cloud/offering/DiskOfferingInfo.java    | 47 ++++++++++++++++++
 .../api/command/user/vm/DeployVMCmd.java        | 50 ++++++++++++++++++++
 .../src/com/cloud/vm/VirtualMachineManager.java |  4 +-
 .../service/VolumeOrchestrationService.java     |  2 +-
 .../com/cloud/vm/VirtualMachineManagerImpl.java | 11 +++--
 .../engine/orchestration/CloudOrchestrator.java | 40 ++++++++++++----
 .../orchestration/VolumeOrchestrator.java       | 10 ++--
 ui/css/cloudstack3.css                          | 40 ++++++++++++++++
 ui/index.jsp                                    | 11 +++++
 ui/scripts/instanceWizard.js                    | 16 ++++++-
 ui/scripts/ui-custom/instanceWizard.js          |  8 ++++
 11 files changed, 218 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c427e8db/api/src/com/cloud/offering/DiskOfferingInfo.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/offering/DiskOfferingInfo.java b/api/src/com/cloud/offering/DiskOfferingInfo.java
new file mode 100644
index 0000000..e9e7da1
--- /dev/null
+++ b/api/src/com/cloud/offering/DiskOfferingInfo.java
@@ -0,0 +1,47 @@
+package com.cloud.offering;
+
+public class DiskOfferingInfo {
+    private DiskOffering _diskOffering;
+    private Long _size;
+    private Long _minIops;
+    private Long _maxIops;
+
+    public DiskOfferingInfo() {
+    }
+
+    public DiskOfferingInfo(DiskOffering diskOffering) {
+        _diskOffering = diskOffering;
+    }
+
+    public void setDiskOffering(DiskOffering diskOffering) {
+        _diskOffering = diskOffering;
+    }
+
+    public DiskOffering getDiskOffering() {
+        return _diskOffering;
+    }
+
+    public void setSize(Long size) {
+        _size = size;
+    }
+
+    public Long getSize() {
+        return _size;
+    }
+
+    public void setMinIops(Long minIops) {
+        _minIops = minIops;
+    }
+
+    public Long getMinIops() {
+        return _minIops;
+    }
+
+    public void setMaxIops(Long maxIops) {
+        _maxIops = maxIops;
+    }
+
+    public Long getMaxIops() {
+        return _maxIops;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c427e8db/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
index d33e04e..bd363da 100755
--- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
@@ -462,12 +462,62 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd {
         }
     }
 
+    // this is an opportunity to verify that parameters that came in via the Details Map are OK
+    // for example, minIops and maxIops should either both be specified or neither be specified and,
+    // if specified, minIops should be <= maxIops
+    private void verifyDetails() {
+        Map<String, String> map = getDetails();
+
+        if (map != null) {
+            String minIops = (String)map.get("minIops");
+            String maxIops = (String)map.get("maxIops");
+
+            if ((minIops != null && maxIops == null) || (minIops == null && maxIops != null)) {
+                throw new InvalidParameterValueException("Either 'Min IOPS' and 'Max IOPS' must both be specified or neither be specified.");
+            }
+
+            long lMinIops;
+
+            try {
+                if (minIops != null) {
+                    lMinIops = Long.valueOf(minIops);
+                }
+                else {
+                    lMinIops = 0;
+                }
+            }
+            catch (NumberFormatException ex) {
+                throw new InvalidParameterValueException("'Min IOPS' must be a whole number.");
+            }
+
+            long lMaxIops;
+
+            try {
+                if (maxIops != null) {
+                    lMaxIops = Long.valueOf(maxIops);
+                }
+                else {
+                    lMaxIops = 0;
+                }
+            }
+            catch (NumberFormatException ex) {
+                throw new InvalidParameterValueException("'Max IOPS' must be a whole number.");
+            }
+
+            if (lMinIops > lMaxIops) {
+                throw new InvalidParameterValueException("'Min IOPS' must be less than or equal to 'Max IOPS'.");
+            }
+        }
+    }
+
     @Override
     public void create() throws ResourceAllocationException {
         try {
             //Verify that all objects exist before passing them to the service
             Account owner = _accountService.getActiveAccountById(getEntityOwnerId());
 
+            verifyDetails();
+
             DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
             if (zone == null) {
                 throw new InvalidParameterValueException("Unable to find zone by id=" + zoneId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c427e8db/engine/api/src/com/cloud/vm/VirtualMachineManager.java
----------------------------------------------------------------------
diff --git a/engine/api/src/com/cloud/vm/VirtualMachineManager.java b/engine/api/src/com/cloud/vm/VirtualMachineManager.java
index 3535a32..350f396 100644
--- a/engine/api/src/com/cloud/vm/VirtualMachineManager.java
+++ b/engine/api/src/com/cloud/vm/VirtualMachineManager.java
@@ -37,11 +37,11 @@ import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.network.Network;
 import com.cloud.offering.DiskOffering;
+import com.cloud.offering.DiskOfferingInfo;
 import com.cloud.offering.ServiceOffering;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.Volume;
 import com.cloud.template.VirtualMachineTemplate;
-import com.cloud.utils.Pair;
 import com.cloud.utils.component.Manager;
 import com.cloud.utils.fsm.NoTransitionException;
 
@@ -76,7 +76,7 @@ public interface VirtualMachineManager extends Manager {
      * @param hyperType Hypervisor type
      * @throws InsufficientCapacityException If there are insufficient capacity to deploy this vm.
      */
-    void allocate(String vmInstanceName, VirtualMachineTemplate template, ServiceOffering serviceOffering, Pair<? extends DiskOffering, Long> rootDiskOffering,
+    void allocate(String vmInstanceName, VirtualMachineTemplate template, ServiceOffering serviceOffering, DiskOfferingInfo rootDiskOfferingInfo,
         LinkedHashMap<? extends DiskOffering, Long> dataDiskOfferings, LinkedHashMap<? extends Network, List<? extends NicProfile>> auxiliaryNetworks, DeploymentPlan plan,
         HypervisorType hyperType) throws InsufficientCapacityException;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c427e8db/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
index f79d336..2531074 100644
--- a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
+++ b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
@@ -106,7 +106,7 @@ public interface VolumeOrchestrationService {
 
     boolean canVmRestartOnAnotherServer(long vmId);
 
-    DiskProfile allocateTemplatedVolume(Type type, String name, DiskOffering offering, Long rootDisksize, VirtualMachineTemplate template, VirtualMachine vm,
+    DiskProfile allocateTemplatedVolume(Type type, String name, DiskOffering offering, Long rootDisksize, Long minIops, Long maxIops, VirtualMachineTemplate template, VirtualMachine vm,
         Account owner);
 
     String getVmNameFromVolumeId(long volumeId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c427e8db/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index c13cde7..8edbb76 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -154,6 +154,7 @@ import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.NetworkVO;
 import com.cloud.network.rules.RulesManager;
 import com.cloud.offering.DiskOffering;
+import com.cloud.offering.DiskOfferingInfo;
 import com.cloud.offering.ServiceOffering;
 import com.cloud.org.Cluster;
 import com.cloud.resource.ResourceManager;
@@ -372,7 +373,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
     @Override
     @DB
     public void allocate(String vmInstanceName, final VirtualMachineTemplate template, ServiceOffering serviceOffering,
-            final Pair<? extends DiskOffering, Long> rootDiskOffering, LinkedHashMap<? extends DiskOffering, Long> dataDiskOfferings,
+            final DiskOfferingInfo rootDiskOfferingInfo, LinkedHashMap<? extends DiskOffering, Long> dataDiskOfferings,
             final LinkedHashMap<? extends Network, List<? extends NicProfile>> auxiliaryNetworks, DeploymentPlan plan, HypervisorType hyperType)
                     throws InsufficientCapacityException {
 
@@ -412,11 +413,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
                         }
 
                         if (template.getFormat() == ImageFormat.ISO) {
-                            volumeMgr.allocateRawVolume(Type.ROOT, "ROOT-" + vmFinal.getId(), rootDiskOffering.first(), rootDiskOffering.second(), vmFinal, template, owner);
+                            volumeMgr.allocateRawVolume(Type.ROOT, "ROOT-" + vmFinal.getId(), rootDiskOfferingInfo.getDiskOffering(), rootDiskOfferingInfo.getSize(), vmFinal,
+                                    template, owner);
                         } else if (template.getFormat() == ImageFormat.BAREMETAL) {
                             // Do nothing
                         } else {
-                            volumeMgr.allocateTemplatedVolume(Type.ROOT, "ROOT-" + vmFinal.getId(), rootDiskOffering.first(), rootDiskOffering.second(), template, vmFinal, owner);
+                            volumeMgr.allocateTemplatedVolume(Type.ROOT, "ROOT-" + vmFinal.getId(), rootDiskOfferingInfo.getDiskOffering(), rootDiskOfferingInfo.getSize(),
+                                    rootDiskOfferingInfo.getMinIops(), rootDiskOfferingInfo.getMaxIops(), template, vmFinal, owner);
                         }
 
                         for (Map.Entry<? extends DiskOffering, Long> offering : dataDiskOfferingsFinal.entrySet()) {
@@ -433,7 +436,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
     @Override
     public void allocate(String vmInstanceName, VirtualMachineTemplate template, ServiceOffering serviceOffering,
             LinkedHashMap<? extends Network, List<? extends NicProfile>> networks, DeploymentPlan plan, HypervisorType hyperType) throws InsufficientCapacityException {
-        allocate(vmInstanceName, template, serviceOffering, new Pair<DiskOffering, Long>(serviceOffering, null), null, networks, plan, hyperType);
+        allocate(vmInstanceName, template, serviceOffering, new DiskOfferingInfo(serviceOffering), null, networks, plan, hyperType);
     }
 
     private VirtualMachineGuru getVmGuru(VirtualMachine vm) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c427e8db/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java
index b00b5ad..7969e43 100755
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java
@@ -46,18 +46,19 @@ import com.cloud.network.Network;
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.NetworkVO;
 import com.cloud.offering.DiskOffering;
+import com.cloud.offering.DiskOfferingInfo;
 import com.cloud.service.ServiceOfferingVO;
 import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.user.dao.AccountDao;
-import com.cloud.utils.Pair;
 import com.cloud.utils.component.ComponentContext;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachineManager;
 import com.cloud.vm.dao.UserVmDao;
+import com.cloud.vm.dao.UserVmDetailsDao;
 import com.cloud.vm.dao.VMInstanceDao;
 
 @Component
@@ -79,6 +80,9 @@ public class CloudOrchestrator implements OrchestrationService {
     protected UserVmDao _userVmDao = null;
 
     @Inject
+    protected UserVmDetailsDao _userVmDetailsDao = null;
+
+    @Inject
     protected ServiceOfferingDao _serviceOfferingDao;
 
     @Inject
@@ -176,12 +180,25 @@ public class CloudOrchestrator implements OrchestrationService {
         // If the template represents an ISO, a disk offering must be passed in, and will be used to create the root disk
         // Else, a disk offering is optional, and if present will be used to create the data disk
 
-        Pair<DiskOfferingVO, Long> rootDiskOffering = new Pair<DiskOfferingVO, Long>(null, null);
+        DiskOfferingInfo rootDiskOfferingInfo = new DiskOfferingInfo();
         LinkedHashMap<DiskOfferingVO, Long> dataDiskOfferings = new LinkedHashMap<DiskOfferingVO, Long>();
 
         ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getId(), vm.getServiceOfferingId());
-        rootDiskOffering.first(offering);
-        rootDiskOffering.second(rootDiskSize);
+
+        rootDiskOfferingInfo.setDiskOffering(offering);
+        rootDiskOfferingInfo.setSize(rootDiskSize);
+
+        if (offering.isCustomizedIops()) {
+            Map<String, String> userVmDetails = _userVmDetailsDao.listDetailsKeyPairs(vm.getId());
+
+            if (userVmDetails != null) {
+                String minIops = userVmDetails.get("minIops");
+                String maxIops = userVmDetails.get("maxIops");
+
+                rootDiskOfferingInfo.setMinIops(minIops != null && minIops.trim().length() > 0 ? Long.parseLong(minIops) : null);
+                rootDiskOfferingInfo.setMaxIops(maxIops != null && maxIops.trim().length() > 0 ? Long.parseLong(maxIops) : null);
+            }
+        }
 
         if (vm.getDiskOfferingId() != null) {
             DiskOfferingVO diskOffering = _diskOfferingDao.findById(vm.getDiskOfferingId());
@@ -199,7 +216,7 @@ public class CloudOrchestrator implements OrchestrationService {
             dataDiskOfferings.put(diskOffering, size);
         }
 
-        _itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(templateId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, plan,
+        _itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(templateId)), offering, rootDiskOfferingInfo, dataDiskOfferings, networkIpMap, plan,
             hypervisorType);
 
         return vmEntity;
@@ -217,9 +234,11 @@ public class CloudOrchestrator implements OrchestrationService {
         //load vm instance and offerings and call virtualMachineManagerImpl
         VMInstanceVO vm = _vmDao.findByUuid(id);
 
-        Pair<DiskOffering, Long> rootDiskOffering = new Pair<DiskOffering, Long>(null, null);
         ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getId(), vm.getServiceOfferingId());
-        rootDiskOffering.first(offering);
+
+        DiskOfferingInfo rootDiskOfferingInfo = new DiskOfferingInfo();
+
+        rootDiskOfferingInfo.setDiskOffering(offering);
 
         LinkedHashMap<DiskOffering, Long> dataDiskOfferings = new LinkedHashMap<DiskOffering, Long>();
         Long diskOfferingId = vm.getDiskOfferingId();
@@ -238,8 +257,9 @@ public class CloudOrchestrator implements OrchestrationService {
             }
             _volumeMgr.validateVolumeSizeRange(size * 1024 * 1024 * 1024);
         }
-        rootDiskOffering.first(diskOffering);
-        rootDiskOffering.second(size);
+
+        rootDiskOfferingInfo.setDiskOffering(diskOffering);
+        rootDiskOfferingInfo.setSize(size);
 
         LinkedHashMap<Network, List<? extends NicProfile>> networkIpMap = new LinkedHashMap<Network, List<? extends NicProfile>>();
         for (String uuid : networkNicMap.keySet()) {
@@ -251,7 +271,7 @@ public class CloudOrchestrator implements OrchestrationService {
 
         HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
 
-        _itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, plan, hypervisorType);
+        _itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(isoId)), offering, rootDiskOfferingInfo, dataDiskOfferings, networkIpMap, plan, hypervisorType);
 
         return vmEntity;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c427e8db/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
index 4d0c787..f3753a7 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@ -605,15 +605,19 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
     }
 
     @Override
-    public DiskProfile allocateTemplatedVolume(Type type, String name, DiskOffering offering, Long rootDisksize, VirtualMachineTemplate template, VirtualMachine vm, Account owner) {
+    public DiskProfile allocateTemplatedVolume(Type type, String name, DiskOffering offering, Long rootDisksize, Long minIops, Long maxIops, VirtualMachineTemplate template, VirtualMachine vm, Account owner) {
         assert (template.getFormat() != ImageFormat.ISO) : "ISO is not a template really....";
 
         Long size = _tmpltMgr.getTemplateSize(template.getId(), vm.getDataCenterId());
         if (rootDisksize != null) {
             size = (rootDisksize * 1024 * 1024 * 1024);
         }
-        VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(), owner.getDomainId(), owner.getId(), offering.getId(), size, offering.getMinIops(), offering.getMaxIops(),
-                null);
+
+        minIops = minIops != null ? minIops : offering.getMinIops();
+        maxIops = maxIops != null ? maxIops : offering.getMaxIops();
+
+        VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(), owner.getDomainId(), owner.getId(), offering.getId(), size, minIops, maxIops, null);
+
         vol.setFormat(getSupportedImageFormatForCluster(template.getHypervisorType()));
         if (vm != null) {
             vol.setInstanceId(vm.getId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c427e8db/ui/css/cloudstack3.css
----------------------------------------------------------------------
diff --git a/ui/css/cloudstack3.css b/ui/css/cloudstack3.css
index 162f77b..11c1c7e 100644
--- a/ui/css/cloudstack3.css
+++ b/ui/css/cloudstack3.css
@@ -6050,6 +6050,13 @@ label.error {
   border-radius: 4px;
 }
 
+.multi-wizard.instance-wizard .section.custom-iops {
+  position: relative;
+  background: #F4F4F4;
+  padding: 7px;
+  border-radius: 4px;
+}
+
 .multi-wizard.instance-wizard .section.custom-size input[type=radio] {
   float: left;
 }
@@ -6060,6 +6067,12 @@ label.error {
   margin: 6px -1px 0 8px;
 }
 
+.multi-wizard.instance-wizard .section.custom-iops input[type=text] {
+  float: left;
+  width: 28px;
+  margin: 6px -1px 0 8px;
+}
+
 .multi-wizard.instance-wizard .section.custom-size label.error {
   position: absolute;
   top: 29px;
@@ -6075,29 +6088,56 @@ label.error {
   height: 235px;
 }
 
+.instance-wizard .step.service-offering.custom-iops .select-container {
+  height: 235px;
+}
+
 .instance-wizard .step.service-offering .custom-size {
   display: none;
 }
 
+.instance-wizard .step.service-offering .custom-iops {
+  display: none;
+}
+
 .instance-wizard .step.service-offering.custom-size .custom-size {
   display: block;
 }
 
+.instance-wizard .step.service-offering.custom-iops .custom-iops {
+  display: block;
+}
+
 .instance-wizard .step.service-offering .custom-size .field {
   width: 30%;
   float: left;
   margin-bottom: 13px;
 }
 
+.instance-wizard .step.service-offering .custom-iops .field {
+  width: 30%;
+  float: left;
+  margin-bottom: 13px;
+}
+
 .instance-wizard .step.service-offering .custom-size .field label {
   text-indent: 20px;
 }
 
+.instance-wizard .step.service-offering .custom-iops .field label {
+  text-indent: 20px;
+}
+
 .instance-wizard .step.service-offering .custom-size .field input {
   width: 88%;
   margin-left: 26px;
 }
 
+.instance-wizard .step.service-offering .custom-iops .field input {
+  width: 88%;
+  margin-left: 26px;
+}
+
 /*** Network*/
 .multi-wizard.instance-wizard .no-network {
   background: #FFFFFF;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c427e8db/ui/index.jsp
----------------------------------------------------------------------
diff --git a/ui/index.jsp b/ui/index.jsp
index 4daa9eb..d46c395 100644
--- a/ui/index.jsp
+++ b/ui/index.jsp
@@ -221,6 +221,17 @@
                                         <input type="text" class="required disallowSpecialCharacters" name="compute-memory" />
                                     </div>
                                 </div>
+                                <!-- Custom iops slider -->
+                                <div class="section custom-iops">
+                                    <div class="field">
+                                        <label><fmt:message key="label.disk.iops.min"/></label>
+                                        <input type="text" class="disallowSpecialCharacters" name="disk-min-iops" />
+                                    </div>
+                                    <div class="field">
+                                        <label><fmt:message key="label.disk.iops.max"/></label>
+                                        <input type="text" class="disallowSpecialCharacters" name="disk-max-iops" />
+                                    </div>
+                                </div>
                             </div>
                         </div>
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c427e8db/ui/scripts/instanceWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instanceWizard.js b/ui/scripts/instanceWizard.js
index 3ee9af1..5c04d0e 100644
--- a/ui/scripts/instanceWizard.js
+++ b/ui/scripts/instanceWizard.js
@@ -301,6 +301,7 @@
                         args.response.success({
                             customFlag: 'iscustomized',
                         	//customFlag: 'offerha', //for testing only
+                        	customIopsFlag: 'iscustomizediops',
                             data: {
                                 serviceOfferings: serviceOfferingObjs
                             }
@@ -631,7 +632,20 @@
 	            	});
 	            }               
             }
-            
+
+            if (args.$wizard.find('input[name=disk-min-iops]').parent().parent().css('display') != 'none') {
+	            if (args.$wizard.find('input[name=disk-min-iops]').val().length > 0) {
+	            	$.extend(deployVmData, {
+	            	    'details[0].minIops' : args.$wizard.find('input[name=disk-min-iops]').val()
+	            	});
+	            }
+	            if (args.$wizard.find('input[name=disk-max-iops]').val().length > 0) {
+	            	$.extend(deployVmData, {
+	            	    'details[0].maxIops' : args.$wizard.find('input[name=disk-max-iops]').val()
+	            	});
+	            }
+            }
+
             //step 4: select disk offering
             if (args.data.diskofferingid != null && args.data.diskofferingid != "0") {                
             	$.extend(deployVmData, {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c427e8db/ui/scripts/ui-custom/instanceWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/instanceWizard.js b/ui/scripts/ui-custom/instanceWizard.js
index 8884ebe..f5f7b10 100644
--- a/ui/scripts/ui-custom/instanceWizard.js
+++ b/ui/scripts/ui-custom/instanceWizard.js
@@ -458,6 +458,14 @@
                                             $step.removeClass('custom-size');
                                         }
 
+                                        var customIops = item[args.customIopsFlag];
+
+                                        if (customIops) {
+                                            $step.addClass('custom-iops');
+                                        } else {
+                                            $step.removeClass('custom-iops');
+                                        }
+
                                         return true;
                                     });
 


[08/50] [abbrv] CLOUDSTACK-5920: IAM service plugin.

Posted by ml...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/response/iam/IAMPermissionResponse.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/response/iam/IAMPermissionResponse.java b/services/iam/plugin/src/org/apache/cloudstack/api/response/iam/IAMPermissionResponse.java
new file mode 100644
index 0000000..b7af4da
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/response/iam/IAMPermissionResponse.java
@@ -0,0 +1,125 @@
+// 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.iam;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.apache.cloudstack.acl.IAMEntityType;
+import org.apache.cloudstack.acl.PermissionScope;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.iam.api.IAMPolicyPermission;
+
+import com.cloud.serializer.Param;
+
+public class IAMPermissionResponse extends BaseResponse {
+
+    @SerializedName(ApiConstants.IAM_ACTION)
+    @Param(description = "action of this permission")
+    private String action;
+
+    @SerializedName(ApiConstants.ENTITY_TYPE)
+    @Param(description = "the entity type of this permission")
+    private IAMEntityType entityType;
+
+    @SerializedName(ApiConstants.IAM_SCOPE)
+    @Param(description = "scope of this permission")
+    private PermissionScope scope;
+
+    @SerializedName(ApiConstants.IAM_SCOPE_ID)
+    @Param(description = "scope id of this permission")
+    private Long scopeId;
+
+    @SerializedName(ApiConstants.IAM_ALLOW_DENY)
+    @Param(description = "allow or deny of this permission")
+    private IAMPolicyPermission.Permission permission;
+
+    public IAMEntityType getEntityType() {
+        return entityType;
+    }
+
+    public void setEntityType(IAMEntityType entityType) {
+        this.entityType = entityType;
+    }
+
+    public String getAction() {
+        return action;
+    }
+
+    public void setAction(String action) {
+        this.action = action;
+    }
+
+    public PermissionScope getScope() {
+        return scope;
+    }
+
+    public void setScope(PermissionScope scope) {
+        this.scope = scope;
+    }
+
+    public Long getScopeId() {
+        return scopeId;
+    }
+
+    public void setScopeId(Long scopeId) {
+        this.scopeId = scopeId;
+    }
+
+    public IAMPolicyPermission.Permission getPermission() {
+        return permission;
+    }
+
+    public void setPermission(IAMPolicyPermission.Permission permission) {
+        this.permission = permission;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((action == null) ? 0 : action.hashCode());
+        result = prime * result + ((entityType == null) ? 0 : entityType.hashCode());
+        result = prime * result + ((scope == null) ? 0 : scope.hashCode());
+        result = prime * result + ((scopeId == null) ? 0 : scopeId.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        IAMPermissionResponse other = (IAMPermissionResponse) obj;
+        if ((entityType == null && other.entityType != null) || !entityType.equals(other.entityType)) {
+            return false;
+        } else if ((action == null && other.action != null) || !action.equals(other.action)) {
+            return false;
+        } else if ((scope == null && other.scope != null) || !scope.equals(other.scope)) {
+            return false;
+        } else if ((scopeId == null && other.scopeId != null) || !scopeId.equals(other.scopeId)) {
+            return false;
+        }
+        return true;
+    }
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/api/response/iam/IAMPolicyResponse.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/response/iam/IAMPolicyResponse.java b/services/iam/plugin/src/org/apache/cloudstack/api/response/iam/IAMPolicyResponse.java
new file mode 100644
index 0000000..dc29369
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/api/response/iam/IAMPolicyResponse.java
@@ -0,0 +1,177 @@
+// 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.iam;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
+import org.apache.cloudstack.api.response.ControlledViewEntityResponse;
+import org.apache.cloudstack.iam.api.IAMPolicy;
+
+import com.cloud.serializer.Param;
+
+@SuppressWarnings("unused")
+@EntityReference(value = IAMPolicy.class)
+public class IAMPolicyResponse extends BaseResponse implements ControlledViewEntityResponse {
+
+    @SerializedName(ApiConstants.ID)
+    @Param(description = "the ID of the iam policy")
+    private String id;
+
+    @SerializedName(ApiConstants.NAME)
+    @Param(description = "the name of the iam policy")
+    private String name;
+
+    @SerializedName(ApiConstants.DESCRIPTION)
+    @Param(description = "the description of the iam policy")
+    private String description;
+
+    @SerializedName(ApiConstants.DOMAIN_ID)
+    @Param(description = "the domain ID of the iam policy")
+    private String domainId;
+
+    @SerializedName(ApiConstants.DOMAIN)
+    @Param(description = "the domain name of the iam policy")
+    private String domainName;
+
+    @SerializedName(ApiConstants.ACCOUNT)
+    @Param(description = "the account owning the policy")
+    private String accountName;
+
+    @SerializedName(ApiConstants.IAM_PERMISSIONS)
+    @Param(description = "set of permissions for the iam policy")
+    private Set<IAMPermissionResponse> permissionList;
+
+    public IAMPolicyResponse() {
+        permissionList = new LinkedHashSet<IAMPermissionResponse>();
+    }
+
+    @Override
+    public String getObjectId() {
+        return getId();
+    }
+
+
+    public String getId() {
+        return id;
+     }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Override
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Override
+    public void setDomainName(String domainName) {
+        this.domainName = domainName;
+    }
+
+    public Set<IAMPermissionResponse> getPermissionList() {
+        return permissionList;
+    }
+
+    public void setPermissionList(Set<IAMPermissionResponse> perms) {
+        permissionList = perms;
+    }
+
+    public void addPermission(IAMPermissionResponse perm) {
+        permissionList.add(perm);
+    }
+
+    @Override
+    public void setAccountName(String accountName) {
+        this.accountName = accountName;
+    }
+
+    @Override
+    public void setProjectId(String projectId) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setProjectName(String projectName) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public String getDomainName() {
+        return domainName;
+    }
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((id == null) ? 0 : id.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        IAMPolicyResponse other = (IAMPolicyResponse) obj;
+        if (id == null) {
+            if (other.id != null)
+                return false;
+        } else if (!id.equals(other.id))
+            return false;
+        return true;
+    }
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/iam/IAMApiService.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/iam/IAMApiService.java b/services/iam/plugin/src/org/apache/cloudstack/iam/IAMApiService.java
new file mode 100644
index 0000000..bb8f03b
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/iam/IAMApiService.java
@@ -0,0 +1,87 @@
+// 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.iam;
+
+import java.util.List;
+
+import org.apache.cloudstack.acl.PermissionScope;
+import org.apache.cloudstack.acl.SecurityChecker.AccessType;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.iam.IAMGroupResponse;
+import org.apache.cloudstack.api.response.iam.IAMPolicyResponse;
+import org.apache.cloudstack.iam.api.IAMGroup;
+import org.apache.cloudstack.iam.api.IAMPolicy;
+import org.apache.cloudstack.iam.api.IAMPolicyPermission;
+import org.apache.cloudstack.iam.api.IAMPolicyPermission.Permission;
+
+import com.cloud.user.Account;
+import com.cloud.utils.component.PluggableService;
+
+public interface IAMApiService extends PluggableService {
+
+    /* ACL group related interfaces */
+    IAMGroup createIAMGroup(Account caller, String iamGroupName, String description);
+
+    boolean deleteIAMGroup(Long iamGroupId);
+
+    List<IAMGroup> listIAMGroups(long accountId);
+
+    IAMGroup addAccountsToGroup(List<Long> acctIds, Long groupId);
+
+    IAMGroup removeAccountsFromGroup(List<Long> acctIds, Long groupId);
+
+    /* IAM Policy related interfaces */
+    IAMPolicy createIAMPolicy(Account caller, String iamPolicyName, String description, Long parentPolicyId);
+
+    boolean deleteIAMPolicy(long iamPolicyId);
+
+    List<IAMPolicy> listIAMPolicies(long accountId);
+
+    IAMGroup attachIAMPoliciesToGroup(List<Long> policyIds, Long groupId);
+
+    IAMGroup removeIAMPoliciesFromGroup(List<Long> policyIds, Long groupId);
+
+    void attachIAMPolicyToAccounts(Long policyId, List<Long> accountIds);
+
+    void removeIAMPolicyFromAccounts(Long policyId, List<Long> accountIds);
+
+    IAMPolicy addIAMPermissionToIAMPolicy(long iamPolicyId, String entityType, PermissionScope scope, Long scopeId,
+            String action, Permission perm, Boolean recursive);
+
+    IAMPolicy removeIAMPermissionFromIAMPolicy(long iamPolicyId, String entityType, PermissionScope scope, Long scopeId, String action);
+
+    IAMPolicyPermission getIAMPolicyPermission(long accountId, String entityType, String action);
+
+    /* Utility routine to grant/revoke invidivual resource to list of accounts */
+    void grantEntityPermissioinToAccounts(String entityType, Long entityId, AccessType accessType, String action, List<Long> accountIds);
+
+    void revokeEntityPermissioinFromAccounts(String entityType, Long entityId, AccessType accessType, String action, List<Long> accountIds);
+
+    /* Response Generation */
+    IAMPolicyResponse createIAMPolicyResponse(IAMPolicy policy);
+
+    IAMGroupResponse createIAMGroupResponse(IAMGroup group);
+
+    ListResponse<IAMGroupResponse> listIAMGroups(Long iamGroupId, String iamGroupName,
+            Long domainId, Long startIndex, Long pageSize);
+
+    ListResponse<IAMPolicyResponse> listIAMPolicies(Long iamPolicyId, String iamPolicyName,
+            Long domainId, Long startIndex, Long pageSize);
+
+    // Convert passed scope uuid to internal scope long id
+    Long getPermissionScopeId(String scope, String entityType, String scopeId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/iam/IAMApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/iam/IAMApiServiceImpl.java b/services/iam/plugin/src/org/apache/cloudstack/iam/IAMApiServiceImpl.java
new file mode 100644
index 0000000..97519f2
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/iam/IAMApiServiceImpl.java
@@ -0,0 +1,800 @@
+// 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.iam;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.acl.IAMEntityType;
+import org.apache.cloudstack.acl.PermissionScope;
+import org.apache.cloudstack.acl.SecurityChecker.AccessType;
+import org.apache.cloudstack.affinity.AffinityGroupVO;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.InternalIdentity;
+import org.apache.cloudstack.api.command.iam.AddAccountToIAMGroupCmd;
+import org.apache.cloudstack.api.command.iam.AddIAMPermissionToIAMPolicyCmd;
+import org.apache.cloudstack.api.command.iam.AttachIAMPolicyToAccountCmd;
+import org.apache.cloudstack.api.command.iam.AttachIAMPolicyToIAMGroupCmd;
+import org.apache.cloudstack.api.command.iam.CreateIAMGroupCmd;
+import org.apache.cloudstack.api.command.iam.CreateIAMPolicyCmd;
+import org.apache.cloudstack.api.command.iam.DeleteIAMGroupCmd;
+import org.apache.cloudstack.api.command.iam.DeleteIAMPolicyCmd;
+import org.apache.cloudstack.api.command.iam.ListIAMGroupsCmd;
+import org.apache.cloudstack.api.command.iam.ListIAMPoliciesCmd;
+import org.apache.cloudstack.api.command.iam.RemoveAccountFromIAMGroupCmd;
+import org.apache.cloudstack.api.command.iam.RemoveIAMPermissionFromIAMPolicyCmd;
+import org.apache.cloudstack.api.command.iam.RemoveIAMPolicyFromAccountCmd;
+import org.apache.cloudstack.api.command.iam.RemoveIAMPolicyFromIAMGroupCmd;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.iam.IAMGroupResponse;
+import org.apache.cloudstack.api.response.iam.IAMPermissionResponse;
+import org.apache.cloudstack.api.response.iam.IAMPolicyResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO;
+import org.apache.cloudstack.framework.messagebus.MessageBus;
+import org.apache.cloudstack.framework.messagebus.MessageSubscriber;
+import org.apache.cloudstack.iam.api.IAMGroup;
+import org.apache.cloudstack.iam.api.IAMPolicy;
+import org.apache.cloudstack.iam.api.IAMPolicyPermission;
+import org.apache.cloudstack.iam.api.IAMPolicyPermission.Permission;
+import org.apache.cloudstack.iam.api.IAMService;
+import org.apache.cloudstack.iam.server.IAMGroupVO;
+import org.apache.cloudstack.iam.server.IAMPolicyVO;
+import org.apache.cloudstack.region.gslb.GlobalLoadBalancerRuleVO;
+
+import com.cloud.api.ApiServerService;
+import com.cloud.domain.Domain;
+import com.cloud.domain.DomainVO;
+import com.cloud.domain.dao.DomainDao;
+import com.cloud.event.ActionEvent;
+import com.cloud.event.EventTypes;
+import com.cloud.event.EventVO;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.network.UserIpv6AddressVO;
+import com.cloud.network.VpnUserVO;
+import com.cloud.network.as.AutoScalePolicyVO;
+import com.cloud.network.as.AutoScaleVmGroupVO;
+import com.cloud.network.as.AutoScaleVmProfileVO;
+import com.cloud.network.as.ConditionVO;
+import com.cloud.network.dao.IPAddressVO;
+import com.cloud.network.dao.MonitoringServiceVO;
+import com.cloud.network.dao.NetworkVO;
+import com.cloud.network.dao.RemoteAccessVpnVO;
+import com.cloud.network.dao.Site2SiteCustomerGatewayVO;
+import com.cloud.network.dao.Site2SiteVpnConnectionVO;
+import com.cloud.network.dao.Site2SiteVpnGatewayVO;
+import com.cloud.network.dao.SslCertVO;
+import com.cloud.network.rules.FirewallRuleVO;
+import com.cloud.network.rules.PortForwardingRuleVO;
+import com.cloud.network.security.SecurityGroupVO;
+import com.cloud.network.vpc.StaticRouteVO;
+import com.cloud.network.vpc.VpcGatewayVO;
+import com.cloud.network.vpc.VpcVO;
+import com.cloud.projects.ProjectInvitationVO;
+import com.cloud.storage.SnapshotVO;
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.VolumeVO;
+import com.cloud.tags.ResourceTagVO;
+import com.cloud.template.TemplateManager;
+import com.cloud.user.Account;
+import com.cloud.user.AccountManager;
+import com.cloud.user.AccountVO;
+import com.cloud.user.DomainManager;
+import com.cloud.user.SSHKeyPairVO;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.Pair;
+import com.cloud.utils.component.Manager;
+import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.EntityManager;
+import com.cloud.vm.InstanceGroupVO;
+import com.cloud.vm.VMInstanceVO;
+import com.cloud.vm.dao.NicIpAliasVO;
+import com.cloud.vm.dao.NicSecondaryIpVO;
+import com.cloud.vm.snapshot.VMSnapshotVO;
+
+@Local(value = {IAMApiService.class})
+public class IAMApiServiceImpl extends ManagerBase implements IAMApiService, Manager {
+
+    public static final Logger s_logger = Logger.getLogger(IAMApiServiceImpl.class);
+    private String _name;
+
+    @Inject
+    ApiServerService _apiServer;
+
+    @Inject
+    IAMService _iamSrv;
+
+    @Inject
+    DomainDao _domainDao;
+
+    @Inject
+    AccountDao _accountDao;
+
+    @Inject
+    AccountManager _accountMgr;
+
+    @Inject
+    MessageBus _messageBus;
+
+    @Inject
+    EntityManager _entityMgr;
+
+    private static final Map<IAMEntityType, Class<?>> s_typeMap = new HashMap<IAMEntityType, Class<?>>();
+    static {
+        s_typeMap.put(IAMEntityType.VirtualMachine, VMInstanceVO.class);
+        s_typeMap.put(IAMEntityType.Volume, VolumeVO.class);
+        s_typeMap.put(IAMEntityType.ResourceTag, ResourceTagVO.class);
+        s_typeMap.put(IAMEntityType.Account, AccountVO.class);
+        s_typeMap.put(IAMEntityType.AffinityGroup, AffinityGroupVO.class);
+        s_typeMap.put(IAMEntityType.AutoScalePolicy, AutoScalePolicyVO.class);
+        s_typeMap.put(IAMEntityType.AutoScaleVmProfile, AutoScaleVmProfileVO.class);
+        s_typeMap.put(IAMEntityType.AutoScaleVmGroup, AutoScaleVmGroupVO.class);
+        s_typeMap.put(IAMEntityType.Condition, ConditionVO.class);
+        s_typeMap.put(IAMEntityType.Vpc, VpcVO.class);
+        s_typeMap.put(IAMEntityType.VpcGateway, VpcGatewayVO.class);
+        s_typeMap.put(IAMEntityType.PrivateGateway, RemoteAccessVpnVO.class);
+        s_typeMap.put(IAMEntityType.VpnUser, VpnUserVO.class);
+        s_typeMap.put(IAMEntityType.VMSnapshot, VMSnapshotVO.class);
+        s_typeMap.put(IAMEntityType.VirtualMachineTemplate, VMTemplateVO.class);
+        s_typeMap.put(IAMEntityType.UserIpv6Address, UserIpv6AddressVO.class);
+        s_typeMap.put(IAMEntityType.StaticRoute, StaticRouteVO.class);
+        s_typeMap.put(IAMEntityType.SSHKeyPair, SSHKeyPairVO.class);
+        s_typeMap.put(IAMEntityType.Snapshot, SnapshotVO.class);
+        s_typeMap.put(IAMEntityType.Site2SiteVpnGateway, Site2SiteVpnGatewayVO.class);
+        s_typeMap.put(IAMEntityType.Site2SiteCustomerGateway, Site2SiteCustomerGatewayVO.class);
+        s_typeMap.put(IAMEntityType.Site2SiteVpnConnection, Site2SiteVpnConnectionVO.class);
+        s_typeMap.put(IAMEntityType.SecurityGroup, SecurityGroupVO.class);
+        s_typeMap.put(IAMEntityType.RemoteAccessVpn, RemoteAccessVpnVO.class);
+        s_typeMap.put(IAMEntityType.PublicIpAddress, IPAddressVO.class);
+        s_typeMap.put(IAMEntityType.ProjectInvitation, ProjectInvitationVO.class);
+        s_typeMap.put(IAMEntityType.NicSecondaryIp, NicSecondaryIpVO.class);
+        s_typeMap.put(IAMEntityType.NicIpAlias, NicIpAliasVO.class);
+        s_typeMap.put(IAMEntityType.Network, NetworkVO.class);
+        s_typeMap.put(IAMEntityType.IpAddress, IPAddressVO.class);
+        s_typeMap.put(IAMEntityType.InstanceGroup, InstanceGroupVO.class);
+        s_typeMap.put(IAMEntityType.GlobalLoadBalancerRule, GlobalLoadBalancerRuleVO.class);
+        s_typeMap.put(IAMEntityType.FirewallRule, FirewallRuleVO.class);
+        s_typeMap.put(IAMEntityType.PortForwardingRule, PortForwardingRuleVO.class);
+        s_typeMap.put(IAMEntityType.Event, EventVO.class);
+        s_typeMap.put(IAMEntityType.AsyncJob, AsyncJobVO.class);
+        s_typeMap.put(IAMEntityType.IAMGroup, IAMGroupVO.class);
+        s_typeMap.put(IAMEntityType.IAMPolicy, IAMPolicyVO.class);
+        s_typeMap.put(IAMEntityType.MonitorService, MonitoringServiceVO.class);
+        s_typeMap.put(IAMEntityType.SSLCert, SslCertVO.class);
+    }
+
+    @Override
+    public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
+        _messageBus.subscribe(AccountManager.MESSAGE_ADD_ACCOUNT_EVENT, new MessageSubscriber() {
+            @Override
+            public void onPublishMessage(String senderAddress, String subject, Object obj) {
+                HashMap<Long, Long> acctGroupMap = (HashMap<Long, Long>) obj;
+                for (Long accountId : acctGroupMap.keySet()) {
+                    Long groupId = acctGroupMap.get(accountId);
+                    s_logger.debug("MessageBus message: new Account Added: " + accountId + ", adding it to groupId :"
+                            + groupId);
+                    addAccountToIAMGroup(accountId, groupId);
+                    // add it to domain group too
+                    AccountVO account = _accountDao.findById(accountId);
+                    Domain domain = _domainDao.findById(account.getDomainId());
+                    if (domain != null) {
+                        List<IAMGroup> domainGroups = listDomainGroup(domain);
+
+                        if (domainGroups != null) {
+                            for (IAMGroup group : domainGroups) {
+                                addAccountToIAMGroup(accountId, new Long(group.getId()));
+                            }
+                        }
+                    }
+                }
+            }
+        });
+
+        _messageBus.subscribe(AccountManager.MESSAGE_REMOVE_ACCOUNT_EVENT, new MessageSubscriber() {
+            @Override
+            public void onPublishMessage(String senderAddress, String subject, Object obj) {
+                Long accountId = ((Long) obj);
+                if (accountId != null) {
+                    s_logger.debug("MessageBus message: Account removed: " + accountId
+                            + ", releasing the group associations");
+                    removeAccountFromIAMGroups(accountId);
+                }
+            }
+        });
+
+        _messageBus.subscribe(DomainManager.MESSAGE_ADD_DOMAIN_EVENT, new MessageSubscriber() {
+            @Override
+            public void onPublishMessage(String senderAddress, String subject, Object obj) {
+                Long domainId = ((Long) obj);
+                if (domainId != null) {
+                    s_logger.debug("MessageBus message: new Domain created: " + domainId + ", creating a new group");
+                    Domain domain = _domainDao.findById(domainId);
+                    _iamSrv.createIAMGroup("DomainGrp-" + domain.getUuid(), "Domain group", domain.getPath());
+                }
+            }
+        });
+
+        _messageBus.subscribe(DomainManager.MESSAGE_REMOVE_DOMAIN_EVENT, new MessageSubscriber() {
+            @Override
+            public void onPublishMessage(String senderAddress, String subject, Object obj) {
+                Long domainId = ((Long) obj);
+                if (domainId != null) {
+                    s_logger.debug("MessageBus message: Domain removed: " + domainId + ", removing the domain group");
+                    Domain domain = _domainDao.findById(domainId);
+                    List<IAMGroup> groups = listDomainGroup(domain);
+                    for (IAMGroup group : groups) {
+                        _iamSrv.deleteIAMGroup(group.getId());
+                    }
+                }
+            }
+        });
+
+        _messageBus.subscribe(TemplateManager.MESSAGE_REGISTER_PUBLIC_TEMPLATE_EVENT, new MessageSubscriber() {
+            @Override
+            public void onPublishMessage(String senderAddress, String subject, Object obj) {
+                Long templateId = (Long)obj;
+                if (templateId != null) {
+                    s_logger.debug("MessageBus message: new public template registered: " + templateId + ", grant permission to domain admin and normal user policies");
+                    _iamSrv.addIAMPermissionToIAMPolicy(new Long(Account.ACCOUNT_TYPE_DOMAIN_ADMIN + 1), IAMEntityType.VirtualMachineTemplate.toString(),
+                            PermissionScope.RESOURCE.toString(), templateId, "listTemplates", AccessType.UseEntry.toString(), Permission.Allow, false);
+                    _iamSrv.addIAMPermissionToIAMPolicy(new Long(Account.ACCOUNT_TYPE_NORMAL + 1), IAMEntityType.VirtualMachineTemplate.toString(),
+                            PermissionScope.RESOURCE.toString(), templateId, "listTemplates", AccessType.UseEntry.toString(), Permission.Allow, false);
+                }
+            }
+        });
+
+        _messageBus.subscribe(TemplateManager.MESSAGE_RESET_TEMPLATE_PERMISSION_EVENT, new MessageSubscriber() {
+            @Override
+            public void onPublishMessage(String senderAddress, String subject, Object obj) {
+                Long templateId = (Long)obj;
+                if (templateId != null) {
+                    s_logger.debug("MessageBus message: reset template permission: " + templateId);
+                    resetTemplatePermission(templateId);
+                }
+            }
+        });
+
+        _messageBus.subscribe(EntityManager.MESSAGE_REMOVE_ENTITY_EVENT, new MessageSubscriber() {
+            @Override
+            public void onPublishMessage(String senderAddress, String subject, Object obj) {
+                Pair<IAMEntityType, Long> entity = (Pair<IAMEntityType, Long>)obj;
+                if (entity != null) {
+                    String entityType = entity.first().toString();
+                    Long entityId = entity.second();
+                    s_logger.debug("MessageBus message: delete an entity: (" + entityType + "," + entityId + "), remove its related permission");
+                    _iamSrv.removeIAMPermissionForEntity(entityType, entityId);
+                }
+            }
+        });
+
+
+        _messageBus.subscribe(EntityManager.MESSAGE_GRANT_ENTITY_EVENT, new MessageSubscriber() {
+            @Override
+            public void onPublishMessage(String senderAddress, String subject, Object obj) {
+                Map<String, Object> permit = (Map<String, Object>)obj;
+                if (permit != null) {
+                    String entityType = (String)permit.get(ApiConstants.ENTITY_TYPE);
+                    Long entityId = (Long)permit.get(ApiConstants.ENTITY_ID);
+                    AccessType accessType = (AccessType)permit.get(ApiConstants.ACCESS_TYPE);
+                    String action = (String)permit.get(ApiConstants.IAM_ACTION);
+                    List<Long> acctIds = (List<Long>)permit.get(ApiConstants.ACCOUNTS);
+                    s_logger.debug("MessageBus message: grant accounts permission to an entity: (" + entityType + "," + entityId + ")");
+                    grantEntityPermissioinToAccounts(entityType, entityId, accessType, action, acctIds);
+                }
+            }
+        });
+
+        _messageBus.subscribe(EntityManager.MESSAGE_REVOKE_ENTITY_EVENT, new MessageSubscriber() {
+            @Override
+            public void onPublishMessage(String senderAddress, String subject, Object obj) {
+                Map<String, Object> permit = (Map<String, Object>)obj;
+                if (permit != null) {
+                    String entityType = (String)permit.get(ApiConstants.ENTITY_TYPE);
+                    Long entityId = (Long)permit.get(ApiConstants.ENTITY_ID);
+                    AccessType accessType = (AccessType)permit.get(ApiConstants.ACCESS_TYPE);
+                    String action = (String)permit.get(ApiConstants.IAM_ACTION);
+                    List<Long> acctIds = (List<Long>)permit.get(ApiConstants.ACCOUNTS);
+                    s_logger.debug("MessageBus message: revoke from accounts permission to an entity: (" + entityType + "," + entityId + ")");
+                    revokeEntityPermissioinFromAccounts(entityType, entityId, accessType, action, acctIds);
+                }
+            }
+        });
+
+        _messageBus.subscribe(EntityManager.MESSAGE_ADD_DOMAIN_WIDE_ENTITY_EVENT, new MessageSubscriber() {
+            @Override
+            public void onPublishMessage(String senderAddress, String subject, Object obj) {
+                Map<String, Object> params = (Map<String, Object>) obj;
+                if (params != null) {
+                    addDomainWideResourceAccess(params);
+                }
+            }
+        });
+
+        return super.configure(name, params);
+    }
+
+    private void addDomainWideResourceAccess(Map<String, Object> params) {
+
+        IAMEntityType entityType = (IAMEntityType)params.get(ApiConstants.ENTITY_TYPE);
+        Long entityId = (Long) params.get(ApiConstants.ENTITY_ID);
+        Long domainId = (Long) params.get(ApiConstants.DOMAIN_ID);
+        Boolean isRecursive = (Boolean) params.get(ApiConstants.SUBDOMAIN_ACCESS);
+
+        if (entityType == IAMEntityType.Network) {
+            createPolicyAndAddToDomainGroup("DomainWideNetwork-" + entityId, "domain wide network", entityType.toString(),
+                    entityId, "listNetworks", AccessType.UseEntry, domainId, isRecursive);
+        } else if (entityType == IAMEntityType.AffinityGroup) {
+            createPolicyAndAddToDomainGroup("DomainWideNetwork-" + entityId, "domain wide affinityGroup", entityType.toString(),
+                    entityId, "listAffinityGroups", AccessType.UseEntry, domainId, isRecursive);
+        }
+
+    }
+
+    private void createPolicyAndAddToDomainGroup(String policyName, String description, String entityType,
+            Long entityId, String action, AccessType accessType, Long domainId, Boolean recursive) {
+
+       Domain domain = _domainDao.findById(domainId);
+       if (domain != null) {
+            IAMPolicy policy = _iamSrv.createIAMPolicy(policyName, description, null, domain.getPath());
+            _iamSrv.addIAMPermissionToIAMPolicy(policy.getId(), entityType, PermissionScope.RESOURCE.toString(),
+                    entityId, action, accessType.toString(), Permission.Allow, recursive);
+            List<Long> policyList = new ArrayList<Long>();
+            policyList.add(new Long(policy.getId()));
+
+           List<IAMGroup> domainGroups = listDomainGroup(domain);
+           if (domainGroups != null) {
+               for (IAMGroup group : domainGroups) {
+                   _iamSrv.attachIAMPoliciesToGroup(policyList, group.getId());
+               }
+           }
+       }
+    }
+
+    @DB
+    @Override
+    @ActionEvent(eventType = EventTypes.EVENT_IAM_GROUP_CREATE, eventDescription = "Creating Acl Group", create = true)
+    public IAMGroup createIAMGroup(Account caller, String iamGroupName, String description) {
+        Long domainId = caller.getDomainId();
+        Domain callerDomain = _domainDao.findById(domainId);
+        if (callerDomain == null) {
+            throw new InvalidParameterValueException("Caller does not have a domain");
+        }
+        return _iamSrv.createIAMGroup(iamGroupName, description, callerDomain.getPath());
+    }
+
+    @DB
+    @Override
+    @ActionEvent(eventType = EventTypes.EVENT_IAM_GROUP_DELETE, eventDescription = "Deleting Acl Group")
+    public boolean deleteIAMGroup(final Long iamGroupId) {
+        return _iamSrv.deleteIAMGroup(iamGroupId);
+    }
+
+    @Override
+    public List<IAMGroup> listIAMGroups(long accountId) {
+        return _iamSrv.listIAMGroups(accountId);
+    }
+
+
+    @DB
+    @Override
+    @ActionEvent(eventType = EventTypes.EVENT_IAM_GROUP_UPDATE, eventDescription = "Adding accounts to acl group")
+    public IAMGroup addAccountsToGroup(final List<Long> acctIds, final Long groupId) {
+        return _iamSrv.addAccountsToGroup(acctIds, groupId);
+    }
+
+
+    private void removeAccountFromIAMGroups(long accountId) {
+        List<IAMGroup> groups = listIAMGroups(accountId);
+        List<Long> accts = new ArrayList<Long>();
+        accts.add(accountId);
+        if (groups != null) {
+            for (IAMGroup grp : groups) {
+                removeAccountsFromGroup(accts, grp.getId());
+            }
+        }
+    }
+
+    private void addAccountToIAMGroup(long accountId, long groupId) {
+        List<Long> accts = new ArrayList<Long>();
+        accts.add(accountId);
+        addAccountsToGroup(accts, groupId);
+    }
+
+    @DB
+    @Override
+    @ActionEvent(eventType = EventTypes.EVENT_IAM_GROUP_UPDATE, eventDescription = "Removing accounts from acl group")
+    public IAMGroup removeAccountsFromGroup(final List<Long> acctIds, final Long groupId) {
+        return _iamSrv.removeAccountsFromGroup(acctIds, groupId);
+    }
+
+    @DB
+    @Override
+    @ActionEvent(eventType = EventTypes.EVENT_IAM_POLICY_CREATE, eventDescription = "Creating IAM Policy", create = true)
+    public IAMPolicy createIAMPolicy(Account caller, final String iamPolicyName, final String description, final Long parentPolicyId) {
+        Long domainId = caller.getDomainId();
+        Domain callerDomain = _domainDao.findById(domainId);
+        if (callerDomain == null) {
+            throw new InvalidParameterValueException("Caller does not have a domain");
+        }
+        return _iamSrv.createIAMPolicy(iamPolicyName, description, parentPolicyId, callerDomain.getPath());
+    }
+
+    @DB
+    @Override
+    @ActionEvent(eventType = EventTypes.EVENT_IAM_POLICY_DELETE, eventDescription = "Deleting IAM Policy")
+    public boolean deleteIAMPolicy(final long iamPolicyId) {
+        return _iamSrv.deleteIAMPolicy(iamPolicyId);
+    }
+
+
+    @Override
+    public List<IAMPolicy> listIAMPolicies(long accountId) {
+        return _iamSrv.listIAMPolicies(accountId);
+    }
+
+    @DB
+    @Override
+    @ActionEvent(eventType = EventTypes.EVENT_IAM_GROUP_UPDATE, eventDescription = "Attaching policy to acl group")
+    public IAMGroup attachIAMPoliciesToGroup(final List<Long> policyIds, final Long groupId) {
+        return _iamSrv.attachIAMPoliciesToGroup(policyIds, groupId);
+    }
+
+    @DB
+    @Override
+    @ActionEvent(eventType = EventTypes.EVENT_IAM_GROUP_UPDATE, eventDescription = "Removing policies from acl group")
+    public IAMGroup removeIAMPoliciesFromGroup(final List<Long> policyIds, final Long groupId) {
+        return _iamSrv.removeIAMPoliciesFromGroup(policyIds, groupId);
+    }
+
+
+    @DB
+    @Override
+    @ActionEvent(eventType = EventTypes.EVENT_IAM_ACCOUNT_POLICY_UPDATE, eventDescription = "Attaching policy to accounts")
+    public void attachIAMPolicyToAccounts(final Long policyId, final List<Long> accountIds) {
+        _iamSrv.attachIAMPolicyToAccounts(policyId, accountIds);
+    }
+
+    @DB
+    @Override
+    @ActionEvent(eventType = EventTypes.EVENT_IAM_ACCOUNT_POLICY_UPDATE, eventDescription = "Removing policy from accounts")
+    public void removeIAMPolicyFromAccounts(final Long policyId, final List<Long> accountIds) {
+        _iamSrv.removeIAMPolicyFromAccounts(policyId, accountIds);
+    }
+
+    @DB
+    @Override
+    @ActionEvent(eventType = EventTypes.EVENT_IAM_POLICY_GRANT, eventDescription = "Granting acl permission to IAM Policy")
+    public IAMPolicy addIAMPermissionToIAMPolicy(long iamPolicyId, String entityType, PermissionScope scope,
+            Long scopeId, String action, Permission perm, Boolean recursive) {
+        Class<?> cmdClass = _apiServer.getCmdClass(action);
+        AccessType accessType = null;
+        if (BaseListCmd.class.isAssignableFrom(cmdClass)) {
+            accessType = AccessType.UseEntry;
+        }
+        return _iamSrv.addIAMPermissionToIAMPolicy(iamPolicyId, entityType, scope.toString(), scopeId, action,
+                accessType.toString(), perm, recursive);
+    }
+
+    @DB
+    @Override
+    @ActionEvent(eventType = EventTypes.EVENT_IAM_POLICY_REVOKE, eventDescription = "Revoking acl permission from IAM Policy")
+    public IAMPolicy removeIAMPermissionFromIAMPolicy(long iamPolicyId, String entityType, PermissionScope scope, Long scopeId, String action) {
+        return _iamSrv.removeIAMPermissionFromIAMPolicy(iamPolicyId, entityType, scope.toString(), scopeId, action);
+    }
+
+    @Override
+    public IAMPolicyPermission getIAMPolicyPermission(long accountId, String entityType, String action) {
+        List<IAMPolicy> policies = _iamSrv.listIAMPolicies(accountId);
+        IAMPolicyPermission curPerm = null;
+        for (IAMPolicy policy : policies) {
+            List<IAMPolicyPermission> perms = _iamSrv.listPolicyPermissionByActionAndEntity(policy.getId(), action,
+                    entityType);
+            if (perms == null || perms.size() == 0)
+                continue;
+            IAMPolicyPermission perm = perms.get(0); // just pick one
+            if (curPerm == null) {
+                curPerm = perm;
+            } else if (PermissionScope.valueOf(perm.getScope()).greaterThan(PermissionScope.valueOf(curPerm.getScope()))) {
+                // pick the more relaxed allowed permission
+                curPerm = perm;
+            }
+        }
+
+        return curPerm;
+    }
+
+
+    @Override
+    public IAMPolicyResponse createIAMPolicyResponse(IAMPolicy policy) {
+        IAMPolicyResponse response = new IAMPolicyResponse();
+        response.setId(policy.getUuid());
+        response.setName(policy.getName());
+        response.setDescription(policy.getDescription());
+        String domainPath = policy.getPath();
+        if (domainPath != null) {
+            DomainVO domain = _domainDao.findDomainByPath(domainPath);
+            if (domain != null) {
+                response.setDomainId(domain.getUuid());
+                response.setDomainName(domain.getName());
+            }
+        }
+        long accountId = policy.getAccountId();
+        AccountVO owner = _accountDao.findById(accountId);
+        if (owner != null) {
+            response.setAccountName(owner.getAccountName());
+        }
+        // find permissions associated with this policy
+        List<IAMPolicyPermission> permissions = _iamSrv.listPolicyPermissions(policy.getId());
+        if (permissions != null && permissions.size() > 0) {
+            for (IAMPolicyPermission permission : permissions) {
+                IAMPermissionResponse perm = new IAMPermissionResponse();
+                perm.setAction(permission.getAction());
+                if (permission.getEntityType() != null) {
+                    perm.setEntityType(IAMEntityType.valueOf(permission.getEntityType()));
+                }
+                if (permission.getScope() != null) {
+                    perm.setScope(PermissionScope.valueOf(permission.getScope()));
+                }
+                perm.setScopeId(permission.getScopeId());
+                perm.setPermission(permission.getPermission());
+                response.addPermission(perm);
+            }
+        }
+        response.setObjectName("aclpolicy");
+        return response;
+    }
+
+    @Override
+    public IAMGroupResponse createIAMGroupResponse(IAMGroup group) {
+        IAMGroupResponse response = new IAMGroupResponse();
+        response.setId(group.getUuid());
+        response.setName(group.getName());
+        response.setDescription(group.getDescription());
+        String domainPath = group.getPath();
+        if (domainPath != null) {
+            DomainVO domain = _domainDao.findDomainByPath(domainPath);
+            if (domain != null) {
+                response.setDomainId(domain.getUuid());
+                response.setDomainName(domain.getName());
+            }
+        }
+        long accountId = group.getAccountId();
+        AccountVO owner = _accountDao.findById(accountId);
+        if (owner != null) {
+            response.setAccountName(owner.getAccountName());
+        }
+        // find all the members in this group
+        List<Long> members = _iamSrv.listAccountsByGroup(group.getId());
+        if (members != null && members.size() > 0) {
+            for (Long member : members) {
+                AccountVO mem = _accountDao.findById(member);
+                if (mem != null) {
+                    response.addMemberAccount(mem.getAccountName());
+                }
+            }
+        }
+
+        // find all the policies attached to this group
+        List<IAMPolicy> policies = _iamSrv.listIAMPoliciesByGroup(group.getId());
+        if (policies != null && policies.size() > 0) {
+            for (IAMPolicy policy : policies) {
+                response.addPolicy(policy.getName());
+            }
+        }
+
+        response.setObjectName("aclgroup");
+        return response;
+
+    }
+
+    public List<IAMGroup> listDomainGroup(Domain domain) {
+
+        if (domain != null) {
+            String domainPath = domain.getPath();
+            // search for groups
+            Pair<List<IAMGroup>, Integer> result = _iamSrv.listIAMGroups(null, "DomainGrp-" + domain.getUuid(),
+                    domainPath, null, null);
+            return result.first();
+        }
+        return new ArrayList<IAMGroup>();
+
+    }
+
+    @Override
+    public ListResponse<IAMGroupResponse> listIAMGroups(Long iamGroupId, String iamGroupName, Long domainId, Long startIndex, Long pageSize) {
+        // acl check
+        Account caller = CallContext.current().getCallingAccount();
+
+        Domain domain = null;
+        if (domainId != null) {
+            domain = _domainDao.findById(domainId);
+            if (domain == null) {
+                throw new InvalidParameterValueException("Domain id=" + domainId + " doesn't exist");
+            }
+
+            _accountMgr.checkAccess(caller, domain);
+        } else {
+            domain = _domainDao.findById(caller.getDomainId());
+        }
+        String domainPath = domain.getPath();
+        // search for groups
+        Pair<List<IAMGroup>, Integer> result = _iamSrv.listIAMGroups(iamGroupId, iamGroupName, domainPath, startIndex, pageSize);
+        // generate group response
+        ListResponse<IAMGroupResponse> response = new ListResponse<IAMGroupResponse>();
+        List<IAMGroupResponse> groupResponses = new ArrayList<IAMGroupResponse>();
+        for (IAMGroup group : result.first()) {
+            IAMGroupResponse resp = createIAMGroupResponse(group);
+            groupResponses.add(resp);
+        }
+        response.setResponses(groupResponses, result.second());
+        return response;
+    }
+
+    @Override
+    public ListResponse<IAMPolicyResponse> listIAMPolicies(Long iamPolicyId, String iamPolicyName, Long domainId, Long startIndex,
+            Long pageSize) {
+        // acl check
+        Account caller = CallContext.current().getCallingAccount();
+
+        Domain domain = null;
+        if (domainId != null) {
+            domain = _domainDao.findById(domainId);
+            if (domain == null) {
+                throw new InvalidParameterValueException("Domain id=" + domainId + " doesn't exist");
+            }
+
+            _accountMgr.checkAccess(caller, domain);
+        } else {
+            domain = _domainDao.findById(caller.getDomainId());
+        }
+        String domainPath = domain.getPath();
+        // search for policies
+        Pair<List<IAMPolicy>, Integer> result = _iamSrv.listIAMPolicies(iamPolicyId, iamPolicyName, domainPath, startIndex, pageSize);
+        // generate policy response
+        ListResponse<IAMPolicyResponse> response = new ListResponse<IAMPolicyResponse>();
+        List<IAMPolicyResponse> policyResponses = new ArrayList<IAMPolicyResponse>();
+        for (IAMPolicy policy : result.first()) {
+            IAMPolicyResponse resp = createIAMPolicyResponse(policy);
+            policyResponses.add(resp);
+        }
+        response.setResponses(policyResponses, result.second());
+        return response;
+    }
+
+    @Override
+    public void grantEntityPermissioinToAccounts(String entityType, Long entityId, AccessType accessType, String action, List<Long> accountIds) {
+        // check if there is already a policy with only this permission added to it
+        IAMPolicy policy = _iamSrv.getResourceGrantPolicy(entityType, entityId, accessType.toString(), action);
+        if (policy == null) {
+            // not found, just create a policy with resource grant permission
+            Account caller = CallContext.current().getCallingAccount();
+            String aclPolicyName = "policyGrant" + entityType + entityId;
+            String description = "Policy to grant permission to " + entityType + entityId;
+            policy = createIAMPolicy(caller, aclPolicyName, description, null);
+            // add permission to this policy
+            addIAMPermissionToIAMPolicy(policy.getId(), entityType, PermissionScope.RESOURCE, entityId, action, Permission.Allow, false);
+        }
+        // attach this policy to list of accounts if not attached already
+        Long policyId = policy.getId();
+        for (Long acctId : accountIds) {
+            if (!isPolicyAttachedToAccount(policyId, acctId)) {
+                attachIAMPolicyToAccounts(policyId, Collections.singletonList(acctId));
+            }
+        }
+    }
+
+    @Override
+    public void revokeEntityPermissioinFromAccounts(String entityType, Long entityId, AccessType accessType, String action, List<Long> accountIds) {
+        // there should already a policy with only this permission added to it, this call is mainly used
+        IAMPolicy policy = _iamSrv.getResourceGrantPolicy(entityType, entityId, accessType.toString(), action);
+        if (policy == null) {
+            s_logger.warn("Cannot find a policy associated with this entity permissioin to be revoked, just return");
+            return;
+        }
+        // detach this policy from list of accounts if not detached already
+        Long policyId = policy.getId();
+        for (Long acctId : accountIds) {
+            if (isPolicyAttachedToAccount(policyId, acctId)) {
+                removeIAMPolicyFromAccounts(policyId, Collections.singletonList(acctId));
+            }
+        }
+
+    }
+
+    private boolean isPolicyAttachedToAccount(Long policyId, Long accountId) {
+        List<IAMPolicy> pList = listIAMPolicies(accountId);
+        for (IAMPolicy p : pList) {
+            if (p.getId() == policyId.longValue()) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private void resetTemplatePermission(Long templateId){
+        // reset template will change template to private, so we need to remove its permission for domain admin and normal user group
+        _iamSrv.removeIAMPermissionFromIAMPolicy(new Long(Account.ACCOUNT_TYPE_DOMAIN_ADMIN + 1), IAMEntityType.VirtualMachineTemplate.toString(),
+                PermissionScope.RESOURCE.toString(), templateId, "listTemplates");
+        _iamSrv.removeIAMPermissionFromIAMPolicy(new Long(Account.ACCOUNT_TYPE_NORMAL + 1), IAMEntityType.VirtualMachineTemplate.toString(),
+                PermissionScope.RESOURCE.toString(), templateId, "listTemplates");
+        // check if there is a policy with only UseEntry permission for this template added
+        IAMPolicy policy = _iamSrv.getResourceGrantPolicy(IAMEntityType.VirtualMachineTemplate.toString(), templateId, AccessType.UseEntry.toString(), "listTemplates");
+        if ( policy == null ){
+            s_logger.info("No policy found for this template grant: " + templateId + ", no detach to be done");
+            return;
+        }
+        // delete the policy, which should detach it from groups and accounts
+        _iamSrv.deleteIAMPolicy(policy.getId());
+
+    }
+
+    @Override
+    public Long getPermissionScopeId(String scope, String entityType, String scopeId) {
+        if (scopeId.equals("-1")) {
+            return -1L;
+        }
+        PermissionScope permScope = PermissionScope.valueOf(scope);
+        InternalIdentity entity = null;
+        switch (permScope) {
+        case DOMAIN:
+            entity = _domainDao.findByUuid(scopeId);
+            break;
+        case ACCOUNT:
+            entity = _accountDao.findByUuid(scopeId);
+            break;
+        case RESOURCE:
+            Class<?> clazz = s_typeMap.get(IAMEntityType.valueOf(entityType));
+            entity = (InternalIdentity)_entityMgr.findByUuid(clazz, scopeId);
+        }
+
+        if (entity != null) {
+            return entity.getId();
+        }
+        throw new InvalidParameterValueException("Unable to find scopeId " + scopeId + " with scope " + scope + " and type " + entityType);
+    }
+
+    @Override
+    public List<Class<?>> getCommands() {
+        List<Class<?>> cmdList = new ArrayList<Class<?>>();
+        cmdList.add(CreateIAMPolicyCmd.class);
+        cmdList.add(DeleteIAMPolicyCmd.class);
+        cmdList.add(ListIAMPoliciesCmd.class);
+        cmdList.add(AddIAMPermissionToIAMPolicyCmd.class);
+        cmdList.add(RemoveIAMPermissionFromIAMPolicyCmd.class);
+        cmdList.add(AttachIAMPolicyToIAMGroupCmd.class);
+        cmdList.add(RemoveIAMPolicyFromIAMGroupCmd.class);
+        cmdList.add(CreateIAMGroupCmd.class);
+        cmdList.add(DeleteIAMGroupCmd.class);
+        cmdList.add(ListIAMGroupsCmd.class);
+        cmdList.add(AddAccountToIAMGroupCmd.class);
+        cmdList.add(RemoveAccountFromIAMGroupCmd.class);
+        cmdList.add(AttachIAMPolicyToAccountCmd.class);
+        cmdList.add(RemoveIAMPolicyFromAccountCmd.class);
+        return cmdList;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/iam/RoleBasedAPIAccessChecker.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/iam/RoleBasedAPIAccessChecker.java b/services/iam/plugin/src/org/apache/cloudstack/iam/RoleBasedAPIAccessChecker.java
new file mode 100644
index 0000000..fb75db3
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/iam/RoleBasedAPIAccessChecker.java
@@ -0,0 +1,273 @@
+// 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.iam;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+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.acl.IAMEntityType;
+import org.apache.cloudstack.acl.PermissionScope;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.acl.SecurityChecker.AccessType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.iam.api.IAMPolicy;
+import org.apache.cloudstack.iam.api.IAMPolicyPermission;
+import org.apache.cloudstack.iam.api.IAMPolicyPermission.Permission;
+import org.apache.cloudstack.iam.api.IAMService;
+
+import com.cloud.api.ApiServerService;
+import com.cloud.exception.PermissionDeniedException;
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.user.Account;
+import com.cloud.user.AccountService;
+import com.cloud.user.User;
+import com.cloud.utils.PropertiesUtil;
+import com.cloud.utils.component.AdapterBase;
+import com.cloud.utils.component.PluggableService;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+//This is the Role Based API access checker that grab's the  account's roles
+//based on the set of roles, access is granted if any of the role has access to the api
+@Local(value=APIChecker.class)
+public class RoleBasedAPIAccessChecker extends AdapterBase implements APIChecker {
+
+    protected static final Logger s_logger = Logger.getLogger(RoleBasedAPIAccessChecker.class);
+
+    @Inject
+    AccountService _accountService;
+    @Inject
+    ApiServerService _apiServer;
+    @Inject
+    IAMService _iamSrv;
+    @Inject
+    VMTemplateDao _templateDao;
+
+    Set<String> commandsPropertiesOverrides = new HashSet<String>();
+    Map<RoleType, Set<String>> commandsPropertiesRoleBasedApisMap = new HashMap<RoleType, Set<String>>();
+
+    List<PluggableService> _services;
+
+    protected RoleBasedAPIAccessChecker() {
+        super();
+        for (RoleType roleType : RoleType.values()) {
+            commandsPropertiesRoleBasedApisMap.put(roleType, new HashSet<String>());
+        }
+     }
+
+    @Override
+    public boolean checkAccess(User user, String commandName) throws PermissionDeniedException {
+        Account account = _accountService.getAccount(user.getAccountId());
+        if (account == null) {
+            throw new PermissionDeniedException("The account id=" + user.getAccountId() + "for user id=" + user.getId()
+                    + "is null");
+        }
+
+        List<IAMPolicy> policies = _iamSrv.listIAMPolicies(account.getAccountId());
+
+        boolean isAllowed = _iamSrv.isActionAllowedForPolicies(commandName, policies);
+        if (!isAllowed) {
+            throw new PermissionDeniedException("The API does not exist or is blacklisted. api: " + commandName);
+        }
+        return isAllowed;
+     }
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+        super.configure(name, params);
+
+        processMapping(PropertiesUtil.processConfigFile(new String[] { "commands.properties" }));
+        return true;
+     }
+
+    @Override
+    public boolean start() {
+
+        // drop all default policy api permissions - we reload them every time
+        // to include any changes done to the @APICommand or
+        // commands.properties.
+
+        for (RoleType role : RoleType.values()) {
+            Long policyId = getDefaultPolicyId(role);
+            if (policyId != null) {
+                _iamSrv.resetIAMPolicy(policyId);
+            }
+         }
+
+        // add the system-domain capability
+
+        _iamSrv.addIAMPermissionToIAMPolicy(new Long(Account.ACCOUNT_TYPE_ADMIN + 1), null, null, null,
+                "SystemCapability", null, Permission.Allow, false);
+        _iamSrv.addIAMPermissionToIAMPolicy(new Long(Account.ACCOUNT_TYPE_DOMAIN_ADMIN + 1), null, null, null,
+                "DomainCapability", null, Permission.Allow, false);
+        _iamSrv.addIAMPermissionToIAMPolicy(new Long(Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN + 1), null, null, null,
+                "DomainResourceCapability", null, Permission.Allow, false);
+
+        // add permissions for public templates
+        List<VMTemplateVO> pTmplts = _templateDao.listByPublic();
+        for (VMTemplateVO tmpl : pTmplts){
+            _iamSrv.addIAMPermissionToIAMPolicy(new Long(Account.ACCOUNT_TYPE_DOMAIN_ADMIN + 1), IAMEntityType.VirtualMachineTemplate.toString(),
+                    PermissionScope.RESOURCE.toString(), tmpl.getId(), "listTemplates", AccessType.UseEntry.toString(), Permission.Allow, false);
+            _iamSrv.addIAMPermissionToIAMPolicy(new Long(Account.ACCOUNT_TYPE_NORMAL + 1), IAMEntityType.VirtualMachineTemplate.toString(),
+                    PermissionScope.RESOURCE.toString(), tmpl.getId(), "listTemplates", AccessType.UseEntry.toString(), Permission.Allow, false);
+        }
+
+        for (PluggableService service : _services) {
+            for (Class<?> cmdClass : service.getCommands()) {
+                APICommand command = cmdClass.getAnnotation(APICommand.class);
+                if (!commandsPropertiesOverrides.contains(command.name())) {
+                    for (RoleType role : command.authorized()) {
+                        addDefaultAclPolicyPermission(command.name(), cmdClass, role);
+                    }
+                 }
+             }
+         }
+
+        // read commands.properties and load api acl permissions -
+        // commands.properties overrides any @APICommand authorization
+
+        for (String apiName : commandsPropertiesOverrides) {
+            Class<?> cmdClass = _apiServer.getCmdClass(apiName);
+            for (RoleType role : RoleType.values()) {
+                if (commandsPropertiesRoleBasedApisMap.get(role).contains(apiName)) {
+                    // insert permission for this role for this api
+                    addDefaultAclPolicyPermission(apiName, cmdClass, role);
+                }
+             }
+         }
+
+        return super.start();
+     }
+
+    private Long getDefaultPolicyId(RoleType role) {
+        Long policyId = null;
+        switch (role) {
+        case User:
+            policyId = new Long(Account.ACCOUNT_TYPE_NORMAL + 1);
+            break;
+
+        case Admin:
+            policyId = new Long(Account.ACCOUNT_TYPE_ADMIN + 1);
+            break;
+
+        case DomainAdmin:
+            policyId = new Long(Account.ACCOUNT_TYPE_DOMAIN_ADMIN + 1);
+            break;
+
+        case ResourceAdmin:
+            policyId = new Long(Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN + 1);
+            break;
+        }
+
+        return policyId;
+    }
+
+    private void processMapping(Map<String, String> configMap) {
+        for (Map.Entry<String, String> entry : configMap.entrySet()) {
+            String apiName = entry.getKey();
+            String roleMask = entry.getValue();
+            commandsPropertiesOverrides.add(apiName);
+            try {
+                short cmdPermissions = Short.parseShort(roleMask);
+                for (RoleType roleType : RoleType.values()) {
+                    if ((cmdPermissions & roleType.getValue()) != 0)
+                        commandsPropertiesRoleBasedApisMap.get(roleType).add(apiName);
+                }
+            } catch (NumberFormatException nfe) {
+                s_logger.info("Malformed key=value pair for entry: " + entry.toString());
+             }
+         }
+     }
+
+    public List<PluggableService> getServices() {
+        return _services;
+     }
+
+    @Inject
+    public void setServices(List<PluggableService> services) {
+        _services = services;
+     }
+
+    private void addDefaultAclPolicyPermission(String apiName, Class<?> cmdClass, RoleType role) {
+
+        AccessType accessType = null;
+        IAMEntityType[] entityTypes = null;
+        if (cmdClass != null) {
+            BaseCmd cmdObj;
+            try {
+                cmdObj = (BaseCmd) cmdClass.newInstance();
+                if (cmdObj instanceof BaseListCmd) {
+                    accessType = AccessType.UseEntry;
+                } else if (!(cmdObj instanceof BaseAsyncCreateCmd)) {
+                    accessType = AccessType.OperateEntry;
+                }
+            } catch (Exception e) {
+                throw new CloudRuntimeException(String.format(
+                        "%s is claimed as an API command, but it cannot be instantiated", cmdClass.getName()));
+             }
+
+            APICommand at = cmdClass.getAnnotation(APICommand.class);
+            entityTypes = at.entityType();
+        }
+
+        PermissionScope permissionScope = PermissionScope.ACCOUNT;
+        Long policyId = getDefaultPolicyId(role);
+        switch (role) {
+        case User:
+            permissionScope = PermissionScope.ACCOUNT;
+            break;
+
+        case Admin:
+            permissionScope = PermissionScope.ALL;
+            break;
+
+        case DomainAdmin:
+            permissionScope = PermissionScope.DOMAIN;
+            break;
+
+        case ResourceAdmin:
+            permissionScope = PermissionScope.DOMAIN;
+            break;
+         }
+
+
+        if (entityTypes == null || entityTypes.length == 0) {
+            _iamSrv.addIAMPermissionToIAMPolicy(policyId, null, permissionScope.toString(), new Long(IAMPolicyPermission.PERMISSION_SCOPE_ID_CURRENT_CALLER),
+                    apiName, (accessType == null) ? null : accessType.toString(), Permission.Allow, false);
+        } else {
+            for (IAMEntityType entityType : entityTypes) {
+                _iamSrv.addIAMPermissionToIAMPolicy(policyId, entityType.toString(), permissionScope.toString(), new Long(IAMPolicyPermission.PERMISSION_SCOPE_ID_CURRENT_CALLER),
+                        apiName, (accessType == null) ? null : accessType.toString(), Permission.Allow, false);
+            }
+         }
+
+     }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/iam/RoleBasedEntityAccessChecker.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/iam/RoleBasedEntityAccessChecker.java b/services/iam/plugin/src/org/apache/cloudstack/iam/RoleBasedEntityAccessChecker.java
new file mode 100644
index 0000000..d0d9d88
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/iam/RoleBasedEntityAccessChecker.java
@@ -0,0 +1,186 @@
+// 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.iam;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.acl.PermissionScope;
+import org.apache.cloudstack.acl.SecurityChecker;
+import org.apache.cloudstack.api.InternalIdentity;
+import org.apache.cloudstack.iam.api.IAMGroup;
+import org.apache.cloudstack.iam.api.IAMPolicy;
+import org.apache.cloudstack.iam.api.IAMPolicyPermission;
+import org.apache.cloudstack.iam.api.IAMService;
+
+import com.cloud.acl.DomainChecker;
+import com.cloud.domain.dao.DomainDao;
+import com.cloud.exception.PermissionDeniedException;
+import com.cloud.user.Account;
+import com.cloud.user.AccountService;
+
+public class RoleBasedEntityAccessChecker extends DomainChecker implements SecurityChecker {
+
+    private static final Logger s_logger = Logger.getLogger(RoleBasedEntityAccessChecker.class.getName());
+
+    @Inject
+    AccountService _accountService;
+
+    @Inject DomainDao _domainDao;
+
+    @Inject
+    IAMService _iamSrv;
+
+
+    @Override
+    public boolean checkAccess(Account caller, ControlledEntity entity, AccessType accessType)
+            throws PermissionDeniedException {
+        return checkAccess(caller, entity, accessType, null);
+    }
+
+    @Override
+    public boolean checkAccess(Account caller, ControlledEntity entity, AccessType accessType, String action)
+            throws PermissionDeniedException {
+
+        if (entity == null && action != null) {
+            // check if caller can do this action
+            List<IAMPolicy> policies = _iamSrv.listIAMPolicies(caller.getAccountId());
+
+            boolean isAllowed = _iamSrv.isActionAllowedForPolicies(action, policies);
+            if (!isAllowed) {
+                throw new PermissionDeniedException("The action '" + action + "' not allowed for account " + caller);
+            }
+            return true;
+        }
+
+        String entityType = entity.getEntityType().toString();
+
+        if (accessType == null) {
+            accessType = AccessType.UseEntry;
+        }
+
+        // get all Policies of this caller w.r.t the entity
+        List<IAMPolicy> policies = getEffectivePolicies(caller, entity);
+        HashMap<IAMPolicy, Boolean> policyPermissionMap = new HashMap<IAMPolicy, Boolean>();
+
+        for (IAMPolicy policy : policies) {
+            List<IAMPolicyPermission> permissions = new ArrayList<IAMPolicyPermission>();
+
+            if (action != null) {
+                permissions = _iamSrv.listPolicyPermissionByActionAndEntity(policy.getId(), action, entityType);
+                if (permissions.isEmpty()) {
+                    if (accessType != null) {
+                        permissions.addAll(_iamSrv.listPolicyPermissionByAccessAndEntity(policy.getId(),
+                                accessType.toString(), entityType));
+                    }
+                }
+            } else {
+                if (accessType != null) {
+                    permissions.addAll(_iamSrv.listPolicyPermissionByAccessAndEntity(policy.getId(),
+                            accessType.toString(), entityType));
+                }
+            }
+            for (IAMPolicyPermission permission : permissions) {
+                if (checkPermissionScope(caller, permission.getScope(), permission.getScopeId(), entity)) {
+                    if (permission.getEntityType().equals(entityType)) {
+                        policyPermissionMap.put(policy, permission.getPermission().isGranted());
+                        break;
+                    } else if (permission.getEntityType().equals("*")) {
+                        policyPermissionMap.put(policy, permission.getPermission().isGranted());
+                    }
+                }
+            }
+            if (policyPermissionMap.containsKey(policy) && policyPermissionMap.get(policy)) {
+                return true;
+            }
+        }
+
+        if (!policies.isEmpty()) { // Since we reach this point, none of the
+                                   // roles granted access
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Account " + caller + " does not have permission to access resource " + entity
+                        + " for access type: " + accessType);
+            }
+            throw new PermissionDeniedException(caller + " does not have permission to access resource " + entity);
+        }
+
+        return false;
+    }
+
+    private boolean checkPermissionScope(Account caller, String scope, Long scopeId, ControlledEntity entity) {
+
+        if(scopeId != null && !scopeId.equals(new Long(IAMPolicyPermission.PERMISSION_SCOPE_ID_CURRENT_CALLER))){
+            //scopeId is set
+            if (scope.equals(PermissionScope.ACCOUNT.name())) {
+                if(scopeId == entity.getAccountId()){
+                    return true;
+                }
+            } else if (scope.equals(PermissionScope.DOMAIN.name())) {
+                if (_domainDao.isChildDomain(scopeId, entity.getDomainId())) {
+                    return true;
+                }
+            } else if (scope.equals(PermissionScope.RESOURCE.name())) {
+                if (entity instanceof InternalIdentity) {
+                    InternalIdentity entityWithId = (InternalIdentity) entity;
+                    if(scopeId.equals(entityWithId.getId())){
+                        return true;
+                    }
+                }
+            }
+        } else if (scopeId == null || scopeId.equals(new Long(IAMPolicyPermission.PERMISSION_SCOPE_ID_CURRENT_CALLER))) {
+            if (scope.equals(PermissionScope.ACCOUNT.name())) {
+                if(caller.getAccountId() == entity.getAccountId()){
+                    return true;
+                }
+            } else if (scope.equals(PermissionScope.DOMAIN.name())) {
+                if (_domainDao.isChildDomain(caller.getDomainId(), entity.getDomainId())) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    private List<IAMPolicy> getEffectivePolicies(Account caller, ControlledEntity entity) {
+
+        // Get the static Policies of the Caller
+        List<IAMPolicy> policies = _iamSrv.listIAMPolicies(caller.getId());
+
+        // add any dynamic policies w.r.t the entity
+        if (caller.getId() == entity.getAccountId()) {
+            // The caller owns the entity
+            policies.add(_iamSrv.getResourceOwnerPolicy());
+        }
+
+        List<IAMGroup> groups = _iamSrv.listIAMGroups(caller.getId());
+        for (IAMGroup group : groups) {
+            // for each group find the grand parent groups.
+            List<IAMGroup> parentGroups = _iamSrv.listParentIAMGroups(group.getId());
+            for (IAMGroup parentGroup : parentGroups) {
+                policies.addAll(_iamSrv.listRecursiveIAMPoliciesByGroup(parentGroup.getId()));
+            }
+        }
+
+        return policies;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/src/org/apache/cloudstack/iam/RoleBasedEntityQuerySelector.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/iam/RoleBasedEntityQuerySelector.java b/services/iam/plugin/src/org/apache/cloudstack/iam/RoleBasedEntityQuerySelector.java
new file mode 100644
index 0000000..23c57a1
--- /dev/null
+++ b/services/iam/plugin/src/org/apache/cloudstack/iam/RoleBasedEntityQuerySelector.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.iam;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.acl.PermissionScope;
+import org.apache.cloudstack.acl.QuerySelector;
+import org.apache.cloudstack.iam.api.IAMGroup;
+import org.apache.cloudstack.iam.api.IAMPolicy;
+import org.apache.cloudstack.iam.api.IAMPolicyPermission;
+import org.apache.cloudstack.iam.api.IAMService;
+
+import com.cloud.user.Account;
+import com.cloud.utils.component.AdapterBase;
+
+public class RoleBasedEntityQuerySelector extends AdapterBase implements QuerySelector {
+
+    private static final Logger s_logger = Logger.getLogger(RoleBasedEntityQuerySelector.class.getName());
+
+    @Inject
+    IAMService _iamService;
+
+    @Override
+    public List<Long> getAuthorizedDomains(Account caller, String action) {
+        long accountId = caller.getAccountId();
+        // Get the static Policies of the Caller
+        List<IAMPolicy> policies = _iamService.listIAMPolicies(accountId);
+        // for each policy, find granted permission with Domain scope
+        List<Long> domainIds = new ArrayList<Long>();
+        for (IAMPolicy policy : policies) {
+            List<IAMPolicyPermission> pp = _iamService.listPolicyPermissionsByScope(policy.getId(), action, PermissionScope.DOMAIN.toString());
+            if (pp != null) {
+                for (IAMPolicyPermission p : pp) {
+                    if (p.getScopeId() != null) {
+                        if (p.getScopeId().longValue() == -1) {
+                            domainIds.add(caller.getDomainId());
+                        } else {
+                            domainIds.add(p.getScopeId());
+                        }
+                    }
+                }
+            }
+        }
+        return domainIds;
+    }
+
+    @Override
+    public List<Long> getAuthorizedAccounts(Account caller, String action) {
+        long accountId = caller.getAccountId();
+        // Get the static Policies of the Caller
+        List<IAMPolicy> policies = _iamService.listIAMPolicies(accountId);
+        // for each policy, find granted permission with Account scope
+        List<Long> accountIds = new ArrayList<Long>();
+        for (IAMPolicy policy : policies) {
+            List<IAMPolicyPermission> pp = _iamService.listPolicyPermissionsByScope(policy.getId(), action, PermissionScope.ACCOUNT.toString());
+            if (pp != null) {
+                for (IAMPolicyPermission p : pp) {
+                    if (p.getScopeId() != null) {
+                        if (p.getScopeId().longValue() == -1) {
+                            accountIds.add(caller.getId());
+                        } else {
+                            accountIds.add(p.getScopeId());
+                        }
+                    }
+                }
+            }
+        }
+        return accountIds;
+    }
+
+    @Override
+    public List<Long> getAuthorizedResources(Account caller, String action) {
+        long accountId = caller.getAccountId();
+        // Get the static Policies of the Caller
+        List<IAMPolicy> policies = _iamService.listIAMPolicies(accountId);
+
+        // add the policies that grant recursive access
+        List<IAMGroup> groups = _iamService.listIAMGroups(caller.getId());
+        for (IAMGroup group : groups) {
+            // for each group find the grand parent groups.
+            List<IAMGroup> parentGroups = _iamService.listParentIAMGroups(group.getId());
+            for (IAMGroup parentGroup : parentGroups) {
+                policies.addAll(_iamService.listRecursiveIAMPoliciesByGroup(parentGroup.getId()));
+            }
+        }
+
+        // for each policy, find granted permission with Resource scope
+        List<Long> entityIds = new ArrayList<Long>();
+        for (IAMPolicy policy : policies) {
+            List<IAMPolicyPermission> pp = _iamService.listPolicyPermissionsByScope(policy.getId(), action, PermissionScope.RESOURCE.toString());
+            if (pp != null) {
+                for (IAMPolicyPermission p : pp) {
+                    if (p.getScopeId() != null) {
+                        entityIds.add(p.getScopeId());
+                    }
+                }
+            }
+        }
+        return entityIds;
+    }
+
+    @Override
+    public boolean isGrantedAll(Account caller, String action) {
+        long accountId = caller.getAccountId();
+        // Get the static Policies of the Caller
+        List<IAMPolicy> policies = _iamService.listIAMPolicies(accountId);
+        // for each policy, find granted permission with ALL scope
+        for (IAMPolicy policy : policies) {
+            List<IAMPolicyPermission> pp = _iamService.listPolicyPermissionsByScope(policy.getId(), action, PermissionScope.ALL.toString());
+            if (pp != null && pp.size() > 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public List<String> listAclGroupsByAccount(long accountId) {
+        List<IAMGroup> groups = _iamService.listIAMGroups(accountId);
+        List<String> groupNames = new ArrayList<String>();
+        for (IAMGroup grp : groups) {
+            groupNames.add(grp.getName());
+        }
+        return groupNames;
+    }
+
+}


[07/50] [abbrv] CLOUDSTACK-5920: IAM service plugin.

Posted by ml...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/test/org/apache/cloudstack/iam/test/IAMApiServiceTest.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/test/org/apache/cloudstack/iam/test/IAMApiServiceTest.java b/services/iam/plugin/test/org/apache/cloudstack/iam/test/IAMApiServiceTest.java
new file mode 100644
index 0000000..dc5c168
--- /dev/null
+++ b/services/iam/plugin/test/org/apache/cloudstack/iam/test/IAMApiServiceTest.java
@@ -0,0 +1,369 @@
+package org.apache.cloudstack.iam.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.ComponentScan.Filter;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.core.type.classreading.MetadataReader;
+import org.springframework.core.type.classreading.MetadataReaderFactory;
+import org.springframework.core.type.filter.TypeFilter;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.support.AnnotationConfigContextLoader;
+
+import org.apache.cloudstack.acl.IAMEntityType;
+import org.apache.cloudstack.acl.PermissionScope;
+import org.apache.cloudstack.acl.SecurityChecker.AccessType;
+import org.apache.cloudstack.api.command.user.vm.ListVMsCmd;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.iam.IAMGroupResponse;
+import org.apache.cloudstack.api.response.iam.IAMPermissionResponse;
+import org.apache.cloudstack.api.response.iam.IAMPolicyResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.framework.messagebus.MessageBus;
+import org.apache.cloudstack.iam.IAMApiService;
+import org.apache.cloudstack.iam.IAMApiServiceImpl;
+import org.apache.cloudstack.iam.api.IAMGroup;
+import org.apache.cloudstack.iam.api.IAMPolicy;
+import org.apache.cloudstack.iam.api.IAMPolicyPermission;
+import org.apache.cloudstack.iam.api.IAMPolicyPermission.Permission;
+import org.apache.cloudstack.iam.api.IAMService;
+import org.apache.cloudstack.iam.server.IAMGroupVO;
+import org.apache.cloudstack.iam.server.IAMPolicyPermissionVO;
+import org.apache.cloudstack.iam.server.IAMPolicyVO;
+import org.apache.cloudstack.test.utils.SpringUtils;
+
+import com.cloud.api.ApiServerService;
+import com.cloud.domain.DomainVO;
+import com.cloud.domain.dao.DomainDao;
+import com.cloud.network.dao.NetworkDomainDao;
+import com.cloud.user.Account;
+import com.cloud.user.AccountManager;
+import com.cloud.user.AccountVO;
+import com.cloud.user.UserVO;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.Pair;
+import com.cloud.utils.component.ComponentContext;
+import com.cloud.utils.db.EntityManager;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
+public class IAMApiServiceTest {
+
+    @Inject
+    IAMService _iamSrv;
+
+    @Inject
+    DomainDao _domainDao;
+
+    @Inject
+    IAMApiService _aclSrv;
+
+    @Inject
+    AccountManager _accountMgr;
+
+    @Inject
+    AccountDao _accountDao;
+
+    @Inject
+    ApiServerService _apiServer;
+
+    private static Account caller;
+    private static Long callerId;
+    private static String callerAccountName = "tester";
+    private static Long callerDomainId = 3L;
+    private static String callerDomainPath = "/root/testdomain";
+    private static DomainVO callerDomain;
+
+    @BeforeClass
+    public static void setUpClass() throws ConfigurationException {
+    }
+
+    @Before
+    public void setUp() {
+        ComponentContext.initComponentsLifeCycle();
+        caller = new AccountVO(callerAccountName, callerDomainId, null, Account.ACCOUNT_TYPE_ADMIN, UUID.randomUUID().toString());
+        callerId = caller.getId();
+        callerDomain = new DomainVO();
+        callerDomain.setPath(callerDomainPath);
+        UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString());
+        CallContext.register(user, caller);
+
+        when(_domainDao.findById(callerDomainId)).thenReturn(callerDomain);
+        doNothing().when(_accountMgr).checkAccess(caller, callerDomain);
+    }
+
+    @Test
+    public void createIAMGroupTest() {
+        IAMGroup group = new IAMGroupVO("group1", "tester group1");
+        List<IAMGroup> groups = new ArrayList<IAMGroup>();
+        groups.add(group);
+        Pair<List<IAMGroup>, Integer> grpList = new Pair<List<IAMGroup>, Integer>(groups, 1);
+        when(_iamSrv.createIAMGroup("group1", "tester group1", callerDomainPath)).thenReturn(group);
+        when(_iamSrv.listIAMGroups(null, null, callerDomainPath, 0L, 20L)).thenReturn(grpList);
+
+        IAMGroup createdGrp = _aclSrv.createIAMGroup(caller, "group1", "tester group1");
+        assertNotNull("IAM group 'group1' failed to create ", createdGrp);
+        ListResponse<IAMGroupResponse> grpResp = _aclSrv.listIAMGroups(null, null, callerDomainId, 0L, 20L);
+        assertTrue("No. of response items should be one", grpResp.getCount() == 1);
+        IAMGroupResponse resp = grpResp.getResponses().get(0);
+        assertEquals("Error in created group name", "group1", resp.getName());
+    }
+
+    @Test
+    public void deleteIAMGroupTest() {
+        when(_iamSrv.deleteIAMGroup(1L)).thenReturn(true);
+        assertTrue("failed to delete acl group 1", _aclSrv.deleteIAMGroup(1L));
+    }
+
+    @Test
+    public void listIAMGroupTest() {
+        IAMGroup group = new IAMGroupVO("group1", "tester group1");
+        List<IAMGroup> groups = new ArrayList<IAMGroup>();
+        groups.add(group);
+        when(_iamSrv.listIAMGroups(callerId)).thenReturn(groups);
+        List<IAMGroup> grps = _aclSrv.listIAMGroups(callerId);
+        assertTrue(grps != null && grps.size() == 1);
+        IAMGroup grp = grps.get(0);
+        assertEquals("Error to retrieve group", "group1", grp.getName());
+    }
+
+    @Test
+    public void addRemoveAccountToGroupTest() {
+        IAMGroup group = new IAMGroupVO("group1", "tester group1");
+        List<IAMGroup> groups = new ArrayList<IAMGroup>();
+        groups.add(group);
+        Long groupId = group.getId();
+        List<Long> acctIds = new ArrayList<Long>();
+        AccountVO acct1 = new AccountVO(100L);
+        acct1.setAccountName("account1");
+        AccountVO acct2 = new AccountVO(200L);
+        acct2.setAccountName("account2");
+        acctIds.add(acct1.getId());
+        acctIds.add(acct2.getId());
+        when(_accountDao.findById(acct1.getId())).thenReturn(acct1);
+        when(_accountDao.findById(acct2.getId())).thenReturn(acct2);
+        when(_iamSrv.addAccountsToGroup(acctIds, groupId)).thenReturn(group);
+        when(_iamSrv.listAccountsByGroup(groupId)).thenReturn(acctIds);
+        Pair<List<IAMGroup>, Integer> grpList = new Pair<List<IAMGroup>, Integer>(groups, 1);
+        when(_iamSrv.listIAMGroups(null, "group1", callerDomainPath, 0L, 20L)).thenReturn(grpList);
+        _aclSrv.addAccountsToGroup(acctIds, groupId);
+        ListResponse<IAMGroupResponse> grpResp = _aclSrv.listIAMGroups(null, "group1", callerDomainId, 0L, 20L);
+        assertTrue("No. of response items should be one", grpResp.getCount() == 1);
+        IAMGroupResponse resp = grpResp.getResponses().get(0);
+        Set<String> acctNames = resp.getAccountNameList();
+        assertEquals("There should be 2 accounts in the group", 2, acctNames.size());
+        assertTrue("account1 should be assigned to the group", acctNames.contains("account1"));
+        assertTrue("account2 should be assigned to the group", acctNames.contains("account2"));
+        // remove "account2" from group1
+        acctIds.remove(1);
+        List<Long> rmAccts = new ArrayList<Long>();
+        rmAccts.add(acct2.getId());
+        when(_iamSrv.removeAccountsFromGroup(rmAccts, groupId)).thenReturn(group);
+        _aclSrv.removeAccountsFromGroup(acctIds, groupId);
+        grpResp = _aclSrv.listIAMGroups(null, "group1", callerDomainId, 0L, 20L);
+        assertTrue("No. of response items should be one", grpResp.getCount() == 1);
+        resp = grpResp.getResponses().get(0);
+        acctNames = resp.getAccountNameList();
+        assertEquals("There should be 1 accounts in the group", 1, acctNames.size());
+        assertFalse("account2 should not belong to the group anymore", acctNames.contains("account2"));
+    }
+
+    @Test
+    public void createIAMPolicyTest() {
+        IAMPolicy policy = new IAMPolicyVO("policy1", "tester policy1");
+        List<IAMPolicy> policies = new ArrayList<IAMPolicy>();
+        policies.add(policy);
+        Pair<List<IAMPolicy>, Integer> policyList = new Pair<List<IAMPolicy>, Integer>(policies, 1);
+        when(_iamSrv.createIAMPolicy("policy1", "tester policy1", null, callerDomainPath)).thenReturn(policy);
+        when(_iamSrv.listIAMPolicies(null, null, callerDomainPath, 0L, 20L)).thenReturn(policyList);
+
+        IAMPolicy createdPolicy = _aclSrv.createIAMPolicy(caller, "policy1", "tester policy1", null);
+        assertNotNull("IAM policy 'policy1' failed to create ", createdPolicy);
+        ListResponse<IAMPolicyResponse> policyResp = _aclSrv.listIAMPolicies(null, null, callerDomainId, 0L, 20L);
+        assertTrue("No. of response items should be one", policyResp.getCount() == 1);
+        IAMPolicyResponse resp = policyResp.getResponses().get(0);
+        assertEquals("Error in created group name", "policy1", resp.getName());
+    }
+
+    @Test
+    public void deleteIAMPolicyTest() {
+        when(_iamSrv.deleteIAMPolicy(1L)).thenReturn(true);
+        assertTrue("failed to delete acl policy 1", _aclSrv.deleteIAMPolicy(1L));
+    }
+
+    @Test
+    public void listIAMPolicyTest() {
+        IAMPolicy policy = new IAMPolicyVO("policy1", "tester policy1");
+        List<IAMPolicy> policies = new ArrayList<IAMPolicy>();
+        policies.add(policy);
+        when(_iamSrv.listIAMPolicies(callerId)).thenReturn(policies);
+        List<IAMPolicy> polys = _aclSrv.listIAMPolicies(callerId);
+        assertTrue(polys != null && polys.size() == 1);
+        IAMPolicy p = polys.get(0);
+        assertEquals("Error to retrieve group", "policy1", p.getName());
+    }
+
+    @Test
+    public void addRemovePolicyToGroupTest() {
+        IAMGroup group = new IAMGroupVO("group1", "tester group1");
+        List<IAMGroup> groups = new ArrayList<IAMGroup>();
+        groups.add(group);
+        Long groupId = group.getId();
+        List<Long> policyIds = new ArrayList<Long>();
+        policyIds.add(100L);
+        policyIds.add(200L);
+        IAMPolicy policy1 = new IAMPolicyVO("policy1", "my first policy");
+        IAMPolicy policy2 = new IAMPolicyVO("policy2", "my second policy");
+        List<IAMPolicy> policies = new ArrayList<IAMPolicy>();
+        policies.add(policy1);
+        policies.add(policy2);
+        when(_iamSrv.attachIAMPoliciesToGroup(policyIds, groupId)).thenReturn(group);
+        when(_iamSrv.listIAMPoliciesByGroup(groupId)).thenReturn(policies);
+        Pair<List<IAMGroup>, Integer> grpList = new Pair<List<IAMGroup>, Integer>(groups, 1);
+        when(_iamSrv.listIAMGroups(null, "group1", callerDomainPath, 0L, 20L)).thenReturn(grpList);
+        _aclSrv.attachIAMPoliciesToGroup(policyIds, groupId);
+        ListResponse<IAMGroupResponse> grpResp = _aclSrv.listIAMGroups(null, "group1", callerDomainId, 0L, 20L);
+        assertTrue("No. of response items should be one", grpResp.getCount() == 1);
+        IAMGroupResponse resp = grpResp.getResponses().get(0);
+        Set<String> policyNames = resp.getPolicyList();
+        assertEquals("There should be 2 policies in the group", 2, policyNames.size());
+        assertTrue("policy1 should be assigned to the group", policyNames.contains("policy1"));
+        assertTrue("policy2 should be assigned to the group", policyNames.contains("policy2"));
+        // remove "policy2" from group1
+        policyIds.remove(1);
+        policies.remove(policy2);
+        when(_iamSrv.removeIAMPoliciesFromGroup(policyIds, groupId)).thenReturn(group);
+        _aclSrv.removeIAMPoliciesFromGroup(policyIds, groupId);
+        grpResp = _aclSrv.listIAMGroups(null, "group1", callerDomainId, 0L, 20L);
+        assertTrue("No. of response items should be one", grpResp.getCount() == 1);
+        resp = grpResp.getResponses().get(0);
+        policyNames = resp.getPolicyList();
+        assertEquals("There should be 1 policy attached to the group", 1, policyNames.size());
+        assertFalse("policy2 should not belong to the group anymore", policyNames.contains("policy2"));
+    }
+
+    @Test
+    public void addRemovePermissionToPolicyTest() {
+        IAMPolicy policy = new IAMPolicyVO("policy1", "tester policy1");
+        List<IAMPolicy> policies = new ArrayList<IAMPolicy>();
+        policies.add(policy);
+        Long policyId = policy.getId();
+        Long resId = 200L;
+        Class clz = ListVMsCmd.class;
+        when(_apiServer.getCmdClass("listVirtualMachines")).thenReturn(clz);
+        when(
+                _iamSrv.addIAMPermissionToIAMPolicy(policyId, IAMEntityType.VirtualMachine.toString(),
+                        PermissionScope.RESOURCE.toString(), resId, "listVirtualMachines",
+                        AccessType.UseEntry.toString(), Permission.Allow, false)).thenReturn(policy);
+        _aclSrv.addIAMPermissionToIAMPolicy(policyId, IAMEntityType.VirtualMachine.toString(),
+                PermissionScope.RESOURCE, resId, "listVirtualMachines", Permission.Allow, false);
+        Pair<List<IAMPolicy>, Integer> policyList = new Pair<List<IAMPolicy>, Integer>(policies, 1);
+        List<IAMPolicyPermission> policyPerms = new ArrayList<IAMPolicyPermission>();
+        IAMPolicyPermission perm = new IAMPolicyPermissionVO(policyId, "listVirtualMachines",
+                IAMEntityType.VirtualMachine.toString(), AccessType.UseEntry.toString(),
+                PermissionScope.RESOURCE.toString(),
+                resId, Permission.Allow, false);
+        policyPerms.add(perm);
+        when(_iamSrv.listIAMPolicies(null, "policy1", callerDomainPath, 0L, 20L)).thenReturn(policyList);
+        when(_iamSrv.listPolicyPermissions(policyId)).thenReturn(policyPerms);
+        ListResponse<IAMPolicyResponse> policyResp = _aclSrv.listIAMPolicies(null, "policy1", callerDomainId, 0L, 20L);
+        assertTrue("No. of response items should be one", policyResp.getCount() == 1);
+        IAMPolicyResponse resp = policyResp.getResponses().get(0);
+        Set<IAMPermissionResponse> permList = resp.getPermissionList();
+        assertTrue("Permission list should not be empty", permList != null && permList.size() > 0);
+        IAMPermissionResponse permResp = permList.iterator().next();
+        assertEquals("There should be one permission for listVirtualMachines", "listVirtualMachines", permResp.getAction());
+
+        //remove permission from policy
+        policyPerms.remove(perm);
+        _aclSrv.removeIAMPermissionFromIAMPolicy(policyId, IAMEntityType.VirtualMachine.toString(),
+                PermissionScope.RESOURCE, resId, "listVirtualMachines");
+        policyResp = _aclSrv.listIAMPolicies(null, "policy1", callerDomainId, 0L, 20L);
+        assertTrue("No. of response items should be one", policyResp.getCount() == 1);
+        resp = policyResp.getResponses().get(0);
+        permList = resp.getPermissionList();
+        assertTrue("Permission list should be empty", permList != null && permList.size() == 0);
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    @Configuration
+    @ComponentScan(basePackageClasses = {IAMApiServiceImpl.class}, includeFilters = {@Filter(value = TestConfiguration.Library.class, type = FilterType.CUSTOM)}, useDefaultFilters = false)
+    public static class TestConfiguration extends SpringUtils.CloudStackTestConfiguration {
+
+        @Bean
+        public DomainDao domainDao() {
+            return Mockito.mock(DomainDao.class);
+        }
+
+        @Bean
+        public IAMService iamService() {
+            return Mockito.mock(IAMService.class);
+        }
+
+        @Bean
+        public AccountDao accountDao() {
+            return Mockito.mock(AccountDao.class);
+        }
+
+        @Bean
+        public NetworkDomainDao networkDomainDao() {
+            return Mockito.mock(NetworkDomainDao.class);
+        }
+
+        @Bean
+        public AccountManager accountManager() {
+            return Mockito.mock(AccountManager.class);
+        }
+
+        @Bean
+        public MessageBus messageBus() {
+            return Mockito.mock(MessageBus.class);
+        }
+
+        @Bean
+        public EntityManager entityMgr() {
+            return Mockito.mock(EntityManager.class);
+        }
+
+        @Bean
+        public ApiServerService apiServerService() {
+            return Mockito.mock(ApiServerService.class);
+        }
+
+        public static class Library implements TypeFilter {
+
+            @Override
+            public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException {
+                ComponentScan cs = TestConfiguration.class.getAnnotation(ComponentScan.class);
+                return SpringUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c28450c1/services/iam/plugin/test/resources/db.properties
----------------------------------------------------------------------
diff --git a/services/iam/plugin/test/resources/db.properties b/services/iam/plugin/test/resources/db.properties
new file mode 100644
index 0000000..e1b5fe9
--- /dev/null
+++ b/services/iam/plugin/test/resources/db.properties
@@ -0,0 +1,75 @@
+# 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.
+
+
+# management server clustering parameters, change cluster.node.IP to the machine IP address
+# in which the management server(Tomcat) is running
+cluster.node.IP=127.0.0.1
+cluster.servlet.port=9090
+region.id=1
+
+# CloudStack database settings
+db.cloud.username=cloud
+db.cloud.password=cloud
+db.root.password=
+db.cloud.host=localhost
+db.cloud.port=3306
+db.cloud.name=cloud
+
+# CloudStack database tuning parameters
+db.cloud.maxActive=250
+db.cloud.maxIdle=30
+db.cloud.maxWait=10000
+db.cloud.autoReconnect=true
+db.cloud.validationQuery=SELECT 1
+db.cloud.testOnBorrow=true
+db.cloud.testWhileIdle=true
+db.cloud.timeBetweenEvictionRunsMillis=40000
+db.cloud.minEvictableIdleTimeMillis=240000
+db.cloud.poolPreparedStatements=false
+db.cloud.url.params=prepStmtCacheSize=517&cachePrepStmts=true&prepStmtCacheSqlLimit=4096
+
+# usage database settings
+db.usage.username=cloud
+db.usage.password=cloud
+db.usage.host=localhost
+db.usage.port=3306
+db.usage.name=cloud_usage
+
+# usage database tuning parameters
+db.usage.maxActive=100
+db.usage.maxIdle=30
+db.usage.maxWait=10000
+db.usage.autoReconnect=true
+
+# awsapi database settings
+db.awsapi.username=cloud
+db.awsapi.password=cloud
+db.awsapi.host=localhost
+db.awsapi.port=3306
+db.awsapi.name=cloudbridge
+
+# Simulator database settings
+db.simulator.username=cloud
+db.simulator.password=cloud
+db.simulator.host=localhost
+db.simulator.port=3306
+db.simulator.name=simulator
+db.simulator.maxActive=250
+db.simulator.maxIdle=30
+db.simulator.maxWait=10000
+db.simulator.autoReconnect=true


[37/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-6047: Fix FindBugs warning


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

Branch: refs/heads/resize-root
Commit: 78b148d0fccdf61e1c6c103e4dfa6b80b0fe9931
Parents: 2de67df
Author: Sheng Yang <sh...@citrix.com>
Authored: Thu Mar 6 19:27:46 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Thu Mar 6 19:27:46 2014 -0800

----------------------------------------------------------------------
 .../cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/78b148d0/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index 49e6812..f22a0db 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -1091,6 +1091,7 @@ public class VirtualRoutingResource {
                 List<ConfigItem> cfg = generateCommandCfg(command);
                 if (cfg == null) {
                     s_logger.warn("Unknown commands for VirtualRoutingResource, but continue: " + cmd.toString());
+                    continue;
                 }
 
                 for (ConfigItem c : cfg) {


[32/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
VPC UI: Restore old 'router' icon


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

Branch: refs/heads/resize-root
Commit: bf8507d564d5df5dbe02fffd45ba76daa8153108
Parents: 9b66866
Author: Brian Federle <br...@citrix.com>
Authored: Thu Mar 6 14:45:28 2014 -0800
Committer: Brian Federle <br...@citrix.com>
Committed: Thu Mar 6 14:45:28 2014 -0800

----------------------------------------------------------------------
 ui/images/sprites.png | Bin 212515 -> 211703 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bf8507d5/ui/images/sprites.png
----------------------------------------------------------------------
diff --git a/ui/images/sprites.png b/ui/images/sprites.png
index ca7f470..0af9a29 100644
Binary files a/ui/images/sprites.png and b/ui/images/sprites.png differ


[21/50] [abbrv] Externalized the hardcodedstrings from UI JAVASCRIPT files.

Posted by ml...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/client/WEB-INF/classes/resources/messages_zh_CN.properties
----------------------------------------------------------------------
diff --git a/client/WEB-INF/classes/resources/messages_zh_CN.properties b/client/WEB-INF/classes/resources/messages_zh_CN.properties
index f4c206b..bb3e50c 100644
--- a/client/WEB-INF/classes/resources/messages_zh_CN.properties
+++ b/client/WEB-INF/classes/resources/messages_zh_CN.properties
@@ -19,7 +19,7 @@ label.remove.ldap=\u5220\u9664 LDAP
 label.configure.ldap=\u914d\u7f6e LDAP
 label.ldap.configuration=LDAP \u914d\u7f6e
 label.ldap.port=LDAP \u7aef\u53e3
-label.create.nfs.secondary.staging.store=\u521b\u5efa NFS \u8f85\u52a9\u6682\u5b58\u5b58\u50a8
+label.create.nfs.secondary.staging.store=\u521b\u5efa NFS \u4e8c\u7ea7\u6682\u5b58\u5b58\u50a8
 label.volatile=\u53ef\u53d8
 label.planner.mode=\u89c4\u5212\u5668\u6a21\u5f0f
 label.deployment.planner=\u90e8\u7f72\u89c4\u5212\u5668
@@ -29,7 +29,7 @@ label.smb.password=SMB \u5bc6\u7801
 label.smb.domain=SMB \u57df
 label.hypervisors=\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f
 label.home=\u9996\u9875
-label.sockets=CPU Sockets
+label.sockets=CPU \u63d2\u69fd
 label.root.disk.size=\u6839\u78c1\u76d8\u5927\u5c0f
 label.s3.nfs.server=S3 NFS \u670d\u52a1\u5668
 label.s3.nfs.path=S3 NFS \u8def\u5f84
@@ -53,18 +53,18 @@ label.disk.iops.min=\u6700\u5c0f IOPS
 label.disk.iops.max=\u6700\u5927 IOPS
 label.disk.iops.total=\u603b IOPS
 label.hypervisor.snapshot.reserve=\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u5feb\u7167\u9884\u7559
-label.view.secondary.ips=\u67e5\u770b\u8f85\u52a9 IP
+label.view.secondary.ips=\u67e5\u770b\u4e8c\u7ea7 IP
 message.validate.invalid.characters=\u67e5\u627e\u5230\u65e0\u6548\u5b57\u7b26\uff0c\u8bf7\u66f4\u6b63\u3002
-message.acquire.ip.nic=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u83b7\u53d6\u6b64 NIC \u7684\u65b0\u8f85\u52a9 IP\u3002<br/>\u6ce8\u610f: \u60a8\u9700\u8981\u5728\u865a\u62df\u673a\u5185\u90e8\u624b\u52a8\u914d\u7f6e\u65b0\u83b7\u53d6\u7684\u8f85\u52a9 IP\u3002
+message.acquire.ip.nic=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u83b7\u53d6\u6b64 NIC \u7684\u65b0\u4e8c\u7ea7 IP\u3002<br/>\u6ce8\u610f: \u60a8\u9700\u8981\u5728\u865a\u62df\u673a\u5185\u90e8\u624b\u52a8\u914d\u7f6e\u65b0\u83b7\u53d6\u7684\u4e8c\u7ea7 IP\u3002
 message.select.affinity.groups=\u8bf7\u9009\u62e9\u60a8\u5e0c\u671b\u6b64 VM \u6240\u5c5e\u7684\u4efb\u4f55\u5173\u8054\u6027\u7ec4:
 message.no.affinity.groups=\u60a8\u6ca1\u6709\u4efb\u4f55\u5173\u8054\u6027\u7ec4\u3002\u8bf7\u7ee7\u7eed\u6267\u884c\u4e0b\u4e00\u6b65\u64cd\u4f5c\u3002
 label.action.delete.nic=\u79fb\u9664 NIC
 message.action.delete.nic=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u79fb\u9664\u6b64 NIC\uff0c\u6b64\u64cd\u4f5c\u8fd8\u5c06\u4ece VM \u4e2d\u79fb\u9664\u5173\u8054\u7684\u7f51\u7edc\u3002
 changed.item.properties=\u66f4\u6539\u9879\u76ee\u5c5e\u6027
-confirm.enable.s3=\u8bf7\u586b\u5199\u4ee5\u4e0b\u4fe1\u606f\u4ee5\u542f\u7528\u5bf9 S3 \u652f\u6301\u7684\u8f85\u52a9\u5b58\u50a8\u7684\u652f\u6301
+confirm.enable.s3=\u8bf7\u586b\u5199\u4ee5\u4e0b\u4fe1\u606f\u4ee5\u542f\u7528\u5bf9 S3 \u652f\u6301\u7684\u4e8c\u7ea7\u5b58\u50a8\u7684\u652f\u6301
 confirm.enable.swift=\u8bf7\u586b\u5199\u4ee5\u4e0b\u4fe1\u606f\u4ee5\u542f\u7528\u5bf9 SWIFT \u7684\u652f\u6301
-error.could.not.change.your.password.because.ldap.is.enabled=Error could not change your password because LDAP is enabled.
-error.could.not.enable.zone=\u65e0\u6cd5\u542f\u7528\u533a\u57df
+error.could.not.change.your.password.because.ldap.is.enabled=\u9519\u8bef\u3002LDAP \u5904\u4e8e\u542f\u7528\u72b6\u6001\uff0c\u65e0\u6cd5\u66f4\u6539\u60a8\u7684\u5bc6\u7801\u3002
+error.could.not.enable.zone=\u65e0\u6cd5\u542f\u7528\u8d44\u6e90\u57df
 error.installWizard.message=\u51fa\u73b0\u95ee\u9898\uff1b\u8bf7\u8fd4\u56de\u5e76\u66f4\u6b63\u4efb\u4f55\u9519\u8bef
 error.invalid.username.password=\u7528\u6237\u540d\u6216\u5bc6\u7801\u65e0\u6548
 error.login=\u60a8\u7684\u7528\u6237\u540d/\u5bc6\u7801\u4e0e\u6211\u4eec\u7684\u8bb0\u5f55\u4e0d\u4e00\u81f4\u3002
@@ -96,7 +96,7 @@ label.account.specific=\u5e10\u6237\u4e13\u7528
 label.account=\u5e10\u6237
 label.accounts=\u5e10\u6237
 label.acquire.new.ip=\u83b7\u53d6\u65b0 IP
-label.acquire.new.secondary.ip=\u83b7\u53d6\u65b0\u8f85\u52a9 IP
+label.acquire.new.secondary.ip=\u83b7\u53d6\u65b0\u4e8c\u7ea7 IP
 label.action.attach.disk.processing=\u6b63\u5728\u9644\u52a0\u78c1\u76d8...
 label.action.attach.disk=\u9644\u52a0\u78c1\u76d8
 label.action.attach.iso.processing=\u6b63\u5728\u9644\u52a0 ISO...
@@ -144,8 +144,8 @@ label.action.delete.pod.processing=\u6b63\u5728\u5220\u9664\u63d0\u4f9b\u70b9...
 label.action.delete.pod=\u5220\u9664\u63d0\u4f9b\u70b9
 label.action.delete.primary.storage.processing=\u6b63\u5728\u5220\u9664\u4e3b\u5b58\u50a8...
 label.action.delete.primary.storage=\u5220\u9664\u4e3b\u5b58\u50a8
-label.action.delete.secondary.storage.processing=\u6b63\u5728\u5220\u9664\u8f85\u52a9\u5b58\u50a8...
-label.action.delete.secondary.storage=\u5220\u9664\u8f85\u52a9\u5b58\u50a8
+label.action.delete.secondary.storage.processing=\u6b63\u5728\u5220\u9664\u4e8c\u7ea7\u5b58\u50a8...
+label.action.delete.secondary.storage=\u5220\u9664\u4e8c\u7ea7\u5b58\u50a8
 label.action.delete.security.group.processing=\u6b63\u5728\u5220\u9664\u5b89\u5168\u7ec4...
 label.action.delete.security.group=\u5220\u9664\u5b89\u5168\u7ec4
 label.action.delete.service.offering.processing=\u6b63\u5728\u5220\u9664\u670d\u52a1\u65b9\u6848...
@@ -159,8 +159,8 @@ label.action.delete.user.processing=\u6b63\u5728\u5220\u9664\u7528\u6237...
 label.action.delete.user=\u5220\u9664\u7528\u6237
 label.action.delete.volume.processing=\u6b63\u5728\u5220\u9664\u5377...
 label.action.delete.volume=\u5220\u9664\u5377
-label.action.delete.zone.processing=\u6b63\u5728\u5220\u9664\u533a\u57df...
-label.action.delete.zone=\u5220\u9664\u533a\u57df
+label.action.delete.zone.processing=\u6b63\u5728\u5220\u9664\u8d44\u6e90\u57df...
+label.action.delete.zone=\u5220\u9664\u8d44\u6e90\u57df
 label.action.destroy.instance.processing=\u6b63\u5728\u9500\u6bc1\u5b9e\u4f8b...
 label.action.destroy.instance=\u9500\u6bc1\u5b9e\u4f8b
 label.action.destroy.systemvm.processing=\u6b63\u5728\u9500\u6bc1\u7cfb\u7edf VM...
@@ -181,8 +181,8 @@ label.action.disable.static.NAT.processing=\u6b63\u5728\u7981\u7528\u9759\u6001
 label.action.disable.static.NAT=\u7981\u7528\u9759\u6001 NAT
 label.action.disable.user.processing=\u6b63\u5728\u7981\u7528\u7528\u6237...
 label.action.disable.user=\u7981\u7528\u7528\u6237
-label.action.disable.zone.processing=\u6b63\u5728\u7981\u7528\u533a\u57df...
-label.action.disable.zone=\u7981\u7528\u533a\u57df
+label.action.disable.zone.processing=\u6b63\u5728\u7981\u7528\u8d44\u6e90\u57df...
+label.action.disable.zone=\u7981\u7528\u8d44\u6e90\u57df
 label.action.download.ISO=\u4e0b\u8f7d ISO
 label.action.download.template=\u4e0b\u8f7d\u6a21\u677f
 label.action.download.volume.processing=\u6b63\u5728\u4e0b\u8f7d\u5377...
@@ -203,7 +203,7 @@ label.action.edit.resource.limits=\u7f16\u8f91\u8d44\u6e90\u9650\u5236
 label.action.edit.service.offering=\u7f16\u8f91\u670d\u52a1\u65b9\u6848
 label.action.edit.template=\u7f16\u8f91\u6a21\u677f
 label.action.edit.user=\u7f16\u8f91\u7528\u6237
-label.action.edit.zone=\u7f16\u8f91\u533a\u57df
+label.action.edit.zone=\u7f16\u8f91\u8d44\u6e90\u57df
 label.action.enable.account.processing=\u6b63\u5728\u542f\u7528\u5e10\u6237...
 label.action.enable.account=\u542f\u7528\u5e10\u6237
 label.action.enable.cluster.processing=\u6b63\u5728\u542f\u7528\u7fa4\u96c6...
@@ -218,8 +218,8 @@ label.action.enable.static.NAT.processing=\u6b63\u5728\u542f\u7528\u9759\u6001 N
 label.action.enable.static.NAT=\u542f\u7528\u9759\u6001 NAT
 label.action.enable.user.processing=\u6b63\u5728\u542f\u7528\u7528\u6237...
 label.action.enable.user=\u542f\u7528\u7528\u6237
-label.action.enable.zone.processing=\u6b63\u5728\u542f\u7528\u533a\u57df...
-label.action.enable.zone=\u542f\u7528\u533a\u57df
+label.action.enable.zone.processing=\u6b63\u5728\u542f\u7528\u8d44\u6e90\u57df...
+label.action.enable.zone=\u542f\u7528\u8d44\u6e90\u57df
 label.action.expunge.instance=\u5220\u9664\u5b9e\u4f8b
 label.action.expunge.instance.processing=\u6b63\u5728\u5220\u9664\u5b9e\u4f8b...
 label.action.force.reconnect.processing=\u6b63\u5728\u91cd\u65b0\u8fde\u63a5...
@@ -325,11 +325,11 @@ label.add.physical.network=\u6dfb\u52a0\u7269\u7406\u7f51\u7edc
 label.add.pod=\u6dfb\u52a0\u63d0\u4f9b\u70b9
 label.add.port.forwarding.rule=\u6dfb\u52a0\u7aef\u53e3\u8f6c\u53d1\u89c4\u5219
 label.add.primary.storage=\u6dfb\u52a0\u4e3b\u5b58\u50a8
-label.add.region=\u6dfb\u52a0\u533a\u57df
+label.add.region=\u6dfb\u52a0\u5730\u7406\u533a\u57df
 label.add.resources=\u6dfb\u52a0\u8d44\u6e90
 label.add.route=\u6dfb\u52a0\u8def\u7531
 label.add.rule=\u6dfb\u52a0\u89c4\u5219
-label.add.secondary.storage=\u6dfb\u52a0\u8f85\u52a9\u5b58\u50a8
+label.add.secondary.storage=\u6dfb\u52a0\u4e8c\u7ea7\u5b58\u50a8
 label.add.security.group=\u6dfb\u52a0\u5b89\u5168\u7ec4
 label.add.service.offering=\u6dfb\u52a0\u670d\u52a1\u65b9\u6848
 label.add.SRX.device=\u6dfb\u52a0 SRX \u8bbe\u5907
@@ -351,7 +351,7 @@ label.add.vpc=\u6dfb\u52a0 VPC
 label.add.vpn.customer.gateway=\u6dfb\u52a0 VPN \u5ba2\u6237\u7f51\u5173
 label.add.VPN.gateway=\u6dfb\u52a0 VPN \u7f51\u5173
 label.add.vpn.user=\u6dfb\u52a0 VPN \u7528\u6237
-label.add.zone=\u6dfb\u52a0\u533a\u57df
+label.add.zone=\u6dfb\u52a0\u8d44\u6e90\u57df
 label.add=\u6dfb\u52a0
 label.adding.cluster=\u6b63\u5728\u6dfb\u52a0\u7fa4\u96c6
 label.adding.failed=\u6dfb\u52a0\u5931\u8d25
@@ -359,7 +359,7 @@ label.adding.pod=\u6b63\u5728\u6dfb\u52a0\u63d0\u4f9b\u70b9
 label.adding.processing=\u6b63\u5728\u6dfb\u52a0...
 label.adding.succeeded=\u5df2\u6210\u529f\u6dfb\u52a0
 label.adding.user=\u6b63\u5728\u6dfb\u52a0\u7528\u6237
-label.adding.zone=\u6b63\u5728\u6dfb\u52a0\u533a\u57df
+label.adding.zone=\u6b63\u5728\u6dfb\u52a0\u8d44\u6e90\u57df
 label.adding=\u6b63\u5728\u6dfb\u52a0
 label.additional.networks=\u5176\u4ed6\u7f51\u7edc
 label.admin.accounts=\u7ba1\u7406\u5458\u5e10\u6237
@@ -389,7 +389,7 @@ label.associated.network=\u5173\u8054\u7f51\u7edc
 label.attached.iso=\u5df2\u9644\u52a0 ISO
 label.author.email=\u4f5c\u8005\u7535\u5b50\u90ae\u4ef6
 label.author.name=\u4f5c\u8005\u59d3\u540d
-label.availability.zone=\u53ef\u7528\u533a\u57df
+label.availability.zone=\u53ef\u7528\u8d44\u6e90\u57df
 label.availability=\u53ef\u7528\u6027
 label.available.public.ips=\u53ef\u7528\u516c\u7528 IP \u5730\u5740
 label.available=\u53ef\u7528
@@ -411,10 +411,10 @@ label.by.pod=\u6309\u63d0\u4f9b\u70b9
 label.by.role=\u6309\u89d2\u8272
 label.by.start.date=\u6309\u5f00\u59cb\u65e5\u671f
 label.by.state=\u6309\u72b6\u6001
-label.by.traffic.type=\u6309\u901a\u4fe1\u7c7b\u578b
+label.by.traffic.type=\u6309\u6d41\u91cf\u7c7b\u578b
 label.by.type.id=\u6309\u7c7b\u578b ID
 label.by.type=\u6309\u7c7b\u578b
-label.by.zone=\u6309\u533a\u57df
+label.by.zone=\u6309\u8d44\u6e90\u57df
 label.bytes.received=\u63a5\u6536\u7684\u5b57\u8282\u6570
 label.bytes.sent=\u53d1\u9001\u7684\u5b57\u8282\u6570
 label.cancel=\u53d6\u6d88
@@ -474,7 +474,7 @@ label.create.template=\u521b\u5efa\u6a21\u677f
 label.create.VPN.connection=\u521b\u5efa VPN \u8fde\u63a5
 label.created.by.system=\u7531\u7cfb\u7edf\u521b\u5efa
 label.created=\u521b\u5efa\u65e5\u671f
-label.cross.zones=\u8de8\u533a\u57df
+label.cross.zones=\u8de8\u8d44\u6e90\u57df
 label.custom.disk.size=\u81ea\u5b9a\u4e49\u78c1\u76d8\u5927\u5c0f
 label.daily=\u6bcf\u5929
 label.data.disk.offering=\u6570\u636e\u78c1\u76d8\u65b9\u6848
@@ -505,7 +505,7 @@ label.deleting.failed=\u5220\u9664\u5931\u8d25
 label.deleting.processing=\u6b63\u5728\u5220\u9664...
 label.description=\u8bf4\u660e
 label.destination.physical.network.id=\u76ee\u6807\u7269\u7406\u7f51\u7edc ID
-label.destination.zone=\u76ee\u6807\u533a\u57df
+label.destination.zone=\u76ee\u6807\u8d44\u6e90\u57df
 label.destroy.router=\u9500\u6bc1\u8def\u7531\u5668
 label.destroy=\u9500\u6bc1
 label.detaching.disk=\u6b63\u5728\u53d6\u6d88\u9644\u52a0\u78c1\u76d8
@@ -554,7 +554,7 @@ label.edit.lb.rule=\u7f16\u8f91\u8d1f\u8f7d\u5e73\u8861\u5668\u89c4\u5219
 label.edit.network.details=\u7f16\u8f91\u7f51\u7edc\u8be6\u60c5
 label.edit.project.details=\u7f16\u8f91\u9879\u76ee\u8be6\u60c5
 label.edit.tags=\u7f16\u8f91\u6807\u7b7e
-label.edit.traffic.type=\u7f16\u8f91\u901a\u4fe1\u7c7b\u578b
+label.edit.traffic.type=\u7f16\u8f91\u6d41\u91cf\u7c7b\u578b
 label.edit.vpc=\u7f16\u8f91 VPC
 label.edit=\u7f16\u8f91
 label.egress.rule=\u51fa\u53e3\u89c4\u5219
@@ -564,7 +564,7 @@ label.elastic.LB=\u5f39\u6027\u8d1f\u8f7d\u5e73\u8861\u5668
 label.elastic=\u5f39\u6027
 label.email=\u7535\u5b50\u90ae\u4ef6
 label.enable.provider=\u542f\u7528\u63d0\u4f9b\u7a0b\u5e8f
-label.enable.s3=\u542f\u7528 S3 \u652f\u6301\u7684\u8f85\u52a9\u5b58\u50a8
+label.enable.s3=\u542f\u7528 S3 \u652f\u6301\u7684\u4e8c\u7ea7\u5b58\u50a8
 label.enable.swift=\u542f\u7528 SWIFT
 label.enable.vpn=\u542f\u7528 VPN
 label.enabling.vpn.access=\u6b63\u5728\u542f\u7528 VPN \u8bbf\u95ee
@@ -601,6 +601,7 @@ label.full=\u6ee1\u8f7d
 label.gateway=\u7f51\u5173
 label.general.alerts=\u5e38\u89c4\u8b66\u62a5
 label.generating.url=\u6b63\u5728\u751f\u6210 URL
+label.gluster.volume=\u5377
 label.go.step.2=\u8f6c\u81f3\u6b65\u9aa4 2
 label.go.step.3=\u8f6c\u81f3\u6b65\u9aa4 3
 label.go.step.4=\u8f6c\u81f3\u6b65\u9aa4 4
@@ -615,7 +616,7 @@ label.guest.ip=\u6765\u5bbe IP \u5730\u5740
 label.guest.netmask=\u6765\u5bbe\u7f51\u7edc\u63a9\u7801
 label.guest.networks=\u6765\u5bbe\u7f51\u7edc
 label.guest.start.ip=\u6765\u5bbe\u8d77\u59cb IP
-label.guest.traffic=\u6765\u5bbe\u901a\u4fe1
+label.guest.traffic=\u6765\u5bbe\u6d41\u91cf
 label.guest.type=\u6765\u5bbe\u7c7b\u578b
 label.guest=\u6765\u5bbe
 label.ha.enabled=\u5df2\u542f\u7528\u9ad8\u53ef\u7528\u6027
@@ -650,11 +651,11 @@ label.installWizard.addPodIntro.subtitle=\u4ec0\u4e48\u662f\u63d0\u4f9b\u70b9?
 label.installWizard.addPodIntro.title=\u6dfb\u52a0\u4e00\u4e2a\u63d0\u4f9b\u70b9
 label.installWizard.addPrimaryStorageIntro.subtitle=\u4ec0\u4e48\u662f\u4e3b\u5b58\u50a8?
 label.installWizard.addPrimaryStorageIntro.title=\u6dfb\u52a0\u4e00\u4e2a\u4e3b\u5b58\u50a8
-label.installWizard.addSecondaryStorageIntro.subtitle=\u4ec0\u4e48\u662f\u8f85\u52a9\u5b58\u50a8?
-label.installWizard.addSecondaryStorageIntro.title=\u6dfb\u52a0\u4e00\u4e2a\u8f85\u52a9\u5b58\u50a8
-label.installWizard.addZone.title=\u6dfb\u52a0\u533a\u57df
-label.installWizard.addZoneIntro.subtitle=\u4ec0\u4e48\u662f\u533a\u57df?
-label.installWizard.addZoneIntro.title=\u6dfb\u52a0\u4e00\u4e2a\u533a\u57df
+label.installWizard.addSecondaryStorageIntro.subtitle=\u4ec0\u4e48\u662f\u4e8c\u7ea7\u5b58\u50a8?
+label.installWizard.addSecondaryStorageIntro.title=\u6dfb\u52a0\u4e00\u4e2a\u4e8c\u7ea7\u5b58\u50a8
+label.installWizard.addZone.title=\u6dfb\u52a0\u8d44\u6e90\u57df
+label.installWizard.addZoneIntro.subtitle=\u4ec0\u4e48\u662f\u8d44\u6e90\u57df?
+label.installWizard.addZoneIntro.title=\u6dfb\u52a0\u4e00\u4e2a\u8d44\u6e90\u57df
 label.installWizard.click.launch=\u8bf7\u5355\u51fb\u201c\u542f\u52a8\u201d\u6309\u94ae\u3002
 label.installWizard.subtitle=\u6b64\u6559\u7a0b\u5c06\u5e2e\u52a9\u60a8\u8bbe\u7f6e CloudStack&\#8482 \u5b89\u88c5
 label.installWizard.title=\u60a8\u597d\uff0c\u6b22\u8fce\u4f7f\u7528 CloudStack&\#8482
@@ -698,13 +699,13 @@ label.item.listing=\u9879\u76ee\u5217\u8868
 label.keep=\u4fdd\u7559
 label.key=\u5bc6\u94a5
 label.keyboard.type=\u952e\u76d8\u7c7b\u578b
-label.kvm.traffic.label=KVM \u901a\u4fe1\u6807\u7b7e
+label.kvm.traffic.label=KVM \u6d41\u91cf\u6807\u7b7e
 label.label=\u6807\u7b7e
 label.lang.arabic=\u963f\u62c9\u4f2f\u8bed
 label.lang.brportugese=\u8461\u8404\u7259\u8bed(\u5df4\u897f)
 label.lang.catalan=\u52a0\u6cf0\u7f57\u5c3c\u4e9a\u8bed
 label.lang.chinese=\u7b80\u4f53\u4e2d\u6587
-label.lang.dutch=Dutch (Netherlands)
+label.lang.dutch=\u8377\u5170\u8bed(\u8377\u5170)
 label.lang.english=\u82f1\u8bed
 label.lang.french=\u6cd5\u8bed
 label.lang.german=\u5fb7\u8bed
@@ -712,14 +713,14 @@ label.lang.italian=\u610f\u5927\u5229\u8bed
 label.lang.japanese=\u65e5\u8bed
 label.lang.korean=\u97e9\u8bed
 label.lang.norwegian=\u632a\u5a01\u8bed
-label.lang.polish=Polish
+label.lang.polish=\u6ce2\u5170\u8bed
 label.lang.russian=\u4fc4\u8bed
 label.lang.spanish=\u897f\u73ed\u7259\u8bed
 label.last.disconnected=\u4e0a\u6b21\u65ad\u5f00\u8fde\u63a5\u65f6\u95f4
 label.last.name=\u59d3\u6c0f
 label.latest.events=\u6700\u65b0\u4e8b\u4ef6
 label.launch.vm=\u542f\u52a8 VM
-label.launch.zone=\u542f\u52a8\u533a\u57df
+label.launch.zone=\u542f\u52a8\u8d44\u6e90\u57df
 label.launch=\u542f\u52a8
 label.LB.isolation=\u8d1f\u8f7d\u5e73\u8861\u5668\u9694\u79bb
 label.least.connections=\u6700\u5c11\u8fde\u63a5\u7b97\u6cd5
@@ -747,7 +748,7 @@ label.max.memory=\u6700\u5927\u5185\u5b58(MiB)
 label.max.networks=\u6700\u5927\u7f51\u7edc\u6570
 label.max.primary.storage=\u6700\u5927\u4e3b\u5b58\u50a8(GiB)
 label.max.public.ips=\u6700\u5927\u516c\u7528 IP \u6570
-label.max.secondary.storage=\u6700\u5927\u8f85\u52a9\u5b58\u50a8(GiB)
+label.max.secondary.storage=\u6700\u5927\u4e8c\u7ea7\u5b58\u50a8(GiB)
 label.max.snapshots=\u6700\u5927\u5feb\u7167\u6570
 label.max.templates=\u6700\u5927\u6a21\u677f\u6570
 label.max.vms=\u6700\u5927\u7528\u6237 VM \u6570
@@ -787,7 +788,7 @@ label.menu.my.templates=\u6211\u7684\u6a21\u677f
 label.menu.network.offerings=\u7f51\u7edc\u65b9\u6848
 label.menu.network=\u7f51\u7edc
 label.menu.physical.resources=\u7269\u7406\u8d44\u6e90
-label.menu.regions=\u533a\u57df
+label.menu.regions=\u5730\u7406\u533a\u57df
 label.menu.running.instances=\u6b63\u5728\u8fd0\u884c\u7684\u5b9e\u4f8b
 label.menu.security.groups=\u5b89\u5168\u7ec4
 label.menu.service.offerings=\u670d\u52a1\u65b9\u6848
@@ -863,7 +864,7 @@ label.nfs=NFS
 label.nic.adapter.type=NIC \u9002\u914d\u5668\u7c7b\u578b
 label.nicira.controller.address=\u63a7\u5236\u5668\u5730\u5740
 label.nicira.l3gatewayserviceuuid=L3 Gateway Service UUID
-label.nicira.transportzoneuuid=\u4f20\u8f93\u533a\u57df UUID
+label.nicira.transportzoneuuid=\u4f20\u8f93\u8d44\u6e90\u57df UUID
 label.nics=NIC
 label.no.actions=\u65e0\u53ef\u7528\u64cd\u4f5c
 label.no.alerts=\u65e0\u6700\u8fd1\u53d1\u51fa\u7684\u8b66\u62a5
@@ -883,7 +884,7 @@ label.number.of.hosts=\u4e3b\u673a\u6570\u91cf
 label.number.of.pods=\u63d0\u4f9b\u70b9\u6570\u91cf
 label.number.of.system.vms=\u7cfb\u7edf VM \u6570
 label.number.of.virtual.routers=\u865a\u62df\u8def\u7531\u5668\u6570
-label.number.of.zones=\u533a\u57df\u6570\u91cf
+label.number.of.zones=\u8d44\u6e90\u57df\u6570\u91cf
 label.numretries=\u91cd\u8bd5\u6b21\u6570
 label.ocfs2=OCFS2
 label.offer.ha=\u63d0\u4f9b\u9ad8\u53ef\u7528\u6027
@@ -934,7 +935,7 @@ label.private.ip=\u4e13\u7528 IP \u5730\u5740
 label.private.ips=\u4e13\u7528 IP \u5730\u5740
 label.private.network=\u4e13\u7528\u7f51\u7edc
 label.private.port=\u4e13\u7528\u7aef\u53e3
-label.private.zone=\u4e13\u7528\u533a\u57df
+label.private.zone=\u4e13\u7528\u8d44\u6e90\u57df
 label.privatekey=PKCS\#8 \u79c1\u94a5
 label.project.dashboard=\u9879\u76ee\u63a7\u5236\u677f
 label.project.id=\u9879\u76ee ID
@@ -950,8 +951,8 @@ label.public.ip=\u516c\u7528 IP \u5730\u5740
 label.public.ips=\u516c\u7528 IP \u5730\u5740
 label.public.network=\u516c\u7528\u7f51\u7edc
 label.public.port=\u516c\u7528\u7aef\u53e3
-label.public.traffic=\u516c\u5171\u901a\u4fe1
-label.public.zone=\u516c\u7528\u533a\u57df
+label.public.traffic=\u516c\u5171\u6d41\u91cf
+label.public.zone=\u516c\u7528\u8d44\u6e90\u57df
 label.public=\u516c\u7528
 label.purpose=\u76ee\u7684
 label.Pxe.server.type=Pxe \u670d\u52a1\u5668\u7c7b\u578b
@@ -962,7 +963,7 @@ label.redundant.router.capability=\u5197\u4f59\u8def\u7531\u5668\u529f\u80fd
 label.redundant.router=\u5197\u4f59\u8def\u7531\u5668
 label.redundant.state=\u5197\u4f59\u72b6\u6001
 label.refresh=\u5237\u65b0
-label.region=\u533a\u57df
+label.region=\u5730\u7406\u533a\u57df
 label.related=\u76f8\u5173\u8054
 label.remind.later=\u4ee5\u540e\u63d0\u9192\u6211
 label.remove.ACL=\u5220\u9664 ACL
@@ -972,7 +973,7 @@ label.remove.ingress.rule=\u5220\u9664\u5165\u53e3\u89c4\u5219
 label.remove.ip.range=\u5220\u9664 IP \u8303\u56f4
 label.remove.pf=\u5220\u9664\u7aef\u53e3\u8f6c\u53d1\u89c4\u5219
 label.remove.project.account=\u4ece\u9879\u76ee\u4e2d\u5220\u9664\u5e10\u6237
-label.remove.region=\u79fb\u9664\u533a\u57df
+label.remove.region=\u5220\u9664\u5730\u7406\u533a\u57df
 label.remove.rule=\u5220\u9664\u89c4\u5219
 label.remove.static.nat.rule=\u5220\u9664\u9759\u6001 NAT \u89c4\u5219
 label.remove.static.route=\u5220\u9664\u9759\u6001\u8def\u7531
@@ -1019,11 +1020,11 @@ label.save=\u4fdd\u5b58
 label.saving.processing=\u6b63\u5728\u4fdd\u5b58...
 label.scope=\u8303\u56f4
 label.search=\u641c\u7d22
-label.secondary.storage.count=\u8f85\u52a9\u5b58\u50a8\u6c60
-label.secondary.storage.limits=\u8f85\u52a9\u5b58\u50a8\u9650\u5236(GiB)
-label.secondary.storage.vm=\u8f85\u52a9\u5b58\u50a8 VM
-label.secondary.storage=\u8f85\u52a9\u5b58\u50a8
-label.secondary.used=\u5df2\u4f7f\u7528\u7684\u8f85\u52a9\u5b58\u50a8
+label.secondary.storage.count=\u4e8c\u7ea7\u5b58\u50a8\u6c60
+label.secondary.storage.limits=\u4e8c\u7ea7\u5b58\u50a8\u9650\u5236(GiB)
+label.secondary.storage.vm=\u4e8c\u7ea7\u5b58\u50a8 VM
+label.secondary.storage=\u4e8c\u7ea7\u5b58\u50a8
+label.secondary.used=\u5df2\u4f7f\u7528\u7684\u4e8c\u7ea7\u5b58\u50a8
 label.secret.key=\u5bc6\u94a5
 label.security.group.name=\u5b89\u5168\u7ec4\u540d\u79f0
 label.security.group=\u5b89\u5168\u7ec4
@@ -1031,7 +1032,7 @@ label.security.groups.enabled=\u5df2\u542f\u7528\u5b89\u5168\u7ec4
 label.security.groups=\u5b89\u5168\u7ec4
 label.select-view=\u9009\u62e9\u89c6\u56fe
 label.select.a.template=\u9009\u62e9\u4e00\u4e2a\u6a21\u677f
-label.select.a.zone=\u9009\u62e9\u4e00\u4e2a\u533a\u57df
+label.select.a.zone=\u9009\u62e9\u4e00\u4e2a\u8d44\u6e90\u57df
 label.select.instance.to.attach.volume.to=\u9009\u62e9\u8981\u5c06\u5377\u9644\u52a0\u5230\u7684\u5b9e\u4f8b
 label.select.instance=\u9009\u62e9\u5b9e\u4f8b
 label.select.iso.or.template=\u9009\u62e9 ISO \u6216\u6a21\u677f
@@ -1045,9 +1046,9 @@ label.server=\u670d\u52a1\u5668
 label.service.capabilities=\u670d\u52a1\u529f\u80fd
 label.service.offering=\u670d\u52a1\u65b9\u6848
 label.session.expired=\u4f1a\u8bdd\u5df2\u8fc7\u671f
-label.set.up.zone.type=\u8bbe\u7f6e\u533a\u57df\u7c7b\u578b
+label.set.up.zone.type=\u8bbe\u7f6e\u8d44\u6e90\u57df\u7c7b\u578b
 label.setup.network=\u8bbe\u7f6e\u7f51\u7edc
-label.setup.zone=\u8bbe\u7f6e\u533a\u57df
+label.setup.zone=\u8bbe\u7f6e\u8d44\u6e90\u57df
 label.setup=\u8bbe\u7f6e
 label.shared=\u5df2\u5171\u4eab
 label.SharedMountPoint=SharedMountPoint
@@ -1067,7 +1068,7 @@ label.source=\u6e90\u7b97\u6cd5
 label.specify.IP.ranges=\u6307\u5b9a IP \u8303\u56f4
 label.specify.vlan=\u6307\u5b9a VLAN
 label.specify.vxlan=\u6307\u5b9a VXLAN
-label.SR.name = SR Name-Label
+label.SR.name=SR \u540d\u79f0\u6807\u7b7e
 label.srx=SRX
 label.PA=Palo Alto
 label.start.IP=\u8d77\u59cb IP
@@ -1108,10 +1109,10 @@ label.sticky.tablesize=\u8868\u5927\u5c0f
 label.stop=\u505c\u6b62
 label.stopped.vms=\u5df2\u505c\u6b62\u7684 VM
 label.storage.tags=\u5b58\u50a8\u6807\u7b7e
-label.storage.traffic=\u5b58\u50a8\u901a\u4fe1
+label.storage.traffic=\u5b58\u50a8\u6d41\u91cf
 label.storage.type=\u5b58\u50a8\u7c7b\u578b
 label.qos.type=QoS \u7c7b\u578b
-label.cache.mode=Write-cache Type
+label.cache.mode=\u5199\u5165\u7f13\u5b58\u7c7b\u578b
 label.storage=\u5b58\u50a8
 label.subdomain.access=\u5b50\u57df\u8bbf\u95ee
 label.submit=\u63d0\u4ea4
@@ -1144,7 +1145,7 @@ label.tier.details=\u5c42\u8be6\u7ec6\u4fe1\u606f
 label.tier=\u5c42
 label.time.zone=\u65f6\u533a
 label.time=\u65f6\u95f4
-label.timeout.in.second = Timeout(seconds)
+label.timeout.in.second=\u8d85\u65f6(\u79d2)
 label.timeout=\u8d85\u65f6
 label.timezone=\u65f6\u533a
 label.token=\u4ee4\u724c
@@ -1156,9 +1157,9 @@ label.total.of.ip=\u603b IP \u5730\u5740\u6570
 label.total.of.vm=\u603b VM \u6570
 label.total.storage=\u5b58\u50a8\u603b\u91cf
 label.total.vms=\u603b VM \u6570
-label.traffic.label=\u901a\u4fe1\u6807\u7b7e
-label.traffic.type=\u901a\u4fe1\u7c7b\u578b
-label.traffic.types=\u901a\u4fe1\u7c7b\u578b
+label.traffic.label=\u6d41\u91cf\u6807\u7b7e
+label.traffic.type=\u6d41\u91cf\u7c7b\u578b
+label.traffic.types=\u6d41\u91cf\u7c7b\u578b
 label.tuesday=\u661f\u671f\u4e8c
 label.type.id=\u7c7b\u578b ID
 label.type=\u7c7b\u578b
@@ -1166,8 +1167,8 @@ label.unavailable=\u4e0d\u53ef\u7528
 label.unlimited=\u65e0\u9650\u5236
 label.untagged=\u5df2\u53d6\u6d88\u6807\u8bb0
 label.update.project.resources=\u66f4\u65b0\u9879\u76ee\u8d44\u6e90
-label.update.ssl.cert= SSL Certificate
-label.update.ssl= SSL Certificate
+label.update.ssl.cert=SSL \u8bc1\u4e66
+label.update.ssl=SSL \u8bc1\u4e66
 label.updating=\u6b63\u5728\u66f4\u65b0
 label.upload.volume=\u4e0a\u8f7d\u5377
 label.upload=\u4e0a\u8f7d
@@ -1224,7 +1225,7 @@ label.vmsnapshot.memory=\u5feb\u7167\u5185\u5b58
 label.vmsnapshot.parentname=\u7236\u540d\u79f0
 label.vmsnapshot.type=\u7c7b\u578b
 label.vmsnapshot=VM \u5feb\u7167
-label.vmware.traffic.label=VMware \u901a\u4fe1\u6807\u7b7e
+label.vmware.traffic.label=VMware \u6d41\u91cf\u6807\u7b7e
 label.volgroup=\u5377\u7ec4
 label.volume.limits=\u5377\u9650\u5236
 label.volume.name=\u5377\u540d\u79f0
@@ -1249,23 +1250,23 @@ label.weekly=\u6bcf\u5468
 label.welcome.cloud.console=\u6b22\u8fce\u4f7f\u7528\u7ba1\u7406\u63a7\u5236\u53f0
 label.welcome=\u6b22\u8fce
 label.what.is.cloudstack=\u4ec0\u4e48\u662f CloudStack&\#8482?
-label.xen.traffic.label=XenServer \u901a\u4fe1\u6807\u7b7e
+label.xen.traffic.label=XenServer \u6d41\u91cf\u6807\u7b7e
 label.yes=\u662f
-label.zone.details=\u533a\u57df\u8be6\u60c5
-label.zone.id=\u533a\u57df ID
-label.zone.name=\u533a\u57df\u540d\u79f0
+label.zone.details=\u8d44\u6e90\u57df\u8be6\u7ec6\u4fe1\u606f
+label.zone.id=\u8d44\u6e90\u57df ID
+label.zone.name=\u8d44\u6e90\u57df\u540d\u79f0
 label.zone.step.1.title=\u6b65\u9aa4 1\: <strong>\u9009\u62e9\u4e00\u4e2a\u7f51\u7edc</strong>
-label.zone.step.2.title=\u6b65\u9aa4 2\: <strong>\u6dfb\u52a0\u4e00\u4e2a\u533a\u57df</strong>
+label.zone.step.2.title=\u6b65\u9aa4 2\: <strong>\u6dfb\u52a0\u4e00\u4e2a\u8d44\u6e90\u57df</strong>
 label.zone.step.3.title=\u6b65\u9aa4 3\: <strong>\u6dfb\u52a0\u4e00\u4e2a\u63d0\u4f9b\u70b9</strong>
 label.zone.step.4.title=\u6b65\u9aa4 4\: <strong>\u6dfb\u52a0\u4e00\u4e2a IP \u8303\u56f4</strong>
-label.zone.type=\u533a\u57df\u7c7b\u578b
-label.zone.wide=\u6574\u4e2a\u533a\u57df
-label.zone=\u533a\u57df
-label.zones=\u533a\u57df
-label.zoneWizard.trafficType.guest=\u6765\u5bbe\: \u6700\u7ec8\u7528\u6237\u865a\u62df\u673a\u4e4b\u95f4\u7684\u901a\u4fe1
-label.zoneWizard.trafficType.management=\u7ba1\u7406\: CloudStack \u7684\u5185\u90e8\u8d44\u6e90(\u5305\u62ec\u4e0e\u7ba1\u7406\u670d\u52a1\u5668\u901a\u4fe1\u7684\u4efb\u4f55\u7ec4\u4ef6\uff0c\u4f8b\u5982\u4e3b\u673a\u548c CloudStack \u7cfb\u7edf VM)\u4e4b\u95f4\u7684\u901a\u4fe1
-label.zoneWizard.trafficType.public=\u516c\u7528\: \u4e91\u4e2d Internet \u4e0e\u865a\u62df\u673a\u4e4b\u95f4\u7684\u901a\u4fe1\u3002
-label.zoneWizard.trafficType.storage=\u5b58\u50a8\: \u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u4e0e\u8f85\u52a9\u5b58\u50a8\u670d\u52a1\u5668(\u4f8b\u5982 VM \u6a21\u677f\u4e0e\u5feb\u7167)\u4e4b\u95f4\u7684\u901a\u4fe1
+label.zone.type=\u8d44\u6e90\u57df\u7c7b\u578b
+label.zone.wide=\u6574\u4e2a\u8d44\u6e90\u57df
+label.zone=\u8d44\u6e90\u57df
+label.zones=\u8d44\u6e90\u57df
+label.zoneWizard.trafficType.guest=\u6765\u5bbe\: \u6700\u7ec8\u7528\u6237\u865a\u62df\u673a\u4e4b\u95f4\u7684\u6d41\u91cf
+label.zoneWizard.trafficType.management=\u7ba1\u7406\: CloudStack \u7684\u5185\u90e8\u8d44\u6e90(\u5305\u62ec\u4e0e\u7ba1\u7406\u670d\u52a1\u5668\u901a\u4fe1\u7684\u4efb\u4f55\u7ec4\u4ef6\uff0c\u4f8b\u5982\u4e3b\u673a\u548c CloudStack \u7cfb\u7edf VM)\u4e4b\u95f4\u7684\u6d41\u91cf
+label.zoneWizard.trafficType.public=\u516c\u5171\: \u4e91\u4e2d Internet \u4e0e\u865a\u62df\u673a\u4e4b\u95f4\u7684\u6d41\u91cf\u3002
+label.zoneWizard.trafficType.storage=\u5b58\u50a8\: \u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u4e0e\u4e8c\u7ea7\u5b58\u50a8\u670d\u52a1\u5668(\u4f8b\u5982 VM \u6a21\u677f\u4e0e\u5feb\u7167)\u4e4b\u95f4\u7684\u6d41\u91cf
 label.ldap.group.name=LDAP \u7ec4
 label.password.reset.confirm=\u5bc6\u7801\u5df2\u91cd\u7f6e\u4e3a
 label.provider=\u63d0\u4f9b\u7a0b\u5e8f
@@ -1283,17 +1284,18 @@ label.ipv6.address=IPv6 IP \u5730\u5740
 label.ipv6.gateway=IPv6 \u7f51\u5173
 label.ipv6.CIDR=IPv6 CIDR
 label.VPC.limits=VPC \u9650\u5236
-label.edit.region=\u7f16\u8f91\u533a\u57df
+label.edit.region=\u7f16\u8f91\u5730\u7406\u533a\u57df
 label.gslb.domain.name=GSLB \u57df\u540d
 label.add.gslb=\u6dfb\u52a0 GSLB
 label.gslb.servicetype=\u670d\u52a1\u7c7b\u578b
 label.gslb.details=GSLB \u8be6\u7ec6\u4fe1\u606f
 label.gslb.delete=\u5220\u9664 GSLB
-label.opendaylight.controllers=OpenDaylight Controllers
+label.opendaylight.controller=OpenDaylight \u63a7\u5236\u5668
+label.opendaylight.controllers=OpenDaylight \u63a7\u5236\u5668
 label.portable.ip.ranges=\u53ef\u79fb\u690d IP \u8303\u56f4
 label.add.portable.ip.range=\u6dfb\u52a0\u53ef\u79fb\u690d IP \u8303\u56f4
 label.delete.portable.ip.range=\u5220\u9664\u53ef\u79fb\u690d IP \u8303\u56f4
-label.opendaylight.controllerdetail=OpenDaylight Controller Details
+label.opendaylight.controllerdetail=OpenDaylight \u63a7\u5236\u5668\u8be6\u7ec6\u4fe1\u606f
 label.portable.ip.range.details=\u53ef\u79fb\u690d IP \u8303\u56f4\u8be6\u7ec6\u4fe1\u606f
 label.portable.ips=\u53ef\u79fb\u690d IP
 label.gslb.assigned.lb=\u5df2\u5206\u914d\u8d1f\u8f7d\u5e73\u8861
@@ -1305,22 +1307,183 @@ label.enable.autoscale=\u542f\u7528\u81ea\u52a8\u6269\u5c55
 label.disable.autoscale=\u7981\u7528\u81ea\u52a8\u6269\u5c55
 label.min.instances=\u6700\u5c0f\u5b9e\u4f8b\u6570
 label.max.instances=\u6700\u5927\u5b9e\u4f8b\u6570
-label.add.OpenDaylight.device=Add OpenDaylight Controller
+label.add.OpenDaylight.device=\u6dfb\u52a0 OpenDaylight \u63a7\u5236\u5668
 label.show.advanced.settings=\u663e\u793a\u9ad8\u7ea7\u8bbe\u7f6e
-label.delete.OpenDaylight.device=Delete OpenDaylight Controller
+label.delete.OpenDaylight.device=\u5220\u9664 OpenDaylight \u63a7\u5236\u5668
 label.polling.interval.sec=\u8f6e\u8be2\u65f6\u95f4\u95f4\u9694(\u79d2)
 label.quiet.time.sec=\u5b89\u9759\u65f6\u95f4(\u79d2)
 label.destroy.vm.graceperiod=\u9500\u6bc1 VM \u5bbd\u9650\u671f
 label.SNMP.community=SNMP \u793e\u533a
 label.SNMP.port=SNMP \u7aef\u53e3
 label.add.ucs.manager=\u6dfb\u52a0 UCS \u7ba1\u7406\u5668
-label.ovm.traffic.label=OVM \u901a\u4fe1\u6807\u7b7e
-label.lxc.traffic.label=LXC \u901a\u4fe1\u6807\u7b7e
-label.hyperv.traffic.label=HyperV \u901a\u4fe1\u6807\u7b7e
+label.ovm.traffic.label=OVM \u6d41\u91cf\u6807\u7b7e
+label.lxc.traffic.label=LXC \u6d41\u91cf\u6807\u7b7e
+label.hyperv.traffic.label=HyperV \u6d41\u91cf\u6807\u7b7e
+label.resource.name=\u8d44\u6e90\u540d\u79f0
+label.reource.id=\u8d44\u6e90 ID
+label.vnmc.devices=VNMC \u8bbe\u5907
+label.add.vnmc.provider=\u6dfb\u52a0 VNMC \u63d0\u4f9b\u7a0b\u5e8f
+label.enable.vnmc.provider=\u542f\u7528 VNMC \u63d0\u4f9b\u7a0b\u5e8f
+label.add.vnmc.device=\u6dfb\u52a0 VNMC \u8bbe\u5907
+label.ciscovnmc.resource.details=CiscoVNMC \u8d44\u6e90\u8be6\u7ec6\u4fe1\u606f
+label.delete.ciscovnmc.resource=\u5220\u9664 CiscoVNMC \u8d44\u6e90
+label.enable.vnmc.device=\u542f\u7528 VNMC \u8bbe\u5907
+label.disbale.vnmc.device=\u7981\u7528 VNMC \u8bbe\u5907
+label.disable.vnmc.provider=\u7981\u7528 VNMC \u63d0\u4f9b\u7a0b\u5e8f
+label.services=\u670d\u52a1
+label.secondary.staging.store=\u4e8c\u7ea7\u6682\u5b58\u5b58\u50a8
+label.release.account=\u4ece\u5e10\u6237\u4e2d\u91ca\u653e
+label.release.account.lowercase=\u4ece\u5e10\u6237\u4e2d\u91ca\u653e
+label.vlan.vni.ranges=VLAN/VNI \u8303\u56f4
+label.dedicated.vlan.vni.ranges=VLAN/VNI \u8303\u56f4\u5df2\u4e13\u7528
+label.dedicate.vlan.vni.range=\u5c06 VLAN/VNI \u8303\u56f4\u4e13\u7528
+label.vlan.vni.range=VLAN/VNI \u8303\u56f4
+label.vlan.range.details=VLAN \u8303\u56f4\u8be6\u7ec6\u4fe1\u606f
+label.release.dedicated.vlan.range=\u91ca\u653e\u4e13\u7528 VLAN \u8303\u56f4
+label.broadcat.uri=\u5e7f\u64ad URI
+label.ipv4.cidr=IPv4 CIDR
+label.guest.network.details=\u6765\u5bbe\u7f51\u7edc\u8be6\u7ec6\u4fe1\u606f
+label.ipv4.gateway=IPv4 \u7f51\u5173
+label.release.dedicated.vlan.range=\u91ca\u653e\u4e13\u7528 VLAN \u8303\u56f4
+label.vlan.ranges=VLAN \u8303\u56f4
+label.virtual.appliance.details=\u865a\u62df\u8bbe\u5907\u8be6\u7ec6\u4fe1\u606f
+label.start.lb.vm=\u542f\u52a8 LB VM
+label.stop.lb.vm=\u505c\u6b62 LB VM
+label.migrate.lb.vm=\u8fc1\u79fb LB VM
+label.vpc.virtual.router=VPC \u865a\u62df\u8def\u7531\u5668
+label.ovs=OVS
+label.gslb.service=GSLB \u670d\u52a1
+label.gslb.service.public.ip=GSLB \u670d\u52a1\u516c\u7528 IP
+label.gslb.service.private.ip=GSLB \u670d\u52a1\u4e13\u7528 IP
+label.baremetal.dhcp.provider=\u88f8\u673a DHCP \u63d0\u4f9b\u7a0b\u5e8f
+label.add.baremetal.dhcp.device=\u6dfb\u52a0\u88f8\u673a DHCP \u8bbe\u5907
+label.baremetal.pxe.provider=\u88f8\u673a PXE \u63d0\u4f9b\u7a0b\u5e8f
+label.baremetal.pxe.device=\u6dfb\u52a0\u88f8\u673a PXE \u8bbe\u5907
+label.tftp.root.directory=Tftp \u6839\u76ee\u5f55
+label.add.vmware.datacenter=\u6dfb\u52a0 VMware \u6570\u636e\u4e2d\u5fc3
+label.remove.vmware.datacenter=\u5220\u9664 VMware \u6570\u636e\u4e2d\u5fc3
+label.dc.name=\u6570\u636e\u4e2d\u5fc3\u540d\u79f0
+label.vcenter=vCenter
+label.dedicate.zone=\u5c06\u8d44\u6e90\u57df\u4e13\u7528
+label.zone.dedicated=\u8d44\u6e90\u57df\u5df2\u4e13\u7528
+label.release.dedicated.zone=\u91ca\u653e\u4e13\u7528\u8d44\u6e90\u57df
+label.ipv6.dns1=IPv6 DNS1
+label.ipv6.dns2=IPv6 DNS2
+label.vmware.datacenter.name=VMware \u6570\u636e\u4e2d\u5fc3\u540d\u79f0
+label.vmware.datacenter.vcenter=VMware \u6570\u636e\u4e2d\u5fc3 vCenter
+label.vmware.datacenter.id=VMware \u6570\u636e\u4e2d\u5fc3 ID
+label.system.vm.details=\u7cfb\u7edf VM \u8be6\u7ec6\u4fe1\u606f
+label.system.vm.scaled.up=\u5df2\u6269\u5c55\u7cfb\u7edf VM
+label.console.proxy.vm=\u63a7\u5236\u5668\u4ee3\u7406 VM
+label.settings=\u8bbe\u7f6e
+label.requires.upgrade=\u9700\u8981\u5347\u7ea7
+label.upgrade.router.newer.template=\u5347\u7ea7\u8def\u7531\u5668\u4ee5\u4f7f\u7528\u66f4\u65b0\u7684\u6a21\u677f
+label.router.vm.scaled.up=\u5df2\u6269\u5c55\u8def\u7531\u5668 VM
+label.total.virtual.routers=\u865a\u62df\u8def\u7531\u5668\u603b\u6570
+label.upgrade.required=\u9700\u8981\u5347\u7ea7
+label.virtual.routers.group.zone=\u865a\u62df\u8def\u7531\u5668(\u6309\u8d44\u6e90\u57df\u5206\u7ec4)
+label.total.virtual.routers.upgrade=\u9700\u8981\u5347\u7ea7\u7684\u865a\u62df\u8def\u7531\u5668\u603b\u6570
+label.virtual.routers.group.pod=\u865a\u62df\u8def\u7531\u5668(\u6309\u63d0\u4f9b\u70b9\u5206\u7ec4)
+label.virtual.routers.group.cluster=\u865a\u62df\u8def\u7531\u5668(\u6309\u7fa4\u96c6\u5206\u7ec4)
+label.zone.lower=\u8d44\u6e90\u57df
+label.virtual.routers.group.account=\u865a\u62df\u8def\u7531\u5668(\u6309\u5e10\u6237\u5206\u7ec4)
+label.netscaler.details=NetScaler \u8be6\u7ec6\u4fe1\u606f
+label.baremetal.dhcp.devices=\u88f8\u673a DHCP \u8bbe\u5907
+label.baremetal.pxe.devices=\u88f8\u673a PXE \u8bbe\u5907
+label.addes.new.f5=\u5df2\u6dfb\u52a0\u65b0 F5
+label.f5.details=F5 \u8be6\u7ec6\u4fe1\u606f
+label.srx.details=SRX \u8be6\u7ec6\u4fe1\u606f
+label.palo.alto.details=Palo Alto \u8be6\u7ec6\u4fe1\u606f
+label.added.nicira.nvp.controller=\u5df2\u6dfb\u52a0\u65b0 Nicira NVP \u63a7\u5236\u5668\
+label.nicira.nvp.details=Nicira NVP \u8be6\u7ec6\u4fe1\u606f
+label.added.new.bigswitch.vns.controller=\u5df2\u6dfb\u52a0\u65b0 BigSwitch VNS \u63a7\u5236\u5668
+label.bigswitch.vns.details=BigSwitch VNS \u8be6\u7ec6\u4fe1\u606f
+label.dedicate=\u4e13\u7528
+label.dedicate.pod=\u5c06\u63d0\u4f9b\u70b9\u4e13\u7528
+label.pod.dedicated=\u63d0\u4f9b\u70b9\u5df2\u4e13\u7528
+label.release.dedicated.pod=\u91ca\u653e\u4e13\u7528\u63d0\u4f9b\u70b9
+label.override.public.traffic=\u66ff\u4ee3\u516c\u5171\u6d41\u91cf
+label.public.traffic.vswitch.type=\u516c\u5171\u6d41\u91cf\u865a\u62df\u4ea4\u6362\u673a\u7c7b\u578b
+label.public.traffic.vswitch.name=\u516c\u5171\u6d41\u91cf\u865a\u62df\u4ea4\u6362\u673a\u540d\u79f0
+label.override.guest.traffic=\u66ff\u4ee3\u6765\u5bbe\u6d41\u91cf
+label.guest.traffic.vswitch.type=\u6765\u5bbe\u6d41\u91cf\u865a\u62df\u4ea4\u6362\u673a\u7c7b\u578b
+label.guest.traffic.vswitch.name=\u6765\u5bbe\u6d41\u91cf\u865a\u62df\u4ea4\u6362\u673a\u540d\u79f0
+label.cisco.nexus1000v.ip.address=Nexus 1000v IP \u5730\u5740
+label.cisco.nexus1000v.username=Nexus 1000v \u7528\u6237\u540d
+label.cisco.nexus1000v.password=Nexus 1000v \u5bc6\u7801
+label.dedicate.cluster=\u5c06\u7fa4\u96c6\u4e13\u7528
+label.release.dedicated.cluster=\u91ca\u653e\u4e13\u7528\u7fa4\u96c6
+label.dedicate.host=\u5c06\u4e3b\u673a\u4e13\u7528
+label.release.dedicated.host=\u91ca\u653e\u4e13\u7528\u4e3b\u673a
+label.number.of.cpu.sockets=CPU \u63d2\u69fd\u6570
+label.delete.ucs.manager=\u5220\u9664 UCS Manager
+label.blades=\u5200\u7247\u5f0f\u670d\u52a1\u5668
+label.chassis=\u673a\u7bb1
+label.blade.id=\u5200\u7247\u5f0f\u670d\u52a1\u5668 ID
+label.associated.profile=\u5df2\u5173\u8054\u914d\u7f6e\u6587\u4ef6
+label.refresh.blades=\u5237\u65b0\u5200\u7247\u5f0f\u670d\u52a1\u5668
+label.instanciate.template.associate.profile.blade=\u5c06\u6a21\u677f\u5b9e\u4f8b\u5316\u5e76\u5c06\u914d\u7f6e\u6587\u4ef6\u4e0e\u5200\u7247\u5f0f\u670d\u52a1\u5668\u5173\u8054
+label.select.template=\u9009\u62e9\u6a21\u677f
+label.profile=\u914d\u7f6e\u6587\u4ef6
+label.delete.profile=\u5220\u9664\u914d\u7f6e\u6587\u4ef6
+label.disassociate.profile.blade=\u53d6\u6d88\u5c06\u914d\u7f6e\u6587\u4ef6\u4e0e\u5200\u7247\u5f0f\u670d\u52a1\u5668\u5173\u8054
+label.secondary.storage.details=\u4e8c\u7ea7\u5b58\u50a8\u8be6\u7ec6\u4fe1\u606f
+label.secondary.staging.store.details=\u4e8c\u7ea7\u6682\u5b58\u5b58\u50a8\u8be6\u7ec6\u4fe1\u606f
+label.add.nfs.secondary.staging.store=\u6dfb\u52a0 NFS \u4e8c\u7ea7\u6682\u5b58\u5b58\u50a8
+label.delete.secondary.staging.store=\u5220\u9664\u4e8c\u7ea7\u6682\u5b58\u5b58\u50a8
+label.ipv4.start.ip=IPv4 \u8d77\u59cb IP
+label.ipv4.end.ip=IPv4 \u7ed3\u675f IP
+label.ipv6.start.ip=IPv6 \u8d77\u59cb IP
+label.ipv6.end.ip=IPv6 \u7ed3\u675f IP
+label.vm.password=VM \u7684\u5bc6\u7801
+label.group.by.zone=\u6309\u8d44\u6e90\u57df\u5206\u7ec4
+label.group.by.pod=\u6309\u63d0\u4f9b\u70b9\u5206\u7ec4
+label.group.by.cluster=\u6309\u7fa4\u96c6\u5206\u7ec4
+label.group.by.account=\u6309\u5e10\u6237\u5206\u7ec4
+label.no.grouping=(\u4e0d\u5206\u7ec4)\
+label.create.nfs.secondary.staging.storage=\u521b\u5efa NFS \u4e8c\u7ea7\u6682\u5b58\u5b58\u50a8
+label.username.lower=\u7528\u6237\u540d
+label.password.lower=\u5bc6\u7801
+label.email.lower=\u7535\u5b50\u90ae\u4ef6
+label.firstname.lower=\u540d\u5b57
+label.lastname.lower=\u59d3\u6c0f
+label.domain.lower=\u57df
+label.account.lower=\u5e10\u6237
+label.type.lower=\u7c7b\u578b
+label.rule.number=\u89c4\u5219\u7f16\u53f7
+label.action=\u64cd\u4f5c
+label.name.lower=\u540d\u79f0
+label.ucs=UCS
+label.change.affinity=\u66f4\u6539\u5173\u8054\u6027
+label.persistent=\u6c38\u4e45
+label.broadcasturi=\u5e7f\u64ad URI
+label.network.cidr=\u7f51\u7edc CIDR
+label.reserved.ip.range=\u9884\u7559 IP \u8303\u56f4
+label.autoscale=\u81ea\u52a8\u6269\u5c55
+label.health.check=\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5
+label.public.load.balancer.provider=\u516c\u7528\u8d1f\u8f7d\u5e73\u8861\u5668\u63d0\u4f9b\u7a0b\u5e8f
+label.add.isolated.network=\u6dfb\u52a0\u9694\u79bb\u7f51\u7edc
+label.vlan=VLAN
+label.secondary.isolated.vlan.id=\u4e8c\u7ea7\u9694\u79bb VLAN ID
+label.ipv4.netmask=IPv4 \u7f51\u7edc\u63a9\u7801
+label.custom=\u81ea\u5b9a\u4e49
+label.disable.network.offering=\u7981\u7528\u7f51\u7edc\u65b9\u6848
+label.enable.network.offering=\u542f\u7528\u7f51\u7edc\u65b9\u6848
+label.remove.network.offering=\u5220\u9664\u7f51\u7edc\u65b9\u6848
+label.system.offering.for.router=\u8def\u7531\u5668\u7684\u7cfb\u7edf\u65b9\u6848
+label.mode=\u6a21\u5f0f
+label.associate.public.ip=\u5173\u8054\u516c\u7528 IP
+label.acl=ACL
+label.user.data=\u7528\u6237\u6570\u636e
+label.virtual.networking=\u865a\u62df\u7f51\u7edc\u8fde\u63a5
+label.allow=\u5141\u8bb8
+label.deny=\u62d2\u7edd
+label.default.egress.policy=\u9ed8\u8ba4\u51fa\u53e3\u89c4\u5219
+label.xenserver.tools.version.61.plus=XenServer Tools \u7248\u672c 6.1\+
 managed.state=\u6258\u7ba1\u72b6\u6001
 message.acquire.new.ip.vpc=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u4e3a\u6b64 VPC \u83b7\u53d6\u4e00\u4e2a\u65b0 IP\u3002
 message.acquire.new.ip=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u4e3a\u6b64\u7f51\u7edc\u83b7\u53d6\u4e00\u4e2a\u65b0 IP\u3002
-message.acquire.public.ip=\u8bf7\u9009\u62e9\u4e00\u4e2a\u8981\u4ece\u4e2d\u83b7\u53d6\u65b0 IP \u7684\u533a\u57df\u3002
+message.acquire.public.ip=\u8bf7\u9009\u62e9\u4e00\u4e2a\u8981\u4ece\u4e2d\u83b7\u53d6\u65b0 IP \u7684\u8d44\u6e90\u57df\u3002
 message.action.cancel.maintenance.mode=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u53d6\u6d88\u6b64\u7ef4\u62a4\u6a21\u5f0f\u3002
 message.action.cancel.maintenance=\u5df2\u6210\u529f\u53d6\u6d88\u7ef4\u62a4\u60a8\u7684\u4e3b\u673a\u3002\u6b64\u8fc7\u7a0b\u53ef\u80fd\u9700\u8981\u957f\u8fbe\u51e0\u5206\u949f\u65f6\u95f4\u3002
 message.action.change.service.warning.for.instance=\u5fc5\u987b\u5148\u7981\u7528\u60a8\u7684\u5b9e\u4f8b\uff0c\u7136\u540e\u518d\u5c1d\u8bd5\u66f4\u6539\u5176\u5f53\u524d\u7684\u670d\u52a1\u65b9\u6848\u3002
@@ -1331,22 +1494,22 @@ message.action.delete.domain=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9
 message.action.delete.external.firewall=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5916\u90e8\u9632\u706b\u5899\u3002\u8b66\u544a\: \u5982\u679c\u60a8\u8ba1\u5212\u91cd\u65b0\u6dfb\u52a0\u540c\u4e00\u4e2a\u5916\u90e8\u9632\u706b\u5899\uff0c\u5219\u5fc5\u987b\u5728\u8bbe\u5907\u4e0a\u91cd\u7f6e\u4f7f\u7528\u6570\u636e\u3002
 message.action.delete.external.load.balancer=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5916\u90e8\u8d1f\u8f7d\u5e73\u8861\u5668\u3002\u8b66\u544a\: \u5982\u679c\u60a8\u8ba1\u5212\u91cd\u65b0\u6dfb\u52a0\u540c\u4e00\u4e2a\u5916\u90e8\u8d1f\u8f7d\u5e73\u8861\u5668\uff0c\u5219\u5fc5\u987b\u5728\u8bbe\u5907\u4e0a\u91cd\u7f6e\u4f7f\u7528\u6570\u636e\u3002
 message.action.delete.ingress.rule=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5165\u53e3\u89c4\u5219\u3002
-message.action.delete.ISO.for.all.zones=\u6b64 ISO \u7531\u6240\u6709\u533a\u57df\u4f7f\u7528\u3002\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5c06\u5176\u4ece\u6240\u6709\u533a\u57df\u4e2d\u5220\u9664\u3002
+message.action.delete.ISO.for.all.zones=\u6b64 ISO \u7531\u6240\u6709\u8d44\u6e90\u57df\u4f7f\u7528\u3002\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5c06\u5176\u4ece\u6240\u6709\u8d44\u6e90\u57df\u4e2d\u5220\u9664\u3002
 message.action.delete.ISO=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64 ISO\u3002
 message.action.delete.network=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u7f51\u7edc\u3002
 message.action.delete.nexusVswitch=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64 Nexus 1000v
 message.action.delete.physical.network=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u7269\u7406\u7f51\u7edc
 message.action.delete.pod=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u63d0\u4f9b\u70b9\u3002
 message.action.delete.primary.storage=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u4e3b\u5b58\u50a8\u3002
-message.action.delete.secondary.storage=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u8f85\u52a9\u5b58\u50a8\u3002
+message.action.delete.secondary.storage=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u4e8c\u7ea7\u5b58\u50a8\u3002
 message.action.delete.security.group=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5b89\u5168\u7ec4\u3002
 message.action.delete.service.offering=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u670d\u52a1\u65b9\u6848\u3002
 message.action.delete.snapshot=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5feb\u7167\u3002
 message.action.delete.system.service.offering=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u7cfb\u7edf\u670d\u52a1\u65b9\u6848\u3002
-message.action.delete.template.for.all.zones=\u6b64\u6a21\u677f\u7531\u6240\u6709\u533a\u57df\u4f7f\u7528\u3002\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5c06\u5176\u4ece\u6240\u6709\u533a\u57df\u4e2d\u5220\u9664\u3002
+message.action.delete.template.for.all.zones=\u6b64\u6a21\u677f\u7531\u6240\u6709\u8d44\u6e90\u57df\u4f7f\u7528\u3002\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5c06\u5176\u4ece\u6240\u6709\u8d44\u6e90\u57df\u4e2d\u5220\u9664\u3002
 message.action.delete.template=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u6a21\u677f\u3002
 message.action.delete.volume=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5377\u3002
-message.action.delete.zone=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u533a\u57df\u3002
+message.action.delete.zone=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u8d44\u6e90\u57df\u3002
 message.action.destroy.instance=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u9500\u6bc1\u6b64\u5b9e\u4f8b\u3002
 message.action.destroy.systemvm=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u9500\u6bc1\u6b64\u7cfb\u7edf VM\u3002
 message.action.disable.cluster=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u7981\u7528\u6b64\u7fa4\u96c6\u3002
@@ -1354,7 +1517,7 @@ message.action.disable.nexusVswitch=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u
 message.action.disable.physical.network=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u7981\u7528\u6b64\u7269\u7406\u7f51\u7edc\u3002
 message.action.disable.pod=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u7981\u7528\u6b64\u63d0\u4f9b\u70b9\u3002
 message.action.disable.static.NAT=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u7981\u7528\u9759\u6001 NAT\u3002
-message.action.disable.zone=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u7981\u7528\u6b64\u533a\u57df\u3002
+message.action.disable.zone=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u7981\u7528\u6b64\u8d44\u6e90\u57df\u3002
 message.action.download.iso=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u4e0b\u8f7d\u6b64 ISO\u3002
 message.action.download.template=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u4e0b\u8f7d\u6b64\u6a21\u677f\u3002
 message.action.enable.cluster=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64\u7fa4\u96c6\u3002
@@ -1362,7 +1525,7 @@ message.action.enable.maintenance=\u5df2\u6210\u529f\u51c6\u5907\u597d\u7ef4\u62
 message.action.enable.nexusVswitch=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64 Nexus 1000v
 message.action.enable.physical.network=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64\u7269\u7406\u7f51\u7edc\u3002
 message.action.enable.pod=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64\u63d0\u4f9b\u70b9\u3002
-message.action.enable.zone=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64\u533a\u57df\u3002
+message.action.enable.zone=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64\u8d44\u6e90\u57df\u3002
 message.action.expunge.instance=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5b9e\u4f8b\u3002
 message.action.force.reconnect=\u5df2\u6210\u529f\u5f3a\u5236\u91cd\u65b0\u8fde\u63a5\u60a8\u7684\u4e3b\u673a\u3002\u6b64\u8fc7\u7a0b\u53ef\u80fd\u9700\u8981\u957f\u8fbe\u51e0\u5206\u949f\u65f6\u95f4\u3002
 message.action.host.enable.maintenance.mode=\u542f\u7528\u7ef4\u62a4\u6a21\u5f0f\u4f1a\u5bfc\u81f4\u5c06\u6b64\u4e3b\u673a\u4e0a\u6b63\u5728\u8fd0\u884c\u7684\u6240\u6709\u5b9e\u4f8b\u5b9e\u65f6\u8fc1\u79fb\u5230\u4efb\u4f55\u53ef\u7528\u7684\u4e3b\u673a\u3002
@@ -1389,26 +1552,26 @@ message.action.unmanage.cluster=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u53d6
 message.action.vmsnapshot.delete=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64 VM \u5feb\u7167\u3002
 message.action.vmsnapshot.revert=\u8fd8\u539f VM \u5feb\u7167
 message.activate.project=\u662f\u5426\u786e\u5b9e\u8981\u6fc0\u6d3b\u6b64\u9879\u76ee?
-message.add.cluster.zone=\u5411\u533a\u57df <b><span id\="zone_name"></span></b> \u4e2d\u6dfb\u52a0\u4e00\u4e2a\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u6258\u7ba1\u7684\u7fa4\u96c6
-message.add.cluster=\u5411\u533a\u57df <b><span id\="zone_name"></span></b>\u3001\u63d0\u4f9b\u70b9 <b><span id\="pod_name"></span></b> \u4e2d\u6dfb\u52a0\u4e00\u4e2a\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u6258\u7ba1\u7684\u7fa4\u96c6
+message.add.cluster.zone=\u5411\u8d44\u6e90\u57df <b><span id\="zone_name"></span></b> \u4e2d\u6dfb\u52a0\u4e00\u4e2a\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u6258\u7ba1\u7684\u7fa4\u96c6
+message.add.cluster=\u5411\u8d44\u6e90\u57df <b><span id\="zone_name"></span></b>\u3001\u63d0\u4f9b\u70b9 <b><span id\="pod_name"></span></b> \u4e2d\u6dfb\u52a0\u4e00\u4e2a\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u6258\u7ba1\u7684\u7fa4\u96c6
 message.add.disk.offering=\u8bf7\u6307\u5b9a\u4ee5\u4e0b\u53c2\u6570\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u78c1\u76d8\u65b9\u6848
 message.add.domain=\u8bf7\u6307\u5b9a\u8981\u5728\u6b64\u57df\u4e0b\u521b\u5efa\u7684\u5b50\u57df
-message.add.firewall=\u5411\u533a\u57df\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u9632\u706b\u5899
+message.add.firewall=\u5411\u8d44\u6e90\u57df\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u9632\u706b\u5899
 message.add.guest.network=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u6dfb\u52a0\u4e00\u4e2a\u6765\u5bbe\u7f51\u7edc
 message.add.host=\u8bf7\u6307\u5b9a\u4ee5\u4e0b\u53c2\u6570\u4ee5\u6dfb\u52a0\u4e00\u53f0\u65b0\u4e3b\u673a
-message.add.ip.range.direct.network=\u5411\u533a\u57df <b><span id\="zone_name"></span></b> \u4e2d\u7684\u76f4\u63a5\u7f51\u7edc <b><span id\="directnetwork_name"></span></b> \u6dfb\u52a0\u4e00\u4e2a IP \u8303\u56f4
+message.add.ip.range.direct.network=\u5411\u8d44\u6e90\u57df <b><span id\="zone_name"></span></b> \u4e2d\u7684\u76f4\u63a5\u7f51\u7edc <b><span id\="directnetwork_name"></span></b> \u6dfb\u52a0\u4e00\u4e2a IP \u8303\u56f4
 message.add.ip.range.to.pod=<p>\u5411\u63d0\u4f9b\u70b9\u6dfb\u52a0\u4e00\u4e2a IP \u8303\u56f4\: <b><span id\="pod_name_label"></span></b></p>
-message.add.ip.range=\u5411\u533a\u57df\u4e2d\u7684\u516c\u7528\u7f51\u7edc\u6dfb\u52a0\u4e00\u4e2a IP \u8303\u56f4
+message.add.ip.range=\u5411\u8d44\u6e90\u57df\u4e2d\u7684\u516c\u7528\u7f51\u7edc\u6dfb\u52a0\u4e00\u4e2a IP \u8303\u56f4
 message.add.load.balancer.under.ip=\u5df2\u5728\u4ee5\u4e0b IP \u4e0b\u6dfb\u52a0\u8d1f\u8f7d\u5e73\u8861\u5668\u89c4\u5219\:
-message.add.load.balancer=\u5411\u533a\u57df\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u8d1f\u8f7d\u5e73\u8861\u5668
-message.add.network=\u4e3a\u533a\u57df <b><span id\="zone_name"></span></b> \u6dfb\u52a0\u4e00\u4e2a\u65b0\u7f51\u7edc
+message.add.load.balancer=\u5411\u8d44\u6e90\u57df\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u8d1f\u8f7d\u5e73\u8861\u5668
+message.add.network=\u4e3a\u8d44\u6e90\u57df <b><span id\="zone_name"></span></b> \u6dfb\u52a0\u4e00\u4e2a\u65b0\u7f51\u7edc 
 message.add.new.gateway.to.vpc=\u8bf7\u6307\u5b9a\u5c06\u65b0\u7f51\u5173\u6dfb\u52a0\u5230\u6b64 VPC \u6240\u9700\u7684\u4fe1\u606f\u3002
-message.add.pod.during.zone.creation=\u6bcf\u4e2a\u533a\u57df\u4e2d\u5fc5\u987b\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u63d0\u4f9b\u70b9\uff0c\u73b0\u5728\u6211\u4eec\u5c06\u6dfb\u52a0\u7b2c\u4e00\u4e2a\u63d0\u4f9b\u70b9\u3002\u63d0\u4f9b\u70b9\u4e2d\u5305\u542b\u4e3b\u673a\u548c\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\uff0c\u60a8\u5c06\u5728\u968f\u540e\u7684\u67d0\u4e2a\u6b65\u9aa4\u4e2d\u6dfb\u52a0\u8fd9\u4e9b\u4e3b\u673a\u548c\u670d\u52a1\u5668\u3002\u9996\u5148\uff0c\u8bf7\u4e3a CloudStack \u7684\u5185\u90e8\u7ba1\u7406\u901a\u4fe1\u914d\u7f6e\u4e00\u4e2a\u9884\u7559 IP \u5730\u5740\u8303\u56f4\u3002\u9884\u7559\u7684 IP \u8303\u56f4\u5bf9\u4e91\u4e2d\u7684\u6bcf\u4e2a\u533a\u57df\u6765\u8bf4\u5fc5\u987b\u552f\u4e00\u3002
-message.add.pod=\u4e3a\u533a\u57df <b><span id\="add_pod_zone_name"></span></b> \u6dfb\u52a0\u4e00\u4e2a\u65b0\u63d0\u4f9b\u70b9
-message.add.primary.storage=\u4e3a\u533a\u57df <b><span id\="add_pod_zone_name"></span></b>\u3001\u63d0\u4f9b\u70b9 <b><span id\="pod_name"></span></b> \u6dfb\u52a0\u4e00\u4e2a\u65b0\u4e3b\u5b58\u50a8
+message.add.pod.during.zone.creation=\u6bcf\u4e2a\u8d44\u6e90\u57df\u4e2d\u5fc5\u987b\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u63d0\u4f9b\u70b9\uff0c\u73b0\u5728\u6211\u4eec\u5c06\u6dfb\u52a0\u7b2c\u4e00\u4e2a\u63d0\u4f9b\u70b9\u3002\u63d0\u4f9b\u70b9\u4e2d\u5305\u542b\u4e3b\u673a\u548c\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\uff0c\u60a8\u5c06\u5728\u968f\u540e\u7684\u67d0\u4e2a\u6b65\u9aa4\u4e2d\u6dfb\u52a0\u8fd9\u4e9b\u4e3b\u673a\u548c\u670d\u52a1\u5668\u3002\u9996\u5148\uff0c\u8bf7\u4e3a CloudStack \u7684\u5185\u90e8\u7ba1\u7406\u6d41\u91cf\u914d\u7f6e\u4e00\u4e2a\u9884\u7559 IP \u5730\u5740\u8303\u56f4\u3002\u9884\u7559\u7684 IP \u8303\u56f4\u5bf9\u4e91\u4e2d\u7684\u6bcf\u4e2a\u8d44\u6e90\u57df\u6765\u8bf4\u5fc5\u987b\u552f\u4e00\u3002
+message.add.pod=\u4e3a\u8d44\u6e90\u57df <b><span id\="add_pod_zone_name"></span></b> \u6dfb\u52a0\u4e00\u4e2a\u65b0\u63d0\u4f9b\u70b9
+message.add.primary.storage=\u4e3a\u8d44\u6e90\u57df <b><span id\="add_pod_zone_name"></span></b>\u3001\u63d0\u4f9b\u70b9 <b><span id\="pod_name"></span></b> \u6dfb\u52a0\u4e00\u4e2a\u65b0\u4e3b\u5b58\u50a8
 message.add.primary=\u8bf7\u6307\u5b9a\u4ee5\u4e0b\u53c2\u6570\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u65b0\u4e3b\u5b58\u50a8
-message.add.region=\u8bf7\u6307\u5b9a\u6dfb\u52a0\u65b0\u533a\u57df\u6240\u9700\u7684\u4fe1\u606f\u3002
-message.add.secondary.storage=\u4e3a\u533a\u57df <b><span id\="zone_name"></span></b> \u6dfb\u52a0\u4e00\u4e2a\u65b0\u5b58\u50a8
+message.add.region=\u8bf7\u6307\u5b9a\u6dfb\u52a0\u65b0\u5730\u7406\u533a\u57df\u6240\u9700\u7684\u4fe1\u606f\u3002
+message.add.secondary.storage=\u4e3a\u8d44\u6e90\u57df <b><span id\="zone_name"></span></b> \u6dfb\u52a0\u4e00\u4e2a\u65b0\u5b58\u50a8
 message.add.service.offering=\u8bf7\u586b\u5199\u4ee5\u4e0b\u6570\u636e\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u65b0\u8ba1\u7b97\u65b9\u6848\u3002
 message.add.system.service.offering=\u8bf7\u586b\u5199\u4ee5\u4e0b\u6570\u636e\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u7cfb\u7edf\u670d\u52a1\u65b9\u6848\u3002
 message.add.template=\u8bf7\u8f93\u5165\u4ee5\u4e0b\u6570\u636e\u4ee5\u521b\u5efa\u65b0\u6a21\u677f
@@ -1420,8 +1583,8 @@ message.adding.Netscaler.provider=\u6b63\u5728\u6dfb\u52a0 Netscaler \u63d0\u4f9
 message.additional.networks.desc=\u8bf7\u9009\u62e9\u865a\u62df\u673a\u8981\u8fde\u63a5\u5230\u7684\u5176\u4ed6\u7f51\u7edc\u3002
 message.advanced.mode.desc=\u5982\u679c\u60a8\u5e0c\u671b\u542f\u7528 VLAN \u652f\u6301\uff0c\u8bf7\u9009\u62e9\u6b64\u7f51\u7edc\u6a21\u5f0f\u3002\u6b64\u7f51\u7edc\u6a21\u5f0f\u5728\u5141\u8bb8\u7ba1\u7406\u5458\u63d0\u4f9b\u9632\u706b\u5899\u3001VPN \u6216\u8d1f\u8f7d\u5e73\u8861\u5668\u652f\u6301\u7b49\u81ea\u5b9a\u4e49\u7f51\u7edc\u65b9\u6848\u4ee5\u53ca\u542f\u7528\u76f4\u63a5\u7f51\u7edc\u8fde\u63a5\u4e0e\u865a\u62df\u7f51\u7edc\u8fde\u63a5\u7b49\u65b9\u9762\u63d0\u4f9b\u4e86\u6700\u5927\u7684\u7075\u6d3b\u6027\u3002
 message.advanced.security.group=\u5982\u679c\u8981\u4f7f\u7528\u5b89\u5168\u7ec4\u63d0\u4f9b\u6765\u5bbe VM \u9694\u79bb\uff0c\u8bf7\u9009\u62e9\u6b64\u6a21\u5f0f\u3002
-message.advanced.virtual=\u5982\u679c\u8981\u4f7f\u7528\u6574\u4e2a\u533a\u57df\u7684 VLAN \u63d0\u4f9b\u6765\u5bbe VM \u9694\u79bb\uff0c\u8bf7\u9009\u62e9\u6b64\u6a21\u5f0f\u3002
-message.after.enable.s3=\u5df2\u914d\u7f6e S3 \u652f\u6301\u7684\u8f85\u52a9\u5b58\u50a8\u3002\u6ce8\u610f\: \u9000\u51fa\u6b64\u9875\u9762\u540e\uff0c\u60a8\u5c06\u65e0\u6cd5\u518d\u6b21\u91cd\u65b0\u914d\u7f6e S3\u3002
+message.advanced.virtual=\u5982\u679c\u8981\u4f7f\u7528\u6574\u4e2a\u8d44\u6e90\u57df\u7684 VLAN \u63d0\u4f9b\u6765\u5bbe VM \u9694\u79bb\uff0c\u8bf7\u9009\u62e9\u6b64\u6a21\u5f0f\u3002
+message.after.enable.s3=\u5df2\u914d\u7f6e S3 \u652f\u6301\u7684\u4e8c\u7ea7\u5b58\u50a8\u3002\u6ce8\u610f\: \u9000\u51fa\u6b64\u9875\u9762\u540e\uff0c\u60a8\u5c06\u65e0\u6cd5\u518d\u6b21\u91cd\u65b0\u914d\u7f6e S3\u3002
 message.after.enable.swift=\u5df2\u914d\u7f6e SWIFT\u3002\u6ce8\u610f\: \u9000\u51fa\u6b64\u9875\u9762\u540e\uff0c\u60a8\u5c06\u65e0\u6cd5\u518d\u6b21\u91cd\u65b0\u914d\u7f6e SWIFT\u3002
 message.alert.state.detected=\u68c0\u6d4b\u5230\u8b66\u62a5\u72b6\u6001
 message.allow.vpn.access=\u8bf7\u8f93\u5165\u8981\u5141\u8bb8\u8fdb\u884c VPN \u8bbf\u95ee\u7684\u7528\u6237\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002
@@ -1431,11 +1594,11 @@ message.attach.volume=\u8bf7\u586b\u5199\u4ee5\u4e0b\u6570\u636e\u4ee5\u9644\u52
 message.basic.mode.desc=\u5982\u679c\u60a8<b>*<u>\u4e0d</u>*</b>\u5e0c\u671b\u542f\u7528\u4efb\u4f55 VLAN \u652f\u6301\uff0c\u8bf7\u9009\u62e9\u6b64\u7f51\u7edc\u6a21\u5f0f\u3002\u5c06\u76f4\u63a5\u4ece\u6b64\u7f51\u7edc\u4e2d\u4e3a\u5728\u6b64\u7f51\u7edc\u6a21\u5f0f\u4e0b\u521b\u5efa\u7684\u6240\u6709\u865a\u62df\u673a\u5b9e\u4f8b\u5206\u914d\u4e00\u4e2a IP\uff0c\u5e76\u4f7f\u7528\u5b89\u5168\u7ec4\u63d0\u4f9b\u5b89\u5168\u6027\u548c\u9694\u79bb\u3002
 message.change.offering.confirm=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u66f4\u6539\u6b64\u865a\u62df\u5b9e\u4f8b\u7684\u670d\u52a1\u65b9\u6848\u3002
 message.change.password=\u8bf7\u66f4\u6539\u60a8\u7684\u5bc6\u7801\u3002
-message.configure.all.traffic.types=\u60a8\u6709\u591a\u4e2a\u7269\u7406\u7f51\u7edc\uff0c\u8bf7\u5355\u51fb\u201c\u7f16\u8f91\u201d\u6309\u94ae\u4e3a\u6bcf\u79cd\u901a\u4fe1\u7c7b\u578b\u914d\u7f6e\u6807\u7b7e\u3002
-message.configuring.guest.traffic=\u6b63\u5728\u914d\u7f6e\u6765\u5bbe\u901a\u4fe1
+message.configure.all.traffic.types=\u60a8\u6709\u591a\u4e2a\u7269\u7406\u7f51\u7edc\uff0c\u8bf7\u5355\u51fb\u201c\u7f16\u8f91\u201d\u6309\u94ae\u4e3a\u6bcf\u79cd\u6d41\u91cf\u7c7b\u578b\u914d\u7f6e\u6807\u7b7e\u3002
+message.configuring.guest.traffic=\u6b63\u5728\u914d\u7f6e\u6765\u5bbe\u6d41\u91cf
 message.configuring.physical.networks=\u6b63\u5728\u914d\u7f6e\u7269\u7406\u7f51\u7edc
-message.configuring.public.traffic=\u6b63\u5728\u914d\u7f6e\u516c\u5171\u901a\u4fe1
-message.configuring.storage.traffic=\u6b63\u5728\u914d\u7f6e\u5b58\u50a8\u901a\u4fe1
+message.configuring.public.traffic=\u6b63\u5728\u914d\u7f6e\u516c\u5171\u6d41\u91cf
+message.configuring.storage.traffic=\u6b63\u5728\u914d\u7f6e\u5b58\u50a8\u6d41\u91cf
 message.confirm.action.force.reconnect=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5f3a\u5236\u91cd\u65b0\u8fde\u63a5\u6b64\u4e3b\u673a\u3002
 message.confirm.delete.F5=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664 F5
 message.confirm.delete.NetScaler=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664 NetScaler
@@ -1448,7 +1611,7 @@ message.confirm.join.project=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u52a0\u5
 message.confirm.remove.IP.range=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64 IP \u8303\u56f4\u3002
 message.confirm.shutdown.provider=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5173\u95ed\u6b64\u63d0\u4f9b\u7a0b\u5e8f
 message.copy.iso.confirm=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5c06 ISO \u590d\u5236\u5230
-message.copy.template=\u5c06\u6a21\u677f <b id\="copy_template_name_text">XXX</b> \u4ece\u533a\u57df <b id\="copy_template_source_zone_text"></b> \u590d\u5236\u5230
+message.copy.template=\u5c06\u6a21\u677f <b id\="copy_template_name_text">XXX</b> \u4ece\u8d44\u6e90\u57df <b id\="copy_template_source_zone_text"></b> \u590d\u5236\u5230
 message.create.template.vm=\u57fa\u4e8e\u6a21\u677f <b id\="p_name"></b> \u521b\u5efa VM
 message.create.template.volume=\u8bf7\u5148\u6307\u5b9a\u4ee5\u4e0b\u4fe1\u606f\uff0c\u7136\u540e\u518d\u521b\u5efa\u78c1\u76d8\u5377 <b><span id\="volume_name"></span></b> \u7684\u6a21\u677f\u3002\u521b\u5efa\u6a21\u677f\u53ef\u80fd\u9700\u8981\u51e0\u5206\u949f\u5230\u66f4\u957f\u7684\u65f6\u95f4\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u78c1\u76d8\u5377\u7684\u5927\u5c0f\u3002
 message.create.template=\u662f\u5426\u786e\u5b9e\u8981\u521b\u5efa\u6a21\u677f?
@@ -1457,10 +1620,10 @@ message.creating.guest.network=\u6b63\u5728\u521b\u5efa\u6765\u5bbe\u7f51\u7edc
 message.creating.physical.networks=\u6b63\u5728\u521b\u5efa\u7269\u7406\u7f51\u7edc
 message.creating.pod=\u6b63\u5728\u521b\u5efa\u63d0\u4f9b\u70b9
 message.creating.primary.storage=\u6b63\u5728\u521b\u5efa\u4e3b\u5b58\u50a8
-message.creating.secondary.storage=\u6b63\u5728\u521b\u5efa\u8f85\u52a9\u5b58\u50a8
-message.creating.zone=\u6b63\u5728\u521b\u5efa\u533a\u57df
+message.creating.secondary.storage=\u6b63\u5728\u521b\u5efa\u4e8c\u7ea7\u5b58\u50a8
+message.creating.zone=\u6b63\u5728\u521b\u5efa\u8d44\u6e90\u57df
 message.decline.invitation=\u662f\u5426\u786e\u5b9e\u8981\u62d2\u7edd\u6b64\u9879\u76ee\u9080\u8bf7?
-message.dedicate.zone=\u6b63\u5728\u5c06\u533a\u57df\u4e13\u6709\u5316
+message.dedicate.zone=\u6b63\u5728\u5c06\u8d44\u6e90\u57df\u4e13\u7528
 message.delete.account=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5e10\u6237\u3002
 message.delete.affinity.group=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5173\u8054\u6027\u7ec4\u3002
 message.delete.gateway=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u7f51\u5173
@@ -1474,8 +1637,8 @@ message.desc.basic.zone=\u63d0\u4f9b\u4e00\u4e2a\u7f51\u7edc\uff0c\u5c06\u76f4\u
 message.desc.cluster=\u6bcf\u4e2a\u63d0\u4f9b\u70b9\u4e2d\u5fc5\u987b\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u7fa4\u96c6\uff0c\u73b0\u5728\u6211\u4eec\u5c06\u6dfb\u52a0\u7b2c\u4e00\u4e2a\u7fa4\u96c6\u3002\u7fa4\u96c6\u63d0\u4f9b\u4e86\u4e00\u79cd\u7f16\u7ec4\u4e3b\u673a\u7684\u65b9\u6cd5\u3002\u7fa4\u96c6\u4e2d\u7684\u6240\u6709\u4e3b\u673a\u90fd\u5177\u6709\u76f8\u540c\u7684\u786c\u4ef6\uff0c\u8fd0\u884c\u76f8\u540c\u7684\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\uff0c\u4f4d\u4e8e\u76f8\u540c\u7684\u5b50\u7f51\u4e2d\uff0c\u5e76\u8bbf\u95ee\u76f8\u540c\u7684\u5171\u4eab\u5b58\u50a8\u3002\u6bcf\u4e2a\u7fa4\u96c6\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u4e3b\u673a\u4ee5\u53ca\u4e00\u4e2a\u6216\u591a\u4e2a\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u7ec4\u6210\u3002
 message.desc.host=\u6bcf\u4e2a\u7fa4\u96c6\u4e2d\u5fc5\u987b\u81f3\u5c11\u5305\u542b\u4e00\u4e2a\u4e3b\u673a\u4ee5\u4f9b\u6765\u5bbe VM \u5728\u4e0a\u9762\u8fd0\u884c\uff0c\u73b0\u5728\u6211\u4eec\u5c06\u6dfb\u52a0\u7b2c\u4e00\u4e2a\u4e3b\u673a\u3002\u8981\u4f7f\u4e3b\u673a\u5728 CloudStack \u4e2d\u8fd0\u884c\uff0c\u5fc5\u987b\u5728\u6b64\u4e3b\u673a\u4e0a\u5b89\u88c5\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u8f6f\u4ef6\uff0c\u4e3a\u5176\u5206\u914d\u4e00\u4e2a IP \u5730\u5740\uff0c\u5e76\u786e\u4fdd\u5c06\u5176\u8fde\u63a5\u5230 CloudStack \u7ba1\u7406\u670d\u52a1\u5668\u3002<br/><br/>\u8bf7\u63d0\u4f9b\u4e3b\u673a\u7684 DNS \u6216 IP \u5730\u5740\u3001\u7528\u6237\u540d(\u901a\u5e38\u4e3a root)\u548c\u5bc6\u7801\uff0c\u4ee5\u53ca\u7528\u4e8e\u5bf9\u4e3b\u673a\u8fdb\u884c\u5206\u7c7b\u7684\u4efb\u4f55\u6807\u7b7e\u3002
 message.desc.primary.storage=\u6bcf\u4e2a\u7fa4\u96c6\u4e2d\u5fc5\u987b\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\uff0c\u73b0\u5728\u6211\u4eec\u5c06\u6dfb\u52a0\u7b2c\u4e00\u4e2a\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u3002\u4e3b\u5b58\u50a8\u4e2d\u5305\u542b\u5728\u7fa4\u96c6\u4e2d\u7684\u4e3b\u673a\u4e0a\u8fd0\u884c\u7684\u6240\u6709 VM \u7684\u78c1\u76d8\u5377\u3002\u8bf7\u4f7f\u7528\u5e95\u5c42\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u652f\u6301\u7684\u7b26\u5408\u6807\u51c6\u7684\u534f\u8bae\u3002
-message.desc.secondary.storage=\u6bcf\u4e2a\u533a\u57df\u4e2d\u5fc5\u987b\u81f3\u5c11\u5305\u542b\u4e00\u4e2a NFS \u6216\u8f85\u52a9\u5b58\u50a8\u670d\u52a1\u5668\uff0c\u73b0\u5728\u6211\u4eec\u5c06\u6dfb\u52a0\u7b2c\u4e00\u4e2a NFS \u6216\u8f85\u52a9\u5b58\u50a8\u670d\u52a1\u5668\u3002\u8f85\u52a9\u5b58\u50a8\u7528\u4e8e\u5b58\u50a8 VM \u6a21\u677f\u3001ISO \u6620\u50cf\u548c VM \u78c1\u76d8\u5377\u5feb\u7167\u3002\u6b64\u670d\u52a1\u5668\u5fc5\u987b\u5bf9\u533a\u57df\u4e2d\u7684\u6240\u6709\u670d\u52a1\u5668\u53ef\u7528\u3002<br/><br/>\u8bf7\u63d0\u4f9b IP \u5730\u5740\u548c\u5bfc\u51fa\u8def\u5f84\u3002
-message.desc.zone=\u533a\u57df\u662f CloudStack \u4e2d\u6700\u5927\u7684\u7ec4\u7ec7\u5355\u4f4d\uff0c\u4e00\u4e2a\u533a\u57df\u901a\u5e38\u4e0e\u4e00\u4e2a\u6570\u636e\u4e2d\u5fc3\u76f8\u5bf9\u5e94\u3002\u533a\u57df\u53ef\u63d0\u4f9b\u7269\u7406\u9694\u79bb\u548c\u5197\u4f59\u3002\u4e00\u4e2a\u533a\u57df\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u63d0\u4f9b\u70b9\u4ee5\u53ca\u7531\u533a\u57df\u4e2d\u7684\u6240\u6709\u63d0\u4f9b\u70b9\u5171\u4eab\u7684\u4e00\u4e2a\u8f85\u52a9\u5b58\u50a8\u670d\u52a1\u5668\u7ec4\u6210\uff0c\u5176\u4e2d\u6bcf\u4e2a\u63d0\u4f9b\u70b9\u4e2d\u5305\u542b\u591a\u4e2a\u4e3b\u673a\u548c\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u3002
+message.desc.secondary.storage=\u6bcf\u4e2a\u8d44\u6e90\u57df\u4e2d\u5fc5\u987b\u81f3\u5c11\u5305\u542b\u4e00\u4e2a NFS \u6216\u4e8c\u7ea7\u5b58\u50a8\u670d\u52a1\u5668\uff0c\u73b0\u5728\u6211\u4eec\u5c06\u6dfb\u52a0\u7b2c\u4e00\u4e2a NFS \u6216\u4e8c\u7ea7\u5b58\u50a8\u670d\u52a1\u5668\u3002\u4e8c\u7ea7\u5b58\u50a8\u7528\u4e8e\u5b58\u50a8 VM \u6a21\u677f\u3001ISO \u6620\u50cf\u548c VM \u78c1\u76d8\u5377\u5feb\u7167\u3002\u6b64\u670d\u52a1\u5668\u5fc5\u987b\u5bf9\u8d44\u6e90\u57df\u4e2d\u7684\u6240\u6709\u670d\u52a1\u5668\u53ef\u7528\u3002<br/><br/>\u8bf7\u63d0\u4f9b IP \u5730\u5740\u548c\u5bfc\u51fa\u8def\u5f84\u3002
+message.desc.zone=\u8d44\u6e90\u57df\u662f CloudStack \u4e2d\u6700\u5927\u7684\u7ec4\u7ec7\u5355\u4f4d\uff0c\u4e00\u4e2a\u8d44\u6e90\u57df\u901a\u5e38\u4e0e\u4e00\u4e2a\u6570\u636e\u4e2d\u5fc3\u76f8\u5bf9\u5e94\u3002\u8d44\u6e90\u57df\u53ef\u63d0\u4f9b\u7269\u7406\u9694\u79bb\u548c\u5197\u4f59\u3002\u4e00\u4e2a\u8d44\u6e90\u57df\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u63d0\u4f9b\u70b9\u4ee5\u53ca\u7531\u8d44\u6e90\u57df\u4e2d\u7684\u6240\u6709\u63d0\u4f9b\u70b9\u5171\u4eab\u7684\u4e00\u4e2a\u4e8c\u7ea7\u5b58\u50a8\u670d\u52a1\u5668\u7ec4\u6210\uff0c\u5176\u4e2d\u6bcf\u4e2a\u63d0\u4f9b\u70b9\u4e2d\u5305\u542b\u591a\u4e2a\u4e3b\u673a\u548c\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u3002
 message.detach.disk=\u662f\u5426\u786e\u5b9e\u8981\u53d6\u6d88\u9644\u52a0\u6b64\u78c1\u76d8?
 message.detach.iso.confirm=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u4ece\u6b64\u865a\u62df\u673a\u4e2d\u53d6\u6d88\u9644\u52a0\u6b64 ISO\u3002
 message.disable.account=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u7981\u7528\u6b64\u5e10\u6237\u3002\u7981\u7528\u540e\uff0c\u6b64\u5e10\u6237\u7684\u6240\u6709\u7528\u6237\u5c06\u4e0d\u518d\u6709\u6743\u8bbf\u95ee\u5404\u81ea\u7684\u4e91\u8d44\u6e90\u3002\u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684\u865a\u62df\u673a\u5c06\u7acb\u5373\u5173\u95ed\u3002
@@ -1490,7 +1653,7 @@ message.download.volume=\u8bf7\u5355\u51fb <a href\="\#">00000</a> \u4e0b\u8f7d\
 message.edit.account=\u7f16\u8f91(\u201c-1\u201d\u8868\u793a\u5bf9\u8981\u521b\u5efa\u7684\u8d44\u6e90\u6570\u91cf\u6ca1\u6709\u4efb\u4f55\u9650\u5236)
 message.edit.confirm=\u8bf7\u5148\u786e\u8ba4\u60a8\u6240\u505a\u7684\u66f4\u6539\uff0c\u7136\u540e\u5355\u51fb\u201c\u4fdd\u5b58\u201d\u3002
 message.edit.limits=\u8bf7\u6307\u5b9a\u5bf9\u4ee5\u4e0b\u8d44\u6e90\u7684\u9650\u5236\u3002\u201c-1\u201d\u8868\u793a\u4e0d\u9650\u5236\u8981\u521b\u5efa\u7684\u8d44\u6e90\u6570\u3002
-message.edit.traffic.type=\u8bf7\u6307\u5b9a\u60a8\u5e0c\u671b\u4e0e\u6b64\u901a\u4fe1\u7c7b\u578b\u5173\u8054\u7684\u901a\u4fe1\u6807\u7b7e\u3002
+message.edit.traffic.type=\u8bf7\u6307\u5b9a\u60a8\u5e0c\u671b\u4e0e\u6b64\u6d41\u91cf\u7c7b\u578b\u5173\u8054\u7684\u6d41\u91cf\u6807\u7b7e\u3002
 message.enable.account=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64\u5e10\u6237\u3002
 message.enable.user=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64\u7528\u6237\u3002
 message.enable.vpn.access=\u5f53\u524d\u5df2\u5bf9\u6b64 IP \u5730\u5740\u7981\u7528\u4e86 VPN\u3002\u662f\u5426\u8981\u542f\u7528 VPN \u8bbf\u95ee?
@@ -1498,51 +1661,51 @@ message.enable.vpn=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5bf9\u6b64 IP \u5
 message.enabled.vpn.ip.sec=\u60a8\u7684 IPSec \u9884\u5171\u4eab\u5bc6\u94a5
 message.enabled.vpn=\u60a8\u7684 VPN \u8bbf\u95ee\u529f\u80fd\u5f53\u524d\u5df2\u542f\u7528\uff0c\u53ef\u4ee5\u901a\u8fc7 IP \u8fdb\u884c\u8bbf\u95ee
 message.enabling.security.group.provider=\u6b63\u5728\u542f\u7528\u5b89\u5168\u7ec4\u63d0\u4f9b\u7a0b\u5e8f
-message.enabling.zone=\u6b63\u5728\u542f\u7528\u533a\u57df
+message.enabling.zone=\u6b63\u5728\u542f\u7528\u8d44\u6e90\u57df
 message.enter.token=\u8bf7\u8f93\u5165\u60a8\u5728\u9080\u8bf7\u7535\u5b50\u90ae\u4ef6\u4e2d\u6536\u5230\u7684\u4ee4\u724c\u3002
 message.generate.keys=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u4e3a\u6b64\u7528\u6237\u751f\u6210\u65b0\u5bc6\u94a5\u3002
-message.guest.traffic.in.advanced.zone=\u6765\u5bbe\u7f51\u7edc\u901a\u4fe1\u662f\u6307\u6700\u7ec8\u7528\u6237\u865a\u62df\u673a\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u6307\u5b9a\u4e00\u4e2a VLAN ID \u8303\u56f4\u53ef\u4f20\u9001\u6bcf\u4e2a\u7269\u7406\u7f51\u7edc\u7684\u6765\u5bbe\u901a\u4fe1\u3002
-message.guest.traffic.in.basic.zone=\u6765\u5bbe\u7f51\u7edc\u901a\u4fe1\u662f\u6307\u6700\u7ec8\u7528\u6237\u865a\u62df\u673a\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u5e94\u6307\u5b9a\u4e00\u4e2a CloudStack \u53ef\u4ee5\u5206\u914d\u7ed9\u6765\u5bbe VM \u7684 IP \u5730\u5740\u8303\u56f4\u3002\u8bf7\u786e\u4fdd\u6b64\u8303\u56f4\u4e0e\u9884\u7559\u7684\u7cfb\u7edf IP \u8303\u56f4\u4e0d\u91cd\u53e0\u3002
+message.guest.traffic.in.advanced.zone=\u6765\u5bbe\u7f51\u7edc\u6d41\u91cf\u662f\u6307\u6700\u7ec8\u7528\u6237\u865a\u62df\u673a\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u6307\u5b9a\u4e00\u4e2a VLAN ID \u8303\u56f4\u53ef\u4f20\u9001\u6bcf\u4e2a\u7269\u7406\u7f51\u7edc\u7684\u6765\u5bbe\u6d41\u91cf\u3002
+message.guest.traffic.in.basic.zone=\u6765\u5bbe\u7f51\u7edc\u6d41\u91cf\u662f\u6307\u6700\u7ec8\u7528\u6237\u865a\u62df\u673a\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u5e94\u6307\u5b9a\u4e00\u4e2a CloudStack \u53ef\u4ee5\u5206\u914d\u7ed9\u6765\u5bbe VM \u7684 IP \u5730\u5740\u8303\u56f4\u3002\u8bf7\u786e\u4fdd\u6b64\u8303\u56f4\u4e0e\u9884\u7559\u7684\u7cfb\u7edf IP \u8303\u56f4\u4e0d\u91cd\u53e0\u3002
 message.installWizard.click.retry=\u8bf7\u5355\u51fb\u6b64\u6309\u94ae\u91cd\u65b0\u5c1d\u8bd5\u542f\u52a8\u3002
-message.installWizard.copy.whatIsACluster=\u7fa4\u96c6\u63d0\u4f9b\u4e86\u4e00\u79cd\u7f16\u7ec4\u4e3b\u673a\u7684\u65b9\u6cd5\u3002\u7fa4\u96c6\u4e2d\u7684\u6240\u6709\u4e3b\u673a\u90fd\u5177\u6709\u76f8\u540c\u7684\u786c\u4ef6\uff0c\u8fd0\u884c\u76f8\u540c\u7684\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\uff0c\u4f4d\u4e8e\u540c\u4e00\u5b50\u7f51\u4e2d\uff0c\u5e76\u8bbf\u95ee\u76f8\u540c\u7684\u5171\u4eab\u5b58\u50a8\u3002\u53ef\u4ee5\u5b9e\u65f6\u5c06\u865a\u62df\u673a\u5b9e\u4f8b(VM)\u4ece\u4e00\u53f0\u4e3b\u673a\u8fc1\u79fb\u5230\u540c\u4e00\u7fa4\u96c6\u5185\u7684\u5176\u4ed6\u4e3b\u673a\uff0c\u800c\u65e0\u9700\u4e2d\u65ad\u5411\u7528\u6237\u63d0\u4f9b\u670d\u52a1\u3002\u7fa4\u96c6\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u7684\u7b2c\u4e09\u5927\u7ec4\u7ec7\u5355\u4f4d\u3002\u7fa4\u96c6\u5305\u542b\u5728\u63d0\u4f9b\u70b9\u4e2d\uff0c\u63d0\u4f9b\u70b9\u5305\u542b\u5728\u533a\u57df\u4e2d\u3002<br/><br/>CloudStack&\#8482; \u5141\u8bb8\u4e91\u90e8\u7f72\u4e2d\u5b58\u5728\u591a\u
 4e2a\u7fa4\u96c6\uff0c\u4f46\u5bf9\u4e8e\u57fa\u672c\u5b89\u88c5\uff0c\u6211\u4eec\u53ea\u9700\u8981\u4e00\u4e2a\u7fa4\u96c6\u3002
-message.installWizard.copy.whatIsAHost=\u4e3b\u673a\u662f\u6307\u4e00\u53f0\u8ba1\u7b97\u673a\u3002\u4e3b\u673a\u63d0\u4f9b\u8fd0\u884c\u6765\u5bbe\u865a\u62df\u673a\u7684\u8ba1\u7b97\u8d44\u6e90\u3002\u6bcf\u53f0\u4e3b\u673a\u4e0a\u90fd\u5b89\u88c5\u6709\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u8f6f\u4ef6\uff0c\u7528\u4e8e\u7ba1\u7406\u6765\u5bbe VM (\u88f8\u673a\u4e3b\u673a\u9664\u5916\uff0c\u5c06\u5728\u201c\u9ad8\u7ea7\u5b89\u88c5\u6307\u5357\u201d\u4e2d\u8ba8\u8bba\u8fd9\u4e00\u7279\u6b8a\u6848\u4f8b)\u3002\u4f8b\u5982\uff0c\u542f\u7528\u4e86 KVM \u7684 Linux \u670d\u52a1\u5668\u3001Citrix XenServer \u670d\u52a1\u5668\u548c ESXi \u670d\u52a1\u5668\u90fd\u53ef\u7528\u4f5c\u4e3b\u673a\u3002\u5728\u57fa\u672c\u5b89\u88c5\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u4e00\u53f0\u8fd0\u884c XenServer \u7684\u4e3b\u673a\u3002<br/><br/>\u4e3b\u673a\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u6700\u5c0f\u7684\u7ec4\u7ec7\u5355\u4f4d\u3002\u4e3b\u673a\u5305\u542b\u5728\u7fa4\u96c6\u4e2d
 \uff0c\u7fa4\u96c6\u5305\u542b\u5728\u63d0\u4f9b\u70b9\u4e2d\uff0c\u63d0\u4f9b\u70b9\u5305\u542b\u5728\u533a\u57df\u4e2d\u3002
-message.installWizard.copy.whatIsAPod=\u4e00\u4e2a\u63d0\u4f9b\u70b9\u901a\u5e38\u4ee3\u8868\u4e00\u4e2a\u673a\u67b6\u3002\u540c\u4e00\u63d0\u4f9b\u70b9\u4e2d\u7684\u4e3b\u673a\u4f4d\u4e8e\u540c\u4e00\u5b50\u7f51\u4e2d\u3002<br/><br/>\u63d0\u4f9b\u70b9\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u7684\u7b2c\u4e8c\u5927\u7ec4\u7ec7\u5355\u4f4d\u3002\u63d0\u4f9b\u70b9\u5305\u542b\u5728\u533a\u57df\u4e2d\u3002\u6bcf\u4e2a\u533a\u57df\u4e2d\u53ef\u4ee5\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u63d0\u4f9b\u70b9\uff1b\u5728\u57fa\u672c\u5b89\u88c5\u4e2d\uff0c\u60a8\u7684\u533a\u57df\u4e2d\u5c06\u4ec5\u5305\u542b\u4e00\u4e2a\u63d0\u4f9b\u70b9\u3002
-message.installWizard.copy.whatIsAZone=\u533a\u57df\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u6700\u5927\u7684\u7ec4\u7ec7\u5355\u4f4d\u3002\u867d\u7136\u5141\u8bb8\u4e00\u4e2a\u6570\u636e\u4e2d\u5fc3\u4e2d\u5b58\u5728\u591a\u4e2a\u533a\u57df\uff0c\u4f46\u662f\u4e00\u4e2a\u533a\u57df\u901a\u5e38\u4e0e\u4e00\u4e2a\u6570\u636e\u4e2d\u5fc3\u76f8\u5bf9\u5e94\u3002\u5c06\u57fa\u7840\u67b6\u6784\u7f16\u7ec4\u5230\u533a\u57df\u4e2d\u7684\u597d\u5904\u662f\u53ef\u4ee5\u63d0\u4f9b\u7269\u7406\u9694\u79bb\u548c\u5197\u4f59\u3002\u4f8b\u5982\uff0c\u6bcf\u4e2a\u533a\u57df\u90fd\u53ef\u4ee5\u62e5\u6709\u5404\u81ea\u7684\u7535\u6e90\u4f9b\u5e94\u548c\u7f51\u7edc\u4e0a\u884c\u65b9\u6848\uff0c\u5e76\u4e14\u5404\u533a\u57df\u53ef\u4ee5\u5728\u5730\u7406\u4f4d\u7f6e\u4e0a\u76f8\u9694\u5f88\u8fdc(\u867d\u7136\u5e76\u975e\u5fc5\u987b\u76f8\u9694\u5f88\u8fdc)\u3002
-message.installWizard.copy.whatIsCloudStack=CloudStack&\#8482 \u662f\u4e00\u4e2a\u8f6f\u4ef6\u5e73\u53f0\uff0c\u53ef\u5c06\u8ba1\u7b97\u8d44\u6e90\u96c6\u4e2d\u5728\u4e00\u8d77\u4ee5\u6784\u5efa\u516c\u5171\u3001\u79c1\u6709\u548c\u6df7\u5408\u57fa\u7840\u8bbe\u65bd\u5373\u670d\u52a1(IaaS)\u4e91\u3002CloudStack&\#8482 \u8d1f\u8d23\u7ba1\u7406\u7ec4\u6210\u4e91\u57fa\u7840\u67b6\u6784\u7684\u7f51\u7edc\u3001\u5b58\u50a8\u548c\u8ba1\u7b97\u8282\u70b9\u3002\u4f7f\u7528 CloudStack&\#8482 \u53ef\u4ee5\u90e8\u7f72\u3001\u7ba1\u7406\u548c\u914d\u7f6e\u4e91\u8ba1\u7b97\u73af\u5883\u3002<br/><br/>CloudStack&\#8482 \u901a\u8fc7\u6269\u5c55\u5546\u7528\u786c\u4ef6\u4e0a\u8fd0\u884c\u7684\u6bcf\u4e2a\u865a\u62df\u673a\u6620\u50cf\u7684\u8303\u56f4\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5b9e\u65f6\u53ef\u7528\u7684\u4e91\u57fa\u7840\u67b6\u6784\u8f6f\u4ef6\u5806\u6808\u7528\u4e8e\u4ee5\u670d\u52a1\u65b9\u5f0f\u4ea4\u4ed8\u865a\u62df\u6570\u636e\u4e2d\u5fc3\uff0c\u5373\u4ea4\u4ed8\u6784\u5efa\u3001
 \u90e8\u7f72\u548c\u7ba1\u7406\u591a\u5c42\u6b21\u548c\u591a\u79df\u6237\u4e91\u5e94\u7528\u7a0b\u5e8f\u5fc5\u9700\u7684\u6240\u6709\u7ec4\u4ef6\u3002\u5f00\u6e90\u7248\u672c\u548c Premium \u7248\u672c\u90fd\u5df2\u53ef\u7528\uff0c\u4e14\u63d0\u4f9b\u7684\u529f\u80fd\u51e0\u4e4e\u5b8c\u5168\u76f8\u540c\u3002
-message.installWizard.copy.whatIsPrimaryStorage=CloudStack&\#8482; \u4e91\u57fa\u7840\u67b6\u6784\u4f7f\u7528\u4ee5\u4e0b\u4e24\u79cd\u7c7b\u578b\u7684\u5b58\u50a8\: \u4e3b\u5b58\u50a8\u548c\u8f85\u52a9\u5b58\u50a8\u3002\u8fd9\u4e24\u79cd\u7c7b\u578b\u7684\u5b58\u50a8\u53ef\u4ee5\u662f iSCSI \u6216 NFS \u670d\u52a1\u5668\uff0c\u4e5f\u53ef\u4ee5\u662f\u672c\u5730\u78c1\u76d8\u3002<br/><br/><strong>\u4e3b\u5b58\u50a8</strong>\u4e0e\u7fa4\u96c6\u76f8\u5173\u8054\uff0c\u7528\u4e8e\u5b58\u50a8\u8be5\u7fa4\u96c6\u4e2d\u7684\u4e3b\u673a\u4e0a\u6b63\u5728\u8fd0\u884c\u7684\u6240\u6709 VM \u5bf9\u5e94\u7684\u6bcf\u4e2a\u6765\u5bbe VM \u7684\u78c1\u76d8\u5377\u3002\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u901a\u5e38\u4f4d\u4e8e\u9760\u8fd1\u4e3b\u673a\u7684\u4f4d\u7f6e\u3002
-message.installWizard.copy.whatIsSecondaryStorage=\u8f85\u52a9\u5b58\u50a8\u4e0e\u533a\u57df\u76f8\u5173\u8054\uff0c\u7528\u4e8e\u5b58\u50a8\u4ee5\u4e0b\u9879\u76ee\:<ul><li>\u6a21\u677f - \u53ef\u7528\u4e8e\u542f\u52a8 VM \u5e76\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u914d\u7f6e\u4fe1\u606f(\u4f8b\u5982\uff0c\u5df2\u5b89\u88c5\u7684\u5e94\u7528\u7a0b\u5e8f)\u7684\u64cd\u4f5c\u7cfb\u7edf\u6620\u50cf</li><li>ISO \u6620\u50cf - \u53ef\u91cd\u65b0\u542f\u52a8\u6216\u4e0d\u53ef\u91cd\u65b0\u542f\u52a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u6620\u50cf</li><li>\u78c1\u76d8\u5377\u5feb\u7167 - \u5df2\u4fdd\u5b58\u7684 VM \u6570\u636e\u526f\u672c\uff0c\u53ef\u7528\u4e8e\u6267\u884c\u6570\u636e\u6062\u590d\u6216\u521b\u5efa\u65b0\u6a21\u677f</ul>
+message.installWizard.copy.whatIsACluster=\u7fa4\u96c6\u63d0\u4f9b\u4e86\u4e00\u79cd\u7f16\u7ec4\u4e3b\u673a\u7684\u65b9\u6cd5\u3002\u7fa4\u96c6\u4e2d\u7684\u6240\u6709\u4e3b\u673a\u90fd\u5177\u6709\u76f8\u540c\u7684\u786c\u4ef6\uff0c\u8fd0\u884c\u76f8\u540c\u7684\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\uff0c\u4f4d\u4e8e\u540c\u4e00\u5b50\u7f51\u4e2d\uff0c\u5e76\u8bbf\u95ee\u76f8\u540c\u7684\u5171\u4eab\u5b58\u50a8\u3002\u53ef\u4ee5\u5b9e\u65f6\u5c06\u865a\u62df\u673a\u5b9e\u4f8b(VM)\u4ece\u4e00\u53f0\u4e3b\u673a\u8fc1\u79fb\u5230\u540c\u4e00\u7fa4\u96c6\u5185\u7684\u5176\u4ed6\u4e3b\u673a\uff0c\u800c\u65e0\u9700\u4e2d\u65ad\u5411\u7528\u6237\u63d0\u4f9b\u670d\u52a1\u3002\u7fa4\u96c6\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u7684\u7b2c\u4e09\u5927\u7ec4\u7ec7\u5355\u4f4d\u3002\u7fa4\u96c6\u5305\u542b\u5728\u63d0\u4f9b\u70b9\u4e2d\uff0c\u63d0\u4f9b\u70b9\u5305\u542b\u5728\u8d44\u6e90\u57df\u4e2d\u3002<br/><br/>CloudStack&\#8482; \u5141\u8bb8\u4e91\u90e8\u7f72\u4e2d\u5b58\u5728\u
 591a\u4e2a\u7fa4\u96c6\uff0c\u4f46\u5bf9\u4e8e\u57fa\u672c\u5b89\u88c5\uff0c\u6211\u4eec\u53ea\u9700\u8981\u4e00\u4e2a\u7fa4\u96c6\u3002
+message.installWizard.copy.whatIsAHost=\u4e3b\u673a\u662f\u6307\u4e00\u53f0\u8ba1\u7b97\u673a\u3002\u4e3b\u673a\u63d0\u4f9b\u8fd0\u884c\u6765\u5bbe\u865a\u62df\u673a\u7684\u8ba1\u7b97\u8d44\u6e90\u3002\u6bcf\u53f0\u4e3b\u673a\u4e0a\u90fd\u5b89\u88c5\u6709\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u8f6f\u4ef6\uff0c\u7528\u4e8e\u7ba1\u7406\u6765\u5bbe VM (\u88f8\u673a\u4e3b\u673a\u9664\u5916\uff0c\u5c06\u5728\u201c\u9ad8\u7ea7\u5b89\u88c5\u6307\u5357\u201d\u4e2d\u8ba8\u8bba\u8fd9\u4e00\u7279\u6b8a\u6848\u4f8b)\u3002\u4f8b\u5982\uff0c\u542f\u7528\u4e86 KVM \u7684 Linux \u670d\u52a1\u5668\u3001Citrix XenServer \u670d\u52a1\u5668\u548c ESXi \u670d\u52a1\u5668\u90fd\u53ef\u7528\u4f5c\u4e3b\u673a\u3002\u5728\u57fa\u672c\u5b89\u88c5\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u4e00\u53f0\u8fd0\u884c XenServer \u7684\u4e3b\u673a\u3002<br/><br/>\u4e3b\u673a\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u6700\u5c0f\u7684\u7ec4\u7ec7\u5355\u4f4d\u3002\u4e3b\u673a\u5305\u542b\u5728\u7fa4\u96c6\u4e2d
 \uff0c\u7fa4\u96c6\u5305\u542b\u5728\u63d0\u4f9b\u70b9\u4e2d\uff0c\u63d0\u4f9b\u70b9\u5305\u542b\u5728\u8d44\u6e90\u57df\u4e2d\u3002
+message.installWizard.copy.whatIsAPod=\u4e00\u4e2a\u63d0\u4f9b\u70b9\u901a\u5e38\u4ee3\u8868\u4e00\u4e2a\u673a\u67b6\u3002\u540c\u4e00\u63d0\u4f9b\u70b9\u4e2d\u7684\u4e3b\u673a\u4f4d\u4e8e\u540c\u4e00\u5b50\u7f51\u4e2d\u3002<br/><br/>\u63d0\u4f9b\u70b9\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u7684\u7b2c\u4e8c\u5927\u7ec4\u7ec7\u5355\u4f4d\u3002\u63d0\u4f9b\u70b9\u5305\u542b\u5728\u8d44\u6e90\u57df\u4e2d\u3002\u6bcf\u4e2a\u8d44\u6e90\u57df\u4e2d\u53ef\u4ee5\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u63d0\u4f9b\u70b9\uff1b\u5728\u57fa\u672c\u5b89\u88c5\u4e2d\uff0c\u60a8\u7684\u8d44\u6e90\u57df\u4e2d\u5c06\u4ec5\u5305\u542b\u4e00\u4e2a\u63d0\u4f9b\u70b9\u3002
+message.installWizard.copy.whatIsAZone=\u8d44\u6e90\u57df\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u6700\u5927\u7684\u7ec4\u7ec7\u5355\u4f4d\u3002\u867d\u7136\u5141\u8bb8\u4e00\u4e2a\u6570\u636e\u4e2d\u5fc3\u4e2d\u5b58\u5728\u591a\u4e2a\u8d44\u6e90\u57df\uff0c\u4f46\u662f\u4e00\u4e2a\u8d44\u6e90\u57df\u901a\u5e38\u4e0e\u4e00\u4e2a\u6570\u636e\u4e2d\u5fc3\u76f8\u5bf9\u5e94\u3002\u5c06\u57fa\u7840\u67b6\u6784\u7f16\u7ec4\u5230\u8d44\u6e90\u57df\u4e2d\u7684\u597d\u5904\u662f\u53ef\u4ee5\u63d0\u4f9b\u7269\u7406\u9694\u79bb\u548c\u5197\u4f59\u3002\u4f8b\u5982\uff0c\u6bcf\u4e2a\u8d44\u6e90\u57df\u90fd\u53ef\u4ee5\u62e5\u6709\u5404\u81ea\u7684\u7535\u6e90\u4f9b\u5e94\u548c\u7f51\u7edc\u4e0a\u884c\u65b9\u6848\uff0c\u5e76\u4e14\u5404\u8d44\u6e90\u57df\u53ef\u4ee5\u5728\u5730\u7406\u4f4d\u7f6e\u4e0a\u76f8\u9694\u5f88\u8fdc(\u867d\u7136\u5e76\u975e\u5fc5\u987b\u76f8\u9694\u5f88\u8fdc)\u3002
+message.installWizard.copy.whatIsCloudStack=CloudStack&\#8482 \u662f\u4e00\u4e2a\u8f6f\u4ef6\u5e73\u53f0\uff0c\u53ef\u5c06\u8ba1\u7b97\u8d44\u6e90\u96c6\u4e2d\u5728\u4e00\u8d77\u4ee5\u6784\u5efa\u516c\u6709\u3001\u79c1\u6709\u548c\u6df7\u5408\u57fa\u7840\u8bbe\u65bd\u5373\u670d\u52a1(IaaS)\u4e91\u3002CloudStack&\#8482 \u8d1f\u8d23\u7ba1\u7406\u7ec4\u6210\u4e91\u57fa\u7840\u67b6\u6784\u7684\u7f51\u7edc\u3001\u5b58\u50a8\u548c\u8ba1\u7b97\u8282\u70b9\u3002\u4f7f\u7528 CloudStack&\#8482 \u53ef\u4ee5\u90e8\u7f72\u3001\u7ba1\u7406\u548c\u914d\u7f6e\u4e91\u8ba1\u7b97\u73af\u5883\u3002<br/><br/>CloudStack&\#8482 \u901a\u8fc7\u6269\u5c55\u5546\u7528\u786c\u4ef6\u4e0a\u8fd0\u884c\u7684\u6bcf\u4e2a\u865a\u62df\u673a\u6620\u50cf\u7684\u8303\u56f4\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5b9e\u65f6\u53ef\u7528\u7684\u4e91\u57fa\u7840\u67b6\u6784\u8f6f\u4ef6\u5806\u6808\u7528\u4e8e\u4ee5\u670d\u52a1\u65b9\u5f0f\u4ea4\u4ed8\u865a\u62df\u6570\u636e\u4e2d\u5fc3\uff0c\u5373\u4ea4\u4ed8\u6784\u5efa\u3001
 \u90e8\u7f72\u548c\u7ba1\u7406\u591a\u5c42\u6b21\u548c\u591a\u79df\u6237\u4e91\u5e94\u7528\u7a0b\u5e8f\u5fc5\u9700\u7684\u6240\u6709\u7ec4\u4ef6\u3002\u5f00\u6e90\u7248\u672c\u548c Premium \u7248\u672c\u90fd\u5df2\u53ef\u7528\uff0c\u4e14\u63d0\u4f9b\u7684\u529f\u80fd\u51e0\u4e4e\u5b8c\u5168\u76f8\u540c\u3002
+message.installWizard.copy.whatIsPrimaryStorage=CloudStack&\#8482; \u4e91\u57fa\u7840\u67b6\u6784\u4f7f\u7528\u4ee5\u4e0b\u4e24\u79cd\u7c7b\u578b\u7684\u5b58\u50a8\: \u4e3b\u5b58\u50a8\u548c\u4e8c\u7ea7\u5b58\u50a8\u3002\u8fd9\u4e24\u79cd\u7c7b\u578b\u7684\u5b58\u50a8\u53ef\u4ee5\u662f iSCSI \u6216 NFS \u670d\u52a1\u5668\uff0c\u4e5f\u53ef\u4ee5\u662f\u672c\u5730\u78c1\u76d8\u3002<br/><br/><strong>\u4e3b\u5b58\u50a8</strong>\u4e0e\u7fa4\u96c6\u76f8\u5173\u8054\uff0c\u7528\u4e8e\u5b58\u50a8\u8be5\u7fa4\u96c6\u4e2d\u7684\u4e3b\u673a\u4e0a\u6b63\u5728\u8fd0\u884c\u7684\u6240\u6709 VM \u5bf9\u5e94\u7684\u6bcf\u4e2a\u6765\u5bbe VM \u7684\u78c1\u76d8\u5377\u3002\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u901a\u5e38\u4f4d\u4e8e\u9760\u8fd1\u4e3b\u673a\u7684\u4f4d\u7f6e\u3002
+message.installWizard.copy.whatIsSecondaryStorage=\u4e8c\u7ea7\u5b58\u50a8\u4e0e\u8d44\u6e90\u57df\u76f8\u5173\u8054\uff0c\u7528\u4e8e\u5b58\u50a8\u4ee5\u4e0b\u9879\u76ee\:<ul><li>\u6a21\u677f - \u53ef\u7528\u4e8e\u542f\u52a8 VM \u5e76\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u914d\u7f6e\u4fe1\u606f(\u4f8b\u5982\uff0c\u5df2\u5b89\u88c5\u7684\u5e94\u7528\u7a0b\u5e8f)\u7684\u64cd\u4f5c\u7cfb\u7edf\u6620\u50cf</li><li>ISO \u6620\u50cf - \u53ef\u91cd\u65b0\u542f\u52a8\u6216\u4e0d\u53ef\u91cd\u65b0\u542f\u52a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u6620\u50cf</li><li>\u78c1\u76d8\u5377\u5feb\u7167 - \u5df2\u4fdd\u5b58\u7684 VM \u6570\u636e\u526f\u672c\uff0c\u53ef\u7528\u4e8e\u6267\u884c\u6570\u636e\u6062\u590d\u6216\u521b\u5efa\u65b0\u6a21\u677f</ul>
 message.installWizard.now.building=\u73b0\u5728\u6b63\u5728\u6784\u5efa\u60a8\u7684\u4e91...
 message.installWizard.tooltip.addCluster.name=\u7fa4\u96c6\u7684\u540d\u79f0\u3002\u6b64\u540d\u79f0\u53ef\u4ee5\u662f\u60a8\u9009\u62e9\u7684\u6587\u672c\uff0c\u4e14\u672a\u7531 CloudStack \u4f7f\u7528\u3002
 message.installWizard.tooltip.addHost.hostname=\u4e3b\u673a\u7684 DNS \u540d\u79f0\u6216 IP \u5730\u5740\u3002
 message.installWizard.tooltip.addHost.password=\u6b64\u4e3a\u4e0a\u8ff0\u7528\u6237\u7684\u5bc6\u7801(\u6765\u81ea XenServer \u5b89\u88c5)\u3002
 message.installWizard.tooltip.addHost.username=\u901a\u5e38\u4e3a root\u3002
 message.installWizard.tooltip.addPod.name=\u63d0\u4f9b\u70b9\u7684\u540d\u79f0
-message.installWizard.tooltip.addPod.reservedSystemEndIp=\u6b64\u4e3a CloudStack \u7528\u4e8e\u7ba1\u7406\u8f85\u52a9\u5b58\u50a8 VM \u548c\u63a7\u5236\u53f0\u4ee3\u7406 VM \u7684\u4e13\u7528\u7f51\u7edc\u4e2d\u7684 IP \u8303\u56f4\u3002\u8fd9\u4e9b IP \u5730\u5740\u6765\u81ea\u4e0e\u8ba1\u7b97\u670d\u52a1\u5668\u76f8\u540c\u7684\u5b50\u7f51\u3002
+message.installWizard.tooltip.addPod.reservedSystemEndIp=\u6b64\u4e3a CloudStack \u7528\u4e8e\u7ba1\u7406\u4e8c\u7ea7\u5b58\u50a8 VM \u548c\u63a7\u5236\u53f0\u4ee3\u7406 VM \u7684\u4e13\u7528\u7f51\u7edc\u4e2d\u7684 IP \u8303\u56f4\u3002\u8fd9\u4e9b IP \u5730\u5740\u6765\u81ea\u4e0e\u8ba1\u7b97\u670d\u52a1\u5668\u76f8\u540c\u7684\u5b50\u7f51\u3002
 message.installWizard.tooltip.addPod.reservedSystemGateway=\u8be5\u63d0\u4f9b\u70b9\u4e2d\u7684\u4e3b\u673a\u7f51\u5173\u3002
 message.installWizard.tooltip.addPod.reservedSystemNetmask=\u6765\u5bbe\u5c06\u8981\u4f7f\u7528\u7684\u5b50\u7f51\u4e0a\u6b63\u5728\u4f7f\u7528\u7684\u7f51\u7edc\u63a9\u7801\u3002
-message.installWizard.tooltip.addPod.reservedSystemStartIp=\u6b64\u4e3a CloudStack \u7528\u4e8e\u7ba1\u7406\u8f85\u52a9\u5b58\u50a8 VM \u548c\u63a7\u5236\u53f0\u4ee3\u7406 VM \u7684\u4e13\u7528\u7f51\u7edc\u4e2d\u7684 IP \u8303\u56f4\u3002\u8fd9\u4e9b IP \u5730\u5740\u6765\u81ea\u4e0e\u8ba1\u7b97\u670d\u52a1\u5668\u76f8\u540c\u7684\u5b50\u7f51\u3002
+message.installWizard.tooltip.addPod.reservedSystemStartIp=\u6b64\u4e3a CloudStack \u7528\u4e8e\u7ba1\u7406\u4e8c\u7ea7\u5b58\u50a8 VM \u548c\u63a7\u5236\u53f0\u4ee3\u7406 VM \u7684\u4e13\u7528\u7f51\u7edc\u4e2d\u7684 IP \u8303\u56f4\u3002\u8fd9\u4e9b IP \u5730\u5740\u6765\u81ea\u4e0e\u8ba1\u7b97\u670d\u52a1\u5668\u76f8\u540c\u7684\u5b50\u7f51\u3002
 message.installWizard.tooltip.addPrimaryStorage.name=\u5b58\u50a8\u8bbe\u5907\u7684\u540d\u79f0\u3002
-message.installWizard.tooltip.addPrimaryStorage.path=(\u9002\u7528\u4e8e NFS)\u5728 NFS \u4e2d\uff0c\u6b64\u8def\u5f84\u4e3a\u670d\u52a1\u5668\u7684\u5bfc\u51fa\u8def\u5f84\u3002\u8def\u5f84(\u9488\u5bf9 SharedMountPoint)\u3002\u5bf9\u4e8e KVM\uff0c\u6b64\u8def\u5f84\u4e3a\u88c5\u8f7d\u4e86\u8f85\u52a9\u5b58\u50a8\u7684\u6bcf\u4e2a\u4e3b\u673a\u4e0a\u7684\u8def\u5f84\u3002\u4f8b\u5982\uff0c/mnt/primary\u3002
+message.installWizard.tooltip.addPrimaryStorage.path=(\u9002\u7528\u4e8e NFS)\u5728 NFS \u4e2d\uff0c\u6b64\u8def\u5f84\u4e3a\u670d\u52a1\u5668\u7684\u5bfc\u51fa\u8def\u5f84\u3002\u8def\u5f84(\u9488\u5bf9 SharedMountPoint)\u3002\u5bf9\u4e8e KVM\uff0c\u6b64\u8def\u5f84\u4e3a\u88c5\u8f7d\u4e86\u4e8c\u7ea7\u5b58\u50a8\u7684\u6bcf\u4e2a\u4e3b\u673a\u4e0a\u7684\u8def\u5f84\u3002\u4f8b\u5982\uff0c/mnt/primary\u3002
 message.installWizard.tooltip.addPrimaryStorage.server=(\u9002\u7528\u4e8e NFS\u3001iSCSI \u6216 PreSetup)\u5b58\u50a8\u8bbe\u5907\u7684 IP \u5730\u5740\u6216 DNS \u540d\u79f0\u3002
-message.installWizard.tooltip.addSecondaryStorage.nfsServer=\u6258\u7ba1\u8f85\u52a9\u5b58\u50a8\u7684 NFS \u670d\u52a1\u5668\u7684 IP \u5730\u5740
+message.installWizard.tooltip.addSecondaryStorage.nfsServer=\u6258\u7ba1\u4e8c\u7ea7\u5b58\u50a8\u7684 NFS \u670d\u52a1\u5668\u7684 IP \u5730\u5740
 message.installWizard.tooltip.addSecondaryStorage.path=\u5bfc\u51fa\u8def\u5f84(\u4f4d\u4e8e\u4e0a\u8ff0\u6307\u5b9a\u670d\u52a1\u5668\u4e0a)
-message.installWizard.tooltip.addZone.dns1=\u8fd9\u4e9b\u670d\u52a1\u5668\u662f\u4f9b\u6b64\u533a\u57df\u4e2d\u7684\u6765\u5bbe VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\uff0c\u5c06\u901a\u8fc7\u60a8\u7a0d\u540e\u8981\u6dfb\u52a0\u7684\u516c\u7528\u7f51\u7edc\u8fdb\u884c\u8bbf\u95ee\u3002\u6b64\u533a\u57df\u7684\u516c\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u5728\u6b64\u5904\u6307\u5b9a\u7684 DNS \u670d\u52a1\u5668\u3002
-message.installWizard.tooltip.addZone.dns2=\u8fd9\u4e9b\u670d\u52a1\u5668\u662f\u4f9b\u6b64\u533a\u57df\u4e2d\u7684\u6765\u5bbe VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\uff0c\u5c06\u901a\u8fc7\u60a8\u7a0d\u540e\u8981\u6dfb\u52a0\u7684\u516c\u7528\u7f51\u7edc\u8fdb\u884c\u8bbf\u95ee\u3002\u6b64\u533a\u57df\u7684\u516c\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u5728\u6b64\u5904\u6307\u5b9a\u7684 DNS \u670d\u52a1\u5668\u3002
-message.installWizard.tooltip.addZone.internaldns1=\u8fd9\u4e9b\u670d\u52a1\u5668\u662f\u4f9b\u6b64\u533a\u57df\u4e2d\u7684\u7cfb\u7edf VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\uff0c\u5c06\u901a\u8fc7\u7cfb\u7edf VM \u7684\u4e13\u7528\u7f51\u7edc\u63a5\u53e3\u8fdb\u884c\u8bbf\u95ee\u3002\u60a8\u4e3a\u63d0\u4f9b\u70b9\u63d0\u4f9b\u7684\u4e13\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u5728\u6b64\u5904\u6307\u5b9a\u7684 DNS \u670d\u52a1\u5668\u3002
-message.installWizard.tooltip.addZone.internaldns2=\u8fd9\u4e9b\u670d\u52a1\u5668\u662f\u4f9b\u6b64\u533a\u57df\u4e2d\u7684\u7cfb\u7edf VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\uff0c\u5c06\u901a\u8fc7\u7cfb\u7edf VM \u7684\u4e13\u7528\u7f51\u7edc\u63a5\u53e3\u8fdb\u884c\u8bbf\u95ee\u3002\u60a8\u4e3a\u63d0\u4f9b\u70b9\u63d0\u4f9b\u7684\u4e13\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u5728\u6b64\u5904\u6307\u5b9a\u7684 DNS \u670d\u52a1\u5668\u3002
-message.installWizard.tooltip.addZone.name=\u533a\u57df\u540d\u79f0
+message.installWiz

<TRUNCATED>

[20/50] [abbrv] Externalized the hardcodedstrings from UI JAVASCRIPT files.

Posted by ml...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/tools/ngui/static/js/app/accounts/accounts.js
----------------------------------------------------------------------
diff --git a/tools/ngui/static/js/app/accounts/accounts.js b/tools/ngui/static/js/app/accounts/accounts.js
index eae5070..61d825b 100644
--- a/tools/ngui/static/js/app/accounts/accounts.js
+++ b/tools/ngui/static/js/app/accounts/accounts.js
@@ -43,32 +43,32 @@ angular.module('accounts').controller('AccountsListCtrl', ['$scope', 'accounts',
             {
                 model: 'username',
                 type: 'input-text',
-                label: 'username'
+                label: 'label.username.lower'
             },
             {
                 model: 'password',
                 type: 'input-password',
-                label: 'password'
+                label: 'label.password.lower'
             },
             {
                 model: 'email',
                 type: 'input-text',
-                label: 'email'
+                label: 'label.email.lower'
             },
             {
                 model: 'firstname',
                 type: 'input-text',
-                label: 'firstname'
+                label: 'label.firstname.lower'
             },
             {
                 model: 'lastname',
                 type: 'input-text',
-                label: 'lastname'
+                label: 'label.lastname.lower'
             },
             {
                 model: 'domainid',
                 type: 'select',
-                label: 'domain',
+                label: 'label.domain.lower',
                 options: Domains.fetch,
                 getName: function(model){
                     return model.name;
@@ -80,12 +80,12 @@ angular.module('accounts').controller('AccountsListCtrl', ['$scope', 'accounts',
             {
                 model: 'account',
                 type: 'input-text',
-                label: 'account'
+                label: 'label.account.lower'
             },
             {
                 model: 'accounttype',
                 type: 'select',
-                label: 'type',
+                label: 'label.type.lower',
                 options: function(){
                     return ['User', 'Admin']
                 },

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/tools/ngui/static/js/app/storage/storage.js
----------------------------------------------------------------------
diff --git a/tools/ngui/static/js/app/storage/storage.js b/tools/ngui/static/js/app/storage/storage.js
index e562a95..af36167 100644
--- a/tools/ngui/static/js/app/storage/storage.js
+++ b/tools/ngui/static/js/app/storage/storage.js
@@ -47,7 +47,7 @@ angular.module("storage").controller("VolumesListCtrl", ["$scope", "$location",
     $scope.toDisplay = ['name', 'type', 'hypervisor', 'vmdisplayname'];
 
     $scope.addVolumeForm = {
-        title: 'Add Volume',
+        title: 'label.add.volume',
         onSubmit: Volumes.getAll,
         fields: [
             {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/ui/dictionary.jsp
----------------------------------------------------------------------
diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp
index 11dbeb5..074db7f 100644
--- a/ui/dictionary.jsp
+++ b/ui/dictionary.jsp
@@ -43,7 +43,6 @@ dictionary = {
 'label.hypervisors': '<fmt:message key="label.hypervisors" />',
 'label.home': '<fmt:message key="label.home" />',
 'label.sockets': '<fmt:message key="label.sockets" />',
-'label.add.ucs.manager': '<fmt:message key="label.add.ucs.manager" />',
 'label.root.disk.size': '<fmt:message key="label.root.disk.size" />',
 'label.s3.nfs.path': '<fmt:message key="label.s3.nfs.path" />',
 'label.s3.nfs.server': '<fmt:message key="label.s3.nfs.server" />',
@@ -704,9 +703,6 @@ dictionary = {
 'label.keyboard.type': '<fmt:message key="label.keyboard.type" />',
 'label.key': '<fmt:message key="label.key" />',
 'label.kvm.traffic.label': '<fmt:message key="label.kvm.traffic.label" />',
-'label.ovm.traffic.label': '<fmt:message key="label.ovm.traffic.label" />',
-'label.lxc.traffic.label': '<fmt:message key="label.lxc.traffic.label" />',
-'label.hyperv.traffic.label': '<fmt:message key="label.hyperv.traffic.label" />',
 'label.lang.chinese': '<fmt:message key="label.lang.chinese" />',
 'label.lang.english': '<fmt:message key="label.lang.english" />',
 'label.lang.japanese': '<fmt:message key="label.lang.japanese" />',
@@ -933,7 +929,6 @@ dictionary = {
 'label.projects': '<fmt:message key="label.projects" />',
 'label.project.view': '<fmt:message key="label.project.view" />',
 'label.protocol': '<fmt:message key="label.protocol" />',
-'label.provider': '<fmt:message key="label.provider" />',
 'label.providers': '<fmt:message key="label.providers" />',
 'label.provider': '<fmt:message key="label.provider" />',
 'label.public': '<fmt:message key="label.public" />',
@@ -1023,7 +1018,6 @@ dictionary = {
 'label.security.group': '<fmt:message key="label.security.group" />',
 'label.security.group.name': '<fmt:message key="label.security.group.name" />',
 'label.security.groups.enabled': '<fmt:message key="label.security.groups.enabled" />',
-'label.security.groups': '<fmt:message key="label.security.groups" />',
 'label.select.a.template': '<fmt:message key="label.select.a.template" />',
 'label.select.a.zone': '<fmt:message key="label.select.a.zone" />',
 'label.select': '<fmt:message key="label.select" />',
@@ -1184,7 +1178,6 @@ dictionary = {
 'label.virtual.network': '<fmt:message key="label.virtual.network" />',
 'label.virtual.router': '<fmt:message key="label.virtual.router" />',
 'label.virtual.routers': '<fmt:message key="label.virtual.routers" />',
-'label.vlan': '<fmt:message key="label.vlan" />',
 'label.vlan.id': '<fmt:message key="label.vlan.id" />',
 'label.vlan.range': '<fmt:message key="label.vlan.range" />',
 'label.vxlan': '<fmt:message key="label.vxlan" />',
@@ -1247,7 +1240,6 @@ dictionary = {
 'label.ldap.group.name': '<fmt:message key="label.ldap.group.name" />',
 'label.password.reset.confirm': '<fmt:message key="label.password.reset.confirm" />',
 'label.openDaylight': '<fmt:message key="OpenDaylight" />',
-'label.change.affinity': '<fmt:message key="label.change.affinity" />',
 'label.assign.instance.another': '<fmt:message key="label.assign.instance.another" />',
 'label.network.addVM': '<fmt:message key="label.network.addVM" />',
 'label.set.default.NIC': '<fmt:message key="label.set.default.NIC" />',
@@ -1260,9 +1252,7 @@ dictionary = {
 'label.ipv6.gateway': '<fmt:message key="label.ipv6.gateway" />',
 'label.ipv6.CIDR': '<fmt:message key="label.ipv6.CIDR" />',
 'label.VPC.limits': '<fmt:message key="label.VPC.limits" />',
-'label.gslb.domain.name': '<fmt:message key="label.gslb.domain.name" />',
 'label.edit.region': '<fmt:message key="label.edit.region" />',
-'label.gslb.domain.name': '<fmt:message key="label.gslb.domain.name" />',
 'label.add.gslb': '<fmt:message key="label.add.gslb" />',
 'label.gslb.servicetype': '<fmt:message key="label.gslb.servicetype" />',
 'label.gslb.details': '<fmt:message key="label.gslb.details" />',
@@ -1653,6 +1643,214 @@ dictionary = {
 'state.Stopping': '<fmt:message key="state.Stopping" />',
 'state.Suspended': '<fmt:message key="state.Suspended" />',
 'ui.listView.filters.all': '<fmt:message key="ui.listView.filters.all" />',
-'ui.listView.filters.mine': '<fmt:message key="ui.listView.filters.mine" />'
+'ui.listView.filters.mine': '<fmt:message key="ui.listView.filters.mine" />',
+'label.security.groups': '<fmt:message key="label.security.groups" />',
+'label.opendaylight.controller': '<fmt:message key="label.opendaylight.controller" />',
+'label.resource.name': '<fmt:message key="label.resource.name" />',
+'label.reource.id': '<fmt:message key="label.reource.id" />',
+'label.vnmc.devices': '<fmt:message key="label.vnmc.devices" />',
+'label.add.vnmc.provider': '<fmt:message key="label.add.vnmc.provider" />',
+'label.enable.vnmc.provider': '<fmt:message key="label.enable.vnmc.provider" />',
+'label.add.vnmc.device': '<fmt:message key="label.add.vnmc.device" />',
+'label.ciscovnmc.resource.details': '<fmt:message key="label.ciscovnmc.resource.details" />',
+'label.delete.ciscovnmc.resource': '<fmt:message key="label.delete.ciscovnmc.resource" />',
+'label.enable.vnmc.device': '<fmt:message key="label.enable.vnmc.device" />',
+'label.disbale.vnmc.device': '<fmt:message key="label.disbale.vnmc.device" />',
+'label.disable.vnmc.provider': '<fmt:message key="label.disable.vnmc.provider" />',
+'label.services': '<fmt:message key="label.services" />',
+'label.secondary.staging.store': '<fmt:message key="label.secondary.staging.store" />',
+'label.release.account': '<fmt:message key="label.release.account" />',
+'label.release.account.lowercase': '<fmt:message key="label.release.account.lowercase" />',
+'label.vlan.vni.ranges': '<fmt:message key="label.vlan.vni.ranges" />',
+'label.dedicated.vlan.vni.ranges': '<fmt:message key="label.dedicated.vlan.vni.ranges" />',
+'label.dedicate.vlan.vni.range': '<fmt:message key="label.dedicate.vlan.vni.range" />',
+'label.vlan.vni.range': '<fmt:message key="label.vlan.vni.range" />',
+'label.vlan.range.details': '<fmt:message key="label.vlan.range.details" />',
+'label.broadcat.uri': '<fmt:message key="label.broadcat.uri" />',
+'label.ipv4.cidr': '<fmt:message key="label.ipv4.cidr" />',
+'label.guest.network.details': '<fmt:message key="label.guest.network.details" />',
+'label.ipv4.gateway': '<fmt:message key="label.ipv4.gateway" />',
+'label.vlan.ranges': '<fmt:message key="label.vlan.ranges" />',
+'label.virtual.appliance.details': '<fmt:message key="label.virtual.appliance.details" />',
+'label.start.lb.vm': '<fmt:message key="label.start.lb.vm" />',
+'label.stop.lb.vm': '<fmt:message key="label.stop.lb.vm" />',
+'label.migrate.lb.vm': '<fmt:message key="label.migrate.lb.vm" />',
+'label.vpc.virtual.router': '<fmt:message key="label.vpc.virtual.router" />',
+'label.ovs': '<fmt:message key="label.ovs" />',
+'label.gslb.service': '<fmt:message key="label.gslb.service" />',
+'label.gslb.service.public.ip': '<fmt:message key="label.gslb.service.public.ip" />',
+'label.gslb.service.private.ip': '<fmt:message key="label.gslb.service.private.ip" />',
+'label.baremetal.dhcp.provider': '<fmt:message key="label.baremetal.dhcp.provider" />',
+'label.add.baremetal.dhcp.device': '<fmt:message key="label.add.baremetal.dhcp.device" />',
+'label.baremetal.pxe.provider': '<fmt:message key="label.baremetal.pxe.provider" />',
+'label.baremetal.pxe.device': '<fmt:message key="label.baremetal.pxe.device" />',
+'label.tftp.root.directory': '<fmt:message key="label.tftp.root.directory" />',
+'label.add.vmware.datacenter': '<fmt:message key="label.add.vmware.datacenter" />',
+'label.remove.vmware.datacenter': '<fmt:message key="label.remove.vmware.datacenter" />',
+'label.dc.name': '<fmt:message key="label.dc.name" />',
+'label.vcenter': '<fmt:message key="label.vcenter" />',
+'label.dedicate.zone': '<fmt:message key="label.dedicate.zone" />',
+'label.zone.dedicated': '<fmt:message key="label.zone.dedicated" />',
+'label.release.dedicated.zone': '<fmt:message key="label.release.dedicated.zone" />',
+'label.ipv6.dns1': '<fmt:message key="label.ipv6.dns1" />',
+'label.ipv6.dns2': '<fmt:message key="label.ipv6.dns2" />',
+'label.vmware.datacenter.name': '<fmt:message key="label.vmware.datacenter.name" />',
+'label.vmware.datacenter.vcenter': '<fmt:message key="label.vmware.datacenter.vcenter" />',
+'label.vmware.datacenter.id': '<fmt:message key="label.vmware.datacenter.id" />',
+'label.system.vm.details': '<fmt:message key="label.system.vm.details" />',
+'label.system.vm.scaled.up': '<fmt:message key="label.system.vm.scaled.up" />',
+'label.console.proxy.vm': '<fmt:message key="label.console.proxy.vm" />',
+'label.settings': '<fmt:message key="label.settings" />',
+'label.requires.upgrade': '<fmt:message key="label.requires.upgrade" />',
+'label.upgrade.router.newer.template': '<fmt:message key="label.upgrade.router.newer.template" />',
+'label.router.vm.scaled.up': '<fmt:message key="label.router.vm.scaled.up" />',
+'label.total.virtual.routers': '<fmt:message key="label.total.virtual.routers" />',
+'label.upgrade.required': '<fmt:message key="label.upgrade.required" />',
+'label.virtual.routers.group.zone': '<fmt:message key="label.virtual.routers.group.zone" />',
+'label.total.virtual.routers.upgrade': '<fmt:message key="label.total.virtual.routers.upgrade" />',
+'label.virtual.routers.group.pod': '<fmt:message key="label.virtual.routers.group.pod" />',
+'label.virtual.routers.group.cluster': '<fmt:message key="label.virtual.routers.group.cluster" />',
+'label.zone.lower': '<fmt:message key="label.zone.lower" />',
+'label.virtual.routers.group.account': '<fmt:message key="label.virtual.routers.group.account" />',
+'label.netscaler.details': '<fmt:message key="label.netscaler.details" />',
+'label.baremetal.dhcp.devices': '<fmt:message key="label.baremetal.dhcp.devices" />',
+'label.baremetal.pxe.devices': '<fmt:message key="label.baremetal.pxe.devices" />',
+'label.addes.new.f5': '<fmt:message key="label.addes.new.f5" />',
+'label.f5.details': '<fmt:message key="label.f5.details" />',
+'label.srx.details': '<fmt:message key="label.srx.details" />',
+'label.palo.alto.details': '<fmt:message key="label.palo.alto.details" />',
+'label.added.nicira.nvp.controller': '<fmt:message key="label.added.nicira.nvp.controller" />',
+'label.nicira.nvp.details': '<fmt:message key="label.nicira.nvp.details" />',
+'label.added.new.bigswitch.vns.controller': '<fmt:message key="label.added.new.bigswitch.vns.controller" />',
+'label.bigswitch.vns.details': '<fmt:message key="label.bigswitch.vns.details" />',
+'label.dedicate': '<fmt:message key="label.dedicate" />',
+'label.dedicate.pod': '<fmt:message key="label.dedicate.pod" />',
+'label.pod.dedicated': '<fmt:message key="label.pod.dedicated" />',
+'label.release.dedicated.pod': '<fmt:message key="label.release.dedicated.pod" />',
+'label.override.public.traffic': '<fmt:message key="label.override.public.traffic" />',
+'label.public.traffic.vswitch.type': '<fmt:message key="label.public.traffic.vswitch.type" />',
+'label.public.traffic.vswitch.name': '<fmt:message key="label.public.traffic.vswitch.name" />',
+'label.override.guest.traffic': '<fmt:message key="label.override.guest.traffic" />',
+'label.guest.traffic.vswitch.type': '<fmt:message key="label.guest.traffic.vswitch.type" />',
+'label.guest.traffic.vswitch.name': '<fmt:message key="label.guest.traffic.vswitch.name" />',
+'label.cisco.nexus1000v.ip.address': '<fmt:message key="label.cisco.nexus1000v.ip.address" />',
+'label.cisco.nexus1000v.username': '<fmt:message key="label.cisco.nexus1000v.username" />',
+'label.cisco.nexus1000v.password': '<fmt:message key="label.cisco.nexus1000v.password" />',
+'label.dedicate.cluster': '<fmt:message key="label.dedicate.cluster" />',
+'label.release.dedicated.cluster': '<fmt:message key="label.release.dedicated.cluster" />',
+'label.dedicate.host': '<fmt:message key="label.dedicate.host" />',
+'label.release.dedicated.host': '<fmt:message key="label.release.dedicated.host" />',
+'label.number.of.cpu.sockets': '<fmt:message key="label.number.of.cpu.sockets" />',
+'label.delete.ucs.manager': '<fmt:message key="label.delete.ucs.manager" />',
+'label.blades': '<fmt:message key="label.blades" />',
+'label.chassis': '<fmt:message key="label.chassis" />',
+'label.blade.id': '<fmt:message key="label.blade.id" />',
+'label.associated.profile': '<fmt:message key="label.associated.profile" />',
+'label.refresh.blades': '<fmt:message key="label.refresh.blades" />',
+'label.instanciate.template.associate.profile.blade': '<fmt:message key="label.instanciate.template.associate.profile.blade" />',
+'label.select.template': '<fmt:message key="label.select.template" />',
+'label.profile': '<fmt:message key="label.profile" />',
+'label.delete.profile': '<fmt:message key="label.delete.profile" />',
+'label.disassociate.profile.blade': '<fmt:message key="label.disassociate.profile.blade" />',
+'label.secondary.storage.details': '<fmt:message key="label.secondary.storage.details" />',
+'label.secondary.staging.store.details': '<fmt:message key="label.secondary.staging.store.details" />',
+'label.add.nfs.secondary.staging.store': '<fmt:message key="label.add.nfs.secondary.staging.store" />',
+'label.delete.secondary.staging.store': '<fmt:message key="label.delete.secondary.staging.store" />',
+'label.ipv4.start.ip': '<fmt:message key="label.ipv4.start.ip" />',
+'label.ipv4.end.ip': '<fmt:message key="label.ipv4.end.ip" />',
+'label.ipv6.start.ip': '<fmt:message key="label.ipv6.start.ip" />',
+'label.ipv6.end.ip': '<fmt:message key="label.ipv6.end.ip" />',
+'label.vm.password': '<fmt:message key="label.vm.password" />',
+'label.group.by.zone': '<fmt:message key="label.group.by.zone" />',
+'label.group.by.pod': '<fmt:message key="label.group.by.pod" />',
+'label.group.by.cluster': '<fmt:message key="label.group.by.cluster" />',
+'label.group.by.account': '<fmt:message key="label.group.by.account" />',
+'label.no.grouping': '<fmt:message key="label.no.grouping" />',
+'label.create.nfs.secondary.staging.storage': '<fmt:message key="label.create.nfs.secondary.staging.storage" />',
+'label.username.lower': '<fmt:message key="label.username.lower" />',
+'label.password.lower': '<fmt:message key="label.password.lower" />',
+'label.email.lower': '<fmt:message key="label.email.lower" />',
+'label.firstname.lower': '<fmt:message key="label.firstname.lower" />',
+'label.lastname.lower': '<fmt:message key="label.lastname.lower" />',
+'label.domain.lower': '<fmt:message key="label.domain.lower" />',
+'label.account.lower': '<fmt:message key="label.account.lower" />',
+'label.type.lower': '<fmt:message key="label.type.lower" />',
+'label.rule.number': '<fmt:message key="label.rule.number" />',
+'label.action': '<fmt:message key="label.action" />',
+'label.name.lower': '<fmt:message key="label.name.lower" />',
+'label.ucs': '<fmt:message key="label.ucs" />',
+'label.change.affinity': '<fmt:message key="label.change.affinity" />',
+'label.persistent': '<fmt:message key="label.persistent" />',
+'label.broadcasturi': '<fmt:message key="label.broadcasturi" />',
+'label.network.cidr': '<fmt:message key="label.network.cidr" />',
+'label.reserved.ip.range': '<fmt:message key="label.reserved.ip.range" />',
+'label.autoscale': '<fmt:message key="label.autoscale" />',
+'label.health.check': '<fmt:message key="label.health.check" />',
+'label.public.load.balancer.provider': '<fmt:message key="label.public.load.balancer.provider" />',
+'label.add.isolated.network': '<fmt:message key="label.add.isolated.network" />',
+'label.vlan': '<fmt:message key="label.vlan" />',
+'label.secondary.isolated.vlan.id': '<fmt:message key="label.secondary.isolated.vlan.id" />',
+'label.ipv4.netmask': '<fmt:message key="label.ipv4.netmask" />',
+'label.custom': '<fmt:message key="label.custom" />',
+'label.disable.network.offering': '<fmt:message key="label.disable.network.offering" />',
+'label.enable.network.offering': '<fmt:message key="label.enable.network.offering" />',
+'label.remove.network.offering': '<fmt:message key="label.remove.network.offering" />',
+'label.system.offering.for.router': '<fmt:message key="label.system.offering.for.router" />',
+'label.mode': '<fmt:message key="label.mode" />',
+'label.associate.public.ip': '<fmt:message key="label.associate.public.ip" />',
+'label.acl': '<fmt:message key="label.acl" />',
+'label.user.data': '<fmt:message key="label.user.data" />',
+'label.virtual.networking': '<fmt:message key="label.virtual.networking" />',
+'label.allow': '<fmt:message key="label.allow" />',
+'label.deny': '<fmt:message key="label.deny" />',
+'label.default.egress.policy': '<fmt:message key="label.default.egress.policy" />',
+'label.xenserver.tools.version.61.plus': '<fmt:message key="label.xenserver.tools.version.61.plus" />',
+'message.confirm.delete.ciscovnmc.resource': '<fmt:message key="message.confirm.delete.ciscovnmc.resource" />',
+'message.confirm.add.vnmc.provider': '<fmt:message key="message.confirm.add.vnmc.provider" />',
+'message.confirm.enable.vnmc.provider': '<fmt:message key="message.confirm.enable.vnmc.provider" />',
+'message.confirm.disable.vnmc.provider': '<fmt:message key="message.confirm.disable.vnmc.provider" />',
+'message.vnmc.available.list': '<fmt:message key="message.vnmc.available.list" />',
+'message.vnmc.not.available.list': '<fmt:message key="message.vnmc.not.available.list" />',
+'message.confirm.release.dedicate.vlan.range': '<fmt:message key="message.confirm.release.dedicate.vlan.range" />',
+'message.confirm.start.lb.vm': '<fmt:message key="message.confirm.start.lb.vm" />',
+'message.confirm.stop.lb.vm': '<fmt:message key="message.confirm.stop.lb.vm" />',
+'message.confirm.remove.vmware.datacenter': '<fmt:message key="message.confirm.remove.vmware.datacenter" />',
+'message.confirm.dedicate.zone': '<fmt:message key="message.confirm.dedicate.zone" />',
+'message.confirm.release.dedicated.zone': '<fmt:message key="message.confirm.release.dedicated.zone" />',
+'message.dedicated.zone.released': '<fmt:message key="message.dedicated.zone.released" />',
+'message.read.admin.guide.scaling.up': '<fmt:message key="message.read.admin.guide.scaling.up" />',
+'message.confirm.scale.up.system.vm': '<fmt:message key="message.confirm.scale.up.system.vm" />',
+'message.confirm.upgrade.router.newer.template': '<fmt:message key="message.confirm.upgrade.router.newer.template" />',
+'message.confirm.scale.up.router.vm': '<fmt:message key="message.confirm.scale.up.router.vm" />',
+'message.confirm.upgrade.routers.newtemplate': '<fmt:message key="message.confirm.upgrade.routers.newtemplate" />',
+'message.confirm.upgrade.routers.pod.newtemplate': '<fmt:message key="message.confirm.upgrade.routers.pod.newtemplate" />',
+'message.confirm.upgrade.routers.cluster.newtemplate': '<fmt:message key="message.confirm.upgrade.routers.cluster.newtemplate" />',
+'message.confirm.upgrade.routers.account.newtemplate': '<fmt:message key="message.confirm.upgrade.routers.account.newtemplate" />',
+'message.confirm.dedicate.pod.domain.account': '<fmt:message key="message.confirm.dedicate.pod.domain.account" />',
+'message.confirm.release.dedicated.pod': '<fmt:message key="message.confirm.release.dedicated.pod" />',
+'message.pod.dedication.released': '<fmt:message key="message.pod.dedication.released" />',
+'message.confirm.dedicate.cluster.domain.account': '<fmt:message key="message.confirm.dedicate.cluster.domain.account" />',
+'message.cluster.dedicated': '<fmt:message key="message.cluster.dedicated" />',
+'message.confirm.release.dedicated.cluster': '<fmt:message key="message.confirm.release.dedicated.cluster" />',
+'message.cluster.dedication.released': '<fmt:message key="message.cluster.dedication.released" />',
+'message.confirm.dedicate.host.domain.account': '<fmt:message key="message.confirm.dedicate.host.domain.account" />',
+'message.host.dedicated': '<fmt:message key="message.host.dedicated" />',
+'message.confirm.release.dedicated.host': '<fmt:message key="message.confirm.release.dedicated.host" />',
+'message.host.dedication.released': '<fmt:message key="message.host.dedication.released" />',
+'message.confirm.delete.ucs.manager': '<fmt:message key="message.confirm.delete.ucs.manager" />',
+'message.confirm.refresh.blades': '<fmt:message key="message.confirm.refresh.blades" />',
+'message.confirm.delete.secondary.staging.store': '<fmt:message key="message.confirm.delete.secondary.staging.store" />',
+'message.select.tier': '<fmt:message key="message.select.tier" />',
+'message.disallowed.characters': '<fmt:message key="message.disallowed.characters" />',
+'message.waiting.for.builtin.templates.to.load': '<fmt:message key="message.waiting.for.builtin.templates.to.load" />',
+'message.systems.vms.ready': '<fmt:message key="message.systems.vms.ready" />',
+'message.your.cloudstack.is.ready': '<fmt:message key="message.your.cloudstack.is.ready" />',
+'message.specifiy.tag.key.value': '<fmt:message key="message.specifiy.tag.key.value" />',
+'message.enter.seperated.list.multiple.cidrs': '<fmt:message key="message.enter.seperated.list.multiple.cidrs" />',
+'message.disabling.network.offering': '<fmt:message key="message.disabling.network.offering" />',
+'message.confirm.enable.network.offering': '<fmt:message key="message.confirm.enable.network.offering" />',
+'message.enabling.network.offering': '<fmt:message key="message.enabling.network.offering" />',
+'message.confirm.remove.network.offering': '<fmt:message key="message.confirm.remove.network.offering" />',
+'message.confirm.disable.network.offering': '<fmt:message key="message.confirm.disable.network.offering" />',
 };
 </script>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/ui/modules/vnmcNetworkProvider/vnmcNetworkProvider.js
----------------------------------------------------------------------
diff --git a/ui/modules/vnmcNetworkProvider/vnmcNetworkProvider.js b/ui/modules/vnmcNetworkProvider/vnmcNetworkProvider.js
index d618b23..c9295a3 100644
--- a/ui/modules/vnmcNetworkProvider/vnmcNetworkProvider.js
+++ b/ui/modules/vnmcNetworkProvider/vnmcNetworkProvider.js
@@ -17,7 +17,7 @@
 (function ($, cloudStack) {
     cloudStack.modules.vnmcNetworkProvider = function (module) {
         var vnmcDeviceViewAll = window._m = [{
-            label: 'VNMC Devices',
+            label: 'label.vnmc.devices',
             path: '_zone.vnmcDevices'
         }];
 
@@ -25,10 +25,10 @@
             id: 'vnmcDevices',
             fields: {
                 resourcename: {
-                    label: 'Resource Name'
+                    label: 'label.resource.name'
                 },
                 provider: {
-                    label: 'Provider'
+                    label: 'label.provider'
                 }
             },
             dataProvider: function (args) {
@@ -47,16 +47,16 @@
             },
             actions: {
                 add: {
-                    label: 'Add VNMC device',
+                    label: 'label.add.vnmc.device',
 
                     messages: {
                         notification: function (args) {
-                            return 'Add VNMC device';
+                            return 'label.add.vnmc.device';
                         }
                     },
 
                     createForm: {
-                        title: 'Add VNMC device',
+                        title: 'label.add.vnmc.device',
                         fields: {
                             hostname: {
                                 label: 'label.host',
@@ -203,16 +203,16 @@
             },
 
             detailView: {
-                name: 'CiscoVNMC resource details',
+                name: 'label.ciscovnmc.resource.details',
                 actions: {
                     remove: {
-                        label: 'delete CiscoVNMC resource',
+                        label: 'label.delete.ciscovnmc.resource',
                         messages: {
                             confirm: function (args) {
-                                return 'Please confirm you want to delete CiscoVNMC resource';
+                                return 'message.confirm.delete.ciscovnmc.resource';
                             },
                             notification: function (args) {
-                                return 'delete CiscoVNMC resource';
+                                return 'label.delete.ciscovnmc.resource';
                             }
                         },
                         action: function (args) {
@@ -242,14 +242,14 @@
                         title: 'label.details',
                         fields: [{
                             resourcename: {
-                                label: 'Resource Name'
+                                label: 'label.resource.name'
                             }
                         }, {
                             resourceid: {
-                                label: 'Resource ID'
+                                label: 'label.reource.id'
                             },
                             provider: {
-                                label: 'Provider'
+                                label: 'label.provider'
                             }
                         }],
                         dataProvider: function (args) {
@@ -277,14 +277,14 @@
             viewAll: vnmcDeviceViewAll,
             actions: {
             	add: {
-            		label: 'Add VNMC provider',
+            		label: 'label.add.vnmc.provider',
 
                     messages: {
                         confirm: function (args) {
-                            return 'Please confirm you would like to add the VNMC provider.';
+                            return 'message.confirm.add.vnmc.provider';
                         },
                         notification: function (args) {
-                            return 'Add VNMC device';
+                            return 'label.add.vnmc.device';
                         }
                     },
 
@@ -327,14 +327,14 @@
                     }
             	},
                 enable: {
-                    label: 'Enable VNMC provider',
+                    label: 'label.enable.vnmc.provider',
 
                     messages: {
                         confirm: function (args) {
-                            return 'Please confirm you would like to enable the VNMC provider.';
+                            return 'message.confirm.enable.vnmc.provider';
                         },
                         notification: function (args) {
-                            return 'Enable VNMC device';
+                            return 'label.enable.vnmc.device';
                         }
                     },
 
@@ -352,7 +352,7 @@
 
                                     enableCiscoVnmcProviderFn(ciscoVnmcProvider);
                                 } else {
-                                    args.response.error('VNMC is not available from provider list.');
+                                    args.response.error('message.vnmc.available.list');
                                 }
                             }
                         });
@@ -419,14 +419,14 @@
                 },
 
                 disable: {
-                    label: 'Disable VNMC provider',
+                    label: 'label.disable.vnmc.provider',
 
                     messages: {
                         confirm: function (args) {
-                            return 'Please confirm you would like to disable the VNMC provider.';
+                            return 'message.confirm.disable.vnmc.provider';
                         },
                         notification: function (args) {
-                            return 'Disable VNMC device';
+                            return 'label.disbale.vnmc.device';
                         }
                     },
 
@@ -444,7 +444,7 @@
 
                                     disableCiscoVnmcProviderFn(ciscoVnmcProvider);
                                 } else {
-                                    args.response.error('VNMC is not available from provider list.');
+                                    args.response.error('message.vnmc.not.available.list');
                                 }
                             }
                         });
@@ -525,7 +525,7 @@
                             label: 'label.id'
                         },
                         servicelist: {
-                            label: 'Services',
+                            label: 'label.services',
                             converter: function (args) {
                                 if (args)
                                     return args.join(', ');

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/ui/scripts/configuration.js
----------------------------------------------------------------------
diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js
index cb54c31..401262c 100644
--- a/ui/scripts/configuration.js
+++ b/ui/scripts/configuration.js
@@ -96,7 +96,7 @@
                                         }
                                     },
                                     isCustomized: {
-                                        label: 'Custom',                                       
+                                        label: 'label.custom',                                       
                                         isBoolean: true,
                                         isReverse: true,
                                         isChecked: false
@@ -2320,34 +2320,34 @@
                                                         // Sanitize names
                                                         switch (serviceName) {
                                                             case 'Vpn':
-                                                                serviceDisplayName = 'VPN';
+                                                                serviceDisplayName = dictionary['label.vpn'];
                                                                 break;
                                                             case 'Dhcp':
                                                                 serviceDisplayName = dictionary['label.dhcp'];
                                                                 break;
                                                             case 'Dns':
-                                                                serviceDisplayName = 'DNS';
+                                                                serviceDisplayName = dictionary['label.dns'];
                                                                 break;
                                                             case 'Lb':
-                                                                serviceDisplayName = 'Load Balancer';
+                                                                serviceDisplayName = dictionary['label.load.balancer'];
                                                                 break;
                                                             case 'SourceNat':
-                                                                serviceDisplayName = 'Source NAT';
+                                                                serviceDisplayName = dictionary['label.source.nat'];
                                                                 break;
                                                             case 'StaticNat':
-                                                                serviceDisplayName = 'Static NAT';
+                                                                serviceDisplayName = dictionary['label.static.nat'];
                                                                 break;
                                                             case 'PortForwarding':
-                                                                serviceDisplayName = 'Port Forwarding';
+                                                                serviceDisplayName = dictionary['label.port.forwarding'];
                                                                 break;
                                                             case 'SecurityGroup':
-                                                                serviceDisplayName = 'Security Groups';
+                                                                serviceDisplayName = dictionary['label.security.groups'];
                                                                 break;
                                                             case 'UserData':
-                                                                serviceDisplayName = 'User Data';
+                                                                serviceDisplayName = dictionary['label.user.data'];
                                                                 break;
                                                             case 'Connectivity':
-                                                                serviceDisplayName = 'Virtual Networking';
+                                                                serviceDisplayName = dictionary['label.virtual.networking'];
                                                                 break;
                                                             default:
                                                                 serviceDisplayName = serviceName;
@@ -2454,7 +2454,7 @@
 
                                     //show or hide upon checked services and selected providers above (begin)
                                     serviceofferingid: {
-                                        label: 'System Offering for Router',
+                                        label: 'label.system.offering.for.router',
                                         isHidden: true,
                                         docID: 'helpNetworkOfferingSystemOffering',
                                         select: function(args) {
@@ -2488,7 +2488,7 @@
                                     },
 
                                     "service.SourceNat.redundantRouterCapabilityCheckbox": {
-                                        label: "label.redundant.router.capability",
+                                        label: 'label.redundant.router.capability',
                                         isHidden: true,
                                         dependsOn: 'service.SourceNat.isEnabled',
                                         docID: 'helpNetworkOfferingRedundantRouterCapability',
@@ -2534,7 +2534,7 @@
                                         }
                                     },
                                     "service.Lb.inlineModeDropdown": {
-                                        label: 'Mode',
+                                        label: 'label.mode',
                                         docID: 'helpNetworkOfferingMode',
                                         select: function(args) {
                                             var items = [];
@@ -2559,7 +2559,7 @@
                                     },
 
                                     "service.StaticNat.associatePublicIP": {
-                                        label: 'Associate Public IP',
+                                        label: 'label.associate.public.ip',
                                         docID: 'helpNetworkOfferingAssociatePublicIP',
                                         isBoolean: true,
                                         isHidden: true
@@ -2585,23 +2585,23 @@
                                             args.response.success({
                                                 data: [{
                                                     id: 'Optional',
-                                                    description: 'Optional'
+                                                    description: 'label.optional'
                                                 }, {
                                                     id: 'Required',
-                                                    description: 'Required'
+                                                    description: 'label.required'
                                                 }]
                                             });
                                         }
                                     },
 
                                     egresspolicy: {
-                                        label: 'Default egress policy',
+                                        label: 'label.default.egress.policy',
                                         isHidden: true,
                                         select: function(args) {
                                             args.response.success({
                                                 data: [
-                                                    { id: 'ALLOW', description: 'Allow' },
-                                                    { id: 'DENY', description: 'Deny' }
+                                                    { id: 'ALLOW', description: 'label.allow' },
+                                                    { id: 'DENY', description: 'label.deny' }
                                                 ]
                                             });
                                         }
@@ -2829,13 +2829,13 @@
                             },
 
                             enable: {
-                                label: 'Enable network offering',
+                                label: 'label.enable.network.offering',
                                 messages: {
                                     confirm: function(args) {
-                                        return 'Are you sure you want to enable this network offering?';
+                                        return 'message.confirm.enable.network.offering';
                                     },
                                     notification: function(args) {
-                                        return 'Enabling network offering';
+                                        return 'message.enabling.network.offering';
                                     }
                                 },
                                 action: function(args) {
@@ -2864,13 +2864,13 @@
                             },
 
                             disable: {
-                                label: 'Disable network offering',
+                                label: 'label.disable.network.offering',
                                 messages: {
                                     confirm: function(args) {
-                                        return 'Are you sure you want to disable this network offering?';
+                                        return 'message.confirm.disable.network.offering';
                                     },
                                     notification: function(args) {
-                                        return 'Disabling network offering';
+                                        return 'message.disabling.network.offering';
                                     }
                                 },
                                 action: function(args) {
@@ -2899,7 +2899,7 @@
                             },
 
                             remove: {
-                                label: 'Remove network offering',
+                                label: 'label.remove.network.offering',
                                 action: function(args) {
                                     $.ajax({
                                         url: createURL('deleteNetworkOffering'),
@@ -2919,10 +2919,10 @@
                                 },
                                 messages: {
                                     confirm: function() {
-                                        return 'Are you sure you want to remove this network offering?';
+                                        return 'message.confirm.remove.network.offering';
                                     },
                                     notification: function() {
-                                        return 'Remove network offering';
+                                        return 'label.remove.network.offering';
                                     }
                                 },
                                 notification: {
@@ -2968,7 +2968,7 @@
                                     },
 
                                     ispersistent: {
-                                        label: 'Persistent ',
+                                        label: 'label.persistent ',
                                         converter: cloudStack.converters.toBooleanText
                                     },
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/ui/scripts/installWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/installWizard.js b/ui/scripts/installWizard.js
index 25de4aa..85eaff0 100644
--- a/ui/scripts/installWizard.js
+++ b/ui/scripts/installWizard.js
@@ -314,7 +314,7 @@
                                                 return vm.state == 'Running';
                                             }).length) {
                                                 clearInterval(poll);
-                                                message('System VMs ready.');
+                                                message('message.systems.vms.ready');
                                                 setTimeout(pollBuiltinTemplates, 500);
                                             }
                                         }
@@ -325,7 +325,7 @@
 
                         // Wait for builtin template to be present -- otherwise VMs cannot launch
                         var pollBuiltinTemplates = function() {
-                            message('Waiting for builtin templates to load...');
+                            message('message.waiting.for.builtin.templates.to.load');
                             var poll = setInterval(function() {
                                 $.ajax({
                                     url: createURL('listTemplates'),
@@ -341,7 +341,7 @@
 
                                         if (builtinTemplates.length) {
                                             clearInterval(poll);
-                                            message('Your CloudStack is ready!');
+                                            message('message.your.cloudstack.is.ready');
                                             setTimeout(success, 1000);
                                         }
                                     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/ui/scripts/instances.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index 53c9e98..e5b2e85 100644
--- a/ui/scripts/instances.js
+++ b/ui/scripts/instances.js
@@ -172,10 +172,10 @@
 
             advSearchFields: {
                 name: {
-                    label: 'Name'
+                    label: 'label.name'
                 },
                 zoneid: {
-                    label: 'Zone',
+                    label: 'label.zone',
                     select: function(args) {
                         $.ajax({
                             url: createURL('listZones'),
@@ -199,7 +199,7 @@
                 },
 
                 domainid: {
-                    label: 'Domain',
+                    label: 'label.domain',
                     select: function(args) {
                         if (isAdmin() || isDomainAdmin()) {
                             $.ajax({
@@ -241,7 +241,7 @@
                     }
                 },
                 account: {
-                    label: 'Account',
+                    label: 'label.account',
                     isHidden: function(args) {
                         if (isAdmin() || isDomainAdmin())
                             return false;
@@ -251,10 +251,10 @@
                 },
 
                 tagKey: {
-                    label: 'Tag Key'
+                    label: 'label.tag.key'
                 },
                 tagValue: {
-                    label: 'Tag Value'
+                    label: 'label.tag.value'
                 }
             },
 
@@ -464,7 +464,7 @@
                             },
                             complete: function(args) {
                                 if (args.password != null) {
-                                    return 'Password of the VM is ' + args.password;
+                                    return 'label.vm.password' + ' ' + args.password;
                                 }
 
                                 return false;
@@ -478,7 +478,7 @@
                         label: 'label.action.stop.instance',
                         compactLabel: 'label.stop',
                         createForm: {
-                            title: 'Stop instance',
+                            title: 'notification.stop.instance',
                             desc: 'message.action.stop.instance',
                             fields: {
                                 forced: {
@@ -764,7 +764,7 @@
                                                 var networks = json.listnetworksresponse.network;
                                                 var items = [{
                                                     id: -1,
-                                                    description: 'Please select a tier'
+                                                    description: 'message.select.tier'
                                                 }];
                                                 $(networks).each(function() {
                                                     items.push({
@@ -1434,7 +1434,7 @@
                             	var description = '';                            	
                             	var vmObj = args.jsonObj;                            	
                             	if (vmObj.state == 'Running' && vmObj.hypervisor == 'VMware') {
-                            		description = 'Please read the dynamic scaling section in the admin guide before scaling up.';
+                            		description = 'message.read.admin.guide.scaling.up';
                             	}                             
                                 return description;                  	                
                             },

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/ui/scripts/network.js
----------------------------------------------------------------------
diff --git a/ui/scripts/network.js b/ui/scripts/network.js
index 6ce66e8..f82a295 100755
--- a/ui/scripts/network.js
+++ b/ui/scripts/network.js
@@ -410,7 +410,7 @@
                 listView: {
                     actions: {
                         add: {
-                            label: 'Add Isolated Network',
+                            label: 'label.add.isolated.network',
 
                             preFilter: function(args) {
                                 if (advZoneObjs != null && advZoneObjs.length > 0) {
@@ -766,13 +766,13 @@
                             label: 'label.cidr'
                         },
                         ip6cidr: {
-                            label: 'IPv6 CIDR'
+                            label: 'label.ipv6.CIDR'
                         }
                     },
 
                     advSearchFields: {
                         zoneid: {
-                            label: 'Zone',
+                            label: 'label.zone',
                             select: function(args) {
                                 $.ajax({
                                     url: createURL('listZones'),
@@ -796,7 +796,7 @@
                         },
 
                         domainid: {
-                            label: 'Domain',
+                            label: 'label.domain',
                             select: function(args) {
                                 if (isAdmin() || isDomainAdmin()) {
                                     $.ajax({
@@ -839,7 +839,7 @@
                         },
 
                         account: {
-                            label: 'Account',
+                            label: 'label.account',
                             isHidden: function(args) {
                                 if (isAdmin() || isDomainAdmin())
                                     return false;
@@ -848,10 +848,10 @@
                             }
                         },
                         tagKey: {
-                            label: 'Tag Key'
+                            label: 'label.tag.key'
                         },
                         tagValue: {
-                            label: 'Tag Value'
+                            label: 'label.tag.value'
                         }
                     },
 
@@ -875,7 +875,7 @@
                     },
 
                     detailView: {
-                        name: 'Guest network details',
+                        name: 'label.guest.network.details',
                         viewAll: {
                             path: 'network.ipAddresses',
                             label: 'label.menu.ipaddresses',
@@ -1245,7 +1245,7 @@
                                     },
                                     
                                     ispersistent: {
-                                        label: 'Persistent ',
+                                        label: 'label.persistent',
                                         converter: cloudStack.converters.toBooleanText
 
                                     },
@@ -1263,7 +1263,7 @@
                                     },
                                     
                                     broadcasturi: {
-                                    	label: 'broadcasturi'
+                                    	label: 'label.broadcasturi'
                                     },
                                     
                                     networkofferingid: {
@@ -1323,20 +1323,20 @@
                                     },
 
                                     networkcidr: {
-                                        label: 'Network CIDR'
+                                        label: 'label.network.cidr'
                                     },
 
                                     ip6gateway: {
-                                        label: 'IPv6 Gateway'
+                                        label: 'label.ipv6.gateway'
                                     },
 
                                     ip6cidr: {
-                                        label: 'IPv6 CIDR'
+                                        label: 'label.ipv6.CIDR'
                                     },
 
 
                                     reservediprange: {
-                                        label: 'Reserved IP Range'
+                                        label: 'label.reserved.ip.range'
                                     },
 
 
@@ -1688,7 +1688,7 @@
                                                 }
                                             },
                                             'autoScale': {
-                                                label: 'AutoScale',
+                                                label: 'label.autoscale',
                                                 custom: {
                                                     requireValidation: true,
                                                     buttonLabel: 'label.configure',
@@ -2785,7 +2785,7 @@
                                         label: 'label.zone'
                                     },
                                     vlanname: {
-                                        label: 'label.vlan'
+                                        label: 'label.vlan.only'
                                     }
                                 }],
 
@@ -3479,7 +3479,7 @@
                                             },
 
                                             'health-check': {
-                                                label: 'Health Check',
+                                                label: 'label.health.check',
                                                 custom: {
                                                     requireValidation: true,
                                                     buttonLabel: 'Configure',
@@ -3489,7 +3489,7 @@
                                             },
 
                                             'autoScale': {
-                                                label: 'AutoScale',
+                                                label: 'label.autoscale',
                                                 custom: {
                                                     requireValidation: true,
                                                     buttonLabel: 'label.configure',
@@ -4475,10 +4475,10 @@
 
                     advSearchFields: {
                         tagKey: {
-                            label: 'Tag Key'
+                            label: 'label.tag.key'
                         },
                         tagValue: {
-                            label: 'Tag Value'
+                            label: 'label.tag.value'
                         }
                     },
 
@@ -5013,10 +5013,10 @@
 
                     advSearchFields: {
                         name: {
-                            label: 'Name'
+                            label: 'label.name'
                         },
                         zoneid: {
-                            label: 'Zone',
+                            label: 'label.zone',
                             select: function(args) {
                                 $.ajax({
                                     url: createURL('listZones'),
@@ -5040,7 +5040,7 @@
                         },
 
                         domainid: {
-                            label: 'Domain',
+                            label: 'label.domain',
                             select: function(args) {
                                 if (isAdmin() || isDomainAdmin()) {
                                     $.ajax({
@@ -5083,7 +5083,7 @@
                         },
 
                         account: {
-                            label: 'Account',
+                            label: 'label.account',
                             isHidden: function(args) {
                                 if (isAdmin() || isDomainAdmin())
                                     return false;
@@ -5092,10 +5092,10 @@
                             }
                         },
                         tagKey: {
-                            label: 'Tag Key'
+                            label: 'label.tag.key'
                         },
                         tagValue: {
-                            label: 'Tag Value'
+                            label: 'label.tag.value'
                         }
                     },
 
@@ -5186,7 +5186,7 @@
                                         label: 'label.DNS.domain.for.guest.networks'
                                     },
                                     publicLoadBalancerProvider: {
-                                        label: 'Public Load Balancer Provider',
+                                        label: 'label.public.load.balancer.provider',
                                         select: function(args) {
                                             var items = [];
                                             items.push({
@@ -5429,7 +5429,7 @@
                                         label: 'label.state'
                                     },
                                     ispersistent: {
-                                        label: 'Persistent ',
+                                        label: 'label.persistent',
                                         converter: cloudStack.converters.toBooleanText
 
                                     },
@@ -5604,8 +5604,8 @@
                                         }
                                     },
                                     cidrlist: {
-                                        label: 'CIDR list',
-                                        desc: 'Please enter a comma separated list of CIDRs if more than one',
+                                        label: 'label.CIDR.list',
+                                        desc: 'message.enter.seperated.list.multiple.cidrs',
                                         validation: {
                                             required: true
                                         }
@@ -5619,7 +5619,7 @@
                                     },
                                     cidrlist: {
                                         label: 'label.CIDR.list',
-                                        desc: 'Please enter a comma separated list of CIDRs if more than one',
+                                        desc: 'message.enter.seperated.list.multiple.cidrs',
                                         docID: 'helpVPNGatewayCIDRList',
                                         validation: {
                                             required: true

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/ui/scripts/sharedFunctions.js
----------------------------------------------------------------------
diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js
index f0afea5..9c24f40 100644
--- a/ui/scripts/sharedFunctions.js
+++ b/ui/scripts/sharedFunctions.js
@@ -297,7 +297,7 @@ var addGuestNetworkDialog = {
                     docID: 'helpGuestNetworkZoneVLANID'
                 },
                 isolatedpvlanId: {
-                    label: 'Secondary Isolated VLAN ID'
+                    label: 'label.secondary.isolated.vlan.id'
                 },
 
                 scope: {
@@ -319,24 +319,24 @@ var addGuestNetworkDialog = {
                         if (selectedZoneObj.networktype == "Advanced" && selectedZoneObj.securitygroupsenabled == true) {
                             array1.push({
                                 id: 'zone-wide',
-                                description: 'All'
+                                description: 'ui.listView.filters.all'
                             });
                         } else {
                             array1.push({
                                 id: 'zone-wide',
-                                description: 'All'
+                                description: 'ui.listView.filters.all'
                             });
                             array1.push({
                                 id: 'domain-specific',
-                                description: 'Domain'
+                                description: 'label.domain'
                             });
                             array1.push({
                                 id: 'account-specific',
-                                description: 'Account'
+                                description: 'label.account'
                             });
                             array1.push({
                                 id: 'project-specific',
-                                description: 'Project'
+                                description: 'label.project'
                             });
                         }
                         args.response.success({
@@ -584,37 +584,37 @@ var addGuestNetworkDialog = {
 
                 //IPv4 (begin)
                 ip4gateway: {
-                    label: 'IPv4 Gateway',
+                    label: 'label.ipv4.gateway',
                     docID: 'helpGuestNetworkZoneGateway'
                 },
                 ip4Netmask: {
-                    label: 'IPv4 Netmask',
+                    label: 'label.ipv4.netmask',
                     docID: 'helpGuestNetworkZoneNetmask'
                 },
                 startipv4: {
-                    label: 'IPv4 Start IP',
+                    label: 'label.ipv4.start.ip',
                     docID: 'helpGuestNetworkZoneStartIP'
                 },
                 endipv4: {
-                    label: 'IPv4 End IP',
+                    label: 'label.ipv4.end.ip',
                     docID: 'helpGuestNetworkZoneEndIP'
                 },
                 //IPv4 (end)
 
                 //IPv6 (begin)
                 ip6gateway: {
-                    label: 'IPv6 Gateway',
+                    label: 'label.ipv6.gateway',
                     docID: 'helpGuestNetworkZoneGateway'
                 },
                 ip6cidr: {
-                    label: 'IPv6 CIDR'
+                    label: 'label.ipv6.CIDR'
                 },
                 startipv6: {
-                    label: 'IPv6 Start IP',
+                    label: 'label.ipv6.start.ip',
                     docID: 'helpGuestNetworkZoneStartIP'
                 },
                 endipv6: {
-                    label: 'IPv6 End IP',
+                    label: 'label.ipv6.end.ip',
                     docID: 'helpGuestNetworkZoneEndIP'
                 },
                 //IPv6 (end)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/ui/scripts/storage.js
----------------------------------------------------------------------
diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js
index 1cd8d2e..e69a07e 100644
--- a/ui/scripts/storage.js
+++ b/ui/scripts/storage.js
@@ -1093,11 +1093,11 @@
                                             isBoolean: true
                                         },
                                         isFeatured: {
-                                            label: "label.featured",
+                                            label: 'label.featured',
                                             isBoolean: true
                                         },
                                         isdynamicallyscalable: {
-                                            label: "Dynamically Scalable",
+                                            label: 'label.dynamically.scalable',
                                             isBoolean: true
                                         }
                                     }
@@ -1688,7 +1688,7 @@
                                             isBoolean: true
                                         },
                                         isdynamicallyscalable: {
-                                            label: "Dynamically Scalable",
+                                            label: 'label.dynamically.scalable',
                                             isBoolean: true
                                         }
                                     }


[43/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
Dispatcher corrections, refactoring and tests

Corrects problems from previous attempt. Fixes based on help comments from
the community and conflict resolution

Signed-off-by: Daan Hoogland <da...@onecht.net>


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

Branch: refs/heads/resize-root
Commit: c211f0bbbe940ed3b9a6e9ef4b5a29be16062e85
Parents: 4552ec6
Author: Antonio Fornie <af...@schubergphilis.com>
Authored: Fri Mar 7 09:57:31 2014 -0600
Committer: Daan Hoogland <da...@onecht.net>
Committed: Fri Mar 7 19:12:07 2014 +0100

----------------------------------------------------------------------
 .../org/apache/cloudstack/api/ApiConstants.java |  15 +-
 api/src/org/apache/cloudstack/api/BaseCmd.java  | 185 ++++---
 .../org/apache/cloudstack/api/BaseListCmd.java  |  30 +-
 .../org/apache/cloudstack/api/BaseCmdTest.java  |  69 +++
 .../core/spring-server-core-misc-context.xml    |  12 +
 server/src/com/cloud/api/ApiDispatcher.java     | 490 +------------------
 server/src/com/cloud/api/ApiServer.java         | 374 +++++++-------
 server/src/com/cloud/api/ApiServlet.java        | 133 ++---
 .../api/dispatch/CommandCreationWorker.java     |  56 +++
 .../com/cloud/api/dispatch/DispatchChain.java   |  40 ++
 .../api/dispatch/DispatchChainFactory.java      |  72 +++
 .../com/cloud/api/dispatch/DispatchTask.java    |  41 ++
 .../com/cloud/api/dispatch/DispatchWorker.java  |  30 ++
 .../dispatch/ParamGenericValidationWorker.java  | 103 ++++
 .../cloud/api/dispatch/ParamProcessWorker.java  | 428 ++++++++++++++++
 .../cloud/api/dispatch/ParamUnpackWorker.java   | 114 +++++
 .../dispatch/SpecificCmdValidationWorker.java   |  34 ++
 .../cloud/network/as/AutoScaleManagerImpl.java  | 466 +++++++++---------
 .../VirtualNetworkApplianceManagerImpl.java     |   2 -
 .../storage/snapshot/SnapshotSchedulerImpl.java | 105 ++--
 .../test/com/cloud/api/ApiDispatcherTest.java   | 106 ----
 .../api/dispatch/CommandCreationWorkerTest.java |  48 ++
 .../api/dispatch/DispatchChainFactoryTest.java  |  55 +++
 .../ParamGenericValidationWorkerTest.java       | 173 +++++++
 .../api/dispatch/ParamProcessWorkerTest.java    | 107 ++++
 .../SpecificCmdValidationWorkerTest.java        |  48 ++
 26 files changed, 2157 insertions(+), 1179 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index 14df653..f0de48e 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -23,7 +23,8 @@ public class ApiConstants {
     public static final String ACCOUNT_ID = "accountid";
     public static final String ALGORITHM = "algorithm";
     public static final String ALLOCATED_ONLY = "allocatedonly";
-    public static final String API_KEY = "userapikey";
+    public static final String API_KEY = "apikey";
+    public static final String USER_API_KEY = "userapikey";
     public static final String APPLIED = "applied";
     public static final String AVAILABLE = "available";
     public static final String BITS = "bits";
@@ -49,10 +50,16 @@ public class ApiConstants {
     public static final String CLUSTER_ID = "clusterid";
     public static final String CLUSTER_NAME = "clustername";
     public static final String CLUSTER_TYPE = "clustertype";
+    public static final String COMMAND = "command";
+    public static final String CMD_EVENT_TYPE = "cmdeventtype";
     public static final String COMPONENT = "component";
     public static final String CPU_NUMBER = "cpunumber";
     public static final String CPU_SPEED = "cpuspeed";
     public static final String CREATED = "created";
+    public static final String CTX_ACCOUNT_ID = "ctxaccountid";
+    public static final String CTX_USER_ID = "ctxuserid";
+    public static final String CTXSTARTEVENTID = "ctxstarteventid";
+    public static final String CTX_START_EVENT_ID = "ctxStartEventId";
     public static final String CUSTOMIZED = "customized";
     public static final String CUSTOMIZED_IOPS = "customizediops";
     public static final String CUSTOM_ID = "customid";
@@ -79,6 +86,7 @@ public class ApiConstants {
     public static final String IP6_DNS2 = "ip6dns2";
     public static final String DOMAIN = "domain";
     public static final String DOMAIN_ID = "domainid";
+    public static final String DOMAIN__ID = "domainId";
     public static final String DURATION = "duration";
     public static final String EMAIL = "email";
     public static final String END_DATE = "enddate";
@@ -86,6 +94,7 @@ public class ApiConstants {
     public static final String END_IPV6 = "endipv6";
     public static final String END_PORT = "endport";
     public static final String ENTRY_TIME = "entrytime";
+    public static final String EXPIRES = "expires";
     public static final String FETCH_LATEST = "fetchlatest";
     public static final String FIRSTNAME = "firstname";
     public static final String FORCED = "forced";
@@ -209,8 +218,11 @@ public class ApiConstants {
     public static final String SENT = "sent";
     public static final String SENT_BYTES = "sentbytes";
     public static final String SERVICE_OFFERING_ID = "serviceofferingid";
+    public static final String SESSIONKEY = "sessionkey";
     public static final String SHOW_CAPACITIES = "showcapacities";
     public static final String SHOW_REMOVED = "showremoved";
+    public static final String SIGNATURE = "signature";
+    public static final String SIGNATURE_VERSION = "signatureversion";
     public static final String SIZE = "size";
     public static final String SNAPSHOT_ID = "snapshotid";
     public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid";
@@ -277,6 +289,7 @@ public class ApiConstants {
     public static final String NETWORKRATE = "networkrate";
     public static final String HOST_TAGS = "hosttags";
     public static final String SSH_KEYPAIR = "keypair";
+    public static final String HTTPMETHOD = "httpmethod";
     public static final String HOST_CPU_CAPACITY = "hostcpucapacity";
     public static final String HOST_CPU_NUM = "hostcpunum";
     public static final String HOST_MEM_CAPACITY = "hostmemcapacity";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/api/src/org/apache/cloudstack/api/BaseCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java
index e869ddf..02250d7 100644
--- a/api/src/org/apache/cloudstack/api/BaseCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseCmd.java
@@ -17,22 +17,28 @@
 
 package org.apache.cloudstack.api;
 
+import java.lang.reflect.Field;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.regex.Pattern;
 
 import javax.inject.Inject;
 
+import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.affinity.AffinityGroupService;
 import org.apache.cloudstack.alert.AlertService;
+import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
 import org.apache.cloudstack.network.lb.ApplicationLoadBalancerService;
 import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
 import org.apache.cloudstack.query.QueryService;
 import org.apache.cloudstack.usage.UsageService;
+
 import org.apache.log4j.Logger;
 
 import com.cloud.configuration.ConfigurationService;
@@ -74,6 +80,7 @@ import com.cloud.user.Account;
 import com.cloud.user.AccountService;
 import com.cloud.user.DomainService;
 import com.cloud.user.ResourceLimitService;
+import com.cloud.utils.ReflectUtil;
 import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.db.UUIDManager;
 import com.cloud.vm.UserVmService;
@@ -97,7 +104,9 @@ public abstract class BaseCmd {
     public static Pattern newInputDateFormat = Pattern.compile("[\\d]+-[\\d]+-[\\d]+ [\\d]+:[\\d]+:[\\d]+");
     private static final DateFormat s_outputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
 
-    private Object _responseObject = null;
+    protected static final Map<Class<?>, List<Field>> fieldsForCmdClass = new HashMap<Class<?>, List<Field>>();
+
+    private Object _responseObject;
     private Map<String, String> fullUrlParams;
 
     public enum HTTPMethod {
@@ -205,7 +214,7 @@ public abstract class BaseCmd {
         return httpMethod;
     }
 
-    public void setHttpMethod(String method) {
+    public void setHttpMethod(final String method) {
         if (method != null) {
             if (method.equalsIgnoreCase("GET"))
                 httpMethod = HTTPMethod.GET;
@@ -227,12 +236,36 @@ public abstract class BaseCmd {
         return responseType;
     }
 
-    public void setResponseType(String responseType) {
+    public void setResponseType(final String responseType) {
         this.responseType = responseType;
     }
 
+    /**
+     * For some reason this method does not return the actual command name, but more a name that
+     * is used to create the response. So you can expect for a XCmd a value like xcmdresponse. Anyways
+     * this methods is used in too many places so for now instead of changing it we just create another
+     * method {@link BaseCmd#getActualCommandName()} that returns the value from {@link APICommand#name()}
+     *
+     * @return
+     */
     public abstract String getCommandName();
 
+
+    /**
+     * Gets the CommandName based on the class annotations: the value from {@link APICommand#name()}
+     *
+     * @return the value from {@link APICommand#name()}
+     */
+    public String getActualCommandName() {
+        String cmdName = null;
+        if (this.getClass().getAnnotation(APICommand.class) != null) {
+            cmdName = this.getClass().getAnnotation(APICommand.class).name();
+        } else {
+            cmdName = this.getClass().getName();
+        }
+       return cmdName;
+    }
+
     /**
      * For commands the API framework needs to know the owner of the object being acted upon. This method is
      * used to determine that information.
@@ -245,7 +278,7 @@ public abstract class BaseCmd {
         return _responseObject;
     }
 
-    public void setResponseObject(Object responseObject) {
+    public void setResponseObject(final Object responseObject) {
         _responseObject = responseObject;
     }
 
@@ -253,7 +286,7 @@ public abstract class BaseCmd {
         return _mgr;
     }
 
-    public static String getDateString(Date date) {
+    public static String getDateString(final Date date) {
         if (date == null) {
             return "";
         }
@@ -264,101 +297,86 @@ public abstract class BaseCmd {
         return formattedString;
     }
 
-    // FIXME: move this to a utils method so that maps can be unpacked and integer/long values can be appropriately cast
-    @SuppressWarnings({"unchecked", "rawtypes"})
-    public Map<String, Object> unpackParams(Map<String, String> params) {
-        Map<String, Object> lowercaseParams = new HashMap<String, Object>();
-        for (String key : params.keySet()) {
-            int arrayStartIndex = key.indexOf('[');
-            int arrayStartLastIndex = key.lastIndexOf('[');
-            if (arrayStartIndex != arrayStartLastIndex) {
-                throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key +
-                    "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
-            }
+    protected List<Field> getAllFieldsForClass(final Class<?> clazz) {
+        List<Field> filteredFields = fieldsForCmdClass.get(clazz);
 
-            if (arrayStartIndex > 0) {
-                int arrayEndIndex = key.indexOf(']');
-                int arrayEndLastIndex = key.lastIndexOf(']');
-                if ((arrayEndIndex < arrayStartIndex) || (arrayEndIndex != arrayEndLastIndex)) {
-                    // malformed parameter
-                    throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key +
-                        "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
-                }
+        // If list of fields was not cached yet
+        if (filteredFields == null) {
+            final List<Field> allFields = ReflectUtil.getAllFieldsForClass(this.getClass(), BaseCmd.class);
+            filteredFields = new ArrayList<Field>();
 
-                // Now that we have an array object, check for a field name in the case of a complex object
-                int fieldIndex = key.indexOf('.');
-                String fieldName = null;
-                if (fieldIndex < arrayEndIndex) {
-                    throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key +
-                        "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
-                } else {
-                    fieldName = key.substring(fieldIndex + 1);
+            for (final Field field : allFields) {
+                final Parameter parameterAnnotation = field.getAnnotation(Parameter.class);
+                if ((parameterAnnotation != null) && parameterAnnotation.expose()) {
+                    filteredFields.add(field);
                 }
+            }
 
-                // parse the parameter name as the text before the first '[' character
-                String paramName = key.substring(0, arrayStartIndex);
-                paramName = paramName.toLowerCase();
-
-                Map<Integer, Map> mapArray = null;
-                Map<String, Object> mapValue = null;
-                String indexStr = key.substring(arrayStartIndex + 1, arrayEndIndex);
-                int index = 0;
-                boolean parsedIndex = false;
-                try {
-                    if (indexStr != null) {
-                        index = Integer.parseInt(indexStr);
-                        parsedIndex = true;
-                    }
-                } catch (NumberFormatException nfe) {
-                    s_logger.warn("Invalid parameter " + key + " received, unable to parse object array, returning an error.");
-                }
+            // Cache the prepared list for future use
+            fieldsForCmdClass.put(clazz, filteredFields);
+        }
+        return filteredFields;
+    }
 
-                if (!parsedIndex) {
-                    throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key +
-                        "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
-                }
+    protected Account getCurrentContextAccount() {
+        return CallContext.current().getCallingAccount();
+    }
 
-                Object value = lowercaseParams.get(paramName);
-                if (value == null) {
-                    // for now, assume object array with sub fields
-                    mapArray = new HashMap<Integer, Map>();
-                    mapValue = new HashMap<String, Object>();
-                    mapArray.put(Integer.valueOf(index), mapValue);
-                } else if (value instanceof Map) {
-                    mapArray = (HashMap)value;
-                    mapValue = mapArray.get(Integer.valueOf(index));
-                    if (mapValue == null) {
-                        mapValue = new HashMap<String, Object>();
-                        mapArray.put(Integer.valueOf(index), mapValue);
+    /**
+     * This method doesn't return all the @{link Parameter}, but only the ones exposed
+     * and allowed for current @{link RoleType}. This method will get the fields for a given
+     * Cmd class only once and never again, so in case of a dynamic update the result would
+     * be obsolete (this might be a plugin update. It is agreed upon that we will not do
+     * upgrades dynamically but in case we come back on that decision we need to revisit this)
+     *
+     * @return
+     */
+    public List<Field> getParamFields() {
+        final List<Field> allFields = getAllFieldsForClass(this.getClass());
+        final List<Field> validFields = new ArrayList<Field>();
+        final Account caller = getCurrentContextAccount();
+
+        for (final Field field : allFields) {
+            final Parameter parameterAnnotation = field.getAnnotation(Parameter.class);
+
+            //TODO: Annotate @Validate on API Cmd classes, FIXME how to process Validate
+            final RoleType[] allowedRoles = parameterAnnotation.authorized();
+            boolean roleIsAllowed = true;
+            if (allowedRoles.length > 0) {
+                roleIsAllowed = false;
+                for (final RoleType allowedRole : allowedRoles) {
+                    if (allowedRole.getValue() == caller.getType()) {
+                        roleIsAllowed = true;
+                        break;
                     }
                 }
+            }
 
-                // we are ready to store the value for a particular field into the map for this object
-                mapValue.put(fieldName, params.get(key));
-
-                lowercaseParams.put(paramName, mapArray);
+            if (roleIsAllowed) {
+                validFields.add(field);
             } else {
-                lowercaseParams.put(key.toLowerCase(), params.get(key));
+                s_logger.debug("Ignoring paremeter " + parameterAnnotation.name() + " as the caller is not authorized to pass it in");
             }
         }
-        return lowercaseParams;
+
+        return validFields;
     }
 
-    protected long getInstanceIdFromJobSuccessResult(String result) {
+    protected long getInstanceIdFromJobSuccessResult(final String result) {
         s_logger.debug("getInstanceIdFromJobSuccessResult not overridden in subclass " + this.getClass().getName());
         return 0;
     }
 
-    public static boolean isAdmin(short accountType) {
+    public static boolean isAdmin(final short accountType) {
         return ((accountType == Account.ACCOUNT_TYPE_ADMIN) || (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) ||
             (accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN));
     }
 
-    public static boolean isRootAdmin(short accountType) {
+    public static boolean isRootAdmin(final short accountType) {
         return ((accountType == Account.ACCOUNT_TYPE_ADMIN));
     }
 
-    public void setFullUrlParams(Map<String, String> map) {
+    public void setFullUrlParams(final Map<String, String> map) {
         fullUrlParams = map;
     }
 
@@ -366,18 +384,18 @@ public abstract class BaseCmd {
         return fullUrlParams;
     }
 
-    public Long finalyzeAccountId(String accountName, Long domainId, Long projectId, boolean enabledOnly) {
+    public Long finalyzeAccountId(final String accountName, final Long domainId, final Long projectId, final boolean enabledOnly) {
         if (accountName != null) {
             if (domainId == null) {
                 throw new InvalidParameterValueException("Account must be specified with domainId parameter");
             }
 
-            Domain domain = _domainService.getDomain(domainId);
+            final Domain domain = _domainService.getDomain(domainId);
             if (domain == null) {
                 throw new InvalidParameterValueException("Unable to find domain by id");
             }
 
-            Account account = _accountService.getActiveAccountByName(accountName, domainId);
+            final Account account = _accountService.getActiveAccountByName(accountName, domainId);
             if (account != null && account.getType() != Account.ACCOUNT_TYPE_PROJECT) {
                 if (!enabledOnly || account.getState() == Account.State.enabled) {
                     return account.getId();
@@ -394,12 +412,12 @@ public abstract class BaseCmd {
         }
 
         if (projectId != null) {
-            Project project = _projectService.getProject(projectId);
+            final Project project = _projectService.getProject(projectId);
             if (project != null) {
                 if (!enabledOnly || project.getState() == Project.State.Active) {
                     return project.getProjectAccountId();
                 } else {
-                    PermissionDeniedException ex =
+                    final PermissionDeniedException ex =
                         new PermissionDeniedException("Can't add resources to the project with specified projectId in state=" + project.getState() +
                             " as it's no longer active");
                     ex.addProxyObject(project.getUuid(), "projectId");
@@ -413,6 +431,13 @@ public abstract class BaseCmd {
     }
 
     /**
+     * To be overwritten by any class who needs specific validation
+     */
+    public void validateSpecificParameters(final Map<String, String> params){
+        // To be overwritten by any class who needs specific validation
+    }
+
+    /**
      * display flag is used to control the display of the resource only to the end user. It doesnt affect Root Admin.
      * @return display flag
      */

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/api/src/org/apache/cloudstack/api/BaseListCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseListCmd.java b/api/src/org/apache/cloudstack/api/BaseListCmd.java
index c1a4b4c..f280003 100644
--- a/api/src/org/apache/cloudstack/api/BaseListCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseListCmd.java
@@ -16,7 +16,10 @@
 // under the License.
 package org.apache.cloudstack.api;
 
+import java.util.Map;
+
 import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.utils.exception.CSExceptionErrorCode;
 
 public abstract class BaseListCmd extends BaseCmd {
 
@@ -83,7 +86,7 @@ public abstract class BaseListCmd extends BaseCmd {
 
     public Long getPageSizeVal() {
         Long defaultPageSize = s_maxPageSize;
-        Integer pageSizeInt = getPageSize();
+        final Integer pageSizeInt = getPageSize();
         if (pageSizeInt != null) {
             defaultPageSize = pageSizeInt.longValue();
         }
@@ -96,12 +99,12 @@ public abstract class BaseListCmd extends BaseCmd {
 
     public Long getStartIndex() {
         Long startIndex = Long.valueOf(0);
-        Long pageSizeVal = getPageSizeVal();
+        final Long pageSizeVal = getPageSizeVal();
 
         if (pageSizeVal == null) {
             startIndex = null;
         } else if (page != null) {
-            int pageNum = page.intValue();
+            final int pageNum = page.intValue();
             if (pageNum > 0) {
                 startIndex = Long.valueOf(pageSizeVal * (pageNum - 1));
             }
@@ -112,4 +115,25 @@ public abstract class BaseListCmd extends BaseCmd {
     public ApiCommandJobType getInstanceType() {
         return ApiCommandJobType.None;
     }
+
+    @Override
+    public void validateSpecificParameters(final Map<String, String> params){
+        super.validateSpecificParameters(params);
+
+        final Object pageSizeObj = params.get(ApiConstants.PAGE_SIZE);
+        Long pageSize = null;
+        if (pageSizeObj != null) {
+            pageSize = Long.valueOf((String)pageSizeObj);
+        }
+
+        if (params.get(ApiConstants.PAGE) == null &&
+                pageSize != null &&
+                !pageSize.equals(BaseListCmd.s_pageSizeUnlimited)) {
+            final ServerApiException ex = new ServerApiException(ApiErrorCode.PARAM_ERROR, "\"page\" parameter is required when \"pagesize\" is specified");
+            ex.setCSErrorCode(CSExceptionErrorCode.getCSErrCode(ex.getClass().getName()));
+            throw ex;
+        } else if (pageSize == null && (params.get(ApiConstants.PAGE) != null)) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "\"pagesize\" parameter is required when \"page\" is specified");
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/api/test/org/apache/cloudstack/api/BaseCmdTest.java
----------------------------------------------------------------------
diff --git a/api/test/org/apache/cloudstack/api/BaseCmdTest.java b/api/test/org/apache/cloudstack/api/BaseCmdTest.java
new file mode 100644
index 0000000..edf5776
--- /dev/null
+++ b/api/test/org/apache/cloudstack/api/BaseCmdTest.java
@@ -0,0 +1,69 @@
+// 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;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+
+public class BaseCmdTest {
+
+    private static final String NON_EXPECTED_COMMAND_NAME = "Non expected command name";
+    protected static final String CMD1_NAME = "Cmd1Name";
+    protected static final String CMD2_NAME = "Cmd2Name";
+    protected static final String CMD1_RESPONSE = "cmd1response";
+    protected static final String CMD2_RESPONSE = "cmd2response";
+
+    @Test
+    public void testGetActualCommandName(){
+        BaseCmd cmd1 = new Cmd1();
+        BaseCmd cmd2 = new Cmd2();
+
+        assertEquals(NON_EXPECTED_COMMAND_NAME, CMD1_NAME, cmd1.getActualCommandName());
+        assertEquals(NON_EXPECTED_COMMAND_NAME, CMD2_NAME, cmd2.getActualCommandName());
+    }
+}
+
+@APICommand(name=BaseCmdTest.CMD1_NAME, responseObject=BaseResponse.class)
+class Cmd1 extends BaseCmd {
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException,
+            NetworkRuleConflictException {
+    }
+    @Override
+    public String getCommandName() {
+        return BaseCmdTest.CMD1_RESPONSE;
+    }
+    @Override
+    public long getEntityOwnerId() {
+        return 0;
+    }
+}
+
+@APICommand(name=BaseCmdTest.CMD2_NAME, responseObject=BaseResponse.class)
+class Cmd2 extends Cmd1 {
+    @Override
+    public String getCommandName() {
+        return BaseCmdTest.CMD2_RESPONSE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/resources/META-INF/cloudstack/core/spring-server-core-misc-context.xml
----------------------------------------------------------------------
diff --git a/server/resources/META-INF/cloudstack/core/spring-server-core-misc-context.xml b/server/resources/META-INF/cloudstack/core/spring-server-core-misc-context.xml
index fd2f5fb..91401e3 100644
--- a/server/resources/META-INF/cloudstack/core/spring-server-core-misc-context.xml
+++ b/server/resources/META-INF/cloudstack/core/spring-server-core-misc-context.xml
@@ -50,6 +50,18 @@
 
     <bean id="apiDispatcher" class="com.cloud.api.ApiDispatcher" />
 
+    <bean id="dispatchChainFactory" class="com.cloud.api.dispatch.DispatchChainFactory" />
+
+    <bean id="paramProcessWorker" class="com.cloud.api.dispatch.ParamProcessWorker" />
+
+    <bean id="paramUnpackWorker" class="com.cloud.api.dispatch.ParamUnpackWorker" />
+
+    <bean id="paramGenericValidationWorker" class="com.cloud.api.dispatch.ParamGenericValidationWorker" />
+
+    <bean id="specificCmdValidationWorker" class="com.cloud.api.dispatch.SpecificCmdValidationWorker" />
+
+    <bean id="commandCreationWorker" class="com.cloud.api.dispatch.CommandCreationWorker" />
+
     <bean id="apiResponseHelper" class="com.cloud.api.ApiResponseHelper" />
 
     <bean id="apiServer" class="com.cloud.api.ApiServer">

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/src/com/cloud/api/ApiDispatcher.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java
index 5bdefe7..5d4b4d3 100755
--- a/server/src/com/cloud/api/ApiDispatcher.java
+++ b/server/src/com/cloud/api/ApiDispatcher.java
@@ -16,127 +16,72 @@
 // under the License.
 package com.cloud.api;
 
-import static org.apache.commons.lang.StringUtils.isNotBlank;
-
-import java.lang.reflect.Field;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.regex.Matcher;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
 
-import org.apache.cloudstack.acl.ControlledEntity;
-import org.apache.cloudstack.acl.InfrastructureEntity;
-import org.apache.cloudstack.acl.RoleType;
-import org.apache.cloudstack.acl.SecurityChecker.AccessType;
-import org.apache.cloudstack.api.ACL;
 import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.BaseAsyncCreateCmd;
 import org.apache.cloudstack.api.BaseAsyncCustomIdCmd;
 import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.BaseCmd.CommandType;
 import org.apache.cloudstack.api.BaseCustomIdCmd;
-import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.EntityReference;
-import org.apache.cloudstack.api.InternalIdentity;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.command.admin.resource.ArchiveAlertsCmd;
-import org.apache.cloudstack.api.command.admin.resource.DeleteAlertsCmd;
-import org.apache.cloudstack.api.command.user.event.ArchiveEventsCmd;
-import org.apache.cloudstack.api.command.user.event.DeleteEventsCmd;
-import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.framework.jobs.AsyncJob;
 import org.apache.cloudstack.framework.jobs.AsyncJobManager;
 import org.apache.log4j.Logger;
 
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.user.Account;
-import com.cloud.user.AccountManager;
-import com.cloud.utils.DateUtil;
-import com.cloud.utils.ReflectUtil;
-import com.cloud.utils.db.EntityManager;
-import com.cloud.utils.exception.CSExceptionErrorCode;
-import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.api.dispatch.DispatchChain;
+import com.cloud.api.dispatch.DispatchChainFactory;
+import com.cloud.api.dispatch.DispatchTask;
 
 public class ApiDispatcher {
     private static final Logger s_logger = Logger.getLogger(ApiDispatcher.class.getName());
 
     Long _createSnapshotQueueSizeLimit;
+
     @Inject
-    AsyncJobManager _asyncMgr = null;
-    @Inject
-    AccountManager _accountMgr = null;
-    @Inject
-    EntityManager _entityMgr = null;
+    AsyncJobManager _asyncMgr;
 
-    private static ApiDispatcher s_instance;
+    @Inject()
+    protected DispatchChainFactory dispatchChainFactory;
 
-    public static ApiDispatcher getInstance() {
-        return s_instance;
-    }
+    protected DispatchChain standardDispatchChain;
+
+    protected DispatchChain asyncCreationDispatchChain;
 
     public ApiDispatcher() {
     }
 
     @PostConstruct
-    void init() {
-        s_instance = this;
+    public void setup() {
+        standardDispatchChain = dispatchChainFactory.getStandardDispatchChain();
+        asyncCreationDispatchChain = dispatchChainFactory.getAsyncCreationDispatchChain();
     }
 
-    public void setCreateSnapshotQueueSizeLimit(Long snapshotLimit) {
+    public void setCreateSnapshotQueueSizeLimit(final Long snapshotLimit) {
         _createSnapshotQueueSizeLimit = snapshotLimit;
     }
 
-    public void dispatchCreateCmd(BaseAsyncCreateCmd cmd, Map<String, String> params) throws Exception {
-        processParameters(cmd, params);
-        CallContext.current().setEventDisplayEnabled(cmd.isDisplayResourceEnabled());
-        cmd.create();
 
+    public void dispatchCreateCmd(final BaseAsyncCreateCmd cmd, final Map<String, String> params) throws Exception {
+        asyncCreationDispatchChain.dispatch(new DispatchTask(cmd, params));
+        CallContext.current().setEventDisplayEnabled(cmd.isDisplayResourceEnabled());
     }
 
-    private void doAccessChecks(BaseCmd cmd, Map<Object, AccessType> entitiesToAccess) {
-        Account caller = CallContext.current().getCallingAccount();
-        Account owner = _accountMgr.getActiveAccountById(cmd.getEntityOwnerId());
+    public void dispatch(final BaseCmd cmd, final Map<String, String> params, final boolean execute) throws Exception {
+        // Let the chain of responsibility dispatch gradually
+        standardDispatchChain.dispatch(new DispatchTask(cmd, params));
 
-        if (cmd instanceof BaseAsyncCreateCmd) {
-            //check that caller can access the owner account.
-            _accountMgr.checkAccess(caller, null, true, owner);
-        }
-
-        if (!entitiesToAccess.isEmpty()) {
-            //check that caller can access the owner account.
-            _accountMgr.checkAccess(caller, null, true, owner);
-            for (Object entity : entitiesToAccess.keySet()) {
-                if (entity instanceof ControlledEntity) {
-                    _accountMgr.checkAccess(caller, entitiesToAccess.get(entity), true, (ControlledEntity)entity);
-                } else if (entity instanceof InfrastructureEntity) {
-                    //FIXME: Move this code in adapter, remove code from Account manager
-                }
-            }
-        }
-    }
-
-    public void dispatch(BaseCmd cmd, Map<String, String> params, boolean execute) throws Exception {
-        processParameters(cmd, params);
-        CallContext ctx = CallContext.current();
+        final CallContext ctx = CallContext.current();
         ctx.setEventDisplayEnabled(cmd.isDisplayResourceEnabled());
 
+        // TODO This if shouldn't be here. Use polymorphism and move it to validateSpecificParameters
         if (cmd instanceof BaseAsyncCmd) {
 
-            BaseAsyncCmd asyncCmd = (BaseAsyncCmd)cmd;
-            String startEventId = params.get("ctxStartEventId");
+            final BaseAsyncCmd asyncCmd = (BaseAsyncCmd)cmd;
+            final String startEventId = params.get(ApiConstants.CTX_START_EVENT_ID);
             ctx.setStartEventId(Long.valueOf(startEventId));
 
             // Synchronise job on the object if needed
@@ -160,6 +105,7 @@ public class ApiDispatcher {
             }
         }
 
+        // TODO This if shouldn't be here. Use polymorphism and move it to validateSpecificParameters
         if (cmd instanceof BaseAsyncCustomIdCmd) {
             ((BaseAsyncCustomIdCmd)cmd).checkUuid();
         } else if (cmd instanceof BaseCustomIdCmd) {
@@ -167,392 +113,6 @@ public class ApiDispatcher {
         }
 
         cmd.execute();
-
     }
 
-    @SuppressWarnings({"unchecked", "rawtypes"})
-    public static void processParameters(BaseCmd cmd, Map<String, String> params) {
-        Map<Object, AccessType> entitiesToAccess = new HashMap<Object, AccessType>();
-        Map<String, Object> unpackedParams = cmd.unpackParams(params);
-
-        if (cmd instanceof BaseListCmd) {
-            Object pageSizeObj = unpackedParams.get(ApiConstants.PAGE_SIZE);
-            Long pageSize = null;
-            if (pageSizeObj != null) {
-                pageSize = Long.valueOf((String)pageSizeObj);
-            }
-
-            if ((unpackedParams.get(ApiConstants.PAGE) == null) && (pageSize != null && !pageSize.equals(BaseListCmd.s_pageSizeUnlimited))) {
-                ServerApiException ex = new ServerApiException(ApiErrorCode.PARAM_ERROR, "\"page\" parameter is required when \"pagesize\" is specified");
-                ex.setCSErrorCode(CSExceptionErrorCode.getCSErrCode(ex.getClass().getName()));
-                throw ex;
-            } else if (pageSize == null && (unpackedParams.get(ApiConstants.PAGE) != null)) {
-                throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "\"pagesize\" parameter is required when \"page\" is specified");
-            }
-        }
-
-        List<Field> fields = ReflectUtil.getAllFieldsForClass(cmd.getClass(), BaseCmd.class);
-
-        for (Field field : fields) {
-            Parameter parameterAnnotation = field.getAnnotation(Parameter.class);
-            if ((parameterAnnotation == null) || !parameterAnnotation.expose()) {
-                continue;
-            }
-
-            //TODO: Annotate @Validate on API Cmd classes, FIXME how to process Validate
-            RoleType[] allowedRoles = parameterAnnotation.authorized();
-            if (allowedRoles.length > 0) {
-                boolean permittedParameter = false;
-                Account caller = CallContext.current().getCallingAccount();
-                for (RoleType allowedRole : allowedRoles) {
-                    if (allowedRole.getValue() == caller.getType()) {
-                        permittedParameter = true;
-                        break;
-                    }
-                }
-                if (!permittedParameter) {
-                    s_logger.debug("Ignoring paremeter " + parameterAnnotation.name() + " as the caller is not authorized to pass it in");
-                    continue;
-                }
-            }
-
-            Object paramObj = unpackedParams.get(parameterAnnotation.name());
-            if (paramObj == null) {
-                if (parameterAnnotation.required()) {
-                    throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to execute API command " +
-                        cmd.getCommandName().substring(0, cmd.getCommandName().length() - 8) + " due to missing parameter " + parameterAnnotation.name());
-                }
-                continue;
-            }
-
-            // marshall the parameter into the correct type and set the field value
-            try {
-                setFieldValue(field, cmd, paramObj, parameterAnnotation);
-            } catch (IllegalArgumentException argEx) {
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Unable to execute API command " + cmd.getCommandName() + " due to invalid value " + paramObj + " for parameter " +
-                        parameterAnnotation.name());
-                }
-                throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to execute API command " +
-                    cmd.getCommandName().substring(0, cmd.getCommandName().length() - 8) + " due to invalid value " + paramObj + " for parameter " +
-                    parameterAnnotation.name());
-            } catch (ParseException parseEx) {
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Invalid date parameter " + paramObj + " passed to command " + cmd.getCommandName().substring(0, cmd.getCommandName().length() - 8));
-                }
-                throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to parse date " + paramObj + " for command " +
-                    cmd.getCommandName().substring(0, cmd.getCommandName().length() - 8) + ", please pass dates in the format mentioned in the api documentation");
-            } catch (InvalidParameterValueException invEx) {
-                throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to execute API command " +
-                    cmd.getCommandName().substring(0, cmd.getCommandName().length() - 8) + " due to invalid value. " + invEx.getMessage());
-            } catch (CloudRuntimeException cloudEx) {
-                s_logger.error("CloudRuntimeException", cloudEx);
-                // FIXME: Better error message? This only happens if the API command is not executable, which typically
-                //means
-                // there was
-                // and IllegalAccessException setting one of the parameters.
-                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Internal error executing API command " +
-                    cmd.getCommandName().substring(0, cmd.getCommandName().length() - 8));
-            }
-
-            //check access on the resource this field points to
-            try {
-                ACL checkAccess = field.getAnnotation(ACL.class);
-                CommandType fieldType = parameterAnnotation.type();
-
-                if (checkAccess != null) {
-                    // Verify that caller can perform actions in behalf of vm owner
-                    //acumulate all Controlled Entities together.
-
-                    //parse the array of resource types and in case of map check access on key or value or both as specified in @acl
-                    //implement external dao for classes that need findByName
-                    //for maps, specify access to be checkd on key or value.
-
-                    // find the controlled entity DBid by uuid
-                    if (parameterAnnotation.entityType() != null) {
-                        Class<?>[] entityList = parameterAnnotation.entityType()[0].getAnnotation(EntityReference.class).value();
-
-                        for (Class entity : entityList) {
-                            // Check if the parameter type is a single
-                            // Id or list of id's/name's
-                            switch (fieldType) {
-                                case LIST:
-                                    CommandType listType = parameterAnnotation.collectionType();
-                                    switch (listType) {
-                                        case LONG:
-                                        case UUID:
-                                            List<Long> listParam = (List<Long>)field.get(cmd);
-                                            for (Long entityId : listParam) {
-                                                Object entityObj = s_instance._entityMgr.findById(entity, entityId);
-                                                entitiesToAccess.put(entityObj, checkAccess.accessType());
-                                            }
-                                            break;
-                                        /*
-                                         * case STRING: List<String> listParam =
-                                         * new ArrayList<String>(); listParam =
-                                         * (List)field.get(cmd); for(String
-                                         * entityName: listParam){
-                                         * ControlledEntity entityObj =
-                                         * (ControlledEntity
-                                         * )daoClassInstance(entityId);
-                                         * entitiesToAccess.add(entityObj); }
-                                         * break;
-                                         */
-                                        default:
-                                            break;
-                                    }
-                                    break;
-                                case LONG:
-                                case UUID:
-                                    Object entityObj = s_instance._entityMgr.findById(entity, (Long)field.get(cmd));
-                                    entitiesToAccess.put(entityObj, checkAccess.accessType());
-                                    break;
-                                default:
-                                    break;
-                            }
-
-                            if (ControlledEntity.class.isAssignableFrom(entity)) {
-                                if (s_logger.isDebugEnabled()) {
-                                    s_logger.debug("ControlledEntity name is:" + entity.getName());
-                                }
-                            }
-
-                            if (InfrastructureEntity.class.isAssignableFrom(entity)) {
-                                if (s_logger.isDebugEnabled()) {
-                                    s_logger.debug("InfrastructureEntity name is:" + entity.getName());
-                                }
-                            }
-                        }
-
-                    }
-
-                }
-
-            } catch (IllegalArgumentException e) {
-                s_logger.error("Error initializing command " + cmd.getCommandName() + ", field " + field.getName() + " is not accessible.");
-                throw new CloudRuntimeException("Internal error initializing parameters for command " + cmd.getCommandName() + " [field " + field.getName() +
-                    " is not accessible]");
-            } catch (IllegalAccessException e) {
-                s_logger.error("Error initializing command " + cmd.getCommandName() + ", field " + field.getName() + " is not accessible.");
-                throw new CloudRuntimeException("Internal error initializing parameters for command " + cmd.getCommandName() + " [field " + field.getName() +
-                    " is not accessible]");
-            }
-
-        }
-
-        //check access on the entities.
-        getInstance().doAccessChecks(cmd, entitiesToAccess);
-
-    }
-
-    private static Long translateUuidToInternalId(String uuid, Parameter annotation) {
-        if (uuid.equals("-1")) {
-            // FIXME: This is to handle a lot of hardcoded special cases where -1 is sent
-            // APITODO: Find and get rid of all hardcoded params in API Cmds and service layer
-            return -1L;
-        }
-        Long internalId = null;
-        // If annotation's empty, the cmd existed before 3.x try conversion to long
-        boolean isPre3x = annotation.since().isEmpty();
-        // Match against Java's UUID regex to check if input is uuid string
-        boolean isUuid = uuid.matches("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$");
-        // Enforce that it's uuid for newly added apis from version 3.x
-        if (!isPre3x && !isUuid)
-            return null;
-        // Allow both uuid and internal id for pre3x apis
-        if (isPre3x && !isUuid) {
-            try {
-                internalId = Long.parseLong(uuid);
-            } catch (NumberFormatException e) {
-                internalId = null;
-            }
-            if (internalId != null)
-                return internalId;
-        }
-        // There may be multiple entities defined on the @EntityReference of a Response.class
-        // UUID CommandType would expect only one entityType, so use the first entityType
-        Class<?>[] entities = annotation.entityType()[0].getAnnotation(EntityReference.class).value();
-        // Go through each entity which is an interface to a VO class and get a VO object
-        // Try to getId() for the object using reflection, break on first non-null value
-        for (Class<?> entity : entities) {
-            // For backward compatibility, we search within removed entities and let service layer deal
-            // with removed ones, return empty response or error
-            Object objVO = s_instance._entityMgr.findByUuidIncludingRemoved(entity, uuid);
-            if (objVO == null) {
-                continue;
-            }
-            // Invoke the getId method, get the internal long ID
-            // If that fails hide exceptions as the uuid may not exist
-            try {
-                internalId = ((InternalIdentity)objVO).getId();
-            } catch (IllegalArgumentException e) {
-            } catch (NullPointerException e) {
-            }
-            // Return on first non-null Id for the uuid entity
-            if (internalId != null)
-                break;
-        }
-        if (internalId == null) {
-            if (s_logger.isDebugEnabled())
-                s_logger.debug("Object entity uuid = " + uuid + " does not exist in the database.");
-            throw new InvalidParameterValueException("Invalid parameter " + annotation.name() + " value=" + uuid +
-                " due to incorrect long value format, or entity does not exist or due to incorrect parameter annotation for the field in api cmd class.");
-        }
-        return internalId;
-    }
-
-    @SuppressWarnings({"unchecked", "rawtypes"})
-    private static void setFieldValue(Field field, BaseCmd cmdObj, Object paramObj, Parameter annotation) throws IllegalArgumentException, ParseException {
-        try {
-            field.setAccessible(true);
-            CommandType fieldType = annotation.type();
-            switch (fieldType) {
-                case BOOLEAN:
-                    field.set(cmdObj, Boolean.valueOf(paramObj.toString()));
-                    break;
-                case DATE:
-                    // This piece of code is for maintaining backward compatibility
-                    // and support both the date formats(Bug 9724)
-                    // Do the date messaging for ListEventsCmd only
-                    if (cmdObj instanceof ListEventsCmd || cmdObj instanceof DeleteEventsCmd || cmdObj instanceof ArchiveEventsCmd ||
-                        cmdObj instanceof ArchiveAlertsCmd || cmdObj instanceof DeleteAlertsCmd) {
-                        boolean isObjInNewDateFormat = isObjInNewDateFormat(paramObj.toString());
-                        if (isObjInNewDateFormat) {
-                            DateFormat newFormat = BaseCmd.NEW_INPUT_FORMAT;
-                            synchronized (newFormat) {
-                                field.set(cmdObj, newFormat.parse(paramObj.toString()));
-                            }
-                        } else {
-                            DateFormat format = BaseCmd.INPUT_FORMAT;
-                            synchronized (format) {
-                                Date date = format.parse(paramObj.toString());
-                                if (field.getName().equals("startDate")) {
-                                    date = messageDate(date, 0, 0, 0);
-                                } else if (field.getName().equals("endDate")) {
-                                    date = messageDate(date, 23, 59, 59);
-                                }
-                                field.set(cmdObj, date);
-                            }
-                        }
-                    } else {
-                        DateFormat format = BaseCmd.INPUT_FORMAT;
-                        synchronized (format) {
-                        format.setLenient(false);
-                            field.set(cmdObj, format.parse(paramObj.toString()));
-                        }
-                    }
-                    break;
-                case FLOAT:
-                    // Assuming that the parameters have been checked for required before now,
-                    // we ignore blank or null values and defer to the command to set a default
-                    // value for optional parameters ...
-                    if (paramObj != null && isNotBlank(paramObj.toString())) {
-                        field.set(cmdObj, Float.valueOf(paramObj.toString()));
-                    }
-                    break;
-                case INTEGER:
-                    // Assuming that the parameters have been checked for required before now,
-                    // we ignore blank or null values and defer to the command to set a default
-                    // value for optional parameters ...
-                    if (paramObj != null && isNotBlank(paramObj.toString())) {
-                        field.set(cmdObj, Integer.valueOf(paramObj.toString()));
-                    }
-                    break;
-                case LIST:
-                    List listParam = new ArrayList();
-                    StringTokenizer st = new StringTokenizer(paramObj.toString(), ",");
-                    while (st.hasMoreTokens()) {
-                        String token = st.nextToken();
-                        CommandType listType = annotation.collectionType();
-                        switch (listType) {
-                            case INTEGER:
-                                listParam.add(Integer.valueOf(token));
-                                break;
-                            case UUID:
-                                if (token.isEmpty())
-                                    break;
-                                Long internalId = translateUuidToInternalId(token, annotation);
-                                listParam.add(internalId);
-                                break;
-                            case LONG: {
-                                listParam.add(Long.valueOf(token));
-                            }
-                                break;
-                            case SHORT:
-                                listParam.add(Short.valueOf(token));
-                            case STRING:
-                                listParam.add(token);
-                                break;
-                        }
-                    }
-                    field.set(cmdObj, listParam);
-                    break;
-                case UUID:
-                    if (paramObj.toString().isEmpty())
-                        break;
-                    Long internalId = translateUuidToInternalId(paramObj.toString(), annotation);
-                    field.set(cmdObj, internalId);
-                    break;
-                case LONG:
-                    field.set(cmdObj, Long.valueOf(paramObj.toString()));
-                    break;
-                case SHORT:
-                    field.set(cmdObj, Short.valueOf(paramObj.toString()));
-                    break;
-                case STRING:
-                    if ((paramObj != null) && paramObj.toString().length() > annotation.length()) {
-                        s_logger.error("Value greater than max allowed length " + annotation.length() + " for param: " + field.getName());
-                        throw new InvalidParameterValueException("Value greater than max allowed length " + annotation.length() + " for param: " + field.getName());
-                    }
-                    field.set(cmdObj, paramObj.toString());
-                    break;
-                case TZDATE:
-                    field.set(cmdObj, DateUtil.parseTZDateString(paramObj.toString()));
-                    break;
-                case MAP:
-                default:
-                    field.set(cmdObj, paramObj);
-                    break;
-            }
-        } catch (IllegalAccessException ex) {
-            s_logger.error("Error initializing command " + cmdObj.getCommandName() + ", field " + field.getName() + " is not accessible.");
-            throw new CloudRuntimeException("Internal error initializing parameters for command " + cmdObj.getCommandName() + " [field " + field.getName() +
-                " is not accessible]");
-        }
-    }
-
-    private static boolean isObjInNewDateFormat(String string) {
-        Matcher matcher = BaseCmd.newInputDateFormat.matcher(string);
-        return matcher.matches();
-    }
-
-    private static Date messageDate(Date date, int hourOfDay, int minute, int second) {
-        Calendar cal = Calendar.getInstance();
-        cal.setTime(date);
-        cal.set(Calendar.HOUR_OF_DAY, hourOfDay);
-        cal.set(Calendar.MINUTE, minute);
-        cal.set(Calendar.SECOND, second);
-        return cal.getTime();
-    }
-
-    public static void plugService(Field field, BaseCmd cmd) {
-
-        Class<?> fc = field.getType();
-        Object instance = null;
-
-        if (instance == null) {
-            throw new CloudRuntimeException("Unable to plug service " + fc.getSimpleName() + " in command " + cmd.getClass().getSimpleName());
-        }
-
-        try {
-            field.setAccessible(true);
-            field.set(cmd, instance);
-        } catch (IllegalArgumentException e) {
-            s_logger.error("IllegalArgumentException at plugService for command " + cmd.getCommandName() + ", field " + field.getName());
-            throw new CloudRuntimeException("Internal error at plugService for command " + cmd.getCommandName() + " [Illegal argumet at field " + field.getName() + "]");
-        } catch (IllegalAccessException e) {
-            s_logger.error("Error at plugService for command " + cmd.getCommandName() + ", field " + field.getName() + " is not accessible.");
-            throw new CloudRuntimeException("Internal error at plugService for command " + cmd.getCommandName() + " [field " + field.getName() + " is not accessible]");
-        }
-    }
 }


[24/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-6205: VPC VR start - when create guest nics for the VR, consider networks not only in Implemented state, but in Setup state as well


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

Branch: refs/heads/resize-root
Commit: d1c0b81dc1b11b1039627d0c400e9e6bfc70d2a8
Parents: 922cdc0
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Wed Mar 5 15:38:45 2014 -0800
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Wed Mar 5 15:39:34 2014 -0800

----------------------------------------------------------------------
 .../network/router/VpcVirtualNetworkApplianceManagerImpl.java      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1c0b81d/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
index f6bd9e1..bed30df 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -1178,7 +1178,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         //3) allocate nic for guest gateway if needed
         List<? extends Network> guestNetworks = _vpcMgr.getVpcNetworks(vpcId);
         for (Network guestNetwork : guestNetworks) {
-            if (guestNetwork.getState() == Network.State.Implemented) {
+            if (guestNetwork.getState() == Network.State.Implemented || guestNetwork.getState() == Network.State.Setup) {
                 NicProfile guestNic = createGuestNicProfileForVpcRouter(guestNetwork);
                 networks.put(guestNetwork, new ArrayList<NicProfile>(Arrays.asList(guestNic)));
             }


[30/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
Refactor DbUpgradeUtils

  - Move database access code to new class DatabaseAccessObject.
    This was done to ease the effort of testing, since
    DbUpgradeUtils has a static API and it is harder to mock
    static things with Mockito.
  - Log exceptions even if ignored
  - Add unit tests for both DbUpgradeUtils and DatabaseAccessObject
  - DbUpgradeUtils.dropTableColumnsIfExist(...) no longer throws
CloudRuntimeException to make it consistent with the other methods in
the class

Signed-off-by: Daan Hoogland <da...@onecht.net>


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

Branch: refs/heads/resize-root
Commit: ea0dec77d98e14e47ca715c46cd0316faa37844c
Parents: 370554e
Author: miguelaferreira <mf...@shubergphilis.com>
Authored: Tue Mar 4 16:41:20 2014 +0100
Committer: Daan Hoogland <da...@onecht.net>
Committed: Thu Mar 6 14:48:35 2014 +0100

----------------------------------------------------------------------
 .../cloud/upgrade/dao/DatabaseAccessObject.java |  99 ++++
 .../com/cloud/upgrade/dao/DbUpgradeUtils.java   |  76 +--
 .../upgrade/dao/DatabaseAccessObjectTest.java   | 463 +++++++++++++++++++
 .../cloud/upgrade/dao/DbUpgradeUtilsTest.java   | 162 +++++++
 4 files changed, 732 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ea0dec77/engine/schema/src/com/cloud/upgrade/dao/DatabaseAccessObject.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/DatabaseAccessObject.java b/engine/schema/src/com/cloud/upgrade/dao/DatabaseAccessObject.java
new file mode 100644
index 0000000..836a537
--- /dev/null
+++ b/engine/schema/src/com/cloud/upgrade/dao/DatabaseAccessObject.java
@@ -0,0 +1,99 @@
+// 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 com.cloud.upgrade.dao;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import org.apache.log4j.Logger;
+
+public class DatabaseAccessObject {
+
+    private static Logger s_logger = Logger.getLogger(DatabaseAccessObject.class);
+
+    public void dropKey(Connection conn, String tableName, String key, boolean isForeignKey) {
+        PreparedStatement pstmt = null;
+        try {
+            if (isForeignKey) {
+                pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP FOREIGN KEY " + key);
+            } else {
+                pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP KEY " + key);
+            }
+            pstmt.executeUpdate();
+            s_logger.debug("Key " + key + " is dropped successfully from the table " + tableName);
+        } catch (SQLException e) {
+            s_logger.warn("Ignored SQL Exception when trying to drop " + (isForeignKey ? "foreign " : "") + "key " + key + " on table " + tableName, e);
+        } finally {
+            closePreparedStatement(pstmt, "Ignored SQL Exception when trying to close PreparedStatement atfer dropping " + (isForeignKey ? "foreign " : "") + "key " + key
+                    + " on table " + tableName);
+        }
+    }
+
+    public void dropPrimaryKey(Connection conn, String tableName) {
+        PreparedStatement pstmt = null;
+        try {
+            pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP PRIMARY KEY ");
+            pstmt.executeUpdate();
+            s_logger.debug("Primary key is dropped successfully from the table " + tableName);
+        } catch (SQLException e) {
+            s_logger.warn("Ignored SQL Exception when trying to drop primary key on table " + tableName, e);
+        } finally {
+            closePreparedStatement(pstmt, "Ignored SQL Exception when trying to close PreparedStatement atfer dropping primary key on table " + tableName);
+        }
+    }
+
+    public void dropColumn(Connection conn, String tableName, String columnName) {
+        PreparedStatement pstmt = null;
+        try {
+            pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP COLUMN " + columnName);
+            pstmt.executeUpdate();
+            s_logger.debug("Column " + columnName + " is dropped successfully from the table " + tableName);
+        } catch (SQLException e) {
+            s_logger.warn("Unable to drop columns using query " + pstmt + " due to exception", e);
+        } finally {
+            closePreparedStatement(pstmt, "Ignored SQL Exception when trying to close PreparedStatement after dropping column " + columnName + " on table " + tableName);
+        }
+    }
+
+    public boolean columnExists(Connection conn, String tableName, String columnName) {
+        boolean columnExists = false;
+        PreparedStatement pstmt = null;
+        try {
+            pstmt = conn.prepareStatement("SELECT " + columnName + " FROM " + tableName);
+            pstmt.executeQuery();
+            columnExists = true;
+        } catch (SQLException e) {
+            s_logger.warn("Field " + columnName + " doesn't exist in " + tableName, e);
+        } finally {
+            closePreparedStatement(pstmt, "Ignored SQL Exception when trying to close PreparedStatement atfer checking if column " + columnName + " existed on table " + tableName);
+        }
+
+        return columnExists;
+    }
+
+    protected static void closePreparedStatement(PreparedStatement pstmt, String errorMessage) {
+        try {
+            if (pstmt != null) {
+                pstmt.close();
+            }
+        } catch (SQLException e) {
+            s_logger.warn(errorMessage, e);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ea0dec77/engine/schema/src/com/cloud/upgrade/dao/DbUpgradeUtils.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/DbUpgradeUtils.java b/engine/schema/src/com/cloud/upgrade/dao/DbUpgradeUtils.java
index af23b87..38ca5c9 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/DbUpgradeUtils.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/DbUpgradeUtils.java
@@ -17,88 +17,28 @@
 package com.cloud.upgrade.dao;
 
 import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
 import java.util.List;
 
-import org.apache.log4j.Logger;
-
-import com.cloud.utils.exception.CloudRuntimeException;
-
 public class DbUpgradeUtils {
-    final static Logger s_logger = Logger.getLogger(DbUpgradeUtils.class);
+
+    private static DatabaseAccessObject dao = new DatabaseAccessObject();
 
     public static void dropKeysIfExist(Connection conn, String tableName, List<String> keys, boolean isForeignKey) {
         for (String key : keys) {
-            PreparedStatement pstmt = null;
-            try {
-                if (isForeignKey) {
-                    pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP FOREIGN KEY " + key);
-                } else {
-                    pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP KEY " + key);
-                }
-                pstmt.executeUpdate();
-                s_logger.debug("Key " + key + " is dropped successfully from the table " + tableName);
-            } catch (SQLException e) {
-                // do nothing here
-
-                continue;
-            } finally {
-                try {
-                    if (pstmt != null) {
-                        pstmt.close();
-                    }
-                } catch (SQLException e) {
-                }
-            }
+            dao.dropKey(conn, tableName, key, isForeignKey);
         }
     }
 
     public static void dropPrimaryKeyIfExists(Connection conn, String tableName) {
-        PreparedStatement pstmt = null;
-        try {
-            pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP PRIMARY KEY ");
-            pstmt.executeUpdate();
-            s_logger.debug("Primary key is dropped successfully from the table " + tableName);
-        } catch (SQLException e) {
-            // do nothing here
-        } finally {
-            try {
-                if (pstmt != null) {
-                    pstmt.close();
-                }
-            } catch (SQLException e) {
-            }
-        }
+        dao.dropPrimaryKey(conn, tableName);
     }
 
     public static void dropTableColumnsIfExist(Connection conn, String tableName, List<String> columns) {
-        PreparedStatement pstmt = null;
-        try {
-            for (String column : columns) {
-                try {
-                    pstmt = conn.prepareStatement("SELECT " + column + " FROM " + tableName);
-                    pstmt.executeQuery();
-                } catch (SQLException e) {
-                    // if there is an exception, it means that field doesn't exist, so do nothing here
-                    s_logger.trace("Field " + column + " doesn't exist in " + tableName);
-                    continue;
-                }
-
-                pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP COLUMN " + column);
-                pstmt.executeUpdate();
-                s_logger.debug("Column " + column + " is dropped successfully from the table " + tableName);
-            }
-        } catch (SQLException e) {
-            s_logger.warn("Unable to drop columns using query " + pstmt + " due to exception", e);
-            throw new CloudRuntimeException("Unable to drop columns due to ", e);
-        } finally {
-            try {
-                if (pstmt != null) {
-                    pstmt.close();
-                }
-            } catch (SQLException e) {
+        for (String columnName : columns) {
+            if (dao.columnExists(conn, tableName, columnName)) {
+                dao.dropColumn(conn, tableName, columnName);
             }
         }
     }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ea0dec77/engine/schema/test/com/cloud/upgrade/dao/DatabaseAccessObjectTest.java
----------------------------------------------------------------------
diff --git a/engine/schema/test/com/cloud/upgrade/dao/DatabaseAccessObjectTest.java b/engine/schema/test/com/cloud/upgrade/dao/DatabaseAccessObjectTest.java
new file mode 100644
index 0000000..5d37fbf
--- /dev/null
+++ b/engine/schema/test/com/cloud/upgrade/dao/DatabaseAccessObjectTest.java
@@ -0,0 +1,463 @@
+// 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 com.cloud.upgrade.dao;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.contains;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.internal.util.reflection.Whitebox;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class DatabaseAccessObjectTest {
+
+    @Mock
+    private PreparedStatement preparedStatementMock;
+
+    @Mock
+    private Connection connectionMock;
+
+    @Mock
+    private Logger loggerMock;
+
+    private final DatabaseAccessObject dao = new DatabaseAccessObject();
+
+    @Before
+    public void setup() {
+        Whitebox.setInternalState(dao, "s_logger", loggerMock);
+    }
+
+    @Test
+    public void testDropKey() throws Exception {
+        when(connectionMock.prepareStatement(contains("DROP KEY"))).thenReturn(preparedStatementMock);
+
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String key = "key";
+        boolean isForeignKey = false;
+
+        dao.dropKey(conn, tableName, key, isForeignKey);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(1)).executeUpdate();
+        verify(preparedStatementMock, times(1)).close();
+        verify(loggerMock, times(1)).debug(anyString());
+        verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class));
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testDropKeyWhenConnectionIsNull() throws Exception {
+        Connection conn = null;
+        String tableName = "tableName";
+        String key = "key";
+        boolean isForeignKey = false;
+
+        dao.dropKey(conn, tableName, key, isForeignKey);
+    }
+
+    @Test
+    public void testDropKeyWhenTableNameIsNull() throws Exception {
+        SQLException sqlException = new SQLException();
+        when(connectionMock.prepareStatement(contains("null DROP KEY"))).thenReturn(preparedStatementMock);
+        when(preparedStatementMock.executeUpdate()).thenThrow(sqlException);
+
+        Connection conn = connectionMock;
+        String tableName = null;
+        String key = "key";
+        boolean isForeignKey = false;
+
+        dao.dropKey(conn, tableName, key, isForeignKey);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(1)).executeUpdate();
+        verify(preparedStatementMock, times(1)).close();
+        verify(loggerMock, times(0)).debug(anyString());
+        verify(loggerMock, times(1)).warn(anyString(), eq(sqlException));
+    }
+
+    @Test
+    public void testDropKeyWhenKeyIsNull() throws Exception {
+        SQLException sqlException = new SQLException();
+        when(connectionMock.prepareStatement(contains("DROP KEY null"))).thenReturn(preparedStatementMock);
+        when(preparedStatementMock.executeUpdate()).thenThrow(sqlException);
+
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String key = null;
+        boolean isForeignKey = false;
+
+        dao.dropKey(conn, tableName, key, isForeignKey);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(1)).executeUpdate();
+        verify(preparedStatementMock, times(1)).close();
+        verify(loggerMock, times(0)).debug(anyString());
+        verify(loggerMock, times(1)).warn(anyString(), eq(sqlException));
+    }
+
+    @Test
+    public void testDropKeyWhenKeysAreForeignKeys() throws Exception {
+        when(connectionMock.prepareStatement(contains("DROP FOREIGN KEY"))).thenReturn(preparedStatementMock);
+
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String key = "key";
+        boolean isForeignKey = true;
+
+        dao.dropKey(conn, tableName, key, isForeignKey);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(1)).executeUpdate();
+        verify(preparedStatementMock, times(1)).close();
+        verify(loggerMock, times(1)).debug(anyString());
+        verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class));
+    }
+
+    @Test
+    public void testDropKeyWhenPrepareStatementResultsInException() throws Exception {
+        SQLException sqlException = new SQLException();
+        when(connectionMock.prepareStatement(any(String.class))).thenThrow(sqlException);
+
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String key = "key";
+        boolean isForeignKey = false;
+
+        dao.dropKey(conn, tableName, key, isForeignKey);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(0)).executeUpdate();
+        verify(preparedStatementMock, times(0)).close();
+        verify(loggerMock, times(0)).debug(anyString());
+        verify(loggerMock, times(1)).warn(anyString(), eq(sqlException));
+    }
+
+    @Test
+    public void testDropKeyWhenExecuteUpdateResultsInException() throws Exception {
+        SQLException sqlException = new SQLException();
+        when(connectionMock.prepareStatement(contains("DROP KEY"))).thenReturn(preparedStatementMock);
+        when(preparedStatementMock.executeUpdate()).thenThrow(sqlException);
+
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String key = "key";
+        boolean isForeignKey = false;
+
+        dao.dropKey(conn, tableName, key, isForeignKey);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(1)).executeUpdate();
+        verify(preparedStatementMock, times(1)).close();
+        verify(loggerMock, times(0)).debug(anyString());
+        verify(loggerMock, times(1)).warn(anyString(), eq(sqlException));
+    }
+
+    @SuppressWarnings("static-access")
+    @Test
+    public void testClosePreparedStatementWhenPreparedStatementIsNull() throws Exception {
+        PreparedStatement preparedStatement = null;
+        String errorMessage = "some message";
+
+        dao.closePreparedStatement(preparedStatement, errorMessage);
+
+        verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class));
+    }
+
+    @SuppressWarnings("static-access")
+    @Test
+    public void testClosePreparedStatementWhenPreparedStatementIsNotNullAndThereIsNoException() throws Exception {
+        PreparedStatement preparedStatement = preparedStatementMock;
+        String errorMessage = "some message";
+
+        dao.closePreparedStatement(preparedStatement, errorMessage);
+
+        verify(preparedStatement, times(1)).close();
+        verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class));
+    }
+
+    @SuppressWarnings("static-access")
+    @Test
+    public void testClosePreparedStatementWhenPreparedStatementIsNotNullAndThereIsException() throws Exception {
+        SQLException sqlException = new SQLException();
+        doThrow(sqlException).when(preparedStatementMock).close();
+
+        PreparedStatement preparedStatement = preparedStatementMock;
+        String errorMessage = "some message";
+
+        dao.closePreparedStatement(preparedStatement, errorMessage);
+
+        verify(preparedStatement, times(1)).close();
+        verify(loggerMock, times(1)).warn(errorMessage, sqlException);
+    }
+
+    @Test
+    public void testDropPrimaryKey() throws Exception {
+        when(connectionMock.prepareStatement(contains("DROP PRIMARY KEY"))).thenReturn(preparedStatementMock);
+
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+
+        dao.dropPrimaryKey(conn, tableName);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(1)).executeUpdate();
+        verify(preparedStatementMock, times(1)).close();
+        verify(loggerMock, times(1)).debug(anyString());
+        verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class));
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testDropPrimaryKeyWhenConnectionIsNull() throws Exception {
+        Connection conn = null;
+        String tableName = "tableName";
+
+        dao.dropPrimaryKey(conn, tableName);
+    }
+
+    @Test
+    public void testDropPrimaryKeyWhenTableNameIsNull() throws Exception {
+        SQLException sqlException = new SQLException();
+        when(connectionMock.prepareStatement(contains("null DROP PRIMARY KEY"))).thenReturn(preparedStatementMock);
+        when(preparedStatementMock.executeUpdate()).thenThrow(sqlException);
+
+        Connection conn = connectionMock;
+        String tableName = null;
+
+        dao.dropPrimaryKey(conn, tableName);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(1)).executeUpdate();
+        verify(preparedStatementMock, times(1)).close();
+        verify(loggerMock, times(0)).debug(anyString());
+        verify(loggerMock, times(1)).warn(anyString(), eq(sqlException));
+    }
+
+    @Test
+    public void testDropPrimaryKeyWhenPrepareStatementResultsInException() throws Exception {
+        SQLException sqlException = new SQLException();
+        when(connectionMock.prepareStatement(contains("DROP PRIMARY KEY"))).thenThrow(sqlException);
+
+        Connection conn = connectionMock;
+        String tableName = null;
+
+        dao.dropPrimaryKey(conn, tableName);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(0)).executeUpdate();
+        verify(preparedStatementMock, times(0)).close();
+        verify(loggerMock, times(0)).debug(anyString());
+        verify(loggerMock, times(1)).warn(anyString(), eq(sqlException));
+    }
+
+    @Test
+    public void testDropPrimaryKeyWhenExecuteUpdateResultsInException() throws Exception {
+        SQLException sqlException = new SQLException();
+        when(connectionMock.prepareStatement(contains("DROP PRIMARY KEY"))).thenReturn(preparedStatementMock);
+        when(preparedStatementMock.executeUpdate()).thenThrow(sqlException);
+
+        Connection conn = connectionMock;
+        String tableName = null;
+
+        dao.dropPrimaryKey(conn, tableName);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(1)).executeUpdate();
+        verify(preparedStatementMock, times(1)).close();
+        verify(loggerMock, times(0)).debug(anyString());
+        verify(loggerMock, times(1)).warn(anyString(), eq(sqlException));
+    }
+
+    @Test
+    public void testColumnExists() throws Exception {
+        when(connectionMock.prepareStatement(contains("SELECT"))).thenReturn(preparedStatementMock);
+
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String columnName = "columnName";
+
+        dao.columnExists(conn, tableName, columnName);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(1)).executeQuery();
+        verify(preparedStatementMock, times(1)).close();
+        verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class));
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testColumnExistsWhenConnectionIsNull() throws Exception {
+        Connection conn = null;
+        String tableName = "tableName";
+        String columnName = "columnName";
+
+        dao.columnExists(conn, tableName, columnName);
+    }
+
+    @Test
+    public void testColumnExistsWhenTableNameIsNull() throws Exception {
+        SQLException sqlException = new SQLException();
+        when(connectionMock.prepareStatement(contains("FROM null"))).thenReturn(preparedStatementMock);
+        when(preparedStatementMock.executeQuery()).thenThrow(sqlException);
+
+        Connection conn = connectionMock;
+        String tableName = null;
+        String columnName = "columnName";
+
+        dao.columnExists(conn, tableName, columnName);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(1)).executeQuery();
+        verify(preparedStatementMock, times(1)).close();
+        verify(loggerMock, times(1)).warn(anyString(), eq(sqlException));
+    }
+
+    @Test
+    public void testColumnExistsWhenColumnNameIsNull() throws Exception {
+        SQLException sqlException = new SQLException();
+        when(connectionMock.prepareStatement(contains("SELECT null"))).thenReturn(preparedStatementMock);
+        when(preparedStatementMock.executeQuery()).thenThrow(sqlException);
+
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String columnName = null;
+
+        dao.columnExists(conn, tableName, columnName);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(1)).executeQuery();
+        verify(preparedStatementMock, times(1)).close();
+        verify(loggerMock, times(1)).warn(anyString(), eq(sqlException));
+    }
+
+    @Test
+    public void testDropColumn() throws Exception {
+        when(connectionMock.prepareStatement(anyString())).thenReturn(preparedStatementMock);
+
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String columnName = "columnName";
+
+        dao.dropColumn(conn, tableName, columnName);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(0)).executeQuery();
+        verify(preparedStatementMock, times(1)).executeUpdate();
+        verify(preparedStatementMock, times(1)).close();
+        verify(loggerMock, times(1)).debug(anyString());
+        verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class));
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testDropColumnWhenConnectionIsNull() throws Exception {
+
+        Connection conn = null;
+        String tableName = "tableName";
+        String columnName = "columnName";
+
+        dao.dropColumn(conn, tableName, columnName);
+    }
+
+    @Test
+    public void testDropColumnWhenTableNameIsNull() throws Exception {
+        SQLException sqlException = new SQLException();
+        when(connectionMock.prepareStatement(contains("ALTER TABLE null"))).thenReturn(preparedStatementMock);
+        when(preparedStatementMock.executeUpdate()).thenThrow(sqlException);
+
+        Connection conn = connectionMock;
+        String tableName = null;
+        String columnName = "columnName";
+
+        dao.dropColumn(conn, tableName, columnName);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(1)).executeUpdate();
+        verify(preparedStatementMock, times(1)).close();
+        verify(loggerMock, times(0)).debug(anyString());
+        verify(loggerMock, times(1)).warn(anyString(), eq(sqlException));
+    }
+
+    @Test
+    public void testDropColumnWhenColumnNameIsNull() throws Exception {
+        SQLException sqlException = new SQLException();
+        when(connectionMock.prepareStatement(contains("DROP COLUMN null"))).thenReturn(preparedStatementMock);
+        when(preparedStatementMock.executeUpdate()).thenThrow(sqlException);
+
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String columnName = null;
+
+        dao.dropColumn(conn, tableName, columnName);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(1)).executeUpdate();
+        verify(preparedStatementMock, times(1)).close();
+        verify(loggerMock, times(0)).debug(anyString());
+        verify(loggerMock, times(1)).warn(anyString(), eq(sqlException));
+    }
+
+    @Test
+    public void testDropColumnWhenPrepareStatementResultsInException() throws Exception {
+        SQLException sqlException = new SQLException();
+        when(connectionMock.prepareStatement(anyString())).thenThrow(sqlException);
+
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String columnName = "columnName";
+
+        dao.dropColumn(conn, tableName, columnName);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(0)).executeUpdate();
+        verify(preparedStatementMock, times(0)).close();
+        verify(loggerMock, times(0)).debug(anyString());
+        verify(loggerMock, times(1)).warn(anyString(), eq(sqlException));
+    }
+
+    @Test
+    public void testDropColumnWhenexecuteUpdateResultsInException() throws Exception {
+        SQLException sqlException = new SQLException();
+        when(connectionMock.prepareStatement(anyString())).thenReturn(preparedStatementMock);
+        when(preparedStatementMock.executeUpdate()).thenThrow(sqlException);
+
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String columnName = "columnName";
+
+        dao.dropColumn(conn, tableName, columnName);
+
+        verify(connectionMock, times(1)).prepareStatement(anyString());
+        verify(preparedStatementMock, times(1)).executeUpdate();
+        verify(preparedStatementMock, times(1)).close();
+        verify(loggerMock, times(0)).debug(anyString());
+        verify(loggerMock, times(1)).warn(anyString(), eq(sqlException));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ea0dec77/engine/schema/test/com/cloud/upgrade/dao/DbUpgradeUtilsTest.java
----------------------------------------------------------------------
diff --git a/engine/schema/test/com/cloud/upgrade/dao/DbUpgradeUtilsTest.java b/engine/schema/test/com/cloud/upgrade/dao/DbUpgradeUtilsTest.java
new file mode 100644
index 0000000..d248cfb
--- /dev/null
+++ b/engine/schema/test/com/cloud/upgrade/dao/DbUpgradeUtilsTest.java
@@ -0,0 +1,162 @@
+// 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 com.cloud.upgrade.dao;
+
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+import java.sql.Connection;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.reflect.Whitebox;
+
+@RunWith(PowerMockRunner.class)
+public class DbUpgradeUtilsTest {
+
+    @Mock
+    private Connection connectionMock;
+
+    @Mock
+    private DatabaseAccessObject daoMock;
+
+    @Before
+    public void setupClass() {
+        Whitebox.setInternalState(DbUpgradeUtils.class, "dao", daoMock);
+    }
+
+    @Test
+    public void testDropKeyIfExistWhenNoKeysAreSupplied() throws Exception {
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        List<String> keys = new ArrayList<String>();
+        boolean isForeignKey = false;
+
+        DbUpgradeUtils.dropKeysIfExist(conn, tableName, keys, isForeignKey);
+
+        verify(daoMock, times(0)).dropKey(eq(conn), eq(tableName), anyString(), eq(isForeignKey));
+    }
+
+    @Test
+    public void testDropKeyIfExistWhenOneKeysIsSupplied() throws Exception {
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String key = "key";
+        List<String> keys = Arrays.asList(new String[] {key});
+        boolean isForeignKey = false;
+
+        DbUpgradeUtils.dropKeysIfExist(conn, tableName, keys, isForeignKey);
+
+        verify(daoMock, times(1)).dropKey(conn, tableName, key, isForeignKey);
+    }
+
+    @Test
+    public void testDropKeyIfExistWhenThreeKeysAreSupplied() throws Exception {
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String key1 = "key1";
+        String key2 = "key2";
+        List<String> keys = Arrays.asList(new String[] {key1, key2});
+        boolean isForeignKey = false;
+
+        DbUpgradeUtils.dropKeysIfExist(conn, tableName, keys, isForeignKey);
+
+        verify(daoMock, times(1)).dropKey(conn, tableName, key1, isForeignKey);
+        verify(daoMock, times(1)).dropKey(conn, tableName, key2, isForeignKey);
+    }
+
+    @Test
+    public void testDropPrimaryKey() throws Exception {
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+
+        DbUpgradeUtils.dropPrimaryKeyIfExists(conn, tableName);
+
+        verify(daoMock, times(1)).dropPrimaryKey(conn, tableName);
+    }
+
+    @Test
+    public void testDropTableColumnsIfExistWhenNoKeysAreSupplied() throws Exception {
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        List<String> columns = new ArrayList<String>();
+
+        DbUpgradeUtils.dropTableColumnsIfExist(conn, tableName, columns);
+
+        verify(daoMock, times(0)).columnExists(eq(conn), eq(tableName), anyString());
+        verify(daoMock, times(0)).dropColumn(eq(conn), eq(tableName), anyString());
+    }
+
+    @Test
+    public void testDropTableColumnsIfExistWhenOneKeysIsSuppliedAndColumnExists() throws Exception {
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String column = "column";
+        when(daoMock.columnExists(conn, tableName, column)).thenReturn(true);
+        List<String> columns = Arrays.asList(new String[] {column});
+
+        DbUpgradeUtils.dropTableColumnsIfExist(conn, tableName, columns);
+
+        verify(daoMock, times(1)).columnExists(conn, tableName, column);
+        verify(daoMock, times(1)).dropColumn(conn, tableName, column);
+    }
+
+    @Test
+    public void testDropTableColumnsIfExistWhenOneKeysIsSuppliedAndColumnDoesNotExists() throws Exception {
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String column = "column";
+        when(daoMock.columnExists(conn, tableName, column)).thenReturn(false);
+        List<String> columns = Arrays.asList(new String[] {column});
+
+        DbUpgradeUtils.dropTableColumnsIfExist(conn, tableName, columns);
+
+        verify(daoMock, times(1)).columnExists(conn, tableName, column);
+        verify(daoMock, times(0)).dropColumn(conn, tableName, column);
+    }
+
+    @Test
+    public void testDropTableColumnsIfExistWhenThreeKeysAreSuppliedAnOneDoesnotExist() throws Exception {
+        Connection conn = connectionMock;
+        String tableName = "tableName";
+        String column1 = "column1";
+        String column2 = "column2";
+        String column3 = "column3";
+        when(daoMock.columnExists(conn, tableName, column1)).thenReturn(true);
+        when(daoMock.columnExists(conn, tableName, column2)).thenReturn(false);
+        when(daoMock.columnExists(conn, tableName, column3)).thenReturn(true);
+        List<String> keys = Arrays.asList(new String[] {column1, column2, column3});
+
+        DbUpgradeUtils.dropTableColumnsIfExist(conn, tableName, keys);
+
+        verify(daoMock, times(1)).columnExists(conn, tableName, column1);
+        verify(daoMock, times(1)).dropColumn(conn, tableName, column1);
+        verify(daoMock, times(1)).columnExists(conn, tableName, column2);
+        verify(daoMock, times(0)).dropColumn(conn, tableName, column2);
+        verify(daoMock, times(1)).columnExists(conn, tableName, column3);
+        verify(daoMock, times(1)).dropColumn(conn, tableName, column3);
+    }
+}


[14/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-6203: KVM Migration fixes. Moved migration to a thread
so we can monitor it and potentially take action to make migration
complete if admin has defined such.


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

Branch: refs/heads/resize-root
Commit: e5449e29c9bdc03c93fe8eb361f32878c9a1b980
Parents: 63e3eea
Author: Marcus Sorensen <ma...@betterservers.com>
Authored: Wed Mar 5 12:24:04 2014 -0700
Committer: Marcus Sorensen <ma...@betterservers.com>
Committed: Wed Mar 5 12:24:04 2014 -0700

----------------------------------------------------------------------
 agent/conf/agent.properties                     | 11 +++
 .../kvm/resource/LibvirtComputingResource.java  | 97 ++++++++++++++++++--
 2 files changed, 101 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e5449e29/agent/conf/agent.properties
----------------------------------------------------------------------
diff --git a/agent/conf/agent.properties b/agent/conf/agent.properties
index a7376b6..e7e3b9c 100644
--- a/agent/conf/agent.properties
+++ b/agent/conf/agent.properties
@@ -70,6 +70,17 @@ domr.scripts.dir=scripts/network/domr/kvm
 # In MegaBytes per second
 #vm.migrate.speed=0
 
+# set target downtime at end of livemigration, the 'hiccup' for final copy. Higher numbers
+# make livemigration easier, lower numbers may cause migration to never complete. Less than 1
+# means hypervisor default (20ms).
+#vm.migrate.downtime=0
+
+# Busy VMs may never finish migrating, depending on environment. When its available, we will
+# want to add support for autoconvergence migration flag which should fix this. Set an upper
+# limit in seconds for how long live migration should wait, at which point VM is paused and
+# migration will finish quickly.  Less than 1 means disabled.
+#vm.migrate.pauseafter=0
+
 # set the type of bridge used on the hypervisor, this defines what commands the resource 
 # will use to setup networking. Currently supported NATIVE, OPENVSWITCH
 #network.bridge.type=native

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e5449e29/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index 1056bcf..3f6abfc 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -254,11 +254,14 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 import java.util.UUID;
+import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -306,6 +309,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
     private String _pod;
     private String _clusterId;
     private int _migrateSpeed;
+    private int _migrateDowntime;
+    private int _migratePauseAfter;
 
     private long _hvVersion;
     private long _kernelVersion;
@@ -889,6 +894,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             _mountPoint = "/mnt";
         }
 
+        value = (String) params.get("vm.migrate.downtime");
+        _migrateDowntime = NumbersUtil.parseInt(value, -1);
+
+        value = (String) params.get("vm.migrate.pauseafter");
+        _migratePauseAfter = NumbersUtil.parseInt(value, -1);
+
         value = (String)params.get("vm.migrate.speed");
         _migrateSpeed = NumbersUtil.parseInt(value, -1);
         if (_migrateSpeed == -1) {
@@ -2986,7 +2997,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         Connect conn = null;
         String xmlDesc = null;
         try {
-            conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName());
+            conn = LibvirtConnection.getConnectionByVmName(vmName);
             ifaces = getInterfaces(conn, vmName);
             disks = getDisks(conn, vmName);
             dm = conn.domainLookupByName(vmName);
@@ -3006,17 +3017,65 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             xmlDesc = dm.getXMLDesc(0).replace(_privateIp, cmd.getDestinationIp());
 
             dconn = new Connect("qemu+tcp://" + cmd.getDestinationIp() + "/system");
-            /*
-             * Hard code lm flag: VIR_MIGRATE_LIVE(1<<0)
-             */
-            destDomain = dm.migrate(dconn, (1 << 0), xmlDesc, vmName, "tcp:" + cmd.getDestinationIp(), _migrateSpeed);
 
-            for (DiskDef disk : disks) {
-                cleanupDisk(disk);
+            //run migration in thread so we can monitor it
+            s_logger.info("Live migration of instance " + vmName + " initiated");
+            ExecutorService executor = Executors.newFixedThreadPool(1);
+            Callable<Domain> worker = new MigrateKVMAsync(dm, dconn, vmName, cmd.getDestinationIp());
+            Future<Domain> migrateThread = executor.submit(worker);
+            executor.shutdown();
+            long sleeptime = 0;
+            while (!executor.isTerminated()) {
+                Thread.sleep(100);
+                sleeptime += 100;
+                if (sleeptime == 1000) { // wait 1s before attempting to set downtime on migration, since I don't know of a VIR_DOMAIN_MIGRATING state
+                    if (_migrateDowntime > 0 ) {
+                        try {
+                            int setDowntime = dm.migrateSetMaxDowntime(_migrateDowntime);
+                            if (setDowntime == 0 ) {
+                                s_logger.debug("Set max downtime for migration of " + vmName + " to " + String.valueOf(_migrateDowntime) + "ms");
+                            }
+                        } catch (LibvirtException e) {
+                            s_logger.debug("Failed to set max downtime for migration, perhaps migration completed? Error: " + e.getMessage());
+                        }
+                    }
+                }
+                if ((sleeptime % 1000) == 0) {
+                    s_logger.info("Waiting for migration of " + vmName + " to complete, waited " + sleeptime + "ms");
+                }
+
+                // pause vm if we meet the vm.migrate.pauseafter threshold and not already paused
+                if (_migratePauseAfter > 0 && sleeptime > _migratePauseAfter && dm.getInfo().state == DomainInfo.DomainState.VIR_DOMAIN_RUNNING ) {
+                    s_logger.info("Pausing VM " + vmName + " due to property vm.migrate.pauseafter setting to " + _migratePauseAfter+ "ms to complete migration");
+                    try {
+                        dm.suspend();
+                    } catch (LibvirtException e) {
+                        // pause could be racy if it attempts to pause right when vm is finished, simply warn
+                        s_logger.info("Failed to pause vm " + vmName + " : " + e.getMessage());
+                    }
+                }
+            }
+            s_logger.info("Migration thread for " + vmName + " is done");
+
+            destDomain = migrateThread.get(10, TimeUnit.SECONDS);
+
+            if (destDomain != null) {
+                for (DiskDef disk : disks) {
+                    cleanupDisk(disk);
+                }
             }
         } catch (LibvirtException e) {
             s_logger.debug("Can't migrate domain: " + e.getMessage());
             result = e.getMessage();
+        } catch (InterruptedException e) {
+            s_logger.debug("Interrupted while migrating domain: " + e.getMessage());
+            result = e.getMessage();
+        } catch (ExecutionException e) {
+            s_logger.debug("Failed to execute while migrating domain: " + e.getMessage());
+            result = e.getMessage();
+        } catch (TimeoutException e) {
+            s_logger.debug("Timed out while migrating domain: " + e.getMessage());
+            result = e.getMessage();
         } finally {
             try {
                 if (dm != null) {
@@ -3054,6 +3113,30 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         return new MigrateAnswer(cmd, result == null, result, null);
     }
 
+    private class MigrateKVMAsync implements Callable<Domain> {
+        Domain dm = null;
+        Connect dconn = null;
+        String vmName = "";
+        String destIp = "";
+
+        MigrateKVMAsync(Domain dm, Connect dconn, String vmName, String destIp) {
+            this.dm = dm;
+            this.dconn = dconn;
+            this.vmName = vmName;
+            this.destIp = destIp;
+        }
+
+        @Override
+        public Domain call() throws LibvirtException {
+            // set compression flag for migration if libvirt version supports it
+            if (dconn.getLibVirVersion() < 1003000) {
+                return dm.migrate(dconn, (1 << 0), vmName, "tcp:" + destIp, _migrateSpeed);
+            } else {
+                return dm.migrate(dconn, (1 << 0)|(1 << 11), vmName, "tcp:" + destIp, _migrateSpeed);
+            }
+        }
+    }
+
     private synchronized Answer execute(PrepareForMigrationCommand cmd) {
 
         VirtualMachineTO vm = cmd.getVirtualMachine();


[42/50] [abbrv] Dispatcher corrections, refactoring and tests

Posted by ml...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index 7e29324..c94bc97 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -86,6 +86,7 @@ import org.springframework.stereotype.Component;
 
 import org.apache.cloudstack.acl.APIChecker;
 import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.BaseAsyncCreateCmd;
@@ -122,6 +123,8 @@ import org.apache.cloudstack.framework.jobs.AsyncJobManager;
 import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO;
 import org.apache.cloudstack.managed.context.ManagedContextRunnable;
 
+import com.cloud.api.dispatch.DispatchChainFactory;
+import com.cloud.api.dispatch.DispatchTask;
 import com.cloud.api.response.ApiResponseSerializer;
 import com.cloud.configuration.Config;
 import com.cloud.domain.Domain;
@@ -156,14 +159,22 @@ import com.cloud.utils.exception.ExceptionProxyObject;
 
 @Component
 public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiServerService {
+    private static final String UTF_8 = "UTF-8";
     private static final Logger s_logger = Logger.getLogger(ApiServer.class.getName());
     private static final Logger s_accessLogger = Logger.getLogger("apiserver." + ApiServer.class.getName());
 
-    private static boolean encodeApiResponse = false;
-    private static String jsonContentType = "text/javascript";
-    private static String controlCharacters = "[\000-\011\013-\014\016-\037\177]"; // Non-printable ASCII characters - numbers 0 to 31 and 127 decimal
-    @Inject ApiDispatcher _dispatcher;
+    public static boolean encodeApiResponse = false;
+    public static String jsonContentType = "text/javascript";
 
+    /**
+     * Non-printable ASCII characters - numbers 0 to 31 and 127 decimal
+     */
+    public static final String CONTROL_CHARACTERS = "[\000-\011\013-\014\016-\037\177]";
+
+    @Inject
+    protected ApiDispatcher _dispatcher;
+    @Inject
+    protected DispatchChainFactory dispatchChainFactory;
     @Inject
     private AccountManager _accountMgr;
     @Inject
@@ -191,27 +202,27 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
     }
 
     @Override
-    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+    public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
         return true;
     }
 
     @Override
     public boolean start() {
         Integer apiPort = null; // api port, null by default
-        SearchCriteria<ConfigurationVO> sc = _configDao.createSearchCriteria();
+        final SearchCriteria<ConfigurationVO> sc = _configDao.createSearchCriteria();
         sc.addAnd("name", SearchCriteria.Op.EQ, Config.IntegrationAPIPort.key());
-        List<ConfigurationVO> values = _configDao.search(sc, null);
+        final List<ConfigurationVO> values = _configDao.search(sc, null);
         if ((values != null) && (values.size() > 0)) {
-            ConfigurationVO apiPortConfig = values.get(0);
+            final ConfigurationVO apiPortConfig = values.get(0);
             if (apiPortConfig.getValue() != null) {
                 apiPort = Integer.parseInt(apiPortConfig.getValue());
             }
         }
 
-        Map<String, String> configs = _configDao.getConfiguration();
-        String strSnapshotLimit = configs.get(Config.ConcurrentSnapshotsThresholdPerHost.key());
+        final Map<String, String> configs = _configDao.getConfiguration();
+        final String strSnapshotLimit = configs.get(Config.ConcurrentSnapshotsThresholdPerHost.key());
         if (strSnapshotLimit != null) {
-            Long snapshotLimit = NumbersUtil.parseLong(strSnapshotLimit, 1L);
+            final Long snapshotLimit = NumbersUtil.parseLong(strSnapshotLimit, 1L);
             if (snapshotLimit.longValue() <= 0) {
                 s_logger.debug("Global config parameter " + Config.ConcurrentSnapshotsThresholdPerHost.toString() + " is less or equal 0; defaulting to unlimited");
             } else {
@@ -219,20 +230,20 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
             }
         }
 
-        Set<Class<?>> cmdClasses = new HashSet<Class<?>>();
-        for (PluggableService pluggableService : _pluggableServices) {
+        final Set<Class<?>> cmdClasses = new HashSet<Class<?>>();
+        for (final PluggableService pluggableService : _pluggableServices) {
             cmdClasses.addAll(pluggableService.getCommands());
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug("Discovered plugin " + pluggableService.getClass().getSimpleName());
             }
         }
 
-        for (Class<?> cmdClass : cmdClasses) {
-            APICommand at = cmdClass.getAnnotation(APICommand.class);
+        for (final Class<?> cmdClass : cmdClasses) {
+            final APICommand at = cmdClass.getAnnotation(APICommand.class);
             if (at == null) {
                 throw new CloudRuntimeException(String.format("%s is claimed as a API command, but it doesn't have @APICommand annotation", cmdClass.getName()));
             }
-            String apiName = at.name();
+            final String apiName = at.name();
             if (s_apiNameCmdClassMap.containsKey(apiName)) {
                 s_logger.error("API Cmd class " + cmdClass.getName() + " has non-unique apiname" + apiName);
                 continue;
@@ -241,13 +252,13 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         }
 
         setEncodeApiResponse(Boolean.valueOf(_configDao.getValue(Config.EncodeApiResponse.key())));
-        String jsonType = _configDao.getValue(Config.JavaScriptDefaultContentType.key());
+        final String jsonType = _configDao.getValue(Config.JavaScriptDefaultContentType.key());
         if (jsonType != null) {
             jsonContentType = jsonType;
         }
 
         if (apiPort != null) {
-            ListenerThread listenerThread = new ListenerThread(this, apiPort);
+            final ListenerThread listenerThread = new ListenerThread(this, apiPort);
             listenerThread.start();
         }
 
@@ -258,13 +269,13 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
     // If integration api port is not configured, actual OTW requests will be received by ApiServlet
     @SuppressWarnings({"unchecked", "rawtypes"})
     @Override
-    public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
+    public void handle(final HttpRequest request, final HttpResponse response, final HttpContext context) throws HttpException, IOException {
 
         // Create StringBuffer to log information in access log
-        StringBuffer sb = new StringBuffer();
-        HttpServerConnection connObj = (HttpServerConnection)context.getAttribute("http.connection");
+        final StringBuffer sb = new StringBuffer();
+        final HttpServerConnection connObj = (HttpServerConnection)context.getAttribute("http.connection");
         if (connObj instanceof SocketHttpServerConnection) {
-            InetAddress remoteAddr = ((SocketHttpServerConnection)connObj).getRemoteAddress();
+            final InetAddress remoteAddr = ((SocketHttpServerConnection)connObj).getRemoteAddress();
             sb.append(remoteAddr.toString() + " -- ");
         }
         sb.append(StringUtils.cleanString(request.getRequestLine().toString()));
@@ -272,8 +283,8 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         try {
             List<NameValuePair> paramList = null;
             try {
-                paramList = URLEncodedUtils.parse(new URI(request.getRequestLine().getUri()), "UTF-8");
-            } catch (URISyntaxException e) {
+                paramList = URLEncodedUtils.parse(new URI(request.getRequestLine().getUri()), UTF_8);
+            } catch (final URISyntaxException e) {
                 s_logger.error("Error parsing url request", e);
             }
 
@@ -282,9 +293,9 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
             // APITODO: Use Guava's (import com.google.common.collect.Multimap;)
             // (Immutable)Multimap<String, String> paramMultiMap = HashMultimap.create();
             // Map<String, Collection<String>> parameterMap = paramMultiMap.asMap();
-            Map parameterMap = new HashMap<String, String[]>();
+            final Map parameterMap = new HashMap<String, String[]>();
             String responseType = BaseCmd.RESPONSE_TYPE_XML;
-            for (NameValuePair param : paramList) {
+            for (final NameValuePair param : paramList) {
                 if (param.getName().equalsIgnoreCase("response")) {
                     responseType = param.getValue();
                     continue;
@@ -304,15 +315,15 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                 // always trust commands from API port, user context will always be UID_SYSTEM/ACCOUNT_ID_SYSTEM
                 CallContext.register(_accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
                 sb.insert(0, "(userId=" + User.UID_SYSTEM + " accountId=" + Account.ACCOUNT_ID_SYSTEM + " sessionId=" + null + ") ");
-                String responseText = handleRequest(parameterMap, responseType, sb);
+                final String responseText = handleRequest(parameterMap, responseType, sb);
                 sb.append(" 200 " + ((responseText == null) ? 0 : responseText.length()));
 
                 writeResponse(response, responseText, HttpStatus.SC_OK, responseType, null);
-            } catch (ServerApiException se) {
-                String responseText = getSerializedApiError(se, parameterMap, responseType);
+            } catch (final ServerApiException se) {
+                final String responseText = getSerializedApiError(se, parameterMap, responseType);
                 writeResponse(response, responseText, se.getErrorCode().getHttpCode(), responseType, se.getDescription());
                 sb.append(" " + se.getErrorCode() + " " + se.getDescription());
-            } catch (RuntimeException e) {
+            } catch (final RuntimeException e) {
                 // log runtime exception like NullPointerException to help identify the source easier
                 s_logger.error("Unhandled exception, ", e);
                 throw e;
@@ -323,9 +334,32 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         }
     }
 
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    public void checkCharacterInkParams(final Map params) {
+        final Map<String, String> stringMap = new HashMap<String, String>();
+        final Set keys = params.keySet();
+        final Iterator keysIter = keys.iterator();
+        while (keysIter.hasNext()) {
+            final String key = (String)keysIter.next();
+            final String[] value = (String[])params.get(key);
+            // fail if parameter value contains ASCII control (non-printable) characters
+            if (value[0] != null) {
+                final Pattern pattern = Pattern.compile(CONTROL_CHARACTERS);
+                final Matcher matcher = pattern.matcher(value[0]);
+                if (matcher.find()) {
+                    throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Received value " + value[0] + " for parameter " + key +
+                        " is invalid, contains illegal ASCII non-printable characters");
+                }
+            }
+            stringMap.put(key, value[0]);
+        }
+    }
+
     @Override
     @SuppressWarnings("rawtypes")
-    public String handleRequest(Map params, String responseType, StringBuffer auditTrailSb) throws ServerApiException {
+    public String handleRequest(final Map params, final String responseType, final StringBuffer auditTrailSb) throws ServerApiException {
+        checkCharacterInkParams(params);
+
         String response = null;
         String[] command = null;
 
@@ -335,37 +369,27 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                 s_logger.error("invalid request, no command sent");
                 if (s_logger.isTraceEnabled()) {
                     s_logger.trace("dumping request parameters");
-                    for (Object key : params.keySet()) {
-                        String keyStr = (String)key;
-                        String[] value = (String[])params.get(key);
+                    for (final Object key : params.keySet()) {
+                        final String keyStr = (String)key;
+                        final String[] value = (String[])params.get(key);
                         s_logger.trace("   key: " + keyStr + ", value: " + ((value == null) ? "'null'" : value[0]));
                     }
                 }
                 throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "Invalid request, no command sent");
             } else {
-                Map<String, String> paramMap = new HashMap<String, String>();
-                Set keys = params.keySet();
-                Iterator keysIter = keys.iterator();
+                final Map<String, String> paramMap = new HashMap<String, String>();
+                final Set keys = params.keySet();
+                final Iterator keysIter = keys.iterator();
                 while (keysIter.hasNext()) {
-                    String key = (String)keysIter.next();
+                    final String key = (String)keysIter.next();
                     if ("command".equalsIgnoreCase(key)) {
                         continue;
                     }
-                    String[] value = (String[])params.get(key);
-                    // fail if parameter value contains ASCII control (non-printable) characters
-                    if (value[0] != null) {
-                        Pattern pattern = Pattern.compile(controlCharacters);
-                        Matcher matcher = pattern.matcher(value[0]);
-                        if (matcher.find()) {
-                            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Received value " + value[0] + " for parameter " + key +
-                                " is invalid, contains illegal ASCII non-printable characters");
-                        }
-                    }
+                    final String[] value = (String[])params.get(key);
                     paramMap.put(key, value[0]);
                 }
 
                 Class<?> cmdClass = getCmdClass(command[0]);
-
                 if (cmdClass != null) {
                     APICommand annotation = cmdClass.getAnnotation(APICommand.class);
                     if (annotation == null) {
@@ -378,7 +402,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                     cmdObj.configure();
                     cmdObj.setFullUrlParams(paramMap);
                     cmdObj.setResponseType(responseType);
-                    cmdObj.setHttpMethod(paramMap.get("httpmethod").toString());
+                    cmdObj.setHttpMethod(paramMap.get(ApiConstants.HTTPMETHOD).toString());
 
                     // This is where the command is either serialized, or directly dispatched
                     response = queueCommand(cmdObj, paramMap);
@@ -391,24 +415,24 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                         buildAuditTrail(auditTrailSb, command[0], response);
                 } else {
                     if (!command[0].equalsIgnoreCase("login") && !command[0].equalsIgnoreCase("logout")) {
-                        String errorString = "Unknown API command: " + command[0];
+                        final String errorString = "Unknown API command: " + command[0];
                         s_logger.warn(errorString);
                         auditTrailSb.append(" " + errorString);
                         throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, errorString);
                     }
                 }
             }
-        } catch (InvalidParameterValueException ex) {
+        } catch (final InvalidParameterValueException ex) {
             s_logger.info(ex.getMessage());
             throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex.getMessage(), ex);
-        } catch (IllegalArgumentException ex) {
+        } catch (final IllegalArgumentException ex) {
             s_logger.info(ex.getMessage());
             throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex.getMessage(), ex);
-        } catch (PermissionDeniedException ex) {
-            ArrayList<ExceptionProxyObject> idList = ex.getIdProxyList();
+        } catch (final PermissionDeniedException ex) {
+            final ArrayList<ExceptionProxyObject> idList = ex.getIdProxyList();
             if (idList != null) {
-                StringBuffer buf = new StringBuffer();
-                for (ExceptionProxyObject obj : idList) {
+                final StringBuffer buf = new StringBuffer();
+                for (final ExceptionProxyObject obj : idList) {
                     buf.append(obj.getDescription());
                     buf.append(":");
                     buf.append(obj.getUuid());
@@ -419,10 +443,10 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                 s_logger.info("PermissionDenied: " + ex.getMessage());
             }
             throw new ServerApiException(ApiErrorCode.ACCOUNT_ERROR, ex.getMessage(), ex);
-        } catch (AccountLimitException ex) {
+        } catch (final AccountLimitException ex) {
             s_logger.info(ex.getMessage());
             throw new ServerApiException(ApiErrorCode.ACCOUNT_RESOURCE_LIMIT_ERROR, ex.getMessage(), ex);
-        } catch (InsufficientCapacityException ex) {
+        } catch (final InsufficientCapacityException ex) {
             s_logger.info(ex.getMessage());
             String errorMsg = ex.getMessage();
             if (CallContext.current().getCallingAccount().getType() != Account.ACCOUNT_TYPE_ADMIN) {
@@ -430,10 +454,10 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                 errorMsg = BaseCmd.USER_ERROR_MESSAGE;
             }
             throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, errorMsg, ex);
-        } catch (ResourceAllocationException ex) {
+        } catch (final ResourceAllocationException ex) {
             s_logger.info(ex.getMessage());
             throw new ServerApiException(ApiErrorCode.RESOURCE_ALLOCATION_ERROR, ex.getMessage(), ex);
-        } catch (ResourceUnavailableException ex) {
+        } catch (final ResourceUnavailableException ex) {
             s_logger.info(ex.getMessage());
             String errorMsg = ex.getMessage();
             if (CallContext.current().getCallingAccount().getType() != Account.ACCOUNT_TYPE_ADMIN) {
@@ -441,11 +465,11 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                 errorMsg = BaseCmd.USER_ERROR_MESSAGE;
             }
             throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, errorMsg, ex);
-        } catch (ServerApiException ex) {
+        } catch (final ServerApiException ex) {
             s_logger.info(ex.getDescription());
             throw ex;
-        } catch (Exception ex) {
-            s_logger.error("unhandled exception executing api command: " + ((command == null) ? "null" : command[0]), ex);
+        } catch (final Exception ex) {
+            s_logger.error("unhandled exception executing api command: " + ((command == null) ? "null" : command), ex);
             String errorMsg = ex.getMessage();
             if (CallContext.current().getCallingAccount().getType() != Account.ACCOUNT_TYPE_ADMIN) {
                 // hide internal details to non-admin user for security reason
@@ -457,28 +481,28 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         return response;
     }
 
-    private String getBaseAsyncResponse(long jobId, BaseAsyncCmd cmd) {
-        AsyncJobResponse response = new AsyncJobResponse();
+    private String getBaseAsyncResponse(final long jobId, final BaseAsyncCmd cmd) {
+        final AsyncJobResponse response = new AsyncJobResponse();
 
-        AsyncJob job = _entityMgr.findById(AsyncJob.class, jobId);
+        final AsyncJob job = _entityMgr.findById(AsyncJob.class, jobId);
         response.setJobId(job.getUuid());
         response.setResponseName(cmd.getCommandName());
         return ApiResponseSerializer.toSerializedString(response, cmd.getResponseType());
     }
 
-    private String getBaseAsyncCreateResponse(long jobId, BaseAsyncCreateCmd cmd, String objectUuid) {
-        CreateCmdResponse response = new CreateCmdResponse();
-        AsyncJob job = _entityMgr.findById(AsyncJob.class, jobId);
+    private String getBaseAsyncCreateResponse(final long jobId, final BaseAsyncCreateCmd cmd, final String objectUuid) {
+        final CreateCmdResponse response = new CreateCmdResponse();
+        final AsyncJob job = _entityMgr.findById(AsyncJob.class, jobId);
         response.setJobId(job.getUuid());
         response.setId(objectUuid);
         response.setResponseName(cmd.getCommandName());
         return ApiResponseSerializer.toSerializedString(response, cmd.getResponseType());
     }
 
-    private String queueCommand(BaseCmd cmdObj, Map<String, String> params) throws Exception {
-        CallContext ctx = CallContext.current();
-        Long callerUserId = ctx.getCallingUserId();
-        Account caller = ctx.getCallingAccount();
+    private String queueCommand(final BaseCmd cmdObj, final Map<String, String> params) throws Exception {
+        final CallContext ctx = CallContext.current();
+        final Long callerUserId = ctx.getCallingUserId();
+        final Account caller = ctx.getCallingAccount();
 
         // Queue command based on Cmd super class:
         // BaseCmd: cmd is dispatched to ApiDispatcher, executed, serialized and returned.
@@ -488,16 +512,16 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
             Long objectId = null;
             String objectUuid = null;
             if (cmdObj instanceof BaseAsyncCreateCmd) {
-                BaseAsyncCreateCmd createCmd = (BaseAsyncCreateCmd)cmdObj;
+                final BaseAsyncCreateCmd createCmd = (BaseAsyncCreateCmd)cmdObj;
                 _dispatcher.dispatchCreateCmd(createCmd, params);
                 objectId = createCmd.getEntityId();
                 objectUuid = createCmd.getEntityUuid();
                 params.put("id", objectId.toString());
             } else {
-                ApiDispatcher.processParameters(cmdObj, params);
+                dispatchChainFactory.getStandardDispatchChain().dispatch(new DispatchTask(cmdObj, params));
             }
 
-            BaseAsyncCmd asyncCmd = (BaseAsyncCmd)cmdObj;
+            final BaseAsyncCmd asyncCmd = (BaseAsyncCmd)cmdObj;
 
             if (callerUserId != null) {
                 params.put("ctxUserId", callerUserId.toString());
@@ -510,7 +534,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
             asyncCmd.setStartEventId(startEventId);
 
             // save the scheduled event
-            Long eventId =
+            final Long eventId =
                 ActionEventUtils.onScheduledActionEvent((callerUserId == null) ? User.UID_SYSTEM : callerUserId, asyncCmd.getEntityOwnerId(), asyncCmd.getEventType(),
                     asyncCmd.getEventDescription(), asyncCmd.isDisplayResourceEnabled(), startEventId);
             if (startEventId == 0) {
@@ -527,16 +551,16 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                     asyncCmd.getInstanceType() != null ? asyncCmd.getInstanceType().toString() : null);
             job.setDispatcher(_asyncDispatcher.getName());
 
-            long jobId = _asyncMgr.submitAsyncJob(job);
+            final long jobId = _asyncMgr.submitAsyncJob(job);
 
             if (jobId == 0L) {
-                String errorMsg = "Unable to schedule async job for command " + job.getCmd();
+                final String errorMsg = "Unable to schedule async job for command " + job.getCmd();
                 s_logger.warn(errorMsg);
                 throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, errorMsg);
             }
 
             if (objectId != null) {
-                String objUuid = (objectUuid == null) ? objectId.toString() : objectUuid;
+                final String objUuid = (objectUuid == null) ? objectId.toString() : objectUuid;
                 return getBaseAsyncCreateResponse(jobId, (BaseAsyncCreateCmd)asyncCmd, objUuid);
             } else {
                 SerializationContext.current().setUuidTranslation(true);
@@ -563,8 +587,8 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
     }
 
     @SuppressWarnings("unchecked")
-    private void buildAsyncListResponse(BaseListCmd command, Account account) {
-        List<ResponseObject> responses = ((ListResponse)command.getResponseObject()).getResponses();
+    private void buildAsyncListResponse(final BaseListCmd command, final Account account) {
+        final List<ResponseObject> responses = ((ListResponse)command.getResponseObject()).getResponses();
         if (responses != null && responses.size() > 0) {
             List<? extends AsyncJob> jobs = null;
 
@@ -579,18 +603,18 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                 return;
             }
 
-            Map<String, AsyncJob> objectJobMap = new HashMap<String, AsyncJob>();
-            for (AsyncJob job : jobs) {
+            final Map<String, AsyncJob> objectJobMap = new HashMap<String, AsyncJob>();
+            for (final AsyncJob job : jobs) {
                 if (job.getInstanceId() == null) {
                     continue;
                 }
-                String instanceUuid = ApiDBUtils.findJobInstanceUuid(job);
+                final String instanceUuid = ApiDBUtils.findJobInstanceUuid(job);
                 objectJobMap.put(instanceUuid, job);
             }
 
-            for (ResponseObject response : responses) {
+            for (final ResponseObject response : responses) {
                 if (response.getObjectId() != null && objectJobMap.containsKey(response.getObjectId())) {
-                    AsyncJob job = objectJobMap.get(response.getObjectId());
+                    final AsyncJob job = objectJobMap.get(response.getObjectId());
                     response.setJobId(job.getUuid());
                     response.setJobStatus(job.getStatus().ordinal());
                 }
@@ -598,7 +622,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         }
     }
 
-    private void buildAuditTrail(StringBuffer auditTrailSb, String command, String result) {
+    private void buildAuditTrail(final StringBuffer auditTrailSb, final String command, final String result) {
         if (result == null) {
             return;
         }
@@ -611,31 +635,31 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
     }
 
     @Override
-    public boolean verifyRequest(Map<String, Object[]> requestParameters, Long userId) throws ServerApiException {
+    public boolean verifyRequest(final Map<String, Object[]> requestParameters, final Long userId) throws ServerApiException {
         try {
             String apiKey = null;
             String secretKey = null;
             String signature = null;
             String unsignedRequest = null;
 
-            String[] command = (String[])requestParameters.get("command");
+            final String[] command = (String[])requestParameters.get(ApiConstants.COMMAND);
             if (command == null) {
                 s_logger.info("missing command, ignoring request...");
                 return false;
             }
 
-            String commandName = command[0];
+            final String commandName = command[0];
 
             // if userId not null, that mean that user is logged in
             if (userId != null) {
-                User user = ApiDBUtils.findUserById(userId);
+                final User user = ApiDBUtils.findUserById(userId);
 
                 try {
                     checkCommandAvailable(user, commandName);
-                } catch (RequestLimitException ex) {
+                } catch (final RequestLimitException ex) {
                     s_logger.debug(ex.getMessage());
                     throw new ServerApiException(ApiErrorCode.API_LIMIT_EXCEED, ex.getMessage());
-                } catch (PermissionDeniedException ex) {
+                } catch (final PermissionDeniedException ex) {
                     s_logger.debug("The given command:" + commandName + " does not exist or it is not available for user with id:" + userId);
                     throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "The given command does not exist or it is not available for user");
                 }
@@ -650,9 +674,9 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
 
             // - build a request string with sorted params, make sure it's all lowercase
             // - sign the request, verify the signature is the same
-            List<String> parameterNames = new ArrayList<String>();
+            final List<String> parameterNames = new ArrayList<String>();
 
-            for (Object paramNameObj : requestParameters.keySet()) {
+            for (final Object paramNameObj : requestParameters.keySet()) {
                 parameterNames.add((String)paramNameObj); // put the name in a list that we'll sort later
             }
 
@@ -661,25 +685,25 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
             String signatureVersion = null;
             String expires = null;
 
-            for (String paramName : parameterNames) {
+            for (final String paramName : parameterNames) {
                 // parameters come as name/value pairs in the form String/String[]
-                String paramValue = ((String[])requestParameters.get(paramName))[0];
+                final String paramValue = ((String[])requestParameters.get(paramName))[0];
 
-                if ("signature".equalsIgnoreCase(paramName)) {
+                if (ApiConstants.SIGNATURE.equalsIgnoreCase(paramName)) {
                     signature = paramValue;
                 } else {
-                    if ("apikey".equalsIgnoreCase(paramName)) {
+                    if (ApiConstants.API_KEY.equalsIgnoreCase(paramName)) {
                         apiKey = paramValue;
-                    } else if ("signatureversion".equalsIgnoreCase(paramName)) {
+                    } else if (ApiConstants.SIGNATURE_VERSION.equalsIgnoreCase(paramName)) {
                         signatureVersion = paramValue;
-                    } else if ("expires".equalsIgnoreCase(paramName)) {
+                    } else if (ApiConstants.EXPIRES.equalsIgnoreCase(paramName)) {
                         expires = paramValue;
                     }
 
                     if (unsignedRequest == null) {
-                        unsignedRequest = paramName + "=" + URLEncoder.encode(paramValue, "UTF-8").replaceAll("\\+", "%20");
+                        unsignedRequest = paramName + "=" + URLEncoder.encode(paramValue, UTF_8).replaceAll("\\+", "%20");
                     } else {
-                        unsignedRequest = unsignedRequest + "&" + paramName + "=" + URLEncoder.encode(paramValue, "UTF-8").replaceAll("\\+", "%20");
+                        unsignedRequest = unsignedRequest + "&" + paramName + "=" + URLEncoder.encode(paramValue, UTF_8).replaceAll("\\+", "%20");
                     }
                 }
             }
@@ -701,30 +725,30 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                 synchronized (DateFormatToUse) {
                     try {
                         expiresTS = DateFormatToUse.parse(expires);
-                    } catch (ParseException pe) {
+                    } catch (final ParseException pe) {
                         s_logger.debug("Incorrect date format for Expires parameter", pe);
                         return false;
                     }
                 }
-                Date now = new Date(System.currentTimeMillis());
+                final Date now = new Date(System.currentTimeMillis());
                 if (expiresTS.before(now)) {
                     s_logger.debug("Request expired -- ignoring ...sig: " + signature + ", apiKey: " + apiKey);
                     return false;
                 }
             }
 
-            TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
+            final TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
             txn.close();
             User user = null;
             // verify there is a user with this api key
-            Pair<User, Account> userAcctPair = _accountMgr.findUserByApiKey(apiKey);
+            final Pair<User, Account> userAcctPair = _accountMgr.findUserByApiKey(apiKey);
             if (userAcctPair == null) {
                 s_logger.debug("apiKey does not map to a valid user -- ignoring request, apiKey: " + apiKey);
                 return false;
             }
 
             user = userAcctPair.first();
-            Account account = userAcctPair.second();
+            final Account account = userAcctPair.second();
 
             if (user.getState() != Account.State.enabled || !account.getState().equals(Account.State.enabled)) {
                 s_logger.info("disabled or locked user accessing the api, userid = " + user.getId() + "; name = " + user.getUsername() + "; state: " + user.getState() +
@@ -734,10 +758,10 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
 
             try {
                 checkCommandAvailable(user, commandName);
-            } catch (RequestLimitException ex) {
+            } catch (final RequestLimitException ex) {
                 s_logger.debug(ex.getMessage());
                 throw new ServerApiException(ApiErrorCode.API_LIMIT_EXCEED, ex.getMessage());
-            } catch (PermissionDeniedException ex) {
+            } catch (final PermissionDeniedException ex) {
                 s_logger.debug("The given command:" + commandName + " does not exist or it is not available for user");
                 throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, "The given command:" + commandName + " does not exist or it is not available for user with id:"
                         + userId);
@@ -752,30 +776,30 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
 
             unsignedRequest = unsignedRequest.toLowerCase();
 
-            Mac mac = Mac.getInstance("HmacSHA1");
-            SecretKeySpec keySpec = new SecretKeySpec(secretKey.getBytes(), "HmacSHA1");
+            final Mac mac = Mac.getInstance("HmacSHA1");
+            final SecretKeySpec keySpec = new SecretKeySpec(secretKey.getBytes(), "HmacSHA1");
             mac.init(keySpec);
             mac.update(unsignedRequest.getBytes());
-            byte[] encryptedBytes = mac.doFinal();
-            String computedSignature = Base64.encodeBase64String(encryptedBytes);
-            boolean equalSig = signature.equals(computedSignature);
+            final byte[] encryptedBytes = mac.doFinal();
+            final String computedSignature = Base64.encodeBase64String(encryptedBytes);
+            final boolean equalSig = signature.equals(computedSignature);
             if (!equalSig) {
                 s_logger.info("User signature: " + signature + " is not equaled to computed signature: " + computedSignature);
             } else {
                 CallContext.register(user, account);
             }
             return equalSig;
-        } catch (ServerApiException ex) {
+        } catch (final ServerApiException ex) {
             throw ex;
-        } catch (Exception ex) {
+        } catch (final Exception ex) {
             s_logger.error("unable to verify request signature");
         }
         return false;
     }
 
     @Override
-    public Long fetchDomainId(String domainUUID) {
-        Domain domain = _domainMgr.getDomain(domainUUID);
+    public Long fetchDomainId(final String domainUUID) {
+        final Domain domain = _domainMgr.getDomain(domainUUID);
         if (domain != null)
             return domain.getId();
         else
@@ -783,15 +807,15 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
     }
 
     @Override
-    public void loginUser(HttpSession session, String username, String password, Long domainId, String domainPath, String loginIpAddress,
-        Map<String, Object[]> requestParameters) throws CloudAuthenticationException {
+    public void loginUser(final HttpSession session, final String username, final String password, Long domainId, final String domainPath, final String loginIpAddress,
+        final Map<String, Object[]> requestParameters) throws CloudAuthenticationException {
         // We will always use domainId first. If that does not exist, we will use domain name. If THAT doesn't exist
         // we will default to ROOT
         if (domainId == null) {
             if (domainPath == null || domainPath.trim().length() == 0) {
                 domainId = Domain.ROOT_DOMAIN;
             } else {
-                Domain domainObj = _domainMgr.findDomainByPath(domainPath);
+                final Domain domainObj = _domainMgr.findDomainByPath(domainPath);
                 if (domainObj != null) {
                     domainId = domainObj.getId();
                 } else { // if an unknown path is passed in, fail the login call
@@ -800,26 +824,26 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
             }
         }
 
-        UserAccount userAcct = _accountMgr.authenticateUser(username, password, domainId, loginIpAddress, requestParameters);
+        final UserAccount userAcct = _accountMgr.authenticateUser(username, password, domainId, loginIpAddress, requestParameters);
         if (userAcct != null) {
-            String timezone = userAcct.getTimezone();
+            final String timezone = userAcct.getTimezone();
             float offsetInHrs = 0f;
             if (timezone != null) {
-                TimeZone t = TimeZone.getTimeZone(timezone);
+                final TimeZone t = TimeZone.getTimeZone(timezone);
                 s_logger.info("Current user logged in under " + timezone + " timezone");
 
-                java.util.Date date = new java.util.Date();
-                long longDate = date.getTime();
-                float offsetInMs = (t.getOffset(longDate));
+                final java.util.Date date = new java.util.Date();
+                final long longDate = date.getTime();
+                final float offsetInMs = (t.getOffset(longDate));
                 offsetInHrs = offsetInMs / (1000 * 60 * 60);
                 s_logger.info("Timezone offset from UTC is: " + offsetInHrs);
             }
 
-            Account account = _accountMgr.getAccount(userAcct.getAccountId());
+            final Account account = _accountMgr.getAccount(userAcct.getAccountId());
 
             // set the userId and account object for everyone
             session.setAttribute("userid", userAcct.getId());
-            UserVO user = (UserVO)_accountMgr.getActiveUser(userAcct.getId());
+            final UserVO user = (UserVO)_accountMgr.getActiveUser(userAcct.getId());
             if (user.getUuid() != null) {
                 session.setAttribute("user_UUID", user.getUuid());
             }
@@ -831,7 +855,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
             session.setAttribute("account", account.getAccountName());
 
             session.setAttribute("domainid", account.getDomainId());
-            DomainVO domain = (DomainVO)_domainMgr.getDomain(account.getDomainId());
+            final DomainVO domain = (DomainVO)_domainMgr.getDomain(account.getDomainId());
             if (domain.getUuid() != null) {
                 session.setAttribute("domain_UUID", domain.getUuid());
             }
@@ -847,10 +871,10 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
 
             // (bug 5483) generate a session key that the user must submit on every request to prevent CSRF, add that
             // to the login response so that session-based authenticators know to send the key back
-            SecureRandom sesssionKeyRandom = new SecureRandom();
-            byte sessionKeyBytes[] = new byte[20];
+            final SecureRandom sesssionKeyRandom = new SecureRandom();
+            final byte sessionKeyBytes[] = new byte[20];
             sesssionKeyRandom.nextBytes(sessionKeyBytes);
-            String sessionKey = Base64.encodeBase64String(sessionKeyBytes);
+            final String sessionKey = Base64.encodeBase64String(sessionKeyBytes);
             session.setAttribute("sessionkey", sessionKey);
 
             return;
@@ -859,14 +883,14 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
     }
 
     @Override
-    public void logoutUser(long userId) {
+    public void logoutUser(final long userId) {
         _accountMgr.logoutUser(userId);
         return;
     }
 
     @Override
-    public boolean verifyUser(Long userId) {
-        User user = _accountMgr.getUserIncludingRemoved(userId);
+    public boolean verifyUser(final Long userId) {
+        final User user = _accountMgr.getUserIncludingRemoved(userId);
         Account account = null;
         if (user != null) {
             account = _accountMgr.getAccount(user.getAccountId());
@@ -880,46 +904,46 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         return true;
     }
 
-    private void checkCommandAvailable(User user, String commandName) throws PermissionDeniedException {
+    private void checkCommandAvailable(final User user, final String commandName) throws PermissionDeniedException {
         if (user == null) {
             throw new PermissionDeniedException("User is null for role based API access check for command" + commandName);
         }
 
-        for (APIChecker apiChecker : _apiAccessCheckers) {
+        for (final APIChecker apiChecker : _apiAccessCheckers) {
             apiChecker.checkAccess(user, commandName);
         }
     }
 
     @Override
-    public Class<?> getCmdClass(String cmdName) {
+    public Class<?> getCmdClass(final String cmdName) {
         return s_apiNameCmdClassMap.get(cmdName);
     }
 
     // FIXME: rather than isError, we might was to pass in the status code to give more flexibility
-    private void writeResponse(HttpResponse resp, final String responseText, final int statusCode, String responseType, String reasonPhrase) {
+    private void writeResponse(final HttpResponse resp, final String responseText, final int statusCode, final String responseType, final String reasonPhrase) {
         try {
             resp.setStatusCode(statusCode);
             resp.setReasonPhrase(reasonPhrase);
 
-            BasicHttpEntity body = new BasicHttpEntity();
+            final BasicHttpEntity body = new BasicHttpEntity();
             if (BaseCmd.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
                 // JSON response
                 body.setContentType(jsonContentType);
                 if (responseText == null) {
-                    body.setContent(new ByteArrayInputStream("{ \"error\" : { \"description\" : \"Internal Server Error\" } }".getBytes("UTF-8")));
+                    body.setContent(new ByteArrayInputStream("{ \"error\" : { \"description\" : \"Internal Server Error\" } }".getBytes(UTF_8)));
                 }
             } else {
                 body.setContentType("text/xml");
                 if (responseText == null) {
-                    body.setContent(new ByteArrayInputStream("<error>Internal Server Error</error>".getBytes("UTF-8")));
+                    body.setContent(new ByteArrayInputStream("<error>Internal Server Error</error>".getBytes(UTF_8)));
                 }
             }
 
             if (responseText != null) {
-                body.setContent(new ByteArrayInputStream(responseText.getBytes("UTF-8")));
+                body.setContent(new ByteArrayInputStream(responseText.getBytes(UTF_8)));
             }
             resp.setEntity(body);
-        } catch (Exception ex) {
+        } catch (final Exception ex) {
             s_logger.error("error!", ex);
         }
     }
@@ -934,10 +958,10 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         private ServerSocket _serverSocket = null;
         private HttpParams _params = null;
 
-        public ListenerThread(ApiServer requestHandler, int port) {
+        public ListenerThread(final ApiServer requestHandler, final int port) {
             try {
                 _serverSocket = new ServerSocket(port);
-            } catch (IOException ioex) {
+            } catch (final IOException ioex) {
                 s_logger.error("error initializing api server", ioex);
                 return;
             }
@@ -950,14 +974,14 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                 .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1");
 
             // Set up the HTTP protocol processor
-            BasicHttpProcessor httpproc = new BasicHttpProcessor();
+            final BasicHttpProcessor httpproc = new BasicHttpProcessor();
             httpproc.addInterceptor(new ResponseDate());
             httpproc.addInterceptor(new ResponseServer());
             httpproc.addInterceptor(new ResponseContent());
             httpproc.addInterceptor(new ResponseConnControl());
 
             // Set up request handlers
-            HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
+            final HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
             reqistry.register("*", requestHandler);
 
             // Set up the HTTP service
@@ -972,15 +996,15 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
             while (!Thread.interrupted()) {
                 try {
                     // Set up HTTP connection
-                    Socket socket = _serverSocket.accept();
-                    DefaultHttpServerConnection conn = new DefaultHttpServerConnection();
+                    final Socket socket = _serverSocket.accept();
+                    final DefaultHttpServerConnection conn = new DefaultHttpServerConnection();
                     conn.bind(socket, _params);
 
                     // Execute a new worker task to handle the request
                     s_executor.execute(new WorkerTask(_httpService, conn, s_workerCount++));
-                } catch (InterruptedIOException ex) {
+                } catch (final InterruptedIOException ex) {
                     break;
-                } catch (IOException e) {
+                } catch (final IOException e) {
                     s_logger.error("I/O error initializing connection thread", e);
                     break;
                 }
@@ -999,33 +1023,33 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
 
         @Override
         protected void runInContext() {
-            HttpContext context = new BasicHttpContext(null);
+            final HttpContext context = new BasicHttpContext(null);
             try {
                 while (!Thread.interrupted() && _conn.isOpen()) {
                     _httpService.handleRequest(_conn, context);
                     _conn.close();
                 }
-            } catch (ConnectionClosedException ex) {
+            } catch (final ConnectionClosedException ex) {
                 if (s_logger.isTraceEnabled()) {
                     s_logger.trace("ApiServer:  Client closed connection");
                 }
-            } catch (IOException ex) {
+            } catch (final IOException ex) {
                 if (s_logger.isTraceEnabled()) {
                     s_logger.trace("ApiServer:  IOException - " + ex);
                 }
-            } catch (HttpException ex) {
+            } catch (final HttpException ex) {
                 s_logger.warn("ApiServer:  Unrecoverable HTTP protocol violation" + ex);
             } finally {
                 try {
                     _conn.shutdown();
-                } catch (IOException ignore) {
+                } catch (final IOException ignore) {
                 }
             }
         }
     }
 
     @Override
-    public String getSerializedApiError(int errorCode, String errorText, Map<String, Object[]> apiCommandParams, String responseType) {
+    public String getSerializedApiError(final int errorCode, final String errorText, final Map<String, Object[]> apiCommandParams, final String responseType) {
         String responseName = null;
         Class<?> cmdClass = null;
         String responseText = null;
@@ -1034,10 +1058,10 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
             if (apiCommandParams == null || apiCommandParams.isEmpty()) {
                 responseName = "errorresponse";
             } else {
-                Object cmdObj = apiCommandParams.get("command");
+                final Object cmdObj = apiCommandParams.get(ApiConstants.COMMAND);
                 // cmd name can be null when "command" parameter is missing in the request
                 if (cmdObj != null) {
-                    String cmdName = ((String[])cmdObj)[0];
+                    final String cmdName = ((String[])cmdObj)[0];
                     cmdClass = getCmdClass(cmdName);
                     if (cmdClass != null) {
                         responseName = ((BaseCmd)cmdClass.newInstance()).getCommandName();
@@ -1046,21 +1070,21 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                     }
                 }
             }
-            ExceptionResponse apiResponse = new ExceptionResponse();
+            final ExceptionResponse apiResponse = new ExceptionResponse();
             apiResponse.setErrorCode(errorCode);
             apiResponse.setErrorText(errorText);
             apiResponse.setResponseName(responseName);
             SerializationContext.current().setUuidTranslation(true);
             responseText = ApiResponseSerializer.toSerializedString(apiResponse, responseType);
 
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.error("Exception responding to http request", e);
         }
         return responseText;
     }
 
     @Override
-    public String getSerializedApiError(ServerApiException ex, Map<String, Object[]> apiCommandParams, String responseType) {
+    public String getSerializedApiError(final ServerApiException ex, final Map<String, Object[]> apiCommandParams, final String responseType) {
         String responseName = null;
         Class<?> cmdClass = null;
         String responseText = null;
@@ -1073,11 +1097,11 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
             if (ex.getErrorCode() == ApiErrorCode.UNSUPPORTED_ACTION_ERROR || apiCommandParams == null || apiCommandParams.isEmpty()) {
                 responseName = "errorresponse";
             } else {
-                Object cmdObj = apiCommandParams.get("command");
+                final Object cmdObj = apiCommandParams.get(ApiConstants.COMMAND);
                 // cmd name can be null when "command" parameter is missing in
                 // the request
                 if (cmdObj != null) {
-                    String cmdName = ((String[])cmdObj)[0];
+                    final String cmdName = ((String[])cmdObj)[0];
                     cmdClass = getCmdClass(cmdName);
                     if (cmdClass != null) {
                         responseName = ((BaseCmd)cmdClass.newInstance()).getCommandName();
@@ -1086,11 +1110,11 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                     }
                 }
             }
-            ExceptionResponse apiResponse = new ExceptionResponse();
+            final ExceptionResponse apiResponse = new ExceptionResponse();
             apiResponse.setErrorCode(ex.getErrorCode().getHttpCode());
             apiResponse.setErrorText(ex.getDescription());
             apiResponse.setResponseName(responseName);
-            ArrayList<ExceptionProxyObject> idList = ex.getIdProxyList();
+            final ArrayList<ExceptionProxyObject> idList = ex.getIdProxyList();
             if (idList != null) {
                 for (int i = 0; i < idList.size(); i++) {
                     apiResponse.addProxyObject(idList.get(i));
@@ -1103,7 +1127,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
             SerializationContext.current().setUuidTranslation(true);
             responseText = ApiResponseSerializer.toSerializedString(apiResponse, responseType);
 
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.error("Exception responding to http request", e);
         }
         return responseText;
@@ -1114,7 +1138,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
     }
 
     @Inject
-    public void setPluggableServices(List<PluggableService> pluggableServices) {
+    public void setPluggableServices(final List<PluggableService> pluggableServices) {
         _pluggableServices = pluggableServices;
     }
 
@@ -1123,7 +1147,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
     }
 
     @Inject
-    public void setApiAccessCheckers(List<APIChecker> apiAccessCheckers) {
+    public void setApiAccessCheckers(final List<APIChecker> apiAccessCheckers) {
         _apiAccessCheckers = apiAccessCheckers;
     }
 
@@ -1131,7 +1155,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         return encodeApiResponse;
     }
 
-    private static void setEncodeApiResponse(boolean encodeApiResponse) {
+    private static void setEncodeApiResponse(final boolean encodeApiResponse) {
         ApiServer.encodeApiResponse = encodeApiResponse;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/src/com/cloud/api/ApiServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServlet.java b/server/src/com/cloud/api/ApiServlet.java
index 46f7eba..37a2549 100755
--- a/server/src/com/cloud/api/ApiServlet.java
+++ b/server/src/com/cloud/api/ApiServlet.java
@@ -35,6 +35,7 @@ import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 import org.springframework.web.context.support.SpringBeanAutowiringSupport;
 
+import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.ServerApiException;
@@ -67,40 +68,40 @@ public class ApiServlet extends HttpServlet {
     }
 
     @Override
-    public void init(ServletConfig config) throws ServletException {
+    public void init(final ServletConfig config) throws ServletException {
         SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, config.getServletContext());
     }
 
     @Override
-    protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
+    protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) {
         processRequest(req, resp);
     }
 
     @Override
-    protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
+    protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) {
         processRequest(req, resp);
     }
 
-    private void utf8Fixup(HttpServletRequest req, Map<String, Object[]> params) {
+    private void utf8Fixup(final HttpServletRequest req, final Map<String, Object[]> params) {
         if (req.getQueryString() == null) {
             return;
         }
 
-        String[] paramsInQueryString = req.getQueryString().split("&");
+        final String[] paramsInQueryString = req.getQueryString().split("&");
         if (paramsInQueryString != null) {
-            for (String param : paramsInQueryString) {
-                String[] paramTokens = param.split("=", 2);
+            for (final String param : paramsInQueryString) {
+                final String[] paramTokens = param.split("=", 2);
                 if (paramTokens != null && paramTokens.length == 2) {
                     String name = paramTokens[0];
                     String value = paramTokens[1];
 
                     try {
                         name = URLDecoder.decode(name, "UTF-8");
-                    } catch (UnsupportedEncodingException e) {
+                    } catch (final UnsupportedEncodingException e) {
                     }
                     try {
                         value = URLDecoder.decode(value, "UTF-8");
-                    } catch (UnsupportedEncodingException e) {
+                    } catch (final UnsupportedEncodingException e) {
                     }
                     params.put(name, new String[] {value});
                 } else {
@@ -119,13 +120,13 @@ public class ApiServlet extends HttpServlet {
         });
     }
 
-    private void processRequestInContext(HttpServletRequest req, HttpServletResponse resp) {
-        StringBuffer auditTrailSb = new StringBuffer();
+    private void processRequestInContext(final HttpServletRequest req, final HttpServletResponse resp) {
+        final StringBuffer auditTrailSb = new StringBuffer();
         auditTrailSb.append(" " + req.getRemoteAddr());
         auditTrailSb.append(" -- " + req.getMethod() + " ");
         // get the response format since we'll need it in a couple of places
         String responseType = BaseCmd.RESPONSE_TYPE_XML;
-        Map<String, Object[]> params = new HashMap<String, Object[]>();
+        final Map<String, Object[]> params = new HashMap<String, Object[]>();
         params.putAll(req.getParameterMap());
 
         // For HTTP GET requests, it seems that HttpServletRequest.getParameterMap() actually tries
@@ -143,19 +144,19 @@ public class ApiServlet extends HttpServlet {
 
         try {
             HttpSession session = req.getSession(false);
-            Object[] responseTypeParam = params.get("response");
+            final Object[] responseTypeParam = params.get(ApiConstants.RESPONSE);
             if (responseTypeParam != null) {
                 responseType = (String)responseTypeParam[0];
             }
 
-            Object[] commandObj = params.get("command");
+            final Object[] commandObj = params.get(ApiConstants.COMMAND);
             if (commandObj != null) {
-                String command = (String)commandObj[0];
+                final String command = (String)commandObj[0];
                 if ("logout".equalsIgnoreCase(command)) {
                     // if this is just a logout, invalidate the session and return
                     if (session != null) {
-                        Long userId = (Long)session.getAttribute("userid");
-                        Account account = (Account)session.getAttribute("accountobj");
+                        final Long userId = (Long)session.getAttribute("userid");
+                        final Account account = (Account)session.getAttribute("accountobj");
                         Long accountId = null;
                         if (account != null) {
                             accountId = account.getId();
@@ -166,7 +167,7 @@ public class ApiServlet extends HttpServlet {
                         }
                         try {
                             session.invalidate();
-                        } catch (IllegalStateException ise) {
+                        } catch (final IllegalStateException ise) {
                         }
                     }
                     auditTrailSb.append("command=logout");
@@ -179,18 +180,18 @@ public class ApiServlet extends HttpServlet {
                     if (session != null) {
                         try {
                             session.invalidate();
-                        } catch (IllegalStateException ise) {
+                        } catch (final IllegalStateException ise) {
                         }
                     }
                     session = req.getSession(true);
-                    String[] username = (String[])params.get("username");
-                    String[] password = (String[])params.get("password");
-                    String[] domainIdArr = (String[])params.get("domainid");
+                    final String[] username = (String[])params.get(ApiConstants.USERNAME);
+                    final String[] password = (String[])params.get(ApiConstants.PASSWORD);
+                    String[] domainIdArr = (String[])params.get(ApiConstants.DOMAIN_ID);
 
                     if (domainIdArr == null) {
-                        domainIdArr = (String[])params.get("domainId");
+                        domainIdArr = (String[])params.get(ApiConstants.DOMAIN__ID);
                     }
-                    String[] domainName = (String[])params.get("domain");
+                    final String[] domainName = (String[])params.get(ApiConstants.DOMAIN);
                     Long domainId = null;
                     if ((domainIdArr != null) && (domainIdArr.length > 0)) {
                         try {
@@ -200,10 +201,10 @@ public class ApiServlet extends HttpServlet {
                                 domainId = new Long(Long.parseLong(domainIdArr[0]));
                             }
                             auditTrailSb.append(" domainid=" + domainId);// building the params for POST call
-                        } catch (NumberFormatException e) {
+                        } catch (final NumberFormatException e) {
                             s_logger.warn("Invalid domain id entered by user");
                             auditTrailSb.append(" " + HttpServletResponse.SC_UNAUTHORIZED + " " + "Invalid domain id entered, please enter a valid one");
-                            String serializedResponse =
+                            final String serializedResponse =
                                 _apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED, "Invalid domain id entered, please enter a valid one", params,
                                     responseType);
                             writeResponse(resp, serializedResponse, HttpServletResponse.SC_UNAUTHORIZED, responseType);
@@ -225,24 +226,24 @@ public class ApiServlet extends HttpServlet {
                     }
 
                     if (username != null) {
-                        String pwd = ((password == null) ? null : password[0]);
+                        final String pwd = ((password == null) ? null : password[0]);
                         try {
                             _apiServer.loginUser(session, username[0], pwd, domainId, domain, req.getRemoteAddr(), params);
                             auditTrailSb.insert(0, "(userId=" + session.getAttribute("userid") + " accountId=" + ((Account)session.getAttribute("accountobj")).getId() +
                                 " sessionId=" + session.getId() + ")");
-                            String loginResponse = getLoginSuccessResponse(session, responseType);
+                            final String loginResponse = getLoginSuccessResponse(session, responseType);
                             writeResponse(resp, loginResponse, HttpServletResponse.SC_OK, responseType);
                             return;
-                        } catch (CloudAuthenticationException ex) {
+                        } catch (final CloudAuthenticationException ex) {
                             // TODO: fall through to API key, or just fail here w/ auth error? (HTTP 401)
                             try {
                                 session.invalidate();
-                            } catch (IllegalStateException ise) {
+                            } catch (final IllegalStateException ise) {
                             }
 
                             auditTrailSb.append(" " + ApiErrorCode.ACCOUNT_ERROR + " " + ex.getMessage() != null ? ex.getMessage()
                                 : "failed to authenticate user, check if username/password are correct");
-                            String serializedResponse =
+                            final String serializedResponse =
                                 _apiServer.getSerializedApiError(ApiErrorCode.ACCOUNT_ERROR.getHttpCode(), ex.getMessage() != null ? ex.getMessage()
                                     : "failed to authenticate user, check if username/password are correct", params, responseType);
                             writeResponse(resp, serializedResponse, ApiErrorCode.ACCOUNT_ERROR.getHttpCode(), responseType);
@@ -252,7 +253,7 @@ public class ApiServlet extends HttpServlet {
                 }
             }
             auditTrailSb.append(req.getQueryString());
-            boolean isNew = ((session == null) ? true : session.isNew());
+            final boolean isNew = ((session == null) ? true : session.isNew());
 
             // Initialize an empty context and we will update it after we have verified the request below,
             // we no longer rely on web-session here, verifyRequest will populate user/account information
@@ -261,17 +262,17 @@ public class ApiServlet extends HttpServlet {
 
             if (!isNew) {
                 userId = (Long)session.getAttribute("userid");
-                String account = (String)session.getAttribute("account");
-                Object accountObj = session.getAttribute("accountobj");
-                String sessionKey = (String)session.getAttribute("sessionkey");
-                String[] sessionKeyParam = (String[])params.get("sessionkey");
+                final String account = (String)session.getAttribute("account");
+                final Object accountObj = session.getAttribute("accountobj");
+                final String sessionKey = (String)session.getAttribute("sessionkey");
+                final String[] sessionKeyParam = (String[])params.get(ApiConstants.SESSIONKEY);
                 if ((sessionKeyParam == null) || (sessionKey == null) || !sessionKey.equals(sessionKeyParam[0])) {
                     try {
                         session.invalidate();
-                    } catch (IllegalStateException ise) {
+                    } catch (final IllegalStateException ise) {
                     }
                     auditTrailSb.append(" " + HttpServletResponse.SC_UNAUTHORIZED + " " + "unable to verify user credentials");
-                    String serializedResponse =
+                    final String serializedResponse =
                         _apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED, "unable to verify user credentials", params, responseType);
                     writeResponse(resp, serializedResponse, HttpServletResponse.SC_UNAUTHORIZED, responseType);
                     return;
@@ -279,26 +280,26 @@ public class ApiServlet extends HttpServlet {
 
                 // Do a sanity check here to make sure the user hasn't already been deleted
                 if ((userId != null) && (account != null) && (accountObj != null) && _apiServer.verifyUser(userId)) {
-                    String[] command = (String[])params.get("command");
+                    final String[] command = (String[])params.get(ApiConstants.COMMAND);
                     if (command == null) {
                         s_logger.info("missing command, ignoring request...");
                         auditTrailSb.append(" " + HttpServletResponse.SC_BAD_REQUEST + " " + "no command specified");
-                        String serializedResponse = _apiServer.getSerializedApiError(HttpServletResponse.SC_BAD_REQUEST, "no command specified", params, responseType);
+                        final String serializedResponse = _apiServer.getSerializedApiError(HttpServletResponse.SC_BAD_REQUEST, "no command specified", params, responseType);
                         writeResponse(resp, serializedResponse, HttpServletResponse.SC_BAD_REQUEST, responseType);
                         return;
                     }
-                    User user = _entityMgr.findById(User.class, userId);
+                    final User user = _entityMgr.findById(User.class, userId);
                     CallContext.register(user, (Account)accountObj);
                 } else {
                     // Invalidate the session to ensure we won't allow a request across management server
                     // restarts if the userId was serialized to the stored session
                     try {
                         session.invalidate();
-                    } catch (IllegalStateException ise) {
+                    } catch (final IllegalStateException ise) {
                     }
 
                     auditTrailSb.append(" " + HttpServletResponse.SC_UNAUTHORIZED + " " + "unable to verify user credentials");
-                    String serializedResponse =
+                    final String serializedResponse =
                         _apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED, "unable to verify user credentials", params, responseType);
                     writeResponse(resp, serializedResponse, HttpServletResponse.SC_UNAUTHORIZED, responseType);
                     return;
@@ -326,29 +327,29 @@ public class ApiServlet extends HttpServlet {
 
                 // Add the HTTP method (GET/POST/PUT/DELETE) as well into the params map.
                 params.put("httpmethod", new String[] {req.getMethod()});
-                String response = _apiServer.handleRequest(params, responseType, auditTrailSb);
+                final String response = _apiServer.handleRequest(params, responseType, auditTrailSb);
                 writeResponse(resp, response != null ? response : "", HttpServletResponse.SC_OK, responseType);
             } else {
                 if (session != null) {
                     try {
                         session.invalidate();
-                    } catch (IllegalStateException ise) {
+                    } catch (final IllegalStateException ise) {
                     }
                 }
 
                 auditTrailSb.append(" " + HttpServletResponse.SC_UNAUTHORIZED + " " + "unable to verify user credentials and/or request signature");
-                String serializedResponse =
+                final String serializedResponse =
                     _apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED, "unable to verify user credentials and/or request signature", params,
                         responseType);
                 writeResponse(resp, serializedResponse, HttpServletResponse.SC_UNAUTHORIZED, responseType);
 
             }
-        } catch (ServerApiException se) {
-            String serializedResponseText = _apiServer.getSerializedApiError(se, params, responseType);
+        } catch (final ServerApiException se) {
+            final String serializedResponseText = _apiServer.getSerializedApiError(se, params, responseType);
             resp.setHeader("X-Description", se.getDescription());
             writeResponse(resp, serializedResponseText, se.getErrorCode().getHttpCode(), responseType);
             auditTrailSb.append(" " + se.getErrorCode() + " " + se.getDescription());
-        } catch (Exception ex) {
+        } catch (final Exception ex) {
             s_logger.error("unknown exception writing api response", ex);
             auditTrailSb.append(" unknown exception writing api response");
         } finally {
@@ -372,7 +373,7 @@ public class ApiServlet extends HttpServlet {
      */
 
     // FIXME: rather than isError, we might was to pass in the status code to give more flexibility
-    private void writeResponse(HttpServletResponse resp, String response, int responseCode, String responseType) {
+    private void writeResponse(final HttpServletResponse resp, final String response, final int responseCode, final String responseType) {
         try {
             if (BaseCmd.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
                 resp.setContentType(ApiServer.getJsonContentType() + "; charset=UTF-8");
@@ -382,11 +383,11 @@ public class ApiServlet extends HttpServlet {
 
             resp.setStatus(responseCode);
             resp.getWriter().print(response);
-        } catch (IOException ioex) {
+        } catch (final IOException ioex) {
             if (s_logger.isTraceEnabled()) {
                 s_logger.trace("exception writing response: " + ioex);
             }
-        } catch (Exception ex) {
+        } catch (final Exception ex) {
             if (!(ex instanceof IllegalStateException)) {
                 s_logger.error("unknown exception writing api response", ex);
             }
@@ -394,29 +395,29 @@ public class ApiServlet extends HttpServlet {
     }
 
     @SuppressWarnings("rawtypes")
-    private String getLoginSuccessResponse(HttpSession session, String responseType) {
-        StringBuffer sb = new StringBuffer();
-        int inactiveInterval = session.getMaxInactiveInterval();
+    private String getLoginSuccessResponse(final HttpSession session, final String responseType) {
+        final StringBuffer sb = new StringBuffer();
+        final int inactiveInterval = session.getMaxInactiveInterval();
 
-        String user_UUID = (String)session.getAttribute("user_UUID");
+        final String user_UUID = (String)session.getAttribute("user_UUID");
         session.removeAttribute("user_UUID");
 
-        String domain_UUID = (String)session.getAttribute("domain_UUID");
+        final String domain_UUID = (String)session.getAttribute("domain_UUID");
         session.removeAttribute("domain_UUID");
 
         if (BaseCmd.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
             sb.append("{ \"loginresponse\" : { ");
-            Enumeration attrNames = session.getAttributeNames();
+            final Enumeration attrNames = session.getAttributeNames();
             if (attrNames != null) {
                 sb.append("\"timeout\" : \"" + inactiveInterval + "\"");
                 while (attrNames.hasMoreElements()) {
-                    String attrName = (String)attrNames.nextElement();
+                    final String attrName = (String)attrNames.nextElement();
                     if ("userid".equalsIgnoreCase(attrName)) {
                         sb.append(", \"" + attrName + "\" : \"" + user_UUID + "\"");
                     } else if ("domainid".equalsIgnoreCase(attrName)) {
                         sb.append(", \"" + attrName + "\" : \"" + domain_UUID + "\"");
                     } else {
-                        Object attrObj = session.getAttribute(attrName);
+                        final Object attrObj = session.getAttribute(attrName);
                         if ((attrObj instanceof String) || (attrObj instanceof Long)) {
                             sb.append(", \"" + attrName + "\" : \"" + attrObj.toString() + "\"");
                         }
@@ -428,16 +429,16 @@ public class ApiServlet extends HttpServlet {
             sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
             sb.append("<loginresponse cloud-stack-version=\"" + ApiDBUtils.getVersion() + "\">");
             sb.append("<timeout>" + inactiveInterval + "</timeout>");
-            Enumeration attrNames = session.getAttributeNames();
+            final Enumeration attrNames = session.getAttributeNames();
             if (attrNames != null) {
                 while (attrNames.hasMoreElements()) {
-                    String attrName = (String)attrNames.nextElement();
-                    if ("userid".equalsIgnoreCase(attrName)) {
+                    final String attrName = (String)attrNames.nextElement();
+                    if (ApiConstants.USER_ID.equalsIgnoreCase(attrName)) {
                         sb.append("<" + attrName + ">" + user_UUID + "</" + attrName + ">");
                     } else if ("domainid".equalsIgnoreCase(attrName)) {
                         sb.append("<" + attrName + ">" + domain_UUID + "</" + attrName + ">");
                     } else {
-                        Object attrObj = session.getAttribute(attrName);
+                        final Object attrObj = session.getAttribute(attrName);
                         if (attrObj instanceof String || attrObj instanceof Long || attrObj instanceof Short) {
                             sb.append("<" + attrName + ">" + attrObj.toString() + "</" + attrName + ">");
                         }
@@ -450,8 +451,8 @@ public class ApiServlet extends HttpServlet {
         return sb.toString();
     }
 
-    private String getLogoutSuccessResponse(String responseType) {
-        StringBuffer sb = new StringBuffer();
+    private String getLogoutSuccessResponse(final String responseType) {
+        final StringBuffer sb = new StringBuffer();
         if (BaseCmd.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
             sb.append("{ \"logoutresponse\" : { \"description\" : \"success\" } }");
         } else {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/src/com/cloud/api/dispatch/CommandCreationWorker.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/dispatch/CommandCreationWorker.java b/server/src/com/cloud/api/dispatch/CommandCreationWorker.java
new file mode 100644
index 0000000..30d4637
--- /dev/null
+++ b/server/src/com/cloud/api/dispatch/CommandCreationWorker.java
@@ -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.
+
+package com.cloud.api.dispatch;
+
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.ServerApiException;
+
+import com.cloud.exception.ResourceAllocationException;
+
+
+/**
+ * This worker invokes create on the {@link BaseCmd} itself
+ *
+ * @author afornie
+ */
+public class CommandCreationWorker implements DispatchWorker {
+
+    private static final String ATTEMP_TO_CREATE_NON_CREATION_CMD =
+            "Trying to invoke creation on a Command that is not " +
+            BaseAsyncCreateCmd.class.getName();
+
+    @Override
+    public void handle(final DispatchTask task) {
+        final BaseCmd cmd = task.getCmd();
+
+        if (cmd instanceof BaseAsyncCreateCmd) {
+            try {
+                ((BaseAsyncCreateCmd)cmd).create();
+            } catch (final ResourceAllocationException e) {
+                throw new ServerApiException(ApiErrorCode.RESOURCE_ALLOCATION_ERROR,
+                        e.getMessage(), e);
+            }
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
+                    ATTEMP_TO_CREATE_NON_CREATION_CMD);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/src/com/cloud/api/dispatch/DispatchChain.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/dispatch/DispatchChain.java b/server/src/com/cloud/api/dispatch/DispatchChain.java
new file mode 100644
index 0000000..0ce0ce0
--- /dev/null
+++ b/server/src/com/cloud/api/dispatch/DispatchChain.java
@@ -0,0 +1,40 @@
+// 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 com.cloud.api.dispatch;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.cloudstack.api.ServerApiException;
+
+public class DispatchChain {
+
+    protected List<DispatchWorker> workers = new ArrayList<DispatchWorker>();
+
+    public DispatchChain add(final DispatchWorker worker) {
+        workers.add(worker);
+        return this;
+    }
+
+    public void dispatch(final DispatchTask task)
+            throws ServerApiException {
+
+        for (final DispatchWorker worker : workers) {
+            worker.handle(task);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/src/com/cloud/api/dispatch/DispatchChainFactory.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/dispatch/DispatchChainFactory.java b/server/src/com/cloud/api/dispatch/DispatchChainFactory.java
new file mode 100644
index 0000000..135829e
--- /dev/null
+++ b/server/src/com/cloud/api/dispatch/DispatchChainFactory.java
@@ -0,0 +1,72 @@
+// 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 com.cloud.api.dispatch;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+import com.cloud.user.AccountManager;
+
+public class DispatchChainFactory {
+
+    @Inject
+    protected AccountManager _accountMgr;
+
+    @Inject
+    protected ParamGenericValidationWorker paramGenericValidationWorker;
+
+    @Inject
+    protected ParamUnpackWorker paramUnpackWorker;
+
+    @Inject
+    protected ParamProcessWorker paramProcessWorker;
+
+    @Inject
+    protected SpecificCmdValidationWorker specificCmdValidationWorker;
+
+    @Inject
+    protected CommandCreationWorker commandCreationWorker;
+
+    protected DispatchChain standardDispatchChain;
+
+    protected DispatchChain asyncCreationDispatchChain;
+
+    @PostConstruct
+    public void setup() {
+        standardDispatchChain = new DispatchChain().
+                add(paramUnpackWorker).
+                add(paramProcessWorker).
+                add(paramGenericValidationWorker).
+                add(specificCmdValidationWorker);
+
+        asyncCreationDispatchChain = new DispatchChain().
+                add(paramUnpackWorker).
+                add(paramProcessWorker).
+                add(paramGenericValidationWorker).
+                add(specificCmdValidationWorker).
+                add(commandCreationWorker);
+    }
+
+    public DispatchChain getStandardDispatchChain() {
+        return standardDispatchChain;
+    }
+
+    public DispatchChain getAsyncCreationDispatchChain() {
+        return asyncCreationDispatchChain;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/src/com/cloud/api/dispatch/DispatchTask.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/dispatch/DispatchTask.java b/server/src/com/cloud/api/dispatch/DispatchTask.java
new file mode 100644
index 0000000..2a8a4bd
--- /dev/null
+++ b/server/src/com/cloud/api/dispatch/DispatchTask.java
@@ -0,0 +1,41 @@
+package com.cloud.api.dispatch;
+
+import java.util.Map;
+
+import org.apache.cloudstack.api.BaseCmd;
+
+/**
+ * This class wraps all the data that any worker could need. If we don't wrap it this
+ * way and we pass the parameters one by one, in the end we could end up having all the
+ * N workers receiving plenty of parameters and changing the signature, each time one
+ * of them changes. This way, if a certain worker needs something else, you just need
+ * to change it in this wrapper class and the worker itself.
+ */
+@SuppressWarnings("rawtypes")
+public class DispatchTask {
+
+    protected BaseCmd cmd;
+
+    protected Map params;
+
+    public DispatchTask(final BaseCmd cmd, final Map params) {
+        this.cmd = cmd;
+        this.params = params;
+    }
+
+    public BaseCmd getCmd() {
+        return cmd;
+    }
+
+    public void setCmd(final BaseCmd cmd) {
+        this.cmd = cmd;
+    }
+
+    public Map getParams() {
+        return params;
+    }
+
+    public void setParams(final Map params) {
+        this.params = params;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/src/com/cloud/api/dispatch/DispatchWorker.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/dispatch/DispatchWorker.java b/server/src/com/cloud/api/dispatch/DispatchWorker.java
new file mode 100644
index 0000000..a0dbc6a
--- /dev/null
+++ b/server/src/com/cloud/api/dispatch/DispatchWorker.java
@@ -0,0 +1,30 @@
+// 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 com.cloud.api.dispatch;
+
+import org.apache.cloudstack.api.ServerApiException;
+
+/**
+ * Describes the behavior of the workers in the Chain of Responsibility, that receive and
+ * work on a {@link DispatchTask} which will then be passed to next workers.
+ */
+public interface DispatchWorker {
+
+    public void handle(DispatchTask task)
+            throws ServerApiException;
+}


[26/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
  Use seperate path to sync VM metadata for XS
  VM status sync only does VM status sync


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

Branch: refs/heads/resize-root
Commit: ad88bbb684e9d213c7ec3a3ed75cad98561fd6e0
Parents: ab1d3af
Author: Anthony Xu <an...@citrix.com>
Authored: Wed Mar 5 15:44:31 2014 -0800
Committer: Anthony Xu <an...@citrix.com>
Committed: Wed Mar 5 15:44:50 2014 -0800

----------------------------------------------------------------------
 .../src/com/cloud/vm/VirtualMachineManagerImpl.java       | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ad88bbb6/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 7b98f5d..c13cde7 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -3027,11 +3027,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
 
     @Override
     public boolean processAnswers(long agentId, long seq, Answer[] answers) {
-        if (!VmJobEnabled.value()) {
-            for (final Answer answer : answers) {
-                if (answer instanceof ClusterSyncAnswer) {
+        for (final Answer answer : answers) {
+            if (answer instanceof ClusterSyncAnswer) {
+                if (!VmJobEnabled.value()) {
                     ClusterSyncAnswer hs = (ClusterSyncAnswer)answer;
-                    if (!hs.isExceuted()) {
+                    if (!hs.isExecuted()) {
                         deltaSync(hs.getNewStates());
                         hs.setExecuted();
                     }
@@ -3129,7 +3129,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         if (agent.getHypervisorType() == HypervisorType.XenServer) { // only for Xen
             if (!VmJobEnabled.value()) {
                 StartupRoutingCommand startup = (StartupRoutingCommand)cmd;
-                HashMap<String, Ternary<String, State, String>> allStates = startup.getClusterVMStateChanges();
+                HashMap<String, Pair<String, State>> allStates = startup.getClusterVMStateChanges();
                 if (allStates != null) {
                     fullSync(clusterId, allStates);
                 }


[27/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
vbdmectics may not exist after host reboot


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

Branch: refs/heads/resize-root
Commit: 38c0dd87a9ad0b558ed6aedd521c21bc10a60fd0
Parents: ad88bbb
Author: Anthony Xu <an...@citrix.com>
Authored: Wed Mar 5 16:04:34 2014 -0800
Committer: Anthony Xu <an...@citrix.com>
Committed: Wed Mar 5 16:04:34 2014 -0800

----------------------------------------------------------------------
 .../hypervisor/xen/resource/CitrixResourceBase.java     | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38c0dd87/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index 4a5de18..b1ad63a 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -2361,9 +2361,15 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 double diskReadKBs = 0;
                 double diskWriteKBs = 0;
                 for (VBD vbd : vm.getVBDs(conn)) {
-                    VBDMetrics record = vbd.getMetrics(conn);
-                    diskReadKBs += record.getIoReadKbs(conn);
-                    diskWriteKBs += record.getIoWriteKbs(conn);
+                    VBDMetrics vbdmetrics = vbd.getMetrics(conn);
+                    if (!isRefNull(vbdmetrics)) {
+                        try {
+                            diskReadKBs += vbdmetrics.getIoReadKbs(conn);
+                            diskWriteKBs += vbdmetrics.getIoWriteKbs(conn);
+                        }  catch (Types.HandleInvalid e) {
+                            s_logger.debug("vbdmetrics doesn't exist ");
+                        }
+                    }
                 }
                 if (stats == null) {
                     stats = new VmStatsEntry();


[13/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-5920: enable build of IAM services in pom.xml.


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

Branch: refs/heads/resize-root
Commit: 63e3eea7905e22cab9466b28a2ab2a80b586aeed
Parents: c28450c
Author: Min Chen <mi...@citrix.com>
Authored: Tue Mar 4 17:53:10 2014 -0800
Committer: Min Chen <mi...@citrix.com>
Committed: Wed Mar 5 09:40:56 2014 -0800

----------------------------------------------------------------------
 services/iam/pom.xml | 59 +++++++++++++++++++++++++++++++++++++++++++++++
 services/pom.xml     |  1 +
 2 files changed, 60 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63e3eea7/services/iam/pom.xml
----------------------------------------------------------------------
diff --git a/services/iam/pom.xml b/services/iam/pom.xml
new file mode 100644
index 0000000..d4bf3e7
--- /dev/null
+++ b/services/iam/pom.xml
@@ -0,0 +1,59 @@
+<!--
+  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>cloudstack-service-iam</artifactId>
+  <name>Apache CloudStack IAM Service</name>
+  <packaging>pom</packaging>
+  <parent>
+    <groupId>org.apache.cloudstack</groupId>
+    <artifactId>cloudstack-services</artifactId>
+    <version>4.4.0-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+  <build>
+    <defaultGoal>install</defaultGoal>
+  </build>
+  <modules>
+    <module>plugin</module>
+    <module>server</module>
+  </modules>
+  <!-- 
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-utils</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-api</artifactId>
+      <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>      
+    </dependency>	
+  </dependencies>
+  -->
+  
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63e3eea7/services/pom.xml
----------------------------------------------------------------------
diff --git a/services/pom.xml b/services/pom.xml
index def3027..0212437 100644
--- a/services/pom.xml
+++ b/services/pom.xml
@@ -47,5 +47,6 @@
     <module>console-proxy</module>
     <module>console-proxy-rdp/rdpconsole</module>
     <module>secondary-storage</module>
+    <module>iam</module>    
   </modules>
 </project>


[46/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
Removed unused methods from BaseCmd class. Moved some helper methods to AccountManagerImpl class


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

Branch: refs/heads/resize-root
Commit: 7b0c5cfcbe678fee006f7e00d116fb892b264f2f
Parents: c257fb0
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Fri Mar 7 09:59:12 2014 -0800
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Fri Mar 7 11:33:10 2014 -0800

----------------------------------------------------------------------
 api/src/com/cloud/server/ManagementService.java |   4 -
 api/src/com/cloud/user/AccountService.java      |   2 +
 .../org/apache/cloudstack/api/BaseAsyncCmd.java |  36 -------
 api/src/org/apache/cloudstack/api/BaseCmd.java  | 100 ++-----------------
 .../BaseListTemplateOrIsoPermissionsCmd.java    |   5 +-
 .../api/command/admin/user/CreateUserCmd.java   |   5 +-
 .../affinitygroup/CreateAffinityGroupCmd.java   |   5 +-
 .../affinitygroup/DeleteAffinityGroupCmd.java   |   5 +-
 .../user/autoscale/CreateConditionCmd.java      |   5 +-
 .../api/command/user/iso/ListIsosCmd.java       |   5 +-
 .../api/command/user/iso/RegisterIsoCmd.java    |   5 +-
 .../command/user/network/CreateNetworkCmd.java  |   2 +-
 .../gslb/CreateGlobalLoadBalancerRuleCmd.java   |   5 +-
 .../user/resource/ListResourceLimitsCmd.java    |   5 +-
 .../user/resource/UpdateResourceCountCmd.java   |   7 +-
 .../user/resource/UpdateResourceLimitCmd.java   |   7 +-
 .../AuthorizeSecurityGroupEgressCmd.java        |   5 +-
 .../AuthorizeSecurityGroupIngressCmd.java       |   5 +-
 .../securitygroup/CreateSecurityGroupCmd.java   |   5 +-
 .../securitygroup/DeleteSecurityGroupCmd.java   |   5 +-
 .../command/user/ssh/CreateSSHKeyPairCmd.java   |   5 +-
 .../command/user/ssh/DeleteSSHKeyPairCmd.java   |   5 +-
 .../command/user/ssh/RegisterSSHKeyPairCmd.java |   5 +-
 .../command/user/template/ListTemplatesCmd.java |   5 +-
 .../user/template/RegisterTemplateCmd.java      |   5 +-
 .../api/command/user/vm/DeployVMCmd.java        |   2 +-
 .../command/user/vmgroup/CreateVMGroupCmd.java  |   5 +-
 .../command/user/volume/CreateVolumeCmd.java    |   2 +-
 .../command/user/volume/UploadVolumeCmd.java    |   5 +-
 .../api/command/user/vpc/CreateVPCCmd.java      |   2 +-
 .../api/command/user/vpn/AddVpnUserCmd.java     |   5 +-
 .../user/vpn/CreateVpnCustomerGatewayCmd.java   |   5 +-
 .../api/command/user/vpn/RemoveVpnUserCmd.java  |   5 +-
 .../command/user/vpn/ResetVpnConnectionCmd.java |   5 +-
 .../user/vpn/UpdateVpnCustomerGatewayCmd.java   |   5 +-
 .../api/command/CreateServiceInstanceCmd.java   |   2 +-
 .../contrail/management/MockAccountManager.java |   9 +-
 server/src/com/cloud/acl/DomainChecker.java     |   8 +-
 server/src/com/cloud/api/ApiServer.java         |  61 ++++++-----
 .../api/query/dao/TemplateJoinDaoImpl.java      |  13 +--
 .../com/cloud/server/ManagementServerImpl.java  |  10 --
 .../src/com/cloud/user/AccountManagerImpl.java  |  48 +++++++++
 .../ParamGenericValidationWorkerTest.java       |  58 +++++++----
 .../com/cloud/user/MockAccountManagerImpl.java  |   9 +-
 44 files changed, 214 insertions(+), 293 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/com/cloud/server/ManagementService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/ManagementService.java b/api/src/com/cloud/server/ManagementService.java
index 9b138fe..5fcf0b5 100755
--- a/api/src/com/cloud/server/ManagementService.java
+++ b/api/src/com/cloud/server/ManagementService.java
@@ -269,10 +269,6 @@ public interface ManagementService {
      */
     String generateRandomPassword();
 
-    public Long saveStartedEvent(Long userId, Long accountId, String type, String description, boolean startEventId, Long displayResourceEnabled);
-
-    public Long saveCompletedEvent(Long userId, Long accountId, String level, String type, String description, boolean displayResourceEnabled, long startEventId);
-
     /**
      * Search registered key pairs for the logged in user.
      *

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/com/cloud/user/AccountService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/AccountService.java b/api/src/com/cloud/user/AccountService.java
index a9be292..de0b470 100755
--- a/api/src/com/cloud/user/AccountService.java
+++ b/api/src/com/cloud/user/AccountService.java
@@ -103,4 +103,6 @@ public interface AccountService {
 
     void checkAccess(Account account, AccessType accessType, boolean sameOwner, ControlledEntity... entities) throws PermissionDeniedException;
 
+    Long finalyzeAccountId(String accountName, Long domainId, Long projectId, boolean enabledOnly);
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java b/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
index bbc898f..0b1396f 100644
--- a/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
@@ -16,9 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api;
 
-import org.apache.cloudstack.context.CallContext;
-
-import com.cloud.user.User;
 
 /**
  * queryAsyncJobResult API command.
@@ -92,37 +89,4 @@ public abstract class BaseAsyncCmd extends BaseCmd {
     public Object getJob() {
         return job;
     }
-
-    protected long saveStartedEvent() {
-        return saveStartedEvent(getEventType(), "Executing job for " + getEventDescription(), getStartEventId());
-    }
-
-    protected long saveStartedEvent(String eventType, String description, Long startEventId) {
-        CallContext ctx = CallContext.current();
-        Long userId = ctx.getCallingUserId();
-        userId = (userId == null) ? User.UID_SYSTEM : userId;
-        Long startEvent = startEventId;
-        if (startEvent == null) {
-            startEvent = 0L;
-        }
-        return _mgr.saveStartedEvent((userId == null) ? User.UID_SYSTEM : userId, getEntityOwnerId(), eventType, description,
-                isDisplayResourceEnabled(), startEvent);
-    }
-
-    protected long saveCompletedEvent(String level, String description) {
-        return saveCompletedEvent(level, getEventType(), description, getStartEventId());
-    }
-
-    protected long saveCompletedEvent(String level, String eventType, String description, Long startEventId) {
-        CallContext ctx = CallContext.current();
-        Long userId = ctx.getCallingUserId();
-        userId = (userId == null) ? User.UID_SYSTEM : userId;
-        Long startEvent = startEventId;
-        if (startEvent == null) {
-            startEvent = 0L;
-        }
-        return _mgr.saveCompletedEvent((userId == null) ? User.UID_SYSTEM : userId, getEntityOwnerId(), level, eventType, description,
-                isDisplayResourceEnabled(), startEvent);
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/BaseCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java
index 02250d7..937ccc2 100644
--- a/api/src/org/apache/cloudstack/api/BaseCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseCmd.java
@@ -38,16 +38,12 @@ import org.apache.cloudstack.network.lb.ApplicationLoadBalancerService;
 import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
 import org.apache.cloudstack.query.QueryService;
 import org.apache.cloudstack.usage.UsageService;
-
 import org.apache.log4j.Logger;
 
 import com.cloud.configuration.ConfigurationService;
-import com.cloud.domain.Domain;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.PermissionDeniedException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.NetworkModel;
@@ -65,7 +61,6 @@ import com.cloud.network.vpc.VpcProvisioningService;
 import com.cloud.network.vpc.VpcService;
 import com.cloud.network.vpn.RemoteAccessVpnService;
 import com.cloud.network.vpn.Site2SiteVpnService;
-import com.cloud.projects.Project;
 import com.cloud.projects.ProjectService;
 import com.cloud.resource.ResourceService;
 import com.cloud.server.ManagementService;
@@ -88,36 +83,28 @@ import com.cloud.vm.snapshot.VMSnapshotService;
 
 public abstract class BaseCmd {
     private static final Logger s_logger = Logger.getLogger(BaseCmd.class.getName());
-
-    public static final String USER_ERROR_MESSAGE = "Internal error executing command, please contact your system administrator";
-    public static final int PROGRESS_INSTANCE_CREATED = 1;
-
     public static final String RESPONSE_TYPE_XML = "xml";
     public static final String RESPONSE_TYPE_JSON = "json";
-
-    public enum CommandType {
-        BOOLEAN, DATE, FLOAT, INTEGER, SHORT, LIST, LONG, OBJECT, MAP, STRING, TZDATE, UUID
-    }
-
     public static final DateFormat INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
     public static final DateFormat NEW_INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    public static final String USER_ERROR_MESSAGE = "Internal error executing command, please contact your system administrator";
     public static Pattern newInputDateFormat = Pattern.compile("[\\d]+-[\\d]+-[\\d]+ [\\d]+:[\\d]+:[\\d]+");
     private static final DateFormat s_outputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
-
     protected static final Map<Class<?>, List<Field>> fieldsForCmdClass = new HashMap<Class<?>, List<Field>>();
-
-    private Object _responseObject;
-    private Map<String, String> fullUrlParams;
-
-    public enum HTTPMethod {
+    public static enum HTTPMethod {
         GET, POST, PUT, DELETE
     }
+    public static enum CommandType {
+        BOOLEAN, DATE, FLOAT, INTEGER, SHORT, LIST, LONG, OBJECT, MAP, STRING, TZDATE, UUID
+    }
 
+    private Object _responseObject;
+    private Map<String, String> fullUrlParams;
     private HTTPMethod httpMethod;
-
     @Parameter(name = "response", type = CommandType.STRING)
     private String responseType;
 
+
     @Inject
     public ConfigurationService _configService;
     @Inject
@@ -174,7 +161,6 @@ public abstract class BaseCmd {
     public NetworkACLService _networkACLService;
     @Inject
     public Site2SiteVpnService _s2sVpnService;
-
     @Inject
     public QueryService _queryService;
     @Inject
@@ -282,10 +268,6 @@ public abstract class BaseCmd {
         _responseObject = responseObject;
     }
 
-    public ManagementService getMgmtServiceRef() {
-        return _mgr;
-    }
-
     public static String getDateString(final Date date) {
         if (date == null) {
             return "";
@@ -318,10 +300,6 @@ public abstract class BaseCmd {
         return filteredFields;
     }
 
-    protected Account getCurrentContextAccount() {
-        return CallContext.current().getCallingAccount();
-    }
-
     /**
      * This method doesn't return all the @{link Parameter}, but only the ones exposed
      * and allowed for current @{link RoleType}. This method will get the fields for a given
@@ -334,7 +312,7 @@ public abstract class BaseCmd {
     public List<Field> getParamFields() {
         final List<Field> allFields = getAllFieldsForClass(this.getClass());
         final List<Field> validFields = new ArrayList<Field>();
-        final Account caller = getCurrentContextAccount();
+        final Account caller = CallContext.current().getCallingAccount();
 
         for (final Field field : allFields) {
             final Parameter parameterAnnotation = field.getAnnotation(Parameter.class);
@@ -362,20 +340,6 @@ public abstract class BaseCmd {
         return validFields;
     }
 
-    protected long getInstanceIdFromJobSuccessResult(final String result) {
-        s_logger.debug("getInstanceIdFromJobSuccessResult not overridden in subclass " + this.getClass().getName());
-        return 0;
-    }
-
-    public static boolean isAdmin(final short accountType) {
-        return ((accountType == Account.ACCOUNT_TYPE_ADMIN) || (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) ||
-            (accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN));
-    }
-
-    public static boolean isRootAdmin(final short accountType) {
-        return ((accountType == Account.ACCOUNT_TYPE_ADMIN));
-    }
-
     public void setFullUrlParams(final Map<String, String> map) {
         fullUrlParams = map;
     }
@@ -384,52 +348,6 @@ public abstract class BaseCmd {
         return fullUrlParams;
     }
 
-    public Long finalyzeAccountId(final String accountName, final Long domainId, final Long projectId, final boolean enabledOnly) {
-        if (accountName != null) {
-            if (domainId == null) {
-                throw new InvalidParameterValueException("Account must be specified with domainId parameter");
-            }
-
-            final Domain domain = _domainService.getDomain(domainId);
-            if (domain == null) {
-                throw new InvalidParameterValueException("Unable to find domain by id");
-            }
-
-            final Account account = _accountService.getActiveAccountByName(accountName, domainId);
-            if (account != null && account.getType() != Account.ACCOUNT_TYPE_PROJECT) {
-                if (!enabledOnly || account.getState() == Account.State.enabled) {
-                    return account.getId();
-                } else {
-                    throw new PermissionDeniedException("Can't add resources to the account id=" + account.getId() + " in state=" + account.getState() +
-                        " as it's no longer active");
-                }
-            } else {
-                // idList is not used anywhere, so removed it now
-                //List<IdentityProxy> idList = new ArrayList<IdentityProxy>();
-                //idList.add(new IdentityProxy("domain", domainId, "domainId"));
-                throw new InvalidParameterValueException("Unable to find account by name " + accountName + " in domain with specified id");
-            }
-        }
-
-        if (projectId != null) {
-            final Project project = _projectService.getProject(projectId);
-            if (project != null) {
-                if (!enabledOnly || project.getState() == Project.State.Active) {
-                    return project.getProjectAccountId();
-                } else {
-                    final PermissionDeniedException ex =
-                        new PermissionDeniedException("Can't add resources to the project with specified projectId in state=" + project.getState() +
-                            " as it's no longer active");
-                    ex.addProxyObject(project.getUuid(), "projectId");
-                    throw ex;
-                }
-            } else {
-                throw new InvalidParameterValueException("Unable to find project by id");
-            }
-        }
-        return null;
-    }
-
     /**
      * To be overwritten by any class who needs specific validation
      */

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java b/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java
index 48c1e02..2eb6e5b 100644
--- a/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java
@@ -18,10 +18,9 @@ package org.apache.cloudstack.api;
 
 import java.util.List;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.user.Account;
@@ -80,7 +79,7 @@ public class BaseListTemplateOrIsoPermissionsCmd extends BaseCmd {
         List<String> accountNames = _templateService.listTemplatePermissions(this);
 
         Account account = CallContext.current().getCallingAccount();
-        boolean isAdmin = (isAdmin(account.getType()));
+        boolean isAdmin = (_accountService.isAdmin(account.getType()));
 
         TemplatePermissionsResponse response = _responseGenerator.createTemplatePermissionsResponse(accountNames, id, isAdmin);
         response.setResponseName(getCommandName());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java
index 34feb49..51e218d 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.admin.user;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
@@ -27,6 +25,7 @@ import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.UserResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.user.Account;
 import com.cloud.user.User;
@@ -132,7 +131,7 @@ public class CreateUserCmd extends BaseCmd {
     @Override
     public long getEntityOwnerId() {
         Account account = CallContext.current().getCallingAccount();
-        if ((account == null) || isAdmin(account.getType())) {
+        if ((account == null) || _accountService.isAdmin(account.getType())) {
             if ((domainId != null) && (accountName != null)) {
                 Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
                 if (userAccount != null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java
index 41d5823..e23f890 100644
--- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.affinitygroup;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.affinity.AffinityGroup;
 import org.apache.cloudstack.affinity.AffinityGroupResponse;
 import org.apache.cloudstack.api.APICommand;
@@ -29,6 +27,7 @@ import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ResourceAllocationException;
@@ -102,7 +101,7 @@ public class CreateAffinityGroupCmd extends BaseAsyncCreateCmd {
     @Override
     public long getEntityOwnerId() {
         Account account = CallContext.current().getCallingAccount();
-        if ((account == null) || isAdmin(account.getType())) {
+        if ((account == null) || _accountService.isAdmin(account.getType())) {
             if ((domainId != null) && (accountName != null)) {
                 Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
                 if (userAccount != null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java
index d4d1f2a..6a6dd25 100644
--- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.affinitygroup;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.affinity.AffinityGroupResponse;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
@@ -29,6 +27,7 @@ import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.InvalidParameterValueException;
@@ -105,7 +104,7 @@ public class DeleteAffinityGroupCmd extends BaseAsyncCmd {
     @Override
     public long getEntityOwnerId() {
         Account account = CallContext.current().getCallingAccount();
-        if ((account == null) || isAdmin(account.getType())) {
+        if ((account == null) || _accountService.isAdmin(account.getType())) {
             if ((domainId != null) && (accountName != null)) {
                 Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
                 if (userAccount != null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java
index 356b836..7fbde9e 100644
--- a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java
@@ -17,8 +17,6 @@
 
 package org.apache.cloudstack.api.command.user.autoscale;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
@@ -30,6 +28,7 @@ import org.apache.cloudstack.api.response.ConditionResponse;
 import org.apache.cloudstack.api.response.CounterResponse;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ResourceAllocationException;
@@ -138,7 +137,7 @@ public class CreateConditionCmd extends BaseAsyncCreateCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, null, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
index 8c3e218..28f98f0 100644
--- a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.iso;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
@@ -27,6 +25,7 @@ import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
 import com.cloud.user.Account;
@@ -120,7 +119,7 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd {
     public boolean listInReadyState() {
         Account account = CallContext.current().getCallingAccount();
         // It is account specific if account is admin type and domainId and accountName are not null
-        boolean isAccountSpecific = (account == null || isAdmin(account.getType())) && (getAccountName() != null) && (getDomainId() != null);
+        boolean isAccountSpecific = (account == null || _accountService.isAdmin(account.getType())) && (getAccountName() != null) && (getDomainId() != null);
         // Show only those that are downloaded.
         TemplateFilter templateFilter = TemplateFilter.valueOf(getIsoFilter());
         boolean onlyReady =

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
index af18057..ace662a 100644
--- a/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
@@ -18,8 +18,6 @@ package org.apache.cloudstack.api.command.user.iso;
 
 import java.util.List;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
@@ -33,6 +31,7 @@ import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.template.VirtualMachineTemplate;
@@ -182,7 +181,7 @@ public class RegisterIsoCmd extends BaseCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
index 2f9220f..6a2c6b0 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
@@ -286,7 +286,7 @@ public class CreateNetworkCmd extends BaseCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
index 7015703..6782576 100644
--- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
@@ -19,8 +19,6 @@ package org.apache.cloudstack.api.command.user.region.ha.gslb;
 
 import javax.inject.Inject;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
@@ -32,6 +30,7 @@ import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.GlobalLoadBalancerResponse;
 import org.apache.cloudstack.api.response.RegionResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ResourceAllocationException;
@@ -192,7 +191,7 @@ public class CreateGlobalLoadBalancerRuleCmd extends BaseAsyncCreateCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, null, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/resource/ListResourceLimitsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/resource/ListResourceLimitsCmd.java b/api/src/org/apache/cloudstack/api/command/user/resource/ListResourceLimitsCmd.java
index bd8942a..1576d93 100644
--- a/api/src/org/apache/cloudstack/api/command/user/resource/ListResourceLimitsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/resource/ListResourceLimitsCmd.java
@@ -19,14 +19,13 @@ package org.apache.cloudstack.api.command.user.resource;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.ResourceLimitResponse;
+import org.apache.log4j.Logger;
 
 import com.cloud.configuration.ResourceLimit;
 
@@ -78,7 +77,7 @@ public class ListResourceLimitsCmd extends BaseListProjectAndAccountResourcesCmd
     @Override
     public void execute() {
         List<? extends ResourceLimit> result =
-            _resourceLimitService.searchForLimits(id, finalyzeAccountId(this.getAccountName(), this.getDomainId(), this.getProjectId(), false), this.getDomainId(),
+                _resourceLimitService.searchForLimits(id, _accountService.finalyzeAccountId(this.getAccountName(), this.getDomainId(), this.getProjectId(), false), this.getDomainId(),
                 resourceType, this.getStartIndex(), this.getPageSizeVal());
         ListResponse<ResourceLimitResponse> response = new ListResponse<ResourceLimitResponse>();
         List<ResourceLimitResponse> limitResponses = new ArrayList<ResourceLimitResponse>();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java b/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java
index 2616875..5a41749 100644
--- a/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java
@@ -19,8 +19,6 @@ package org.apache.cloudstack.api.command.user.resource;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
@@ -32,6 +30,7 @@ import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.api.response.ResourceCountResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.configuration.ResourceCount;
 import com.cloud.user.Account;
@@ -107,7 +106,7 @@ public class UpdateResourceCountCmd extends BaseCmd {
     @Override
     public long getEntityOwnerId() {
         Account account = CallContext.current().getCallingAccount();
-        if ((account == null) || isAdmin(account.getType())) {
+        if ((account == null) || _accountService.isAdmin(account.getType())) {
             if ((domainId != null) && (accountName != null)) {
                 Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
                 if (userAccount != null) {
@@ -126,7 +125,7 @@ public class UpdateResourceCountCmd extends BaseCmd {
     @Override
     public void execute() {
         List<? extends ResourceCount> result =
-            _resourceLimitService.recalculateResourceCount(finalyzeAccountId(accountName, domainId, projectId, true), getDomainId(), getResourceType());
+                _resourceLimitService.recalculateResourceCount(_accountService.finalyzeAccountId(accountName, domainId, projectId, true), getDomainId(), getResourceType());
 
         if ((result != null) && (result.size() > 0)) {
             ListResponse<ResourceCountResponse> response = new ListResponse<ResourceCountResponse>();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceLimitCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceLimitCmd.java b/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceLimitCmd.java
index 015cafb..22d20d3 100644
--- a/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceLimitCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceLimitCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.resource;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
@@ -28,6 +26,7 @@ import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.api.response.ResourceLimitResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.configuration.ResourceLimit;
 
@@ -96,7 +95,7 @@ public class UpdateResourceLimitCmd extends BaseCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }
@@ -106,7 +105,7 @@ public class UpdateResourceLimitCmd extends BaseCmd {
 
     @Override
     public void execute() {
-        ResourceLimit result = _resourceLimitService.updateResourceLimit(finalyzeAccountId(accountName, domainId, projectId, true), getDomainId(), resourceType, max);
+        ResourceLimit result = _resourceLimitService.updateResourceLimit(_accountService.finalyzeAccountId(accountName, domainId, projectId, true), getDomainId(), resourceType, max);
         if (result != null || (result == null && max != null && max.longValue() == -1L)) {
             ResourceLimitResponse response = _responseGenerator.createResourceLimitResponse(result);
             response.setResponseName(getCommandName());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java
index 748f60c..7afce6a 100644
--- a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java
@@ -22,8 +22,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
@@ -36,6 +34,7 @@ import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.api.response.SecurityGroupResponse;
 import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.InvalidParameterValueException;
@@ -176,7 +175,7 @@ public class AuthorizeSecurityGroupEgressCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java
index d93a57c..efb34b9 100644
--- a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java
@@ -22,8 +22,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
@@ -36,6 +34,7 @@ import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.api.response.SecurityGroupResponse;
 import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.InvalidParameterValueException;
@@ -175,7 +174,7 @@ public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java
index 9e1bae3..3e94715 100644
--- a/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.securitygroup;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
@@ -28,6 +26,7 @@ import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.api.response.SecurityGroupResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.network.security.SecurityGroup;
 import com.cloud.user.Account;
@@ -97,7 +96,7 @@ public class CreateSecurityGroupCmd extends BaseCmd {
     @Override
     public long getEntityOwnerId() {
         Account account = CallContext.current().getCallingAccount();
-        if ((account == null) || isAdmin(account.getType())) {
+        if ((account == null) || _accountService.isAdmin(account.getType())) {
             if ((domainId != null) && (accountName != null)) {
                 Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
                 if (userAccount != null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java
index 2b23ac0..c9bffe7 100644
--- a/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.securitygroup;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
@@ -29,6 +27,7 @@ import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.api.response.SecurityGroupResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceInUseException;
@@ -110,7 +109,7 @@ public class DeleteSecurityGroupCmd extends BaseCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java b/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java
index 3da6dc1..274c0cb 100644
--- a/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.ssh;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseCmd;
@@ -26,6 +24,7 @@ import org.apache.cloudstack.api.response.CreateSSHKeyPairResponse;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.user.SSHKeyPair;
 
@@ -80,7 +79,7 @@ public class CreateSSHKeyPairCmd extends BaseCmd {
     /////////////////////////////////////////////////////
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/ssh/DeleteSSHKeyPairCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/ssh/DeleteSSHKeyPairCmd.java b/api/src/org/apache/cloudstack/api/command/user/ssh/DeleteSSHKeyPairCmd.java
index cddf199..92105c1 100644
--- a/api/src/org/apache/cloudstack/api/command/user/ssh/DeleteSSHKeyPairCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/ssh/DeleteSSHKeyPairCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.ssh;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseCmd;
@@ -26,6 +24,7 @@ import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.user.Account;
 
@@ -91,7 +90,7 @@ public class DeleteSSHKeyPairCmd extends BaseCmd {
     @Override
     public long getEntityOwnerId() {
         Account account = CallContext.current().getCallingAccount();
-        if ((account == null) || isAdmin(account.getType())) {
+        if ((account == null) || _accountService.isAdmin(account.getType())) {
             if ((domainId != null) && (accountName != null)) {
                 Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
                 if (userAccount != null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/ssh/RegisterSSHKeyPairCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/ssh/RegisterSSHKeyPairCmd.java b/api/src/org/apache/cloudstack/api/command/user/ssh/RegisterSSHKeyPairCmd.java
index 5b330f3..f6074e3 100644
--- a/api/src/org/apache/cloudstack/api/command/user/ssh/RegisterSSHKeyPairCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/ssh/RegisterSSHKeyPairCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.ssh;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseCmd;
@@ -26,6 +24,7 @@ import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.api.response.SSHKeyPairResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.user.SSHKeyPair;
 
@@ -88,7 +87,7 @@ public class RegisterSSHKeyPairCmd extends BaseCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
index 9e95cf6..132d10c 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.template;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
@@ -27,6 +25,7 @@ import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
 import com.cloud.user.Account;
@@ -101,7 +100,7 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
 
         Account account = CallContext.current().getCallingAccount();
         // It is account specific if account is admin type and domainId and accountName are not null
-        boolean isAccountSpecific = (account == null || isAdmin(account.getType())) && (getAccountName() != null) && (getDomainId() != null);
+        boolean isAccountSpecific = (account == null || _accountService.isAdmin(account.getType())) && (getAccountName() != null) && (getDomainId() != null);
         // Show only those that are downloaded.
         TemplateFilter templateFilter = TemplateFilter.valueOf(getTemplateFilter());
         boolean onlyReady =

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
index 61e9428..e6abab2 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
@@ -21,8 +21,6 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
@@ -37,6 +35,7 @@ import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.template.VirtualMachineTemplate;
@@ -252,7 +251,7 @@ public class RegisterTemplateCmd extends BaseCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
index 1cc8380..d33e04e 100755
--- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
@@ -381,7 +381,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/vmgroup/CreateVMGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vmgroup/CreateVMGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/vmgroup/CreateVMGroupCmd.java
index 4676def..c364c2a 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vmgroup/CreateVMGroupCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vmgroup/CreateVMGroupCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.vmgroup;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
@@ -28,6 +26,7 @@ import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.InstanceGroupResponse;
 import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.vm.InstanceGroup;
 
@@ -90,7 +89,7 @@ public class CreateVMGroupCmd extends BaseCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
index 80b49fd..31d75d8 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
@@ -178,7 +178,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java
index 2d97ec9..737e8dc 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
@@ -29,6 +27,7 @@ import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.api.response.VolumeResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
@@ -149,7 +148,7 @@ public class UploadVolumeCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java
index 62fa29f..a632b6d 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java
@@ -199,7 +199,7 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java
index 45d8703..68b5ea2 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.vpn;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
@@ -28,6 +26,7 @@ import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.api.response.VpnUsersResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.domain.Domain;
 import com.cloud.event.EventTypes;
@@ -97,7 +96,7 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnCustomerGatewayCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnCustomerGatewayCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnCustomerGatewayCmd.java
index 1894835..edc4680 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnCustomerGatewayCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnCustomerGatewayCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.vpn;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
@@ -27,6 +25,7 @@ import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.Site2SiteCustomerGatewayResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.network.Site2SiteCustomerGateway;
@@ -143,7 +142,7 @@ public class CreateVpnCustomerGatewayCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, null, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true);
         if (accountId == null) {
             accountId = CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
index d49a208..f704db7 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.vpn;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
@@ -28,6 +26,7 @@ import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.user.Account;
@@ -88,7 +87,7 @@ public class RemoveVpnUserCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/vpn/ResetVpnConnectionCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/ResetVpnConnectionCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/ResetVpnConnectionCmd.java
index 8c3f1d6..ee03000 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpn/ResetVpnConnectionCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/ResetVpnConnectionCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.vpn;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
@@ -27,6 +25,7 @@ import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ResourceUnavailableException;
@@ -82,7 +81,7 @@ public class ResetVpnConnectionCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, null, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnCustomerGatewayCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnCustomerGatewayCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnCustomerGatewayCmd.java
index e0cafed..4583776 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnCustomerGatewayCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnCustomerGatewayCmd.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.vpn;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
@@ -27,6 +25,7 @@ import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.Site2SiteCustomerGatewayResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.network.Site2SiteCustomerGateway;
@@ -146,7 +145,7 @@ public class UpdateVpnCustomerGatewayCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, null, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true);
         if (accountId == null) {
             accountId = CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/api/command/CreateServiceInstanceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/api/command/CreateServiceInstanceCmd.java b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/api/command/CreateServiceInstanceCmd.java
index 86e2949..d2cb4de 100644
--- a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/api/command/CreateServiceInstanceCmd.java
+++ b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/api/command/CreateServiceInstanceCmd.java
@@ -186,7 +186,7 @@ public class CreateServiceInstanceCmd extends BaseAsyncCreateCmd {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+        Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
         if (accountId == null) {
             return CallContext.current().getCallingAccount().getId();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/MockAccountManager.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/MockAccountManager.java b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/MockAccountManager.java
index fa7be58..fb08dc6 100644
--- a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/MockAccountManager.java
+++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/MockAccountManager.java
@@ -23,8 +23,6 @@ import java.util.Map;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.acl.ControlledEntity;
 import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
@@ -33,6 +31,7 @@ import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
 import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
 import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.api.query.vo.ControlledViewEntity;
 import com.cloud.configuration.ResourceLimit;
@@ -347,4 +346,10 @@ public class MockAccountManager extends ManagerBase implements AccountManager {
 
     }
 
+    @Override
+    public Long finalyzeAccountId(String accountName, Long domainId, Long projectId, boolean enabledOnly) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/server/src/com/cloud/acl/DomainChecker.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/acl/DomainChecker.java b/server/src/com/cloud/acl/DomainChecker.java
index f8acceb..7b1deaa 100755
--- a/server/src/com/cloud/acl/DomainChecker.java
+++ b/server/src/com/cloud/acl/DomainChecker.java
@@ -19,12 +19,10 @@ package com.cloud.acl;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
-import org.springframework.stereotype.Component;
-
 import org.apache.cloudstack.acl.ControlledEntity;
 import org.apache.cloudstack.acl.SecurityChecker;
 import org.apache.cloudstack.affinity.AffinityGroup;
-import org.apache.cloudstack.api.BaseCmd;
+import org.springframework.stereotype.Component;
 
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.DedicatedResourceVO;
@@ -104,7 +102,7 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
             Account owner = _accountDao.findById(template.getAccountId());
             // validate that the template is usable by the account
             if (!template.isPublicTemplate()) {
-                if (BaseCmd.isRootAdmin(caller.getType()) || (owner.getId() == caller.getId())) {
+                if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || (owner.getId() == caller.getId())) {
                     return true;
                 }
                 //special handling for the project case
@@ -121,7 +119,7 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
             } else {
                 // Domain admin and regular user can delete/modify only templates created by them
                 if (accessType != null && accessType == AccessType.ModifyEntry) {
-                    if (!BaseCmd.isRootAdmin(caller.getType()) && owner.getId() != caller.getId()) {
+                    if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN && owner.getId() != caller.getId()) {
                         // For projects check if the caller account can access the project account
                         if (owner.getType() != Account.ACCOUNT_TYPE_PROJECT || !(_projectMgr.canAccessProjectAccount(caller, owner.getId()))) {
                             throw new PermissionDeniedException("Domain Admin and regular users can modify only their own Public templates");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index c94bc97..a9b1130 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -53,37 +53,6 @@ import javax.naming.ConfigurationException;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
-import org.apache.commons.codec.binary.Base64;
-import org.apache.http.ConnectionClosedException;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpServerConnection;
-import org.apache.http.HttpStatus;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.utils.URLEncodedUtils;
-import org.apache.http.entity.BasicHttpEntity;
-import org.apache.http.impl.DefaultHttpResponseFactory;
-import org.apache.http.impl.DefaultHttpServerConnection;
-import org.apache.http.impl.NoConnectionReuseStrategy;
-import org.apache.http.impl.SocketHttpServerConnection;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.CoreConnectionPNames;
-import org.apache.http.params.CoreProtocolPNames;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.BasicHttpProcessor;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.protocol.HttpRequestHandlerRegistry;
-import org.apache.http.protocol.HttpService;
-import org.apache.http.protocol.ResponseConnControl;
-import org.apache.http.protocol.ResponseContent;
-import org.apache.http.protocol.ResponseDate;
-import org.apache.http.protocol.ResponseServer;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
 import org.apache.cloudstack.acl.APIChecker;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
@@ -122,6 +91,36 @@ import org.apache.cloudstack.framework.jobs.AsyncJob;
 import org.apache.cloudstack.framework.jobs.AsyncJobManager;
 import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO;
 import org.apache.cloudstack.managed.context.ManagedContextRunnable;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.http.ConnectionClosedException;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpServerConnection;
+import org.apache.http.HttpStatus;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.http.entity.BasicHttpEntity;
+import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.DefaultHttpServerConnection;
+import org.apache.http.impl.NoConnectionReuseStrategy;
+import org.apache.http.impl.SocketHttpServerConnection;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.CoreConnectionPNames;
+import org.apache.http.params.CoreProtocolPNames;
+import org.apache.http.params.HttpParams;
+import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.protocol.BasicHttpProcessor;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpRequestHandler;
+import org.apache.http.protocol.HttpRequestHandlerRegistry;
+import org.apache.http.protocol.HttpService;
+import org.apache.http.protocol.ResponseConnControl;
+import org.apache.http.protocol.ResponseContent;
+import org.apache.http.protocol.ResponseDate;
+import org.apache.http.protocol.ResponseServer;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 
 import com.cloud.api.dispatch.DispatchChainFactory;
 import com.cloud.api.dispatch.DispatchTask;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
index fedc13d..07b4c91 100644
--- a/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
@@ -24,15 +24,13 @@ import java.util.Map;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 
 import com.cloud.api.ApiDBUtils;
 import com.cloud.api.ApiResponseHelper;
@@ -44,6 +42,7 @@ import com.cloud.storage.VMTemplateHostVO;
 import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.user.Account;
+import com.cloud.user.AccountService;
 import com.cloud.utils.Pair;
 import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.GenericDaoBase;
@@ -59,6 +58,8 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO, Long> im
 
     @Inject
     private ConfigurationDao _configDao;
+    @Inject
+    private AccountService _accountService;
 
     private final SearchBuilder<TemplateJoinVO> tmpltIdPairSearch;
 
@@ -98,7 +99,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO, Long> im
     private String getTemplateStatus(TemplateJoinVO template) {
         boolean isAdmin = false;
         Account caller = CallContext.current().getCallingAccount();
-        if ((caller == null) || BaseCmd.isAdmin(caller.getType())) {
+        if ((caller == null) || _accountService.isAdmin(caller.getType())) {
             isAdmin = true;
         }
 
@@ -307,7 +308,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO, Long> im
 
         Account caller = CallContext.current().getCallingAccount();
         boolean isAdmin = false;
-        if ((caller == null) || BaseCmd.isAdmin(caller.getType())) {
+        if ((caller == null) || _accountService.isAdmin(caller.getType())) {
             isAdmin = true;
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 4fa9467..49a9eb5 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -3301,16 +3301,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
     }
 
     @Override
-    public Long saveStartedEvent(Long userId, Long accountId, String type, String description, boolean displayResourceEnabled, Long startEventId) {
-        return ActionEventUtils.onStartedActionEvent(userId, accountId, type, description, displayResourceEnabled, startEventId);
-    }
-
-    @Override
-    public Long saveCompletedEvent(Long userId, Long accountId, String level, String type, String description, boolean displayResourceEnabled, long startEventId) {
-        return ActionEventUtils.onCompletedActionEvent(userId, accountId, level, type, displayResourceEnabled, description, startEventId);
-    }
-
-    @Override
     @DB
     public String uploadCertificate(UploadCustomCertificateCmd cmd) {
         if (cmd.getPrivateKey() != null && cmd.getAlias() != null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b0c5cfc/server/src/com/cloud/user/AccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java
index 186cfb2..c48e9b5 100755
--- a/server/src/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/com/cloud/user/AccountManagerImpl.java
@@ -2326,4 +2326,52 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
     public UserAccount getUserByApiKey(String apiKey) {
         return _userAccountDao.getUserByApiKey(apiKey);
     }
+
+    @Override
+    public Long finalyzeAccountId(final String accountName, final Long domainId, final Long projectId, final boolean enabledOnly) {
+        if (accountName != null) {
+            if (domainId == null) {
+                throw new InvalidParameterValueException("Account must be specified with domainId parameter");
+            }
+
+            final Domain domain = _domainMgr.getDomain(domainId);
+            if (domain == null) {
+                throw new InvalidParameterValueException("Unable to find domain by id");
+            }
+
+            final Account account = getActiveAccountByName(accountName, domainId);
+            if (account != null && account.getType() != Account.ACCOUNT_TYPE_PROJECT) {
+                if (!enabledOnly || account.getState() == Account.State.enabled) {
+                    return account.getId();
+                } else {
+                    throw new PermissionDeniedException("Can't add resources to the account id=" + account.getId() + " in state=" + account.getState() +
+                            " as it's no longer active");
+                }
+            } else {
+                // idList is not used anywhere, so removed it now
+                // List<IdentityProxy> idList = new ArrayList<IdentityProxy>();
+                // idList.add(new IdentityProxy("domain", domainId, "domainId"));
+                throw new InvalidParameterValueException("Unable to find account by name " + accountName + " in domain with specified id");
+            }
+        }
+
+        if (projectId != null) {
+            final Project project = _projectMgr.getProject(projectId);
+            if (project != null) {
+                if (!enabledOnly || project.getState() == Project.State.Active) {
+                    return project.getProjectAccountId();
+                } else {
+                    final PermissionDeniedException ex =
+                            new PermissionDeniedException("Can't add resources to the project with specified projectId in state=" + project.getState() +
+                                    " as it's no longer active");
+                    ex.addProxyObject(project.getUuid(), "projectId");
+                    throw ex;
+                }
+            } else {
+                throw new InvalidParameterValueException("Unable to find project by id");
+            }
+        }
+        return null;
+    }
+
 }


[25/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
    Use seperate path to sync VM metadata for XS
    VM status sync only does VM status sync


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

Branch: refs/heads/resize-root
Commit: ab1d3af46089aaf8adaa196bd2bec2e6a41cbf31
Parents: d1c0b81
Author: Anthony Xu <an...@citrix.com>
Authored: Wed Mar 5 15:08:48 2014 -0800
Committer: Anthony Xu <an...@citrix.com>
Committed: Wed Mar 5 15:44:50 2014 -0800

----------------------------------------------------------------------
 .../cloud/agent/api/HostVmStateReportEntry.java |  10 +-
 .../com/cloud/agent/api/ClusterSyncAnswer.java  |  10 +-
 .../agent/api/ClusterVMMetaDataSyncAnswer.java  |  52 ++++++++
 .../agent/api/ClusterVMMetaDataSyncCommand.java |  47 +++++++
 .../cloud/agent/api/StartupRoutingCommand.java  |   8 +-
 .../com/cloud/vm/VirtualMachineManagerImpl.java |  84 ++++++++-----
 .../networkservice/BareMetalResourceBase.java   |   3 +-
 .../resource/HypervDirectConnectResource.java   |   2 +-
 .../kvm/resource/LibvirtComputingResource.java  |   4 +-
 .../cloud/ovm/hypervisor/OvmResourceBase.java   |   2 +-
 .../cloud/resource/AgentRoutingResource.java    |   2 +-
 .../vmware/resource/VmwareResource.java         |   2 +-
 .../xen/resource/CitrixResourceBase.java        | 125 +++++++++++--------
 .../xen/resource/XenServer610Resource.java      |   8 --
 .../xen/resource/XenServerPoolVms.java          |  41 +++---
 .../xenserver/XenServerResourceNewBase.java     |  20 +--
 16 files changed, 271 insertions(+), 149 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/api/src/com/cloud/agent/api/HostVmStateReportEntry.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/HostVmStateReportEntry.java b/api/src/com/cloud/agent/api/HostVmStateReportEntry.java
index 4f0fb91..08acfef 100644
--- a/api/src/com/cloud/agent/api/HostVmStateReportEntry.java
+++ b/api/src/com/cloud/agent/api/HostVmStateReportEntry.java
@@ -32,16 +32,12 @@ public class HostVmStateReportEntry {
     // host name or host uuid
     String host;
 
-    // XS needs Xen Tools version info
-    String hostToolsVersion;
-
     public HostVmStateReportEntry() {
     }
 
-    public HostVmStateReportEntry(PowerState state, String host, String hostToolsVersion) {
+    public HostVmStateReportEntry(PowerState state, String host) {
         this.state = state;
         this.host = host;
-        this.hostToolsVersion = hostToolsVersion;
     }
 
     public PowerState getState() {
@@ -51,8 +47,4 @@ public class HostVmStateReportEntry {
     public String getHost() {
         return host;
     }
-
-    public String getHostToolsVersion() {
-        return hostToolsVersion;
-    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/core/src/com/cloud/agent/api/ClusterSyncAnswer.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/ClusterSyncAnswer.java b/core/src/com/cloud/agent/api/ClusterSyncAnswer.java
index 90ce02d..7b8a525 100644
--- a/core/src/com/cloud/agent/api/ClusterSyncAnswer.java
+++ b/core/src/com/cloud/agent/api/ClusterSyncAnswer.java
@@ -18,18 +18,18 @@ package com.cloud.agent.api;
 
 import java.util.HashMap;
 
-import com.cloud.utils.Ternary;
+import com.cloud.utils.Pair;
 import com.cloud.vm.VirtualMachine.State;
 
 public class ClusterSyncAnswer extends Answer {
     private long _clusterId;
-    private HashMap<String, Ternary<String, State, String>> _newStates;
+    private HashMap<String, Pair<String, State>> _newStates;
     private boolean _isExecuted = false;
 
     // this is here because a cron command answer is being sent twice
     //  AgentAttache.processAnswers
     //  AgentManagerImpl.notifyAnswersToMonitors
-    public boolean isExceuted() {
+    public boolean isExecuted() {
         return _isExecuted;
     }
 
@@ -37,7 +37,7 @@ public class ClusterSyncAnswer extends Answer {
         _isExecuted = true;
     }
 
-    public ClusterSyncAnswer(long clusterId, HashMap<String, Ternary<String, State, String>> newStates) {
+    public ClusterSyncAnswer(long clusterId, HashMap<String, Pair<String, State>> newStates) {
         _clusterId = clusterId;
         _newStates = newStates;
         result = true;
@@ -47,7 +47,7 @@ public class ClusterSyncAnswer extends Answer {
         return _clusterId;
     }
 
-    public HashMap<String, Ternary<String, State, String>> getNewStates() {
+    public HashMap<String, Pair<String, State>> getNewStates() {
         return _newStates;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/core/src/com/cloud/agent/api/ClusterVMMetaDataSyncAnswer.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/ClusterVMMetaDataSyncAnswer.java b/core/src/com/cloud/agent/api/ClusterVMMetaDataSyncAnswer.java
new file mode 100644
index 0000000..04fd967
--- /dev/null
+++ b/core/src/com/cloud/agent/api/ClusterVMMetaDataSyncAnswer.java
@@ -0,0 +1,52 @@
+// 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 com.cloud.agent.api;
+
+import java.util.HashMap;
+
+public class ClusterVMMetaDataSyncAnswer extends Answer {
+    private long _clusterId;
+    private HashMap<String, String> _vmMetaDatum;
+    private boolean _isExecuted=false;
+
+    // this is here because a cron command answer is being sent twice
+    //  AgentAttache.processAnswers
+    //  AgentManagerImpl.notifyAnswersToMonitors
+    public boolean isExecuted(){
+        return _isExecuted;
+    }
+
+    public void setExecuted(){
+        _isExecuted = true;
+    }
+
+
+    public ClusterVMMetaDataSyncAnswer(long clusterId, HashMap<String, String> vmMetaDatum){
+        _clusterId = clusterId;
+        _vmMetaDatum = vmMetaDatum;
+        result = true;
+    }
+
+    public long getClusterId() {
+        return _clusterId;
+    }
+
+    public HashMap<String, String> getVMMetaDatum() {
+        return _vmMetaDatum;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/core/src/com/cloud/agent/api/ClusterVMMetaDataSyncCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/ClusterVMMetaDataSyncCommand.java b/core/src/com/cloud/agent/api/ClusterVMMetaDataSyncCommand.java
new file mode 100644
index 0000000..0f6ca50
--- /dev/null
+++ b/core/src/com/cloud/agent/api/ClusterVMMetaDataSyncCommand.java
@@ -0,0 +1,47 @@
+// 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 com.cloud.agent.api;
+
+
+public class ClusterVMMetaDataSyncCommand extends Command implements CronCommand {
+    int _interval;
+
+    long _clusterId;
+
+    public ClusterVMMetaDataSyncCommand() {
+    }
+
+    public ClusterVMMetaDataSyncCommand(int interval, long clusterId){
+        _interval = interval;
+        _clusterId = clusterId;
+    }
+
+    @Override
+    public int getInterval() {
+        return _interval;
+    }
+
+    public long getClusterId() {
+        return _clusterId;
+    }
+
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/core/src/com/cloud/agent/api/StartupRoutingCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/StartupRoutingCommand.java b/core/src/com/cloud/agent/api/StartupRoutingCommand.java
index 626c87f..8c0eb8a 100755
--- a/core/src/com/cloud/agent/api/StartupRoutingCommand.java
+++ b/core/src/com/cloud/agent/api/StartupRoutingCommand.java
@@ -22,7 +22,7 @@ import java.util.Map;
 import com.cloud.host.Host;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.network.Networks.RouterPrivateIpStrategy;
-import com.cloud.utils.Ternary;
+import com.cloud.utils.Pair;
 import com.cloud.vm.VirtualMachine.State;
 
 public class StartupRoutingCommand extends StartupCommand {
@@ -63,7 +63,7 @@ public class StartupRoutingCommand extends StartupCommand {
     // TODO vmsync
     // deprecated, will delete after full replacement
     Map<String, VmState> vms;
-    HashMap<String, Ternary<String, State, String>> _clusterVMStates;
+    HashMap<String, Pair<String, State>> _clusterVMStates;
 
     String caps;
     String pool;
@@ -137,7 +137,7 @@ public class StartupRoutingCommand extends StartupCommand {
         }
     }
 
-    public void setClusterVMStateChanges(HashMap<String, Ternary<String, State, String>> allStates) {
+    public void setClusterVMStateChanges(HashMap<String, Pair<String, State>> allStates) {
         _clusterVMStates = allStates;
     }
 
@@ -169,7 +169,7 @@ public class StartupRoutingCommand extends StartupCommand {
         return vms;
     }
 
-    public HashMap<String, Ternary<String, State, String>> getClusterVMStateChanges() {
+    public HashMap<String, Pair<String, State>> getClusterVMStateChanges() {
         return _clusterVMStates;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 3c272e4..7b98f5d 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -80,6 +80,8 @@ import com.cloud.agent.api.CheckVirtualMachineAnswer;
 import com.cloud.agent.api.CheckVirtualMachineCommand;
 import com.cloud.agent.api.ClusterSyncAnswer;
 import com.cloud.agent.api.ClusterSyncCommand;
+import com.cloud.agent.api.ClusterVMMetaDataSyncCommand;
+import com.cloud.agent.api.ClusterVMMetaDataSyncAnswer;
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.MigrateAnswer;
 import com.cloud.agent.api.MigrateCommand;
@@ -340,6 +342,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
     static final ConfigKey<Integer> ClusterDeltaSyncInterval = new ConfigKey<Integer>("Advanced", Integer.class, "sync.interval", "60",
             "Cluster Delta sync interval in seconds",
             false);
+    static final ConfigKey<Integer> ClusterVMMetaDataSyncInterval = new ConfigKey<Integer>("Advanced", Integer.class, "vmmetadata.sync.interval", "180", "Cluster VM metadata sync interval in seconds",
+            false);
 
     static final ConfigKey<Boolean> VmJobEnabled = new ConfigKey<Boolean>("Advanced",
             Boolean.class, "vm.job.enabled", "true",
@@ -2521,7 +2525,35 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         return commands;
     }
 
-    public void deltaSync(Map<String, Ternary<String, State, String>> newStates) {
+    // this is XenServer specific
+    public void syncVMMetaData(Map<String, String> vmMetadatum) {
+        if (vmMetadatum == null || vmMetadatum.isEmpty()) {
+            return;
+        }
+        for (Map.Entry<String, String> entry : vmMetadatum.entrySet()) {
+            String name = entry.getKey();
+            String platform = entry.getValue();
+            if (platform == null || platform.isEmpty()) {
+                continue;
+            }
+            VMInstanceVO vm = _vmDao.findVMByInstanceName(name);
+            if (vm != null && vm.getType() == VirtualMachine.Type.User) {
+                // track platform info
+                UserVmVO userVm = _userVmDao.findById(vm.getId());
+                _userVmDao.loadDetails(userVm);
+                userVm.setDetail("platform",  platform);
+                String pvdriver = "xenserver56";
+                if ( platform.contains("device_id")) {
+                    pvdriver = "xenserver61";
+                }
+                userVm.setDetail("hypervisortoolsversion", pvdriver);
+                _userVmDao.saveDetails(userVm);
+            }
+        }
+    }
+
+
+    public void deltaSync(Map<String, Pair<String, State>> newStates) {
         Map<Long, AgentVmInfo> states = convertToInfos(newStates);
 
         for (Map.Entry<Long, AgentVmInfo> entry : states.entrySet()) {
@@ -2556,7 +2588,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         }
     }
 
-    public void fullSync(final long clusterId, Map<String, Ternary<String, State, String>> newStates) {
+    public void fullSync(final long clusterId, Map<String, Pair<String, State>> newStates) {
         if (newStates == null)
             return;
         Map<Long, AgentVmInfo> infos = convertToInfos(newStates);
@@ -2686,24 +2718,24 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
 
     }
 
-    protected Map<Long, AgentVmInfo> convertToInfos(final Map<String, Ternary<String, State, String>> newStates) {
+    protected Map<Long, AgentVmInfo> convertToInfos(final Map<String, Pair<String, State>> newStates) {
         final HashMap<Long, AgentVmInfo> map = new HashMap<Long, AgentVmInfo>();
         if (newStates == null) {
             return map;
         }
         boolean is_alien_vm = true;
         long alien_vm_count = -1;
-        for (Map.Entry<String, Ternary<String, State, String>> entry : newStates.entrySet()) {
+        for (Map.Entry<String, Pair<String, State>> entry : newStates.entrySet()) {
             is_alien_vm = true;
             String name = entry.getKey();
             VMInstanceVO vm = _vmDao.findVMByInstanceName(name);
             if (vm != null) {
-                map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vm, entry.getValue().second(), entry.getValue().first(), entry.getValue().third()));
+                map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vm, entry.getValue().second(), entry.getValue().first()));
                 is_alien_vm = false;
             }
             // alien VMs
             if (is_alien_vm) {
-                map.put(alien_vm_count--, new AgentVmInfo(entry.getKey(), null, entry.getValue().second(), entry.getValue().first(), entry.getValue().third()));
+                map.put(alien_vm_count--, new AgentVmInfo(entry.getKey(), null, entry.getValue().second(), entry.getValue().first()));
                 s_logger.warn("Found an alien VM " + entry.getKey());
             }
         }
@@ -2784,15 +2816,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
                     ") stopped on host " + hostDesc + " due to storage failure", "Virtual Machine " + vm.getInstanceName() + " (id: " + vm.getId() + ") running on host [" +
                             vm.getHostId() + "] stopped due to storage failure.");
         }
-        // track platform info
-        if (info.platform != null && !info.platform.isEmpty()) {
-            if (vm.getType() == VirtualMachine.Type.User) {
-                UserVmVO userVm = _userVmDao.findById(vm.getId());
-                _userVmDao.loadDetails(userVm);
-                userVm.setDetail("platform", info.platform);
-                _userVmDao.saveDetails(userVm);
-            }
-        }
 
         if (trackExternalChange) {
             if (serverState == State.Starting) {
@@ -3013,6 +3036,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
                         hs.setExecuted();
                     }
                 }
+            } else if ( answer instanceof ClusterVMMetaDataSyncAnswer) {
+                ClusterVMMetaDataSyncAnswer cvms = (ClusterVMMetaDataSyncAnswer)answer;
+                if (!cvms.isExecuted()) {
+                    syncVMMetaData(cvms.getVMMetaDatum());
+                    cvms.setExecuted();
+                }
             }
         }
         return true;
@@ -3046,7 +3075,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
                         }
                     }
                 }
-
                 if(VmJobEnabled.value()) {
                     if (ping.getHostVmStateReport() != null) {
                         _syncMgr.processHostVmStatePingReport(agentId, ping.getHostVmStateReport());
@@ -3105,7 +3133,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
                 if (allStates != null) {
                     fullSync(clusterId, allStates);
                 }
-
                 // initiate the cron job
                 ClusterSyncCommand syncCmd = new ClusterSyncCommand(ClusterDeltaSyncInterval.value(), clusterId);
                 try {
@@ -3115,6 +3142,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
                     s_logger.fatal("The Cluster VM sync process failed for cluster id " + clusterId + " with ", e);
                 }
             }
+            // initiate the cron job
+            ClusterVMMetaDataSyncCommand syncVMMetaDataCmd = new ClusterVMMetaDataSyncCommand(ClusterVMMetaDataSyncInterval.value(), clusterId);
+            try {
+                long seq_no = _agentMgr.send(agentId, new Commands(syncVMMetaDataCmd), this);
+                s_logger.debug("Cluster VM metadata sync started with jobid " + seq_no);
+            } catch (AgentUnavailableException e) {
+                s_logger.fatal("The Cluster VM metadata sync process failed for cluster id " + clusterId + " with ", e);
+            }
         } else { // for others KVM and VMWare
             if (!VmJobEnabled.value()) {
                 StartupRoutingCommand startup = (StartupRoutingCommand)cmd;
@@ -3185,33 +3220,22 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         public State state;
         public String hostUuid;
         public VMInstanceVO vm;
-        public String platform;
 
         @SuppressWarnings("unchecked")
-        public AgentVmInfo(String name, VMInstanceVO vm, State state, String host, String platform) {
+        public AgentVmInfo(String name, VMInstanceVO vm, State state, String host) {
             this.name = name;
             this.state = state;
             this.vm = vm;
             hostUuid = host;
-            this.platform = platform;
-
-        }
-
-        public AgentVmInfo(String name, VMInstanceVO vm, State state, String host) {
-            this(name, vm, state, host, null);
         }
 
         public AgentVmInfo(String name, VMInstanceVO vm, State state) {
-            this(name, vm, state, null, null);
+            this(name, vm, state, null);
         }
 
         public String getHostUuid() {
             return hostUuid;
         }
-
-        public String getPlatform() {
-            return platform;
-        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
index 70bdb6f..b729d9b 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
@@ -340,8 +340,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
             vmDao = ComponentContext.getComponent(VMInstanceDao.class);
             final List<? extends VMInstanceVO> vms = vmDao.listByHostId(hostId);
             for (VMInstanceVO vm : vms) {
-                states.put(vm.getInstanceName(), new HostVmStateReportEntry(vm.getState() == State.Running ? PowerState.PowerOn : PowerState.PowerOff, "host-" + hostId,
-                    null));
+                states.put(vm.getInstanceName(), new HostVmStateReportEntry(vm.getState() == State.Running ? PowerState.PowerOn : PowerState.PowerOff, "host-" + hostId));
             }
         }
         /*

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
index c79373a..549f06d 100644
--- a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
+++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
@@ -358,7 +358,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
 
         for (Map<String, String> vmMap : vmList) {
             String name = (String)vmMap.keySet().toArray()[0];
-            vmStates.put(name, new HostVmStateReportEntry(PowerState.valueOf(vmMap.get(name)), _guid, null));
+            vmStates.put(name, new HostVmStateReportEntry(PowerState.valueOf(vmMap.get(name)), _guid));
         }
         return vmStates;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index 3f6abfc..5912dd3 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -4530,7 +4530,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                 // Stopped VM around, to work-around that, reporting only powered-on VM
                 //
                 if (state == PowerState.PowerOn)
-                    vmStates.put(vmName, new HostVmStateReportEntry(state, conn.getHostName(), null));
+                    vmStates.put(vmName, new HostVmStateReportEntry(state, conn.getHostName()));
             } catch (final LibvirtException e) {
                 s_logger.warn("Unable to get vms", e);
             } finally {
@@ -4559,7 +4559,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                 // Stopped VM around, to work-around that, reporting only powered-on VM
                 //
                 if (state == PowerState.PowerOn)
-                    vmStates.put(vmName, new HostVmStateReportEntry(state, conn.getHostName(), null));
+                    vmStates.put(vmName, new HostVmStateReportEntry(state, conn.getHostName()));
             } catch (final LibvirtException e) {
                 s_logger.warn("Unable to get vms", e);
             } finally {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmResourceBase.java b/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmResourceBase.java
index 238ac51..1414502 100755
--- a/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmResourceBase.java
+++ b/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmResourceBase.java
@@ -808,7 +808,7 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
         Map<String, String> vms = OvmHost.getAllVms(_conn);
         for (final Map.Entry<String, String> entry : vms.entrySet()) {
             PowerState state = toPowerState(entry.getKey(), entry.getValue());
-            vmStates.put(entry.getKey(), new HostVmStateReportEntry(state, _conn.getIp(), null));
+            vmStates.put(entry.getKey(), new HostVmStateReportEntry(state, _conn.getIp()));
         }
         return vmStates;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/plugins/hypervisors/simulator/src/com/cloud/resource/AgentRoutingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/resource/AgentRoutingResource.java b/plugins/hypervisors/simulator/src/com/cloud/resource/AgentRoutingResource.java
index bb2851f..2fca291 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/resource/AgentRoutingResource.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/resource/AgentRoutingResource.java
@@ -280,7 +280,7 @@ public class AgentRoutingResource extends AgentStorageResource {
         HashMap<String, HostVmStateReportEntry> report = new HashMap<String, HostVmStateReportEntry>();
 
         for (String vmName : _runningVms.keySet()) {
-            report.put(vmName, new HostVmStateReportEntry(PowerState.PowerOn, agentHost.getName(), null));
+            report.put(vmName, new HostVmStateReportEntry(PowerState.PowerOn, agentHost.getName()));
         }
 
         return report;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 3eac0fc..4693f86 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -5238,7 +5238,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                         name = VMInternalCSName;
 
                     if (!isTemplate) {
-                        newStates.put(name, new HostVmStateReportEntry(convertPowerState(powerState), hyperHost.getHyperHostName(), null));
+                        newStates.put(name, new HostVmStateReportEntry(convertPowerState(powerState), hyperHost.getHyperHostName()));
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index 2b441e5..4a5de18 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -99,6 +99,8 @@ import com.cloud.agent.api.CheckVirtualMachineCommand;
 import com.cloud.agent.api.CleanupNetworkRulesCmd;
 import com.cloud.agent.api.ClusterSyncAnswer;
 import com.cloud.agent.api.ClusterSyncCommand;
+import com.cloud.agent.api.ClusterVMMetaDataSyncCommand;
+import com.cloud.agent.api.ClusterVMMetaDataSyncAnswer;
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.CreateStoragePoolCommand;
 import com.cloud.agent.api.CreateVMSnapshotAnswer;
@@ -511,6 +513,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
             return execute((UpdateHostPasswordCommand)cmd);
         } else if (cmd instanceof ClusterSyncCommand) {
             return execute((ClusterSyncCommand)cmd);
+        } else if (cmd instanceof ClusterVMMetaDataSyncCommand) {
+            return execute((ClusterVMMetaDataSyncCommand)cmd);
         } else if (clazz == CheckNetworkCommand.class) {
             return execute((CheckNetworkCommand)cmd);
         } else if (clazz == PlugNicCommand.class) {
@@ -1432,14 +1436,12 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                     platform.put("cores-per-socket", coresPerSocket);
                     vm.setPlatform(conn, platform);
                 }
-
-                String xentoolsversion = details.get("hypervisortoolsversion");
-                if (xentoolsversion == null || !xentoolsversion.equalsIgnoreCase("xenserver61")) {
-                    Map<String, String> platform = vm.getPlatform(conn);
-                    platform.remove("device_id");
-                    vm.setPlatform(conn, platform);
-                }
-
+            }
+            String xentoolsversion = details.get("hypervisortoolsversion");
+            if (xentoolsversion == null || !xentoolsversion.equalsIgnoreCase("xenserver61")) {
+                Map<String, String> platform = vm.getPlatform(conn);
+                platform.remove("device_id");
+                vm.setPlatform(conn, platform);
             }
         }
     }
@@ -2538,7 +2540,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
 
             VmPowerState ps = record.powerState;
             Host host = record.residentOn;
-            String xstoolsversion = getVMXenToolsVersion(record.platform);
             String host_uuid = null;
             if (!isRefNull(host)) {
                 try {
@@ -2554,7 +2555,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 if (host_uuid.equalsIgnoreCase(_host.uuid)) {
                     vmStates.put(
                             record.nameLabel,
-                            new HostVmStateReportEntry(convertPowerState(ps), host_uuid, xstoolsversion)
+                            new HostVmStateReportEntry(convertPowerState(ps), host_uuid)
                             );
                 }
             }
@@ -2564,8 +2565,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
     }
 
     // TODO vmsync {
-    protected HashMap<String, Ternary<String, State, String>> getAllVms(Connection conn) {
-        final HashMap<String, Ternary<String, State, String>> vmStates = new HashMap<String, Ternary<String, State, String>>();
+    protected HashMap<String, Pair<String, State>> getAllVms(Connection conn) {
+        final HashMap<String, Pair<String, State>> vmStates = new HashMap<String, Pair<String, State>>();
         Map<VM, VM.Record> vm_map = null;
         for (int i = 0; i < 2; i++) {
             try {
@@ -2595,7 +2596,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 s_logger.trace("VM " + record.nameLabel + ": powerstate = " + ps + "; vm state=" + state.toString());
             }
             Host host = record.residentOn;
-            String platformstring = StringUtils.mapToString(record.platform);
             String host_uuid = null;
             if (!isRefNull(host)) {
                 try {
@@ -2607,7 +2607,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 } catch (XmlRpcException e) {
                     s_logger.error("Failed to get host uuid for host " + host.toWireString(), e);
                 }
-                vmStates.put(record.nameLabel, new Ternary<String, State, String>(host_uuid, state, platformstring));
+                vmStates.put(record.nameLabel, new Pair<String, State>(host_uuid, state));
             }
         }
 
@@ -3602,11 +3602,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         return new StopAnswer(cmd, "Stop VM failed", platformstring, false);
     }
 
-    /*Override by subclass*/
-    protected String getVMXenToolsVersion(Map<String, String> platform) {
-        return "xenserver56";
-    }
-
     private List<VDI> getVdis(Connection conn, VM vm) {
         List<VDI> vdis = new ArrayList<VDI>();
         try {
@@ -4480,7 +4475,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
 
             Host.Record hostr = poolr.master.getRecord(conn);
             if (_host.uuid.equals(hostr.uuid)) {
-                HashMap<String, Ternary<String, State, String>> allStates = fullClusterSync(conn);
+                HashMap<String, Pair<String, State>> allStates = fullClusterSync(conn);
                 cmd.setClusterVMStateChanges(allStates);
             }
         } catch (Throwable e) {
@@ -7052,11 +7047,49 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
             s_logger.warn("Check for master failed, failing the Cluster sync command");
             return new Answer(cmd);
         }
-        HashMap<String, Ternary<String, State, String>> newStates = deltaClusterSync(conn);
+        HashMap<String, Pair<String, State>> newStates = deltaClusterSync(conn);
         return new ClusterSyncAnswer(cmd.getClusterId(), newStates);
     }
 
-    protected HashMap<String, Ternary<String, State, String>> fullClusterSync(Connection conn) {
+
+    protected ClusterVMMetaDataSyncAnswer execute(final ClusterVMMetaDataSyncCommand cmd) {
+        Connection conn = getConnection();
+        //check if this is master
+        Pool pool;
+        try {
+            pool = Pool.getByUuid(conn, _host.pool);
+            Pool.Record poolr = pool.getRecord(conn);
+            Host.Record hostr = poolr.master.getRecord(conn);
+            if (!_host.uuid.equals(hostr.uuid)) {
+                return new ClusterVMMetaDataSyncAnswer(cmd.getClusterId(), null);
+            }
+        } catch (Throwable e) {
+            s_logger.warn("Check for master failed, failing the Cluster sync VMMetaData command");
+            return new ClusterVMMetaDataSyncAnswer(cmd.getClusterId(), null);
+        }
+        HashMap<String, String> vmMetadatum = clusterVMMetaDataSync(conn);
+        return new ClusterVMMetaDataSyncAnswer(cmd.getClusterId(), vmMetadatum);
+    }
+
+    protected HashMap<String, String> clusterVMMetaDataSync(Connection conn) {
+        final HashMap<String, String> vmMetaDatum = new HashMap<String, String>();
+        try {
+            Map<VM, VM.Record>  vm_map = VM.getAllRecords(conn);  //USE THIS TO GET ALL VMS FROM  A CLUSTER
+            for (VM.Record record: vm_map.values()) {
+                if (record.isControlDomain || record.isASnapshot || record.isATemplate) {
+                    continue; // Skip DOM0
+                }
+                vmMetaDatum.put(record.nameLabel, StringUtils.mapToString(record.platform));
+            }
+        } catch (final Throwable e) {
+            String msg = "Unable to get vms through host " + _host.uuid + " due to to " + e.toString();
+            s_logger.warn(msg, e);
+            throw new CloudRuntimeException(msg);
+        }
+        return vmMetaDatum;
+    }
+
+    protected HashMap<String, Pair<String, State>> fullClusterSync(Connection conn) {
         synchronized (_cluster.intern()) {
             s_vms.clear(_cluster);
         }
@@ -7074,7 +7107,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 if (!isRefNull(host)) {
                     host_uuid = host.getUuid(conn);
                     synchronized (_cluster.intern()) {
-                        s_vms.put(_cluster, host_uuid, vm_name, state, null);
+                        s_vms.put(_cluster, host_uuid, vm_name, state);
                     }
                 }
                 if (s_logger.isTraceEnabled()) {
@@ -7089,44 +7122,32 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         return s_vms.getClusterVmState(_cluster);
     }
 
-    protected HashMap<String, Ternary<String, State, String>> deltaClusterSync(Connection conn) {
-        final HashMap<String, Ternary<String, State, String>> changes = new HashMap<String, Ternary<String, State, String>>();
+    protected HashMap<String, Pair<String, State>> deltaClusterSync(Connection conn) {
+        final HashMap<String, Pair<String, State>> changes = new HashMap<String, Pair<String, State>>();
 
         synchronized (_cluster.intern()) {
-            HashMap<String, Ternary<String, State, String>> newStates = getAllVms(conn);
+            HashMap<String, Pair<String, State>> newStates = getAllVms(conn);
             if (newStates == null) {
                 s_logger.warn("Unable to get the vm states so no state sync at this point.");
                 return null;
             }
-            HashMap<String, Ternary<String, State, String>> oldStates = new HashMap<String, Ternary<String, State, String>>(s_vms.size(_cluster));
+            HashMap<String, Pair<String, State>> oldStates = new HashMap<String, Pair<String, State>>(s_vms.size(_cluster));
             oldStates.putAll(s_vms.getClusterVmState(_cluster));
 
-            for (final Map.Entry<String, Ternary<String, State, String>> entry : newStates.entrySet()) {
+            for (final Map.Entry<String, Pair<String, State>> entry : newStates.entrySet()) {
                 final String vm = entry.getKey();
-                String platform = entry.getValue().third();
                 State newState = entry.getValue().second();
                 String host_uuid = entry.getValue().first();
-                final Ternary<String, State, String> oldState = oldStates.remove(vm);
+                final Pair<String, State> oldState = oldStates.remove(vm);
 
-                // check if platform changed
-                if (platform != null && oldState != null) {
-                    if (!platform.equals(oldState.third()) && newState != State.Stopped && newState != State.Stopping) {
-                        s_logger.warn("Detecting a change in platform for " + vm);
-                        changes.put(vm, new Ternary<String, State, String>(host_uuid, newState, platform));
-
-                        s_logger.debug("11. The VM " + vm + " is in " + newState + " state");
-                        s_vms.put(_cluster, host_uuid, vm, newState, platform);
-                        continue;
-                    }
-                }
                 //check if host is changed
                 if (host_uuid != null && oldState != null) {
                     if (!host_uuid.equals(oldState.first()) && newState != State.Stopped && newState != State.Stopping) {
                         s_logger.warn("Detecting a change in host for " + vm);
-                        changes.put(vm, new Ternary<String, State, String>(host_uuid, newState, platform));
+                        changes.put(vm, new Pair<String, State>(host_uuid, newState));
 
                         s_logger.debug("11. The VM " + vm + " is in " + newState + " state");
-                        s_vms.put(_cluster, host_uuid, vm, newState, platform);
+                        s_vms.put(_cluster, host_uuid, vm, newState);
                         continue;
                     }
                 }
@@ -7144,42 +7165,42 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                     continue;
                 }
                 if (oldState == null) {
-                    s_vms.put(_cluster, host_uuid, vm, newState, platform);
+                    s_vms.put(_cluster, host_uuid, vm, newState);
                     s_logger.warn("Detecting a new state but couldn't find a old state so adding it to the changes: " + vm);
-                    changes.put(vm, new Ternary<String, State, String>(host_uuid, newState, platform));
+                    changes.put(vm, new Pair<String, State>(host_uuid, newState));
                 } else if (oldState.second() == State.Starting) {
                     if (newState == State.Running) {
                         s_logger.debug("12. The VM " + vm + " is in " + State.Running + " state");
-                        s_vms.put(_cluster, host_uuid, vm, newState, platform);
+                        s_vms.put(_cluster, host_uuid, vm, newState);
                     } else if (newState == State.Stopped) {
                         s_logger.warn("Ignoring vm " + vm + " because of a lag in starting the vm.");
                     }
                 } else if (oldState.second() == State.Migrating) {
                     if (newState == State.Running) {
                         s_logger.debug("Detected that an migrating VM is now running: " + vm);
-                        s_vms.put(_cluster, host_uuid, vm, newState, platform);
+                        s_vms.put(_cluster, host_uuid, vm, newState);
                     }
                 } else if (oldState.second() == State.Stopping) {
                     if (newState == State.Stopped) {
                         s_logger.debug("13. The VM " + vm + " is in " + State.Stopped + " state");
-                        s_vms.put(_cluster, host_uuid, vm, newState, platform);
+                        s_vms.put(_cluster, host_uuid, vm, newState);
                     } else if (newState == State.Running) {
                         s_logger.warn("Ignoring vm " + vm + " because of a lag in stopping the vm. ");
                     }
                 } else if (oldState.second() != newState) {
                     s_logger.debug("14. The VM " + vm + " is in " + newState + " state was " + oldState.second());
-                    s_vms.put(_cluster, host_uuid, vm, newState, platform);
+                    s_vms.put(_cluster, host_uuid, vm, newState);
                     if (newState == State.Stopped) {
                         /*
                          * if (s_vmsKilled.remove(vm)) { s_logger.debug("VM " + vm + " has been killed for storage. ");
                          * newState = State.Error; }
                          */
                     }
-                    changes.put(vm, new Ternary<String, State, String>(host_uuid, newState, null));
+                    changes.put(vm, new Pair<String, State>(host_uuid, newState));
                 }
             }
 
-            for (final Map.Entry<String, Ternary<String, State, String>> entry : oldStates.entrySet()) {
+            for (final Map.Entry<String, Pair<String, State>> entry : oldStates.entrySet()) {
                 final String vm = entry.getKey();
                 final State oldState = entry.getValue().second();
                 String host_uuid = entry.getValue().first();
@@ -7201,7 +7222,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 } else {
                     State newState = State.Stopped;
                     s_logger.warn("The VM is now missing marking it as Stopped " + vm);
-                    changes.put(vm, new Ternary<String, State, String>(host_uuid, newState, null));
+                    changes.put(vm, new Pair<String, State>(host_uuid, newState));
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer610Resource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer610Resource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer610Resource.java
index b7199c8..ffedaff 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer610Resource.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer610Resource.java
@@ -446,12 +446,4 @@ public class XenServer610Resource extends XenServer56FP1Resource {
     protected void plugDom0Vif(Connection conn, VIF dom0Vif) throws XmlRpcException, XenAPIException {
         // do nothing. In xenserver 6.1 and beyond this step isn't needed.
     }
-
-    @Override
-    protected String getVMXenToolsVersion(Map<String, String> platform) {
-        if (platform.containsKey("device_id")) {
-            return "xenserver61";
-        }
-        return "xenserver56";
-    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerPoolVms.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerPoolVms.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerPoolVms.java
index 767d77e..488acec 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerPoolVms.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerPoolVms.java
@@ -22,18 +22,18 @@ import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.log4j.Logger;
 
-import com.cloud.utils.Ternary;
+import com.cloud.utils.Pair;
 import com.cloud.vm.VirtualMachine.State;
 
 public class XenServerPoolVms {
     private static final Logger s_logger = Logger.getLogger(XenServerPoolVms.class);
-    private final Map<String/* clusterId */, HashMap<String/* vm name */, Ternary<String/* host uuid */, State/* vm state */, String/* PV driver version*/>>> _clusterVms =
-        new ConcurrentHashMap<String, HashMap<String, Ternary<String, State, String>>>();
+    private final Map<String/* clusterId */, HashMap<String/* vm name */, Pair<String/* host uuid */, State/* vm state */>>> _clusterVms =
+        new ConcurrentHashMap<String, HashMap<String, Pair<String, State>>>();
 
-    public HashMap<String, Ternary<String, State, String>> getClusterVmState(String clusterId) {
-        HashMap<String, Ternary<String, State, String>> _vms = _clusterVms.get(clusterId);
+    public HashMap<String, Pair<String, State>> getClusterVmState(String clusterId) {
+        HashMap<String, Pair<String, State>> _vms = _clusterVms.get(clusterId);
         if (_vms == null) {
-            HashMap<String, Ternary<String, State, String>> vmStates = new HashMap<String, Ternary<String, State, String>>();
+            HashMap<String, Pair<String, State>> vmStates = new HashMap<String, Pair<String, State>>();
             _clusterVms.put(clusterId, vmStates);
             return vmStates;
         } else
@@ -41,50 +41,45 @@ public class XenServerPoolVms {
     }
 
     public void clear(String clusterId) {
-        HashMap<String, Ternary<String, State, String>> _vms = getClusterVmState(clusterId);
+        HashMap<String, Pair<String, State>> _vms = getClusterVmState(clusterId);
         _vms.clear();
     }
 
     public State getState(String clusterId, String name) {
-        HashMap<String, Ternary<String, State, String>> vms = getClusterVmState(clusterId);
-        Ternary<String, State, String> pv = vms.get(name);
+        HashMap<String, Pair<String, State>> vms = getClusterVmState(clusterId);
+        Pair<String, State> pv = vms.get(name);
         return pv == null ? State.Stopped : pv.second(); // if a VM is absent on the cluster, it is effectively in stopped state.
     }
 
-    public Ternary<String, State, String> get(String clusterId, String name) {
-        HashMap<String, Ternary<String, State, String>> vms = getClusterVmState(clusterId);
+    public Pair<String, State> get(String clusterId, String name) {
+        HashMap<String, Pair<String, State>> vms = getClusterVmState(clusterId);
         return vms.get(name);
     }
 
-    public void put(String clusterId, String hostUuid, String name, State state, String platform) {
-        HashMap<String, Ternary<String, State, String>> vms = getClusterVmState(clusterId);
-        vms.put(name, new Ternary<String, State, String>(hostUuid, state, platform));
-    }
-
     public void put(String clusterId, String hostUuid, String name, State state) {
-        HashMap<String, Ternary<String, State, String>> vms = getClusterVmState(clusterId);
-        vms.put(name, new Ternary<String, State, String>(hostUuid, state, null));
+        HashMap<String, Pair<String, State>> vms = getClusterVmState(clusterId);
+        vms.put(name, new Pair<String, State>(hostUuid, state));
     }
 
     public void remove(String clusterId, String hostUuid, String name) {
-        HashMap<String, Ternary<String, State, String>> vms = getClusterVmState(clusterId);
+        HashMap<String, Pair<String, State>> vms = getClusterVmState(clusterId);
         vms.remove(name);
     }
 
-    public void putAll(String clusterId, HashMap<String, Ternary<String, State, String>> newVms) {
-        HashMap<String, Ternary<String, State, String>> vms = getClusterVmState(clusterId);
+    public void putAll(String clusterId, HashMap<String, Pair<String, State>> newVms) {
+        HashMap<String, Pair<String, State>> vms = getClusterVmState(clusterId);
         vms.putAll(newVms);
     }
 
     public int size(String clusterId) {
-        HashMap<String, Ternary<String, State, String>> vms = getClusterVmState(clusterId);
+        HashMap<String, Pair<String, State>> vms = getClusterVmState(clusterId);
         return vms.size();
     }
 
     @Override
     public String toString() {
         StringBuilder sbuf = new StringBuilder("PoolVms=");
-        for (HashMap<String/* vm name */, Ternary<String/* host uuid */, State/* vm state */, String>> clusterVM : _clusterVms.values()) {
+        for (HashMap<String/* vm name */, Pair<String/* host uuid */, State/* vm state */>> clusterVM : _clusterVms.values()) {
             for (String vmname : clusterVM.keySet()) {
                 sbuf.append(vmname).append("-").append(clusterVM.get(vmname).second()).append(",");
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ab1d3af4/plugins/hypervisors/xen/src/org/apache/cloudstack/hypervisor/xenserver/XenServerResourceNewBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/org/apache/cloudstack/hypervisor/xenserver/XenServerResourceNewBase.java b/plugins/hypervisors/xen/src/org/apache/cloudstack/hypervisor/xenserver/XenServerResourceNewBase.java
index 438a392..ec203d8 100644
--- a/plugins/hypervisors/xen/src/org/apache/cloudstack/hypervisor/xenserver/XenServerResourceNewBase.java
+++ b/plugins/hypervisors/xen/src/org/apache/cloudstack/hypervisor/xenserver/XenServerResourceNewBase.java
@@ -40,7 +40,7 @@ import com.cloud.agent.api.ClusterSyncAnswer;
 import com.cloud.agent.api.ClusterSyncCommand;
 import com.cloud.agent.api.StartupCommand;
 import com.cloud.hypervisor.xen.resource.XenServer610Resource;
-import com.cloud.utils.Ternary;
+import com.cloud.utils.Pair;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineName;
@@ -148,13 +148,13 @@ public class XenServerResourceNewBase extends XenServer610Resource {
             return new Answer(cmd);
         }
 
-        HashMap<String, Ternary<String, VirtualMachine.State, String>> newStates = _listener.getChanges();
+        HashMap<String, Pair<String, VirtualMachine.State>> newStates = _listener.getChanges();
         return new ClusterSyncAnswer(cmd.getClusterId(), newStates);
     }
 
     protected class VmEventListener extends Thread {
         boolean _stop = false;
-        HashMap<String, Ternary<String, VirtualMachine.State, String>> _changes = new HashMap<String, Ternary<String, VirtualMachine.State, String>>();
+        HashMap<String, Pair<String, VirtualMachine.State>> _changes = new HashMap<String, Pair<String, VirtualMachine.State>>();
         boolean _isMaster;
         Set<String> _classes;
         String _token = "";
@@ -232,12 +232,12 @@ public class XenServerResourceNewBase extends XenServer610Resource {
 
             // NOTE: For now we only record change when the VM is stopped.  We don't find out any VMs starting for now.
             synchronized (_cluster.intern()) {
-                Ternary<String, VirtualMachine.State, String> oldState = s_vms.get(_cluster, vm);
+                Pair<String, VirtualMachine.State> oldState = s_vms.get(_cluster, vm);
                 if (oldState == null) {
                     if (s_logger.isTraceEnabled()) {
                         s_logger.trace("Unable to find " + vm + " from previous map.  Assuming it was in Stopped state.");
                     }
-                    oldState = new Ternary<String, VirtualMachine.State, String>(null, VirtualMachine.State.Stopped, null);
+                    oldState = new Pair<String, VirtualMachine.State>(null, VirtualMachine.State.Stopped);
                 }
 
                 if (s_logger.isTraceEnabled()) {
@@ -281,7 +281,7 @@ public class XenServerResourceNewBase extends XenServer610Resource {
                     }
                 }
                 if (reportChange) {
-                    Ternary<String, VirtualMachine.State, String> change = _changes.get(vm);
+                    Pair<String, VirtualMachine.State> change = _changes.get(vm);
                     if (hostUuid == null) {
                         // This is really strange code.  It looks like the sync
                         // code wants this to be set, which is extremely weird
@@ -293,7 +293,7 @@ public class XenServerResourceNewBase extends XenServer610Resource {
                         }
                     }
                     if (change == null) {
-                        change = new Ternary<String, VirtualMachine.State, String>(hostUuid, currentState, null);
+                        change = new Pair<String, VirtualMachine.State>(hostUuid, currentState);
                     } else {
                         change.first(hostUuid);
                         change.second(currentState);
@@ -325,13 +325,13 @@ public class XenServerResourceNewBase extends XenServer610Resource {
             return _isMaster;
         }
 
-        public HashMap<String, Ternary<String, VirtualMachine.State, String>> getChanges() {
+        public HashMap<String, Pair<String, VirtualMachine.State>> getChanges() {
             synchronized (_cluster.intern()) {
                 if (_changes.size() == 0) {
                     return null;
                 }
-                HashMap<String, Ternary<String, VirtualMachine.State, String>> diff = _changes;
-                _changes = new HashMap<String, Ternary<String, VirtualMachine.State, String>>();
+                HashMap<String, Pair<String, VirtualMachine.State>> diff = _changes;
+                _changes = new HashMap<String, Pair<String, VirtualMachine.State>>();
                 return diff;
             }
         }


[47/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
Update plugins side nav icon


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

Branch: refs/heads/resize-root
Commit: e37a6cd115e9c5f3ea50e1c77cc474bb5eb5c5d7
Parents: 7b0c5cf
Author: Brian Federle <br...@citrix.com>
Authored: Fri Mar 7 11:49:48 2014 -0800
Committer: Brian Federle <br...@citrix.com>
Committed: Fri Mar 7 11:50:00 2014 -0800

----------------------------------------------------------------------
 ui/images/sprites.png | Bin 211703 -> 211543 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e37a6cd1/ui/images/sprites.png
----------------------------------------------------------------------
diff --git a/ui/images/sprites.png b/ui/images/sprites.png
index 0af9a29..ab39670 100644
Binary files a/ui/images/sprites.png and b/ui/images/sprites.png differ


[03/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-6199: Add the column display_event to event table
~


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

Branch: refs/heads/resize-root
Commit: f291951990fbf0c51c2e9aa95d246d73e8abde8b
Parents: 8b0e04b
Author: Nitin Mehta <ni...@citrix.com>
Authored: Tue Mar 4 18:26:09 2014 -0800
Committer: Nitin Mehta <ni...@citrix.com>
Committed: Tue Mar 4 18:26:09 2014 -0800

----------------------------------------------------------------------
 setup/db/db/schema-430to440.sql | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f2919519/setup/db/db/schema-430to440.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-430to440.sql b/setup/db/db/schema-430to440.sql
index ec7ee4d..f755a08 100644
--- a/setup/db/db/schema-430to440.sql
+++ b/setup/db/db/schema-430to440.sql
@@ -543,6 +543,8 @@ ALTER TABLE `cloud`.`s2s_vpn_gateway` ADD COLUMN `display` tinyint(1) NOT NULL D
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (225, UUID(), 9, 'FreeBSD 10 (32-bit)');
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (226, UUID(), 9, 'FreeBSD 10 (64-bit)');
 
+ALTER TABLE `cloud`.`event` ADD COLUMN `display_event` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the detail can be displayed to the end user';
+
 DROP VIEW IF EXISTS `cloud`.`event_view`;
 CREATE VIEW `cloud`.`event_view` AS
     select


[06/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
CLOUDSTACK-5920: IAM service server.


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

Branch: refs/heads/resize-root
Commit: adb29b21402d4b446471c2d2741e09cd7b2106aa
Parents: 793becf
Author: Min Chen <mi...@citrix.com>
Authored: Tue Mar 4 17:51:17 2014 -0800
Committer: Min Chen <mi...@citrix.com>
Committed: Wed Mar 5 09:40:55 2014 -0800

----------------------------------------------------------------------
 services/iam/server/pom.xml                     |  52 ++
 .../core/spring-iam-server-context.xml          |  40 +
 .../org/apache/cloudstack/iam/api/IAMGroup.java |  37 +
 .../apache/cloudstack/iam/api/IAMPolicy.java    |  41 +
 .../cloudstack/iam/api/IAMPolicyPermission.java |  53 ++
 .../apache/cloudstack/iam/api/IAMService.java   |  92 +++
 .../iam/server/IAMAccountPolicyMapVO.java       |  77 ++
 .../iam/server/IAMGroupAccountMapVO.java        |  78 ++
 .../iam/server/IAMGroupPolicyMapVO.java         |  79 ++
 .../cloudstack/iam/server/IAMGroupVO.java       | 122 +++
 .../iam/server/IAMPolicyPermissionVO.java       | 181 ++++
 .../cloudstack/iam/server/IAMPolicyVO.java      | 138 ++++
 .../cloudstack/iam/server/IAMServiceImpl.java   | 815 +++++++++++++++++++
 .../iam/server/dao/IAMAccountPolicyMapDao.java  |  17 +
 .../server/dao/IAMAccountPolicyMapDaoImpl.java  |  61 ++
 .../iam/server/dao/IAMGroupAccountMapDao.java   |  40 +
 .../server/dao/IAMGroupAccountMapDaoImpl.java   | 119 +++
 .../cloudstack/iam/server/dao/IAMGroupDao.java  |  28 +
 .../iam/server/dao/IAMGroupDaoImpl.java         |  59 ++
 .../iam/server/dao/IAMGroupPolicyMapDao.java    |  16 +
 .../server/dao/IAMGroupPolicyMapDaoImpl.java    |  61 ++
 .../cloudstack/iam/server/dao/IAMPolicyDao.java |  28 +
 .../iam/server/dao/IAMPolicyDaoImpl.java        |  57 ++
 .../iam/server/dao/IAMPolicyPermissionDao.java  |  39 +
 .../server/dao/IAMPolicyPermissionDaoImpl.java  | 129 +++
 .../cloudstack/iam/IAMServiceUnitTest.java      | 211 +++++
 .../iam/server/test/resources/db.properties     |  75 ++
 27 files changed, 2745 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/pom.xml
----------------------------------------------------------------------
diff --git a/services/iam/server/pom.xml b/services/iam/server/pom.xml
new file mode 100644
index 0000000..bed8811
--- /dev/null
+++ b/services/iam/server/pom.xml
@@ -0,0 +1,52 @@
+<!--
+  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-iam</artifactId>
+  <name>Apache CloudStack IAM - Server</name>
+  <parent>
+    <groupId>org.apache.cloudstack</groupId>
+    <artifactId>cloudstack-service-iam</artifactId>
+    <version>4.4.0-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+  <dependencies>
+	<dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-utils</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+	<dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-api</artifactId>
+      <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>      
+    </dependency>       
+  </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/resources/META-INF/cloudstack/core/spring-iam-server-context.xml
----------------------------------------------------------------------
diff --git a/services/iam/server/resources/META-INF/cloudstack/core/spring-iam-server-context.xml b/services/iam/server/resources/META-INF/cloudstack/core/spring-iam-server-context.xml
new file mode 100644
index 0000000..c9f383f
--- /dev/null
+++ b/services/iam/server/resources/META-INF/cloudstack/core/spring-iam-server-context.xml
@@ -0,0 +1,40 @@
+<!--
+  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="IAMGroupDaoImpl" class="org.apache.cloudstack.iam.server.dao.IAMGroupDaoImpl" />
+    <bean id="IAMPolicyDaoImpl" class="org.apache.cloudstack.iam.server.dao.IAMPolicyDaoImpl" />    
+    <bean id="IAMGroupAccountMapDaoImpl" class="org.apache.cloudstack.iam.server.dao.IAMGroupAccountMapDaoImpl" />
+    <bean id="IAMGroupPolicyMapDaoImpl" class="org.apache.cloudstack.iam.server.dao.IAMGroupPolicyMapDaoImpl" />    
+    <bean id="IAMPolicyPermissionDaoImpl" class="org.apache.cloudstack.iam.server.dao.IAMPolicyPermissionDaoImpl" />
+    <bean id="IAMAccountPolicyMapDaoImpl" class="org.apache.cloudstack.iam.server.dao.IAMAccountPolicyMapDaoImpl" />    
+
+        
+    <bean id="IAMServiceImpl" class="org.apache.cloudstack.iam.server.IAMServiceImpl" />
+
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/api/IAMGroup.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/api/IAMGroup.java b/services/iam/server/src/org/apache/cloudstack/iam/api/IAMGroup.java
new file mode 100644
index 0000000..868d0a0
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/api/IAMGroup.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.iam.api;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+public interface IAMGroup extends InternalIdentity, Identity {
+
+    String getName();
+
+    String getDescription();
+
+    @Override
+    long getId();
+
+    @Override
+    String getUuid();
+
+    String getPath();
+
+    long getAccountId();
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/api/IAMPolicy.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/api/IAMPolicy.java b/services/iam/server/src/org/apache/cloudstack/iam/api/IAMPolicy.java
new file mode 100644
index 0000000..e6daeb1
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/api/IAMPolicy.java
@@ -0,0 +1,41 @@
+// 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.iam.api;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+public interface IAMPolicy extends InternalIdentity, Identity {
+
+    String getName();
+
+    String getDescription();
+
+    public enum PolicyType {
+        Static, Dynamic
+    }
+
+    @Override
+    long getId();
+
+    @Override
+    String getUuid();
+
+    String getPath();
+
+    long getAccountId();
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/api/IAMPolicyPermission.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/api/IAMPolicyPermission.java b/services/iam/server/src/org/apache/cloudstack/iam/api/IAMPolicyPermission.java
new file mode 100644
index 0000000..b91086f
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/api/IAMPolicyPermission.java
@@ -0,0 +1,53 @@
+// 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.iam.api;
+
+
+public interface IAMPolicyPermission {
+
+    String getAction();
+
+    long getAclPolicyId();
+
+    String getEntityType();
+
+    String getAccessType();
+
+    String getScope();
+
+    Long getScopeId();
+
+    Permission getPermission();
+
+    public enum Permission {
+        Allow(true), Deny(false);
+
+        boolean result;
+
+        Permission(boolean result) {
+            this.result = result;
+        }
+
+        public boolean isGranted() {
+            return result;
+        }
+    }
+
+    long getId();
+
+    public static final long PERMISSION_SCOPE_ID_CURRENT_CALLER = -1;
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/api/IAMService.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/api/IAMService.java b/services/iam/server/src/org/apache/cloudstack/iam/api/IAMService.java
new file mode 100644
index 0000000..74a0885
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/api/IAMService.java
@@ -0,0 +1,92 @@
+// 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.iam.api;
+
+import java.util.List;
+
+import org.apache.cloudstack.iam.api.IAMPolicyPermission.Permission;
+
+import com.cloud.utils.Pair;
+
+public interface IAMService {
+
+    /* IAM group related interfaces */
+    IAMGroup createIAMGroup(String iamGroupName, String description, String path);
+
+    boolean deleteIAMGroup(Long iamGroupId);
+
+    List<IAMGroup> listIAMGroups(long accountId);
+
+    IAMGroup addAccountsToGroup(List<Long> acctIds, Long groupId);
+
+    IAMGroup removeAccountsFromGroup(List<Long> acctIds, Long groupId);
+
+    List<Long> listAccountsByGroup(long groupId);
+
+    Pair<List<IAMGroup>, Integer> listIAMGroups(Long iamGroupId, String iamGroupName, String path, Long startIndex, Long pageSize);
+
+    /* IAM Policy related interfaces */
+    IAMPolicy createIAMPolicy(String iamPolicyName, String description, Long parentPolicyId, String path);
+
+    boolean deleteIAMPolicy(long iamPolicyId);
+
+    List<IAMPolicy> listIAMPolicies(long accountId);
+
+    List<IAMPolicy> listIAMPoliciesByGroup(long groupId);
+
+    Pair<List<IAMPolicy>, Integer> listIAMPolicies(Long iamPolicyId, String iamPolicyName, String path, Long startIndex, Long pageSize);
+
+    IAMGroup attachIAMPoliciesToGroup(List<Long> policyIds, Long groupId);
+
+    IAMGroup removeIAMPoliciesFromGroup(List<Long> policyIds, Long groupId);
+
+    void attachIAMPolicyToAccounts(Long policyId, List<Long> acctIds);
+
+    void removeIAMPolicyFromAccounts(Long policyId, List<Long> acctIds);
+
+    IAMPolicy addIAMPermissionToIAMPolicy(long iamPolicyId, String entityType, String scope, Long scopeId,
+            String action, String accessType, Permission perm, Boolean recursive);
+
+    IAMPolicy removeIAMPermissionFromIAMPolicy(long iamPolicyId, String entityType, String scope, Long scopeId,
+            String action);
+
+    void removeIAMPermissionForEntity(final String entityType, final Long entityId);
+
+    IAMPolicy getResourceGrantPolicy(String entityType, Long entityId, String accessType, String action);
+
+    IAMPolicy getResourceOwnerPolicy();
+
+    List<IAMPolicyPermission> listPolicyPermissions(long policyId);
+
+    List<IAMPolicyPermission> listPolicyPermissionsByScope(long policyId, String action, String scope);
+
+    List<IAMPolicyPermission> listPolicyPermissionByActionAndEntity(long policyId, String action, String entityType);
+
+    boolean isActionAllowedForPolicies(String action, List<IAMPolicy> policies);
+
+    List<Long> getGrantedEntities(long accountId, String action, String scope);
+
+    IAMPolicy resetIAMPolicy(long iamPolicyId);
+
+    List<IAMPolicyPermission> listPolicyPermissionByAccessAndEntity(long policyId, String accessType,
+            String entityType);
+
+    List<IAMGroup> listParentIAMGroups(long groupId);
+
+    List<IAMPolicy> listRecursiveIAMPoliciesByGroup(long groupId);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/IAMAccountPolicyMapVO.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/IAMAccountPolicyMapVO.java b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMAccountPolicyMapVO.java
new file mode 100644
index 0000000..18f085a
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMAccountPolicyMapVO.java
@@ -0,0 +1,77 @@
+// 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.iam.server;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name = ("iam_account_policy_map"))
+public class IAMAccountPolicyMapVO {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private Long id;
+
+    @Column(name = "account_id")
+    private long accountId;
+
+    @Column(name = "policy_id")
+    private long iamPolicyId;
+
+    @Column(name = GenericDao.REMOVED_COLUMN)
+    private Date removed;
+
+    @Column(name = GenericDao.CREATED_COLUMN)
+    private Date created;
+
+    public IAMAccountPolicyMapVO() {
+    }
+
+    public IAMAccountPolicyMapVO(long accountId, long iamPolicyId) {
+        this.accountId = accountId;
+        this.iamPolicyId = iamPolicyId;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public long getAccountId() {
+        return accountId;
+    }
+
+    public long getIamPolicyId() {
+        return iamPolicyId;
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/IAMGroupAccountMapVO.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/IAMGroupAccountMapVO.java b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMGroupAccountMapVO.java
new file mode 100644
index 0000000..dac7d35
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMGroupAccountMapVO.java
@@ -0,0 +1,78 @@
+// 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.iam.server;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name = ("iam_group_account_map"))
+public class IAMGroupAccountMapVO {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private Long id;
+
+    @Column(name = "group_id")
+    private long aclGroupId;
+
+    @Column(name = "account_id")
+    private long accountId;
+
+    @Column(name = GenericDao.REMOVED_COLUMN)
+    private Date removed;
+
+    @Column(name = GenericDao.CREATED_COLUMN)
+    private Date created;
+
+    public IAMGroupAccountMapVO() {
+    }
+
+    public IAMGroupAccountMapVO(long aclGroupId, long accountId) {
+        this.aclGroupId = aclGroupId;
+        this.accountId = accountId;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public long getAclGroupId() {
+        return aclGroupId;
+    }
+
+
+    public long getAccountId() {
+        return accountId;
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/IAMGroupPolicyMapVO.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/IAMGroupPolicyMapVO.java b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMGroupPolicyMapVO.java
new file mode 100644
index 0000000..946d1f7
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMGroupPolicyMapVO.java
@@ -0,0 +1,79 @@
+// 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.iam.server;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name = ("iam_group_policy_map"))
+public class IAMGroupPolicyMapVO {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private Long id;
+
+    @Column(name = "group_id")
+    private long aclGroupId;
+
+    @Column(name = "policy_id")
+    private long aclPolicyId;
+
+    @Column(name = GenericDao.REMOVED_COLUMN)
+    private Date removed;
+
+    @Column(name = GenericDao.CREATED_COLUMN)
+    private Date created;
+
+    public IAMGroupPolicyMapVO() {
+    }
+
+    public IAMGroupPolicyMapVO(long aclGroupId, long aclPolicyId) {
+        this.aclGroupId = aclGroupId;
+        this.aclPolicyId = aclPolicyId;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public long getAclGroupId() {
+        return aclGroupId;
+    }
+
+
+    public long getAclPolicyId() {
+        return aclPolicyId;
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/IAMGroupVO.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/IAMGroupVO.java b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMGroupVO.java
new file mode 100644
index 0000000..80edb89
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMGroupVO.java
@@ -0,0 +1,122 @@
+// 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.iam.server;
+
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.iam.api.IAMGroup;
+
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name = ("iam_group"))
+public class IAMGroupVO implements IAMGroup {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private long id;
+
+    @Column(name = "name")
+    private String name;
+
+    @Column(name = "description")
+    private String description;
+
+    @Column(name = "uuid")
+    private String uuid;
+
+    @Column(name = "path")
+    private String path;
+
+    @Column(name = "account_id")
+    private long accountId;
+
+    @Column(name = GenericDao.REMOVED_COLUMN)
+    private Date removed;
+
+    @Column(name = GenericDao.CREATED_COLUMN)
+    private Date created;
+
+    public IAMGroupVO() {
+        uuid = UUID.randomUUID().toString();
+    }
+
+    public IAMGroupVO(String name, String description) {
+        this.name = name;
+        this.description = description;
+        uuid = UUID.randomUUID().toString();
+        path = "/";
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String getDescription() {
+        return description;
+    }
+
+    @Override
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    @Override
+    public long getAccountId() {
+        return accountId;
+    }
+
+    public void setAccountId(long acctId) {
+        accountId = acctId;
+    }
+
+    @Override
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/IAMPolicyPermissionVO.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/IAMPolicyPermissionVO.java b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMPolicyPermissionVO.java
new file mode 100644
index 0000000..13d6b81
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMPolicyPermissionVO.java
@@ -0,0 +1,181 @@
+// 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.iam.server;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.iam.api.IAMPolicyPermission;
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name = ("iam_policy_permission"))
+public class IAMPolicyPermissionVO implements IAMPolicyPermission {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private long id;
+
+    @Column(name = "policy_id")
+    private long aclPolicyId;
+
+    @Column(name = "action")
+    private String action;
+
+    @Column(name = "resource_type")
+    private String entityType;
+
+    @Column(name = "access_type")
+    private String accessType;
+
+    @Column(name = "scope")
+    private String scope;
+
+    @Column(name = "scope_id")
+    private Long scopeId;
+
+    @Column(name = "permission")
+    @Enumerated(value = EnumType.STRING)
+    private Permission permission;
+
+    @Column(name = "recursive")
+    private Boolean recursive;
+
+    @Column(name = GenericDao.REMOVED_COLUMN)
+    private Date removed;
+
+    @Column(name = GenericDao.CREATED_COLUMN)
+    private Date created;
+
+    public IAMPolicyPermissionVO() {
+
+    }
+
+    public IAMPolicyPermissionVO(long aclPolicyId, String action, String entityType, String accessType, String scope,
+            Long scopeId, Permission permission, Boolean recursive) {
+        this.aclPolicyId = aclPolicyId;
+        this.action = action;
+        this.entityType = entityType;
+        this.accessType = accessType;
+        this.scope = scope;
+        this.scopeId = scopeId;
+        this.permission = permission;
+        this.recursive = recursive;
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    @Override
+    public long getAclPolicyId() {
+        return aclPolicyId;
+    }
+
+
+    public void setAclPolicyId(long aclPolicyId) {
+        this.aclPolicyId = aclPolicyId;
+    }
+
+    @Override
+    public String getEntityType() {
+        return entityType;
+    }
+
+    @Override
+    public String getAccessType() {
+        return accessType;
+    }
+
+
+    public void setEntityType(String entityType) {
+        this.entityType = entityType;
+    }
+
+    public void setAccessType(String accessType) {
+        this.accessType = accessType;
+    }
+
+    @Override
+    public String getScope() {
+        return scope;
+    }
+
+    public void setScope(String scope) {
+        this.scope = scope;
+    }
+
+
+    @Override
+    public String getAction() {
+        return action;
+    }
+
+    @Override
+    public Long getScopeId() {
+        // TODO
+        // handle special -1 scopeId, current caller domain, account
+        /*
+         * if ( scopeId < 0 ){ Account caller =
+         * CallContext.current().getCallingAccount(); if ( scope ==
+         * PermissionScope.DOMAIN){ return caller.getDomainId(); } else if
+         * (scope == PermissionScope.ACCOUNT) { return caller.getAccountId(); }
+         * }
+         */
+        return scopeId;
+    }
+
+    @Override
+    public Permission getPermission() {
+        return permission;
+    }
+
+    public void setAction(String action) {
+        this.action = action;
+    }
+
+    public void setScopeId(Long scopeId) {
+        this.scopeId = scopeId;
+    }
+
+    public void setPermission(Permission permission) {
+        this.permission = permission;
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    public Boolean isRecursive() {
+        return recursive;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/IAMPolicyVO.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/IAMPolicyVO.java b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMPolicyVO.java
new file mode 100644
index 0000000..25ebd01
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMPolicyVO.java
@@ -0,0 +1,138 @@
+// 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.iam.server;
+
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.iam.api.IAMPolicy;
+
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name = ("iam_policy"))
+public class IAMPolicyVO implements IAMPolicy {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private long id;
+
+    @Column(name = "name")
+    private String name;
+
+    @Column(name = "description")
+    private String description;
+
+    @Column(name = "uuid")
+    private String uuid;
+
+    @Column(name = "path")
+    private String path;
+
+    @Column(name = "account_id")
+    private long accountId;
+
+    @Column(name = GenericDao.REMOVED_COLUMN)
+    private Date removed;
+
+    @Column(name = GenericDao.CREATED_COLUMN)
+    private Date created;
+
+    @Column(name = "policy_type")
+    @Enumerated(value = EnumType.STRING)
+    private IAMPolicy.PolicyType policyType;
+
+    public IAMPolicyVO() {
+        uuid = UUID.randomUUID().toString();
+    }
+
+    public IAMPolicyVO(String name, String description) {
+        this.name = name;
+        this.description = description;
+        uuid = UUID.randomUUID().toString();
+        policyType = IAMPolicy.PolicyType.Static;
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String getDescription() {
+        return description;
+    }
+
+
+    @Override
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    @Override
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    @Override
+    public long getAccountId() {
+        return accountId;
+    }
+
+    public void setAccountId(long accountId) {
+        this.accountId = accountId;
+    }
+
+    public IAMPolicy.PolicyType getPolicyType() {
+        return policyType;
+    }
+
+    public void setPolicyType(IAMPolicy.PolicyType policyType) {
+        this.policyType = policyType;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/IAMServiceImpl.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/IAMServiceImpl.java b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMServiceImpl.java
new file mode 100644
index 0000000..097d84f
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMServiceImpl.java
@@ -0,0 +1,815 @@
+// 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.iam.server;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.acl.PermissionScope;
+import org.apache.cloudstack.iam.api.IAMGroup;
+import org.apache.cloudstack.iam.api.IAMPolicy;
+import org.apache.cloudstack.iam.api.IAMPolicyPermission;
+import org.apache.cloudstack.iam.api.IAMPolicyPermission.Permission;
+import org.apache.cloudstack.iam.api.IAMService;
+import org.apache.cloudstack.iam.server.dao.IAMAccountPolicyMapDao;
+import org.apache.cloudstack.iam.server.dao.IAMGroupAccountMapDao;
+import org.apache.cloudstack.iam.server.dao.IAMGroupDao;
+import org.apache.cloudstack.iam.server.dao.IAMGroupPolicyMapDao;
+import org.apache.cloudstack.iam.server.dao.IAMPolicyDao;
+import org.apache.cloudstack.iam.server.dao.IAMPolicyPermissionDao;
+
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.utils.Pair;
+import com.cloud.utils.component.Manager;
+import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.EntityManager;
+import com.cloud.utils.db.Filter;
+import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.JoinBuilder;
+import com.cloud.utils.db.JoinBuilder.JoinType;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.db.Transaction;
+import com.cloud.utils.db.TransactionCallback;
+import com.cloud.utils.db.TransactionCallbackNoReturn;
+import com.cloud.utils.db.TransactionStatus;
+
+@Local(value = {IAMService.class})
+public class IAMServiceImpl extends ManagerBase implements IAMService, Manager {
+
+    public static final Logger s_logger = Logger.getLogger(IAMServiceImpl.class);
+    private String _name;
+
+    @Inject
+    IAMPolicyDao _aclPolicyDao;
+
+    @Inject
+    IAMGroupDao _aclGroupDao;
+
+    @Inject
+    EntityManager _entityMgr;
+
+    @Inject
+    IAMGroupPolicyMapDao _aclGroupPolicyMapDao;
+
+    @Inject
+    IAMAccountPolicyMapDao _aclAccountPolicyMapDao;
+
+    @Inject
+    IAMGroupAccountMapDao _aclGroupAccountMapDao;
+
+    @Inject
+    IAMPolicyPermissionDao _policyPermissionDao;
+
+    @DB
+    @Override
+    public IAMGroup createIAMGroup(String iamGroupName, String description, String path) {
+        // check if the group is already existing
+        IAMGroup grp = _aclGroupDao.findByName(path, iamGroupName);
+        if (grp != null) {
+            throw new InvalidParameterValueException(
+                    "Unable to create acl group with name " + iamGroupName
+                    + " already exisits for path " + path);
+        }
+        IAMGroupVO rvo = new IAMGroupVO(iamGroupName, description);
+        rvo.setPath(path);
+
+        return _aclGroupDao.persist(rvo);
+    }
+
+    @DB
+    @Override
+    public boolean deleteIAMGroup(final Long iamGroupId) {
+        // get the Acl Group entity
+        final IAMGroup grp = _aclGroupDao.findById(iamGroupId);
+        if (grp == null) {
+            throw new InvalidParameterValueException("Unable to find acl group: " + iamGroupId
+                    + "; failed to delete acl group.");
+        }
+
+        Transaction.execute(new TransactionCallbackNoReturn() {
+            @Override
+            public void doInTransactionWithoutResult(TransactionStatus status) {
+                // remove this group related entry in acl_group_role_map
+                List<IAMGroupPolicyMapVO> groupPolicyMap = _aclGroupPolicyMapDao.listByGroupId(grp.getId());
+                if (groupPolicyMap != null) {
+                    for (IAMGroupPolicyMapVO gr : groupPolicyMap) {
+                        _aclGroupPolicyMapDao.remove(gr.getId());
+                    }
+                }
+
+                // remove this group related entry in acl_group_account table
+                List<IAMGroupAccountMapVO> groupAcctMap = _aclGroupAccountMapDao.listByGroupId(grp.getId());
+                if (groupAcctMap != null) {
+                    for (IAMGroupAccountMapVO grpAcct : groupAcctMap) {
+                        _aclGroupAccountMapDao.remove(grpAcct.getId());
+                    }
+                }
+
+                // remove this group from acl_group table
+                _aclGroupDao.remove(iamGroupId);
+            }
+        });
+
+        return true;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public List<IAMGroup> listIAMGroups(long accountId) {
+
+        GenericSearchBuilder<IAMGroupAccountMapVO, Long> groupSB = _aclGroupAccountMapDao.createSearchBuilder(Long.class);
+        groupSB.selectFields(groupSB.entity().getAclGroupId());
+        groupSB.and("account", groupSB.entity().getAccountId(), Op.EQ);
+        SearchCriteria<Long> groupSc = groupSB.create();
+        groupSc.setParameters("account", accountId);
+
+        List<Long> groupIds = _aclGroupAccountMapDao.customSearch(groupSc, null);
+
+        SearchBuilder<IAMGroupVO> sb = _aclGroupDao.createSearchBuilder();
+        sb.and("ids", sb.entity().getId(), Op.IN);
+        SearchCriteria<IAMGroupVO> sc = sb.create();
+        sc.setParameters("ids", groupIds.toArray(new Object[groupIds.size()]));
+        @SuppressWarnings("rawtypes")
+        List groups = _aclGroupDao.search(sc, null);
+        return groups;
+    }
+
+    @DB
+    @Override
+    public IAMGroup addAccountsToGroup(final List<Long> acctIds, final Long groupId) {
+        // get the Acl Group entity
+        IAMGroup group = _aclGroupDao.findById(groupId);
+        if (group == null) {
+            throw new InvalidParameterValueException("Unable to find acl group: " + groupId
+                    + "; failed to add accounts to acl group.");
+        }
+
+        Transaction.execute(new TransactionCallbackNoReturn() {
+            @Override
+            public void doInTransactionWithoutResult(TransactionStatus status) {
+                // add entries in acl_group_account_map table
+                for (Long acctId : acctIds) {
+                    // check account permissions
+                    IAMGroupAccountMapVO grMap = _aclGroupAccountMapDao.findByGroupAndAccount(groupId, acctId);
+                    if (grMap == null) {
+                        // not there already
+                        grMap = new IAMGroupAccountMapVO(groupId, acctId);
+                        _aclGroupAccountMapDao.persist(grMap);
+                    }
+                }
+            }
+        });
+        return group;
+    }
+
+    @DB
+    @Override
+    public IAMGroup removeAccountsFromGroup(final List<Long> acctIds, final Long groupId) {
+        // get the Acl Group entity
+        IAMGroup group = _aclGroupDao.findById(groupId);
+        if (group == null) {
+            throw new InvalidParameterValueException("Unable to find acl group: " + groupId
+                    + "; failed to remove accounts from acl group.");
+        }
+
+        Transaction.execute(new TransactionCallbackNoReturn() {
+            @Override
+            public void doInTransactionWithoutResult(TransactionStatus status) {
+                // remove entries from acl_group_account_map table
+                for (Long acctId : acctIds) {
+                    IAMGroupAccountMapVO grMap = _aclGroupAccountMapDao.findByGroupAndAccount(groupId, acctId);
+                    if (grMap != null) {
+                        // not removed yet
+                        _aclGroupAccountMapDao.remove(grMap.getId());
+                    }
+                }
+            }
+        });
+        return group;
+    }
+
+    @Override
+    public List<Long> listAccountsByGroup(long groupId) {
+        List<IAMGroupAccountMapVO> grpAcctMap = _aclGroupAccountMapDao.listByGroupId(groupId);
+        if (grpAcctMap == null || grpAcctMap.size() == 0) {
+            return new ArrayList<Long>();
+        }
+
+        List<Long> accts = new ArrayList<Long>();
+        for (IAMGroupAccountMapVO grpAcct : grpAcctMap) {
+            accts.add(grpAcct.getAccountId());
+        }
+        return accts;
+    }
+
+    @Override
+    public Pair<List<IAMGroup>, Integer> listIAMGroups(Long iamGroupId, String iamGroupName, String path, Long startIndex, Long pageSize) {
+        if (iamGroupId != null) {
+            IAMGroup group = _aclGroupDao.findById(iamGroupId);
+            if (group == null) {
+                throw new InvalidParameterValueException("Unable to find acl group by id " + iamGroupId);
+            }
+        }
+
+        Filter searchFilter = new Filter(IAMGroupVO.class, "id", true, startIndex, pageSize);
+
+        SearchBuilder<IAMGroupVO> sb = _aclGroupDao.createSearchBuilder();
+        sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ);
+        sb.and("path", sb.entity().getPath(), SearchCriteria.Op.LIKE);
+        sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
+
+        SearchCriteria<IAMGroupVO> sc = sb.create();
+
+        if (iamGroupName != null) {
+            sc.setParameters("name", iamGroupName);
+        }
+
+        if (iamGroupId != null) {
+            sc.setParameters("id", iamGroupId);
+        }
+
+        sc.setParameters("path", path + "%");
+
+        Pair<List<IAMGroupVO>, Integer> groups = _aclGroupDao.searchAndCount(sc, searchFilter);
+        return new Pair<List<IAMGroup>, Integer>(new ArrayList<IAMGroup>(groups.first()), groups.second());
+    }
+
+    @Override
+    public List<IAMGroup> listParentIAMGroups(long groupId) {
+        IAMGroup group = _aclGroupDao.findById(groupId);
+        if (group == null) {
+            throw new InvalidParameterValueException("Unable to find acl group by id " + groupId);
+        }
+
+        String path = group.getPath();
+        List<String> pathList = new ArrayList<String>();
+
+        String[] parts = path.split("/");
+
+        for (String part : parts) {
+            int start = path.indexOf(part);
+            if (start > 0) {
+                String subPath = path.substring(0, start);
+                pathList.add(subPath);
+            }
+        }
+
+        if (pathList.isEmpty()) {
+            return new ArrayList<IAMGroup>();
+        }
+
+        SearchBuilder<IAMGroupVO> sb = _aclGroupDao.createSearchBuilder();
+        sb.and("paths", sb.entity().getPath(), SearchCriteria.Op.IN);
+
+        SearchCriteria<IAMGroupVO> sc = sb.create();
+        sc.setParameters("paths", pathList.toArray());
+
+        List<IAMGroupVO> groups = _aclGroupDao.search(sc, null);
+
+        return new ArrayList<IAMGroup>(groups);
+
+    }
+
+    @DB
+    @Override
+    public IAMPolicy createIAMPolicy(final String iamPolicyName, final String description, final Long parentPolicyId, final String path) {
+
+        // check if the policy is already existing
+        IAMPolicy ro = _aclPolicyDao.findByName(iamPolicyName);
+        if (ro != null) {
+            throw new InvalidParameterValueException(
+                    "Unable to create acl policy with name " + iamPolicyName
+                    + " already exisits");
+        }
+
+        IAMPolicy role = Transaction.execute(new TransactionCallback<IAMPolicy>() {
+            @Override
+            public IAMPolicy doInTransaction(TransactionStatus status) {
+                IAMPolicyVO rvo = new IAMPolicyVO(iamPolicyName, description);
+                rvo.setPath(path);
+
+                IAMPolicy role = _aclPolicyDao.persist(rvo);
+                if (parentPolicyId != null) {
+                    // copy parent role permissions
+                    List<IAMPolicyPermissionVO> perms = _policyPermissionDao.listByPolicy(parentPolicyId);
+                    if (perms != null) {
+                        for (IAMPolicyPermissionVO perm : perms) {
+                            perm.setAclPolicyId(role.getId());
+                            _policyPermissionDao.persist(perm);
+                        }
+                    }
+                }
+                return role;
+            }
+        });
+
+
+        return role;
+    }
+
+    @DB
+    @Override
+    public boolean deleteIAMPolicy(final long iamPolicyId) {
+        // get the Acl Policy entity
+        final IAMPolicy policy = _aclPolicyDao.findById(iamPolicyId);
+        if (policy == null) {
+            throw new InvalidParameterValueException("Unable to find acl policy: " + iamPolicyId
+                    + "; failed to delete acl policy.");
+        }
+
+        Transaction.execute(new TransactionCallbackNoReturn() {
+            @Override
+            public void doInTransactionWithoutResult(TransactionStatus status) {
+                // remove this role related entry in acl_group_role_map
+                List<IAMGroupPolicyMapVO> groupPolicyMap = _aclGroupPolicyMapDao.listByPolicyId(policy.getId());
+                if (groupPolicyMap != null) {
+                    for (IAMGroupPolicyMapVO gr : groupPolicyMap) {
+                        _aclGroupPolicyMapDao.remove(gr.getId());
+                    }
+                }
+
+                // remove this policy related entry in acl_account_policy_map table
+                List<IAMAccountPolicyMapVO> policyAcctMap = _aclAccountPolicyMapDao.listByPolicyId(policy.getId());
+                if (policyAcctMap != null) {
+                    for (IAMAccountPolicyMapVO policyAcct : policyAcctMap) {
+                        _aclAccountPolicyMapDao.remove(policyAcct.getId());
+                    }
+                }
+
+                // remove this policy related entry in acl_policy_permission table
+                List<IAMPolicyPermissionVO> policyPermMap = _policyPermissionDao.listByPolicy(policy.getId());
+                if (policyPermMap != null) {
+                    for (IAMPolicyPermissionVO policyPerm : policyPermMap) {
+                        _policyPermissionDao.remove(policyPerm.getId());
+                    }
+                }
+
+                // remove this role from acl_role table
+                _aclPolicyDao.remove(iamPolicyId);
+            }
+        });
+
+        return true;
+    }
+
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public List<IAMPolicy> listIAMPolicies(long accountId) {
+
+        // static policies of the account
+        SearchBuilder<IAMGroupAccountMapVO> groupSB = _aclGroupAccountMapDao.createSearchBuilder();
+        groupSB.and("account", groupSB.entity().getAccountId(), Op.EQ);
+
+        GenericSearchBuilder<IAMGroupPolicyMapVO, Long> policySB = _aclGroupPolicyMapDao.createSearchBuilder(Long.class);
+        policySB.selectFields(policySB.entity().getAclPolicyId());
+        policySB.join("accountgroupjoin", groupSB, groupSB.entity().getAclGroupId(), policySB.entity().getAclGroupId(),
+                JoinType.INNER);
+        policySB.done();
+        SearchCriteria<Long> policySc = policySB.create();
+        policySc.setJoinParameters("accountgroupjoin", "account", accountId);
+
+        List<Long> policyIds = _aclGroupPolicyMapDao.customSearch(policySc, null);
+        // add policies directly attached to the account
+        List<IAMAccountPolicyMapVO> acctPolicies = _aclAccountPolicyMapDao.listByAccountId(accountId);
+        for (IAMAccountPolicyMapVO p : acctPolicies) {
+            policyIds.add(p.getIamPolicyId());
+        }
+        if (policyIds.size() == 0) {
+            return new ArrayList<IAMPolicy>();
+        }
+        SearchBuilder<IAMPolicyVO> sb = _aclPolicyDao.createSearchBuilder();
+        sb.and("ids", sb.entity().getId(), Op.IN);
+        SearchCriteria<IAMPolicyVO> sc = sb.create();
+        sc.setParameters("ids", policyIds.toArray(new Object[policyIds.size()]));
+        @SuppressWarnings("rawtypes")
+        List policies = _aclPolicyDao.customSearch(sc, null);
+
+        return policies;
+
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public List<IAMPolicy> listIAMPoliciesByGroup(long groupId) {
+        List<IAMGroupPolicyMapVO> policyGrpMap = _aclGroupPolicyMapDao.listByGroupId(groupId);
+        if (policyGrpMap == null || policyGrpMap.size() == 0) {
+            return new ArrayList<IAMPolicy>();
+        }
+
+        List<Long> policyIds = new ArrayList<Long>();
+        for (IAMGroupPolicyMapVO pg : policyGrpMap) {
+            policyIds.add(pg.getAclPolicyId());
+        }
+
+        SearchBuilder<IAMPolicyVO> sb = _aclPolicyDao.createSearchBuilder();
+        sb.and("ids", sb.entity().getId(), Op.IN);
+        SearchCriteria<IAMPolicyVO> sc = sb.create();
+        sc.setParameters("ids", policyIds.toArray(new Object[policyIds.size()]));
+        @SuppressWarnings("rawtypes")
+        List policies = _aclPolicyDao.customSearch(sc, null);
+
+        return policies;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public List<IAMPolicy> listRecursiveIAMPoliciesByGroup(long groupId) {
+        List<IAMGroupPolicyMapVO> policyGrpMap = _aclGroupPolicyMapDao.listByGroupId(groupId);
+        if (policyGrpMap == null || policyGrpMap.size() == 0) {
+            return new ArrayList<IAMPolicy>();
+        }
+
+        List<Long> policyIds = new ArrayList<Long>();
+        for (IAMGroupPolicyMapVO pg : policyGrpMap) {
+            policyIds.add(pg.getAclPolicyId());
+        }
+
+        SearchBuilder<IAMPolicyPermissionVO> permSb = _policyPermissionDao.createSearchBuilder();
+        permSb.and("isRecursive", permSb.entity().isRecursive(), Op.EQ);
+
+        SearchBuilder<IAMPolicyVO> sb = _aclPolicyDao.createSearchBuilder();
+        sb.and("ids", sb.entity().getId(), Op.IN);
+        sb.join("recursivePerm", permSb, sb.entity().getId(), permSb.entity().getAclPolicyId(),
+                JoinBuilder.JoinType.INNER);
+
+        SearchCriteria<IAMPolicyVO> sc = sb.create();
+        sc.setParameters("ids", policyIds.toArray(new Object[policyIds.size()]));
+        sc.setJoinParameters("recursivePerm", "isRecursive", true);
+
+        @SuppressWarnings("rawtypes")
+        List policies = _aclPolicyDao.customSearch(sc, null);
+
+        return policies;
+    }
+
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Pair<List<IAMPolicy>, Integer> listIAMPolicies(Long iamPolicyId, String iamPolicyName, String path, Long startIndex, Long pageSize) {
+
+        if (iamPolicyId != null) {
+            IAMPolicy policy = _aclPolicyDao.findById(iamPolicyId);
+            if (policy == null) {
+                throw new InvalidParameterValueException("Unable to find acl policy by id " + iamPolicyId);
+            }
+        }
+
+        Filter searchFilter = new Filter(IAMPolicyVO.class, "id", true, startIndex, pageSize);
+
+        SearchBuilder<IAMPolicyVO> sb = _aclPolicyDao.createSearchBuilder();
+        sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ);
+        sb.and("path", sb.entity().getPath(), SearchCriteria.Op.LIKE);
+        sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
+
+        SearchCriteria<IAMPolicyVO> sc = sb.create();
+
+        if (iamPolicyName != null) {
+            sc.setParameters("name", iamPolicyName);
+        }
+
+        if (iamPolicyId != null) {
+            sc.setParameters("id", iamPolicyId);
+        }
+
+        sc.setParameters("path", path + "%");
+
+        Pair<List<IAMPolicyVO>, Integer> policies = _aclPolicyDao.searchAndCount(sc, searchFilter);
+        @SuppressWarnings("rawtypes")
+        List policyList = policies.first();
+        return new Pair<List<IAMPolicy>, Integer>(policyList, policies.second());
+    }
+
+    @DB
+    @Override
+    public IAMGroup attachIAMPoliciesToGroup(final List<Long> policyIds, final Long groupId) {
+        // get the Acl Group entity
+        IAMGroup group = _aclGroupDao.findById(groupId);
+        if (group == null) {
+            throw new InvalidParameterValueException("Unable to find acl group: " + groupId
+                    + "; failed to add roles to acl group.");
+        }
+
+        Transaction.execute(new TransactionCallbackNoReturn() {
+            @Override
+            public void doInTransactionWithoutResult(TransactionStatus status) {
+                // add entries in acl_group_policy_map table
+                for (Long policyId : policyIds) {
+                    IAMPolicy policy = _aclPolicyDao.findById(policyId);
+                    if (policy == null) {
+                        throw new InvalidParameterValueException("Unable to find acl policy: " + policyId
+                                + "; failed to add policies to acl group.");
+                    }
+
+                    IAMGroupPolicyMapVO grMap = _aclGroupPolicyMapDao.findByGroupAndPolicy(groupId, policyId);
+                    if (grMap == null) {
+                        // not there already
+                        grMap = new IAMGroupPolicyMapVO(groupId, policyId);
+                        _aclGroupPolicyMapDao.persist(grMap);
+                    }
+                }
+            }
+        });
+
+        return group;
+    }
+
+    @DB
+    @Override
+    public IAMGroup removeIAMPoliciesFromGroup(final List<Long> policyIds, final Long groupId) {
+        // get the Acl Group entity
+        IAMGroup group = _aclGroupDao.findById(groupId);
+        if (group == null) {
+            throw new InvalidParameterValueException("Unable to find acl group: " + groupId
+                    + "; failed to remove roles from acl group.");
+        }
+
+        Transaction.execute(new TransactionCallbackNoReturn() {
+            @Override
+            public void doInTransactionWithoutResult(TransactionStatus status) {
+                // add entries in acl_group_role_map table
+                for (Long policyId : policyIds) {
+                    IAMPolicy policy = _aclPolicyDao.findById(policyId);
+                    if (policy == null) {
+                        throw new InvalidParameterValueException("Unable to find acl policy: " + policyId
+                                + "; failed to add policies to acl group.");
+                    }
+
+                    IAMGroupPolicyMapVO grMap = _aclGroupPolicyMapDao.findByGroupAndPolicy(groupId, policyId);
+                    if (grMap != null) {
+                        // not removed yet
+                        _aclGroupPolicyMapDao.remove(grMap.getId());
+                    }
+                }
+            }
+        });
+        return group;
+    }
+
+
+    @Override
+    public void attachIAMPolicyToAccounts(final Long policyId, final List<Long> acctIds) {
+        IAMPolicy policy = _aclPolicyDao.findById(policyId);
+        if (policy == null) {
+            throw new InvalidParameterValueException("Unable to find acl policy: " + policyId
+                    + "; failed to add policy to account.");
+        }
+
+        Transaction.execute(new TransactionCallbackNoReturn() {
+            @Override
+            public void doInTransactionWithoutResult(TransactionStatus status) {
+                // add entries in acl_group_policy_map table
+                for (Long acctId : acctIds) {
+                    IAMAccountPolicyMapVO acctMap = _aclAccountPolicyMapDao.findByAccountAndPolicy(acctId, policyId);
+                    if (acctMap == null) {
+                        // not there already
+                        acctMap = new IAMAccountPolicyMapVO(acctId, policyId);
+                        _aclAccountPolicyMapDao.persist(acctMap);
+                    }
+                }
+            }
+        });
+    }
+
+    @Override
+    public void removeIAMPolicyFromAccounts(final Long policyId, final List<Long> acctIds) {
+        IAMPolicy policy = _aclPolicyDao.findById(policyId);
+        if (policy == null) {
+            throw new InvalidParameterValueException("Unable to find acl policy: " + policyId
+                    + "; failed to add policy to account.");
+        }
+
+        Transaction.execute(new TransactionCallbackNoReturn() {
+            @Override
+            public void doInTransactionWithoutResult(TransactionStatus status) {
+                // add entries in acl_group_policy_map table
+                for (Long acctId : acctIds) {
+                    IAMAccountPolicyMapVO acctMap = _aclAccountPolicyMapDao.findByAccountAndPolicy(acctId, policyId);
+                    if (acctMap != null) {
+                        // exists
+                        _aclAccountPolicyMapDao.remove(acctMap.getId());
+                    }
+                }
+            }
+        });
+    }
+
+    @DB
+    @Override
+    public IAMPolicy addIAMPermissionToIAMPolicy(long iamPolicyId, String entityType, String scope, Long scopeId,
+            String action, String accessType, Permission perm, Boolean recursive) {
+        // get the Acl Policy entity
+        IAMPolicy policy = _aclPolicyDao.findById(iamPolicyId);
+        if (policy == null) {
+            throw new InvalidParameterValueException("Unable to find acl policy: " + iamPolicyId
+                    + "; failed to add permission to policy.");
+        }
+
+        // add entry in acl_policy_permission table
+        IAMPolicyPermissionVO permit = _policyPermissionDao.findByPolicyAndEntity(iamPolicyId, entityType, scope, scopeId, action, perm);
+        if (permit == null) {
+            // not there already
+            permit = new IAMPolicyPermissionVO(iamPolicyId, action, entityType, accessType, scope, scopeId, perm,
+                    recursive);
+            _policyPermissionDao.persist(permit);
+        }
+        return policy;
+
+    }
+
+    @DB
+    @Override
+    public IAMPolicy removeIAMPermissionFromIAMPolicy(long iamPolicyId, String entityType, String scope, Long scopeId,
+            String action) {
+        // get the Acl Policy entity
+        IAMPolicy policy = _aclPolicyDao.findById(iamPolicyId);
+        if (policy == null) {
+            throw new InvalidParameterValueException("Unable to find acl policy: " + iamPolicyId
+                    + "; failed to revoke permission from policy.");
+        }
+        // remove entry from acl_entity_permission table
+        IAMPolicyPermissionVO permit = _policyPermissionDao.findByPolicyAndEntity(iamPolicyId, entityType, scope, scopeId, action, Permission.Allow);
+        if (permit != null) {
+            // not removed yet
+            _policyPermissionDao.remove(permit.getId());
+        }
+        return policy;
+    }
+
+    @DB
+    @Override
+    public void removeIAMPermissionForEntity(final String entityType, final Long entityId) {
+        Transaction.execute(new TransactionCallbackNoReturn() {
+            @Override
+            public void doInTransactionWithoutResult(TransactionStatus status) {
+                // remove entry from acl_entity_permission table
+                List<IAMPolicyPermissionVO> permitList = _policyPermissionDao.listByEntity(entityType, entityId);
+                for (IAMPolicyPermissionVO permit : permitList) {
+                    long policyId = permit.getAclPolicyId();
+                    _policyPermissionDao.remove(permit.getId());
+
+                    // remove the policy if there are no other permissions
+                    if ((_policyPermissionDao.listByPolicy(policyId)).isEmpty()) {
+                        deleteIAMPolicy(policyId);
+                    }
+                }
+            }
+        });
+    }
+
+    @DB
+    @Override
+    public IAMPolicy resetIAMPolicy(long iamPolicyId) {
+        // get the Acl Policy entity
+        IAMPolicy policy = _aclPolicyDao.findById(iamPolicyId);
+        if (policy == null) {
+            throw new InvalidParameterValueException("Unable to find acl policy: " + iamPolicyId
+                    + "; failed to reset the policy.");
+        }
+
+        SearchBuilder<IAMPolicyPermissionVO> sb = _policyPermissionDao.createSearchBuilder();
+        sb.and("policyId", sb.entity().getAclPolicyId(), SearchCriteria.Op.EQ);
+        sb.and("scope", sb.entity().getScope(), SearchCriteria.Op.EQ);
+        sb.done();
+        SearchCriteria<IAMPolicyPermissionVO> permissionSC = sb.create();
+        permissionSC.setParameters("policyId", iamPolicyId);
+        _policyPermissionDao.expunge(permissionSC);
+
+        return policy;
+    }
+
+    @Override
+    public boolean isActionAllowedForPolicies(String action, List<IAMPolicy> policies) {
+
+        boolean allowed = false;
+
+        if (policies == null || policies.size() == 0) {
+            return allowed;
+        }
+
+        List<Long> policyIds = new ArrayList<Long>();
+        for (IAMPolicy policy : policies) {
+            policyIds.add(policy.getId());
+        }
+
+        SearchBuilder<IAMPolicyPermissionVO> sb = _policyPermissionDao.createSearchBuilder();
+        sb.and("action", sb.entity().getAction(), Op.EQ);
+        sb.and("policyId", sb.entity().getAclPolicyId(), Op.IN);
+
+        SearchCriteria<IAMPolicyPermissionVO> sc = sb.create();
+        sc.setParameters("policyId", policyIds.toArray(new Object[policyIds.size()]));
+        sc.setParameters("action", action);
+
+        List<IAMPolicyPermissionVO> permissions = _policyPermissionDao.customSearch(sc, null);
+
+        if (permissions != null && !permissions.isEmpty()) {
+            allowed = true;
+        }
+
+        return allowed;
+    }
+
+
+    @Override
+    public List<Long> getGrantedEntities(long accountId, String action, String scope) {
+        // Get the static Policies of the Caller
+        List<IAMPolicy> policies = listIAMPolicies(accountId);
+        // for each policy, find granted permission within the given scope
+        List<Long> entityIds = new ArrayList<Long>();
+        for (IAMPolicy policy : policies) {
+            List<IAMPolicyPermissionVO> pp = _policyPermissionDao.listGrantedByActionAndScope(policy.getId(), action,
+                    scope);
+            if (pp != null) {
+                for (IAMPolicyPermissionVO p : pp) {
+                    if (p.getScopeId() != null) {
+                        entityIds.add(p.getScopeId());
+                    }
+                }
+            }
+        }
+        return entityIds;
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public List<IAMPolicyPermission> listPolicyPermissions(long policyId) {
+        @SuppressWarnings("rawtypes")
+        List pp = _policyPermissionDao.listByPolicy(policyId);
+        return pp;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public List<IAMPolicyPermission> listPolicyPermissionsByScope(long policyId, String action, String scope) {
+        @SuppressWarnings("rawtypes")
+        List pp = _policyPermissionDao.listGrantedByActionAndScope(policyId, action, scope);
+        return pp;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public List<IAMPolicyPermission> listPolicyPermissionByActionAndEntity(long policyId, String action,
+            String entityType) {
+        @SuppressWarnings("rawtypes")
+        List pp = _policyPermissionDao.listByPolicyActionAndEntity(policyId, action, entityType);
+        return pp;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public List<IAMPolicyPermission> listPolicyPermissionByAccessAndEntity(long policyId, String accessType,
+            String entityType) {
+        @SuppressWarnings("rawtypes")
+        List pp = _policyPermissionDao.listByPolicyAccessAndEntity(policyId, accessType, entityType);
+        return pp;
+    }
+
+    @Override
+    public IAMPolicy getResourceOwnerPolicy() {
+        return _aclPolicyDao.findByName("RESOURCE_OWNER");
+    }
+
+    // search for policy with only one resource grant permission
+    @Override
+    public IAMPolicy getResourceGrantPolicy(String entityType, Long entityId, String accessType, String action) {
+        List<IAMPolicyVO> policyList = _aclPolicyDao.listAll();
+        for (IAMPolicyVO policy : policyList){
+            List<IAMPolicyPermission> pp = listPolicyPermissions(policy.getId());
+            if ( pp != null && pp.size() == 1){
+                // resource grant policy should only have one ACL permission assigned
+                IAMPolicyPermission permit = pp.get(0);
+                if ( permit.getEntityType().equals(entityType) && permit.getScope().equals(PermissionScope.RESOURCE.toString()) && permit.getScopeId().longValue() == entityId.longValue()){
+                    if (accessType != null && permit.getAccessType().equals(accessType)){
+                        return policy;
+                    } else if (action != null && permit.getAction().equals(action)) {
+                        return policy;
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDao.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDao.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDao.java
new file mode 100644
index 0000000..4caf659
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDao.java
@@ -0,0 +1,17 @@
+package org.apache.cloudstack.iam.server.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.iam.server.IAMAccountPolicyMapVO;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface IAMAccountPolicyMapDao extends GenericDao<IAMAccountPolicyMapVO, Long> {
+
+    List<IAMAccountPolicyMapVO> listByAccountId(long acctId);
+
+    List<IAMAccountPolicyMapVO> listByPolicyId(long policyId);
+
+    IAMAccountPolicyMapVO findByAccountAndPolicy(long acctId, long policyId);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDaoImpl.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDaoImpl.java
new file mode 100644
index 0000000..3ecca3b
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMAccountPolicyMapDaoImpl.java
@@ -0,0 +1,61 @@
+package org.apache.cloudstack.iam.server.dao;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.ConfigurationException;
+
+import org.apache.cloudstack.iam.server.IAMAccountPolicyMapVO;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+public class IAMAccountPolicyMapDaoImpl extends GenericDaoBase<IAMAccountPolicyMapVO, Long> implements IAMAccountPolicyMapDao {
+
+    private SearchBuilder<IAMAccountPolicyMapVO> ListByAccountId;
+    private SearchBuilder<IAMAccountPolicyMapVO> ListByPolicyId;
+    private SearchBuilder<IAMAccountPolicyMapVO> findByPolicyAccountId;
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+        super.configure(name, params);
+
+        ListByAccountId = createSearchBuilder();
+        ListByAccountId.and("accountId", ListByAccountId.entity().getAccountId(), SearchCriteria.Op.EQ);
+        ListByAccountId.done();
+
+        ListByPolicyId = createSearchBuilder();
+        ListByPolicyId.and("policyId", ListByPolicyId.entity().getIamPolicyId(), SearchCriteria.Op.EQ);
+        ListByPolicyId.done();
+
+        findByPolicyAccountId = createSearchBuilder();
+        findByPolicyAccountId.and("policyId", findByPolicyAccountId.entity().getIamPolicyId(), SearchCriteria.Op.EQ);
+        findByPolicyAccountId.and("accountId", findByPolicyAccountId.entity().getAccountId(), SearchCriteria.Op.EQ);
+        findByPolicyAccountId.done();
+
+        return true;
+    }
+
+    @Override
+    public List<IAMAccountPolicyMapVO> listByAccountId(long acctId) {
+        SearchCriteria<IAMAccountPolicyMapVO> sc = ListByAccountId.create();
+        sc.setParameters("accountId", acctId);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<IAMAccountPolicyMapVO> listByPolicyId(long policyId) {
+        SearchCriteria<IAMAccountPolicyMapVO> sc = ListByPolicyId.create();
+        sc.setParameters("policyId", policyId);
+        return listBy(sc);
+    }
+
+    @Override
+    public IAMAccountPolicyMapVO findByAccountAndPolicy(long acctId, long policyId) {
+        SearchCriteria<IAMAccountPolicyMapVO> sc = findByPolicyAccountId.create();
+        sc.setParameters("policyId", policyId);
+        sc.setParameters("accountId", acctId);
+        return findOneBy(sc);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupAccountMapDao.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupAccountMapDao.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupAccountMapDao.java
new file mode 100644
index 0000000..a94dbaa
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupAccountMapDao.java
@@ -0,0 +1,40 @@
+// 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.iam.server.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.iam.server.IAMGroupAccountMapVO;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface IAMGroupAccountMapDao extends GenericDao<IAMGroupAccountMapVO, Long> {
+
+    List<IAMGroupAccountMapVO> listByGroupId(long groupId);
+
+    List<IAMGroupAccountMapVO> listByAccountId(long accountId);
+
+    IAMGroupAccountMapVO findAccountInAdminGroup(long accountId);
+
+    IAMGroupAccountMapVO findByGroupAndAccount(long groupId, long acctId);
+
+    void removeAccountFromGroups(long accountId);
+
+    IAMGroupAccountMapVO findAccountInDomainAdminGroup(long accountId);
+
+    IAMGroupAccountMapVO findAccountInUserGroup(long accountId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupAccountMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupAccountMapDaoImpl.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupAccountMapDaoImpl.java
new file mode 100644
index 0000000..4bb5d1a
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupAccountMapDaoImpl.java
@@ -0,0 +1,119 @@
+// 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.iam.server.dao;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.ConfigurationException;
+
+import org.apache.cloudstack.iam.server.IAMGroupAccountMapVO;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+public class IAMGroupAccountMapDaoImpl extends GenericDaoBase<IAMGroupAccountMapVO, Long> implements IAMGroupAccountMapDao {
+    private SearchBuilder<IAMGroupAccountMapVO> ListByGroupId;
+    private SearchBuilder<IAMGroupAccountMapVO> ListByAccountId;
+    private SearchBuilder<IAMGroupAccountMapVO> _findByAccountAndGroupId;
+
+    public static final Logger s_logger = Logger.getLogger(IAMGroupAccountMapDaoImpl.class.getName());
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+        super.configure(name, params);
+
+        ListByGroupId = createSearchBuilder();
+        ListByGroupId.and("groupId", ListByGroupId.entity().getAclGroupId(), SearchCriteria.Op.EQ);
+        ListByGroupId.done();
+
+        ListByAccountId = createSearchBuilder();
+        ListByAccountId.and("accountId", ListByAccountId.entity().getAccountId(), SearchCriteria.Op.EQ);
+        ListByAccountId.done();
+
+        _findByAccountAndGroupId = createSearchBuilder();
+        _findByAccountAndGroupId
+                .and("groupId", _findByAccountAndGroupId.entity().getAclGroupId(), SearchCriteria.Op.EQ);
+        _findByAccountAndGroupId.and("accountId", _findByAccountAndGroupId.entity().getAccountId(),
+                SearchCriteria.Op.EQ);
+        _findByAccountAndGroupId.done();
+
+        return true;
+    }
+
+    @Override
+    public List<IAMGroupAccountMapVO> listByGroupId(long groupId) {
+        SearchCriteria<IAMGroupAccountMapVO> sc = ListByGroupId.create();
+        sc.setParameters("groupId", groupId);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<IAMGroupAccountMapVO> listByAccountId(long accountId) {
+        SearchCriteria<IAMGroupAccountMapVO> sc = ListByAccountId.create();
+        sc.setParameters("accountId", accountId);
+        return listBy(sc);
+    }
+
+    @Override
+    public IAMGroupAccountMapVO findAccountInAdminGroup(long accountId) {
+        SearchCriteria<IAMGroupAccountMapVO> sc = _findByAccountAndGroupId.create();
+        sc.setParameters("accountId", accountId);
+        sc.setParameters("groupId", 2);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public IAMGroupAccountMapVO findAccountInDomainAdminGroup(long accountId) {
+        SearchCriteria<IAMGroupAccountMapVO> sc = _findByAccountAndGroupId.create();
+        sc.setParameters("accountId", accountId);
+        sc.setParameters("groupId", 3);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public IAMGroupAccountMapVO findAccountInUserGroup(long accountId) {
+        SearchCriteria<IAMGroupAccountMapVO> sc = _findByAccountAndGroupId.create();
+        sc.setParameters("accountId", accountId);
+        sc.setParameters("groupId", 1);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public IAMGroupAccountMapVO findByGroupAndAccount(long groupId, long acctId) {
+        SearchCriteria<IAMGroupAccountMapVO> sc = _findByAccountAndGroupId.create();
+        sc.setParameters("accountId", acctId);
+        sc.setParameters("groupId", groupId);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public void removeAccountFromGroups(long accountId) {
+        SearchCriteria<IAMGroupAccountMapVO> sc = ListByAccountId.create();
+        sc.setParameters("accountId", accountId);
+
+        int rowsRemoved = remove(sc);
+        if (rowsRemoved > 0) {
+            s_logger.debug("Removed account id=" + accountId + " from " + rowsRemoved + " groups");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupDao.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupDao.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupDao.java
new file mode 100644
index 0000000..54408a6
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupDao.java
@@ -0,0 +1,28 @@
+// 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.iam.server.dao;
+
+import org.apache.cloudstack.iam.api.IAMGroup;
+import org.apache.cloudstack.iam.server.IAMGroupVO;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface IAMGroupDao extends GenericDao<IAMGroupVO, Long> {
+
+    IAMGroup findByName(String path, String groupName);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/adb29b21/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupDaoImpl.java
----------------------------------------------------------------------
diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupDaoImpl.java b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupDaoImpl.java
new file mode 100644
index 0000000..45be0b3
--- /dev/null
+++ b/services/iam/server/src/org/apache/cloudstack/iam/server/dao/IAMGroupDaoImpl.java
@@ -0,0 +1,59 @@
+// 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.iam.server.dao;
+
+import java.util.Map;
+
+import javax.naming.ConfigurationException;
+
+import org.apache.cloudstack.iam.api.IAMGroup;
+import org.apache.cloudstack.iam.server.IAMGroupVO;
+import org.springframework.stereotype.Component;
+
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+public class IAMGroupDaoImpl extends GenericDaoBase<IAMGroupVO, Long> implements IAMGroupDao {
+    private SearchBuilder<IAMGroupVO> nameSearch;
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+        super.configure(name, params);
+
+        nameSearch = createSearchBuilder();
+        nameSearch.and("name", nameSearch.entity().getName(), SearchCriteria.Op.EQ);
+        nameSearch.and("path", nameSearch.entity().getPath(), SearchCriteria.Op.EQ);
+        nameSearch.done();
+
+
+        return true;
+    }
+
+    @Override
+    public IAMGroup findByName(String path, String name) {
+        SearchCriteria<IAMGroupVO> sc = nameSearch.create();
+        sc.setParameters("name", name);
+        if (path != null) {
+            sc.setParameters("path", path);
+        }
+        return findOneBy(sc);
+    }
+
+}


[29/50] [abbrv] git commit: updated refs/heads/resize-root to 0eb9967

Posted by ml...@apache.org.
only ping timeout trigger host HA, otherwise there may be two threads try to HA the same VM


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

Branch: refs/heads/resize-root
Commit: 370554e9d99effa3ff2b534a4bdbdfe8e312a29f
Parents: 830328b
Author: Anthony Xu <an...@citrix.com>
Authored: Wed Mar 5 16:48:40 2014 -0800
Committer: Anthony Xu <an...@citrix.com>
Committed: Wed Mar 5 16:50:33 2014 -0800

----------------------------------------------------------------------
 .../src/com/cloud/agent/manager/DirectAgentAttache.java            | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/370554e9/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java
index 354da4b..9874ee4 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java
@@ -34,7 +34,6 @@ import com.cloud.agent.transport.Request;
 import com.cloud.agent.transport.Response;
 import com.cloud.exception.AgentUnavailableException;
 import com.cloud.host.Status;
-import com.cloud.host.Status.Event;
 import com.cloud.resource.ServerResource;
 
 public class DirectAgentAttache extends AgentAttache {
@@ -145,7 +144,6 @@ public class DirectAgentAttache extends AgentAttache {
                     PingCommand cmd = resource.getCurrentStatus(_id);
                     if (cmd == null) {
                         s_logger.warn("Unable to get current status on " + _id + "(" + _name + ")");
-                        _mgr.disconnectWithInvestigation(DirectAgentAttache.this, Event.AgentDisconnected);
                         return;
                     }
                     if (s_logger.isDebugEnabled()) {


[19/50] [abbrv] Externalized the hardcodedstrings from UI JAVASCRIPT files.

Posted by ml...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/182c3189/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index c21e277..bfdc8d5 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -44,11 +44,11 @@
                 };
                 var fields = {
                     account: {
-                        label: 'Account',
+                        label: 'label.account',
                         defaultValue: data.account
                     },
                     domainid: {
-                        label: 'Domain',
+                        label: 'label.domain',
                         defaultValue: data.domainid,
                         select: function (args) {
                             $.ajax({
@@ -753,7 +753,7 @@
                                             },
                                             
                                             releaseFromAccount: {
-                                                label: 'Release from Account',
+                                                label: 'label.release.account',
                                                 action: function (args) {
                                                     $.ajax({
                                                         url: createURL('releasePublicIpRange'),
@@ -763,7 +763,7 @@
                                                         success: function (json) {
                                                             args.response.success({
                                                                 notification: {
-                                                                    label: 'release from account',
+                                                                    label: 'label.release.account.lowercase',
                                                                     poll: function (args) {
                                                                         args.complete();
                                                                     }
@@ -778,15 +778,15 @@
                                             },
                                             
                                             addAccount: {
-                                                label: 'Add Account',
+                                                label: 'label.add.account',
                                                 createForm: {
-                                                    title: 'Add Account',
+                                                    title: 'label.add.account',
                                                     fields: {
                                                         account: {
-                                                            label: 'Account'
+                                                            label: 'label.account'
                                                         },
                                                         domainid: {
-                                                            label: 'Domain',
+                                                            label: 'label.domain',
                                                             select: function (args) {
                                                                 $.ajax({
                                                                     url: createURL('listDomains'),
@@ -821,7 +821,7 @@
                                                         success: function (json) {
                                                             args.response.success({
                                                                 notification: {
-                                                                    label: 'Add Account',
+                                                                    label: 'label.add.account',
                                                                     poll: function (args) {
                                                                         args.complete();
                                                                     }
@@ -902,15 +902,15 @@
                                         isEditable: true
                                     },
                                     ovmnetworklabel: {
-                                        label: 'OVM traffic label',
+                                        label: 'label.ovm.traffic.label',
                                         isEditable: true
                                     },
                                     lxcnetworklabel: {
-                                        label: 'LXC Traffic Label',
+                                        label: 'label.lxc.traffic.label',
                                         isEditable: true
                                     },
                                     hypervnetworklabel: {
-                                        label: 'HyperV Traffic Label',
+                                        label: 'label.hyperv.traffic.label',
                                         isEditable: true
                                     }
                                 }],
@@ -1114,15 +1114,15 @@
                                         isEditable: true
                                     },
                                     ovmnetworklabel: {
-                                        label: 'OVM traffic label',
+                                        label: 'label.ovm.traffic.label',
                                         isEditable: true
                                     },
                                     lxcnetworklabel: {
-                                        label: 'LXC Traffic Label',
+                                        label: 'label.lxc.traffic.label',
                                         isEditable: true
                                     },
                                     hypervnetworklabel: {
-                                        label: 'HyperV Traffic Label',
+                                        label: 'label.hyperv.traffic.label',
                                         isEditable: true
                                     }
                                 }],
@@ -1277,7 +1277,7 @@
                                         label: 'label.state'
                                     },
                                     vlan: {
-                                        label: 'VLAN/VNI Range(s)',
+                                        label: 'label.vlan.vni.ranges',
                                         isEditable: true
                                     },
                                     tags: {
@@ -1303,15 +1303,15 @@
                                         isEditable: true
                                     },
                                     ovmnetworklabel: {
-                                        label: 'OVM traffic label',
+                                        label: 'label.ovm.traffic.label',
                                         isEditable: true
                                     },
                                     lxcnetworklabel: {
-                                        label: 'LXC Traffic Label',
+                                        label: 'label.lxc.traffic.label',
                                         isEditable: true
                                     },
                                     hypervnetworklabel: {
-                                        label: 'HyperV Traffic Label',
+                                        label: 'label.hyperv.traffic.label',
                                         isEditable: true
                                     }
                                 }],
@@ -1524,13 +1524,13 @@
                                             label: 'label.vnet.id'
                                         },
                                         broadcasturi: {
-                                            label: 'broadcast URI'
+                                            label: 'label.broadcat.uri'
                                         },
                                         cidr: {
-                                            label: 'IPv4 CIDR'
+                                            label: 'label.ipv4.cidr'
                                         },
                                         ip6cidr: {
-                                            label: 'IPv6 CIDR'
+                                            label: 'label.ipv6.cidr'
                                         }
                                         //scope: { label: 'label.scope' }
                                     },
@@ -1593,7 +1593,7 @@
                                     },
                                     
                                     detailView: {
-                                        name: 'Guest network details',
+                                        name: 'label.guest.network.details',
                                         noCompact: true,
                                         viewAll: {
                                             path: '_zone.guestIpRanges',
@@ -1850,7 +1850,7 @@
                                                         label: 'label.vlan.id'
                                                     },
                                                     broadcasturi: {
-                                                        label: 'broadcast URI'
+                                                        label: 'label.broadcat.uri'
                                                     },
                                                     scope: {
                                                         label: 'label.scope'
@@ -1895,18 +1895,18 @@
                                                     },
                                                     
                                                     gateway: {
-                                                        label: 'IPv4 Gateway'
+                                                        label: 'label.ipv4.gateway'
                                                     },
                                                     //netmask: { label: 'label.netmask' },
                                                     cidr: {
-                                                        label: 'IPv4 CIDR'
+                                                        label: 'label.ipv4.cidr'
                                                     },
                                                     
                                                     ip6gateway: {
-                                                        label: 'IPv6 Gateway'
+                                                        label: 'label.ipv6.gateway'
                                                     },
                                                     ip6cidr: {
-                                                        label: 'IPv6 CIDR'
+                                                        label: 'label.ipv6.CIDR'
                                                     },
                                                     
                                                     networkdomaintext: {
@@ -1968,13 +1968,13 @@
                             },
                             
                             dedicatedGuestVlanRanges: {
-                                title: 'Dedicated VLAN/VNI Ranges',
+                                title: 'label.dedicated.vlan.vni.ranges',
                                 listView: {
                                     section: 'dedicatedGuestVlanRanges',
                                     id: 'dedicatedGuestVlanRanges',
                                     fields: {
                                         guestvlanrange: {
-                                            label: 'VLAN/VNI Range(s)'
+                                            label: 'label.vlan.vni.ranges'
                                         },
                                         domain: {
                                             label: 'label.domain'
@@ -1999,17 +1999,17 @@
                                     },
                                     actions: {
                                         add: {
-                                            label: 'Dedicate VLAN/VNI Range',
+                                            label: 'label.dedicate.vlan.vni.range',
                                             messages: {
                                                 notification: function (args) {
-                                                    return 'Dedicate VLAN/VNI Range';
+                                                    return 'label.dedicate.vlan.vni.range';
                                                 }
                                             },
                                             createForm: {
-                                                title: 'Dedicate VLAN/VNI Range',
+                                                title: 'label.dedicate.vlan.vni.range',
                                                 fields: {
                                                     vlanrange: {
-                                                        label: 'VLAN/VNI Range',
+                                                        label: 'label.vlan.vni.range',
                                                         /*  select: function(args) {
                                                         var items = [];
                                                         if(args.context.physicalNetworks[0].vlan != null && args.context.physicalNetworks[0].vlan.length > 0) {
@@ -2083,16 +2083,16 @@
                                     },
                                     
                                     detailView: {
-                                        name: 'VLAN Range details',
+                                        name: 'label.vlan.range.details',
                                         actions: {
                                             remove: {
-                                                label: 'Release dedicated VLAN range',
+                                                label: 'label.release.dedicated.vlan.range',
                                                 messages: {
                                                     confirm: function (args) {
-                                                        return 'Please confirm you want to release dedicated VLAN range';
+                                                        return 'message.confirm.release.dedicate.vlan.range';
                                                     },
                                                     notification: function (args) {
-                                                        return 'Release dedicated VLAN range';
+                                                        return 'label.release.dedicated.vlan.range';
                                                     }
                                                 },
                                                 action: function (args) {
@@ -2124,7 +2124,7 @@
                                                 title: 'label.details',
                                                 fields:[ {
                                                     guestvlanrange: {
-                                                        label: 'VLAN Range(s)'
+                                                        label: 'label.vlan.ranges'
                                                     }
                                                 },
                                                 {
@@ -2417,7 +2417,7 @@
                                                 });
                                     },
                                     detailView: {
-                                        name: 'Virtual applicance details',
+                                        name: 'label.virtual.appliance.details',
                                         actions: {
                                             start: {
                                                 label: 'label.action.start.router',
@@ -2974,16 +2974,16 @@
                                         });
                                     },
                                     detailView: {
-                                        name: 'Virtual applicance details',
+                                        name: 'label.virtual.appliance.details',
                                         actions: {
                                             start: {
-                                                label: 'Start LB VM',
+                                                label: 'label.start.lb.vm',
                                                 messages: {
                                                     confirm: function (args) {
-                                                        return 'Please confirm you want to start LB VM';
+                                                        return 'message.confirm.start.lb.vm';
                                                     },
                                                     notification: function (args) {
-                                                        return 'Start LB VM';
+                                                        return 'label.start.lb.vm';
                                                     }
                                                 },
                                                 action: function (args) {
@@ -3013,10 +3013,10 @@
                                             },
                                             
                                             stop: {
-                                                label: 'Stop LB VM',
+                                                label: 'label.stop.lb.vm',
                                                 createForm: {
-                                                    title: 'Please confirm you want to stop LB VM',
-                                                    desc: 'Stop LB VM',
+                                                    title: 'message.confirm.stop.lb.vm',
+                                                    desc: 'label.stop.lb.vm',
                                                     fields: {
                                                         forced: {
                                                             label: 'force.stop',
@@ -3027,7 +3027,7 @@
                                                 },
                                                 messages: {
                                                     notification: function (args) {
-                                                        return 'Stop LB VM';
+                                                        return 'label.stop.lb.vm';
                                                     }
                                                 },
                                                 action: function (args) {
@@ -3059,9 +3059,9 @@
                                             },
                                             
                                             migrate: {
-                                                label: 'Migrate LB VM',
+                                                label: 'label.migrate.lb.vm',
                                                 createForm: {
-                                                    title: 'Migrate LB VM',
+                                                    title: 'label.migrate.lb.vm',
                                                     fields: {
                                                         hostId: {
                                                             label: 'label.host',
@@ -3097,7 +3097,7 @@
                                                 },
                                                 messages: {
                                                     notification: function (args) {
-                                                        return 'Migrate LB VM';
+                                                        return 'label.migrate.lb.vm';
                                                     }
                                                 },
                                                 action: function (args) {
@@ -3375,7 +3375,7 @@
                     
                     vpcVirtualRouter: {
                         id: 'vpcVirtualRouterProviders',
-                        label: 'VPC Virtual Router',
+                        label: 'label.vpc.virtual.router',
                         isMaximized: true,
                         type: 'detailView',
                         fields: {
@@ -3512,7 +3512,7 @@
                                                 });
                                     },
                                     detailView: {
-                                        name: 'Virtual applicance details',
+                                        name: 'label.virtual.appliance.details',
                                         actions: {
                                             start: {
                                                 label: 'label.action.start.router',
@@ -3828,7 +3828,7 @@
                                                         label: 'label.redundant.state'
                                                     },
                                                     vpcid: {
-                                                        label: 'VPC ID'
+                                                        label: 'label.vpc.id'
                                                     }
                                                 }],
                                                 dataProvider: function (args) {
@@ -3920,7 +3920,7 @@
                     
                     Ovs: {
                         id: "Ovs",
-                        label: "Ovs",
+                        label: "label.ovs",
                         isMaximized: true,
                         type: 'detailView',
                         fields: {
@@ -4122,15 +4122,15 @@
                                         },
                                         
                                         gslbprovider: {
-                                            label: 'GSLB service',
+                                            label: 'label.gslb.service',
                                             isBoolean: true,
                                             isChecked: false
                                         },
                                         gslbproviderpublicip: {
-                                            label: 'GSLB service Public IP'
+                                            label: 'label.gslb.service.public.ip'
                                         },
                                         gslbproviderprivateip: {
-                                            label: 'GSLB service Private IP'
+                                            label: 'label.gslb.service.private.ip'
                                         },
                                         
                                         numretries: {
@@ -4310,7 +4310,7 @@
                     BaremetalDhcpProvider: {
                         type: 'detailView',
                         id: 'BaremetalDhcpProvider',
-                        label: 'Baremetal DHCP Provider',
+                        label: 'label.baremetal.dhcp.provider',
                         viewAll: {
                             label: 'label.devices',
                             path: '_zone.BaremetalDhcpDevices'
@@ -4346,9 +4346,9 @@
                         },
                         actions: {
                             add: {
-                                label: 'Add Baremetal DHCP Device',
+                                label: 'label.add.baremetal.dhcp.device',
                                 createForm: {
-                                    title: 'Add Baremetal DHCP Device',
+                                    title: 'label.add.baremetal.dhcp.device',
                                     fields: {
                                         url: {
                                             label: 'label.url',
@@ -4376,7 +4376,7 @@
                                 },
                                 messages: {
                                     notification: function (args) {
-                                        return 'Add Baremetal DHCP Device';
+                                        return 'label.add.baremetal.dhcp.device';
                                     }
                                 },
                                 notification: {
@@ -4482,7 +4482,7 @@
                     BaremetalPxeProvider: {
                         type: 'detailView',
                         id: 'BaremetalPxeProvider',
-                        label: 'Baremetal PXE Provider',
+                        label: 'label.baremetal.pxe.provider',
                         viewAll: {
                             label: 'label.devices',
                             path: '_zone.BaremetalPxeDevices'
@@ -4518,9 +4518,9 @@
                         },
                         actions: {
                             add: {
-                                label: 'Add Baremetal PXE Device',
+                                label: 'label.baremetal.pxe.device',
                                 createForm: {
-                                    title: 'Add Baremetal PXE Device',
+                                    title: 'label.baremetal.pxe.device',
                                     fields: {
                                         url: {
                                             label: 'label.url',
@@ -4542,7 +4542,7 @@
                                             }
                                         },
                                         tftpdir: {
-                                            label: 'Tftp root directory',
+                                            label: 'label.tftp.root.directory',
                                             validation: {
                                                 required: true
                                             }
@@ -4554,7 +4554,7 @@
                                 },
                                 messages: {
                                     notification: function (args) {
-                                        return 'Add Baremetal PXE Device';
+                                        return 'label.baremetal.pxe.device';
                                     }
                                 },
                                 notification: {
@@ -5474,7 +5474,7 @@
                     // Security groups detail view
                     securityGroups: {
                         id: 'securityGroup-providers',
-                        label: 'Security Groups',
+                        label: 'label.menu.security.groups',
                         type: 'detailView',
                         viewAll: {
                             label: 'label.rules',
@@ -6255,7 +6255,7 @@
                                         });
                                     },
                                     detailView: {
-                                        name: 'Virtual applicance details',
+                                        name: 'label.virtual.appliance.details',
                                         actions: {
                                             start: {
                                                 label: 'label.action.start.router',
@@ -6984,7 +6984,7 @@
             sections: {
                 physicalResources: {
                     type: 'select',
-                    title: 'Physical Resources',
+                    title: 'label.menu.physical.resources',
                     listView: {
                         zones: {
                             id: 'physicalResources',
@@ -7070,24 +7070,24 @@
                                 isMaximized: true,
                                 actions: {
                                     addVmwareDc: {
-                                        label: 'Add VMware datacenter',
-                                        textLabel: 'Add VMware datacenter',
+                                        label: 'label.add.vmware.datacenter',
+                                        textLabel: 'label.add.vmware.datacenter',
                                         messages: {
                                             notification: function (args) {
-                                                return 'Add VMware datacenter';
+                                                return 'label.add.vmware.datacenter';
                                             }
                                         },
                                         createForm: {
-                                            title: 'Add VMware datacenter',
+                                            title: 'label.add.vmware.datacenter',
                                             fields: {
                                                 name: {
-                                                    label: 'DC Name',
+                                                    label: 'label.dc.name',
                                                     validation: {
                                                         required: true
                                                     }
                                                 },
                                                 vcenter: {
-                                                    label: 'vcenter',
+                                                    label: 'label.vcenter',
                                                     validation: {
                                                         required: true
                                                     }
@@ -7143,13 +7143,13 @@
                                     },
                                     
                                     removeVmwareDc: {
-                                        label: 'Remove VMware datacenter',
+                                        label: 'label.remove.vmware.datacenter',
                                         messages: {
                                             confirm: function (args) {
-                                                return 'Please confirm you want to remove VMware datacenter';
+                                                return 'message.confirm.remove.vmware.datacenter';
                                             },
                                             notification: function (args) {
-                                                return 'Remove VMware datacenter';
+                                                return 'label.remove.vmware.datacenter';
                                             }
                                         },
                                         action: function (args) {
@@ -7246,20 +7246,20 @@
                                     },
                                     
                                     dedicateZone: {
-                                        label: 'Dedicate Zone',
+                                        label: 'label.dedicate.zone',
                                         messages: {
                                             confirm: function (args) {
-                                                return 'Do you really want to dedicate this zone to a domain/account? ';
+                                                return 'message.confirm.dedicate.zone';
                                             },
                                             notification: function (args) {
-                                                return 'Zone Dedicated';
+                                                return 'label.zone.dedicated';
                                             }
                                         },
                                         createForm: {
-                                            title: 'Dedicate Zone',
+                                            title: 'label.dedicate.zone',
                                             fields: {
                                                 domainId: {
-                                                    label: 'Domain',
+                                                    label: 'label.domain',
                                                     validation: {
                                                         required: true
                                                     },
@@ -7287,7 +7287,7 @@
                                                     }
                                                 },
                                                 accountId: {
-                                                    label: 'Account',
+                                                    label: 'label.account',
                                                     docID: 'helpAccountForDedication',
                                                     validation: {
                                                         required: false
@@ -7324,13 +7324,13 @@
                                         }
                                     },
                                     releaseDedicatedZone: {
-                                        label: 'Release Dedicated Zone',
+                                        label: 'label.release.dedicated.zone',
                                         messages: {
                                             confirm: function (args) {
-                                                return 'Do you want to release this dedicated zone ?';
+                                                return 'message.confirm.release.dedicated.zone';
                                             },
                                             notification: function (args) {
-                                                return 'Zone dedication released';
+                                                return 'message.dedicated.zone.released';
                                             }
                                         },
                                         action: function (args) {
@@ -7470,11 +7470,11 @@
                                                 isEditable: true
                                             },
                                             ip6dns1: {
-                                                label: 'IPv6 DNS1',
+                                                label: 'label.ipv6.dns1',
                                                 isEditable: true
                                             },
                                             ip6dns2: {
-                                                label: 'IPv6 DNS2',
+                                                label: 'label.ipv6.dns2',
                                                 isEditable: true
                                             },
                                             internaldns1: {
@@ -7511,21 +7511,21 @@
                                         },
                                         {
                                             isdedicated: {
-                                                label: 'Dedicated'
+                                                label: 'label.dedicated'
                                             },
                                             domainid: {
-                                                label: 'Domain ID'
+                                                label: 'label.domain.id'
                                             }
                                         },
                                         {
                                             vmwaredcName: {
-                                                label: 'VMware datacenter Name'
+                                                label: 'label.vmware.datacenter.name'
                                             },
                                             vmwaredcVcenter: {
-                                                label: 'VMware datacenter vcenter'
+                                                label: 'label.vmware.datacenter.vcenter'
                                             },
                                             vmwaredcId: {
-                                                label: 'VMware datacenter Id'
+                                                label: 'label.vmware.datacenter.id'
                                             }
                                         }],
                                         dataProvider: function (args) {
@@ -7678,7 +7678,7 @@
                                             
                                             detailView: {
                                                 noCompact: true,
-                                                name: 'System VM details',
+                                                name: 'label.system.vm.details',
                                                 actions: {
                                                     start: {
                                                         label: 'label.action.start.systemvm',
@@ -7914,7 +7914,7 @@
                                                                 var vmObj = args.jsonObj;
                                                                 //if (vmObj.state == 'Running' && vmObj.hypervisor == 'VMware') { //needs to wait for API fix that will return hypervisor property
                                                                 if (vmObj.state == 'Running') {
-                                                                    description = 'Please read the dynamic scaling section in the admin guide before scaling up.';
+                                                                    description = 'message.read.admin.guide.scaling.up';
                                                                 }
                                                                 return description;
                                                             },
@@ -7977,11 +7977,11 @@
                                                         },
                                                         messages: {
                                                             confirm: function (args) {
-                                                                return 'Do you really want to scale up the system VM ?';
+                                                                return 'message.confirm.scale.up.system.vm';
                                                             },
                                                             notification: function (args) {
                                                                 
-                                                                return 'System VM Scaled Up';
+                                                                return 'label.system.vm.scaled.up';
                                                             }
                                                         },
                                                         notification: {
@@ -8026,8 +8026,8 @@
                                                                 label: 'label.type',
                                                                 converter: function (args) {
                                                                     if (args == "consoleproxy")
-                                                                    return "Console Proxy VM"; else if (args == "secondarystoragevm")
-                                                                    return "Secondary Storage VM"; else
+                                                                    return 'label.console.proxy.vm'; else if (args == "secondarystoragevm")
+                                                                    return 'label.secondary.storage.vm'; else
                                                                     return args;
                                                                 }
                                                             },
@@ -8078,7 +8078,7 @@
                                     
                                     // Granular settings for zone
                                     settings: {
-                                        title: 'Settings',
+                                        title: 'label.settings',
                                         custom: cloudStack.uiCustom.granularSettings({
                                             dataProvider: function (args) {
                                                 $.ajax({
@@ -8741,7 +8741,7 @@
                     routerNoGroup: {
                         id: 'routers',
                         type: 'select',
-                        title: '(no grouping)',
+                        title: 'label.no.grouping',
                         listView: {
                             id: 'routers',
                             label: 'label.virtual.appliances',
@@ -8768,7 +8768,7 @@
                                     }
                                 },
                                 requiresupgrade: {
-                                    label: 'Requires Upgrade',
+                                    label: 'label.requires.upgrade',
                                     converter: cloudStack.converters.toBooleanText
                                 }
                             },
@@ -8830,7 +8830,7 @@
                                         });
                             },
                             detailView: {
-                                name: 'Virtual applicance details',
+                                name: 'label.virtual.appliance.details',
                                 actions: {
                                     start: {
                                         label: 'label.action.start.router',
@@ -8915,13 +8915,13 @@
                                     },
                                     
                                     upgradeRouterToUseNewerTemplate: {
-                                        label: 'Upgrade Router to Use Newer Template',
+                                        label: 'label.upgrade.router.newer.template',
                                         messages: {
                                             confirm: function (args) {
-                                                return 'Please confirm that you want to upgrade router to use newer template';
+                                                return 'message.confirm.upgrade.router.newer.template';
                                             },
                                             notification: function (args) {
-                                                return 'Upgrade Router to Use Newer Template';
+                                                return 'label.upgrade.router.newer.template';
                                             }
                                         },
                                         action: function (args) {
@@ -9102,7 +9102,7 @@
                                                 var vmObj = args.jsonObj;
                                                 //if (vmObj.state == 'Running' && vmObj.hypervisor == 'VMware') { //needs to wait for API fix that will return hypervisor property
                                                 if (vmObj.state == 'Running') {
-                                                    description = 'Please read the dynamic scaling section in the admin guide before scaling up.';
+                                                    description = 'message.read.admin.guide.scaling.up';
                                                 }
                                                 return description;
                                             },
@@ -9163,11 +9163,11 @@
                                         },
                                         messages: {
                                             confirm: function (args) {
-                                                return 'Do you really want to scale up the Router VM ?';
+                                                return 'message.confirm.scale.up.router.vm';
                                             },
                                             notification: function (args) {
                                                 
-                                                return 'Router VM Scaled Up';
+                                                return 'label.router.vm.scaled.up';
                                             }
                                         },
                                         notification: {
@@ -9243,7 +9243,7 @@
                                                 label: 'label.version'
                                             },
                                             requiresupgrade: {
-                                                label: 'Requires Upgrade',
+                                                label: 'label.requires.upgrade',
                                                 converter: cloudStack.converters.toBooleanText
                                             },
                                             guestnetworkid: {
@@ -9285,7 +9285,7 @@
                                                 label: 'label.redundant.state'
                                             },
                                             vpcid: {
-                                                label: 'VPC ID'
+                                                label: 'label.vpc.id'
                                             }
                                         }],
                                         dataProvider: function (args) {
@@ -9371,7 +9371,7 @@
                     routerGroupByZone: {
                         id: 'routerGroupByZone',
                         type: 'select',
-                        title: 'group by zone',
+                        title: 'label.group.by.zone',
                         listView: {
                             id: 'routerGroupByZone',
                             label: 'label.virtual.appliances',
@@ -9380,15 +9380,15 @@
                                     label: 'label.zone'
                                 },
                                 routerCount: {
-                                    label: 'Total of Virtual Routers'
+                                    label: 'label.total.virtual.routers'
                                 },
                                 routerRequiresUpgrade: {
-                                    label: 'Upgrade is required',
+                                    label: 'label.upgrade.required',
                                     converter: function (args) {
                                         if (args > 0) {
-                                            return 'Yes';
+                                            return 'label.yes';
                                         } else {
-                                            return 'No';
+                                            return 'label.no';
                                         }
                                     }
                                 }
@@ -9422,16 +9422,16 @@
                                 });
                             },
                             detailView: {
-                                name: 'Virtual Routers group by zone',
+                                name: 'label.virtual.routers.group.zone',
                                 actions: {
                                     upgradeRouterToUseNewerTemplate: {
-                                        label: 'Upgrade Router to Use Newer Template',
+                                        label: 'label.upgrade.router.newer.template',
                                         messages: {
                                             confirm: function (args) {
-                                                return 'Please confirm that you want to upgrade all routers in this zone to use newer template';
+                                                return 'message.confirm.upgrade.routers.newtemplate';
                                             },
                                             notification: function (args) {
-                                                return 'Upgrade Router to Use Newer Template';
+                                                return 'label.upgrade.router.newer.template';
                                             }
                                         },
                                         action: function (args) {
@@ -9459,7 +9459,7 @@
                                 },
                                 tabs: {
                                     details: {
-                                        title: 'Virtual Routers group by zone',
+                                        title: 'label.virtual.routers.group.zone',
                                         fields:[ {
                                             name: {
                                                 label: 'label.zone'
@@ -9467,10 +9467,10 @@
                                         },
                                         {
                                             routerCount: {
-                                                label: 'Total of Virtual Routers'
+                                                label: 'label.total.virtual.routers'
                                             },
                                             routerRequiresUpgrade: {
-                                                label: 'Upgrade is required',
+                                                label: 'label.upgrade.required',
                                                 converter: function (args) {
                                                     if (args > 0) {
                                                         return 'Yes';
@@ -9480,7 +9480,7 @@
                                                 }
                                             },                                            
                                             numberOfRouterRequiresUpgrade: {
-                                            	label: 'Total of Virtual Routers that require upgrade'
+                                            	label: 'label.total.virtual.routers.upgrade'
                                             }
                                         }],
                                         dataProvider: function (args) {
@@ -9498,7 +9498,7 @@
                     routerGroupByPod: {
                         id: 'routerGroupByPod',
                         type: 'select',
-                        title: 'group by pod',
+                        title: 'label.group.by.pod',
                         listView: {
                             id: 'routerGroupByPod',
                             label: 'label.virtual.appliances',
@@ -9507,15 +9507,15 @@
                                     label: 'label.pod'
                                 },
                                 routerCount: {
-                                    label: 'Total of Virtual Routers'
+                                    label: 'label.total.virtual.routers'
                                 },
                                 routerRequiresUpgrade: {
-                                    label: 'Upgrade is required',
+                                    label: 'label.upgrade.required',
                                     converter: function (args) {
                                         if (args > 0) {
-                                            return 'Yes';
+                                            return 'label.yes';
                                         } else {
-                                            return 'No';
+                                            return 'label.no';
                                         }
                                     }
                                 }
@@ -9549,16 +9549,16 @@
                                 });
                             },
                             detailView: {
-                                name: 'Virtual Routers group by pod',
+                                name: 'label.virtual.routers.group.pod',
                                 actions: {
                                     upgradeRouterToUseNewerTemplate: {
-                                        label: 'Upgrade Router to Use Newer Template',
+                                        label: 'label.upgrade.router.newer.template',
                                         messages: {
                                             confirm: function (args) {
-                                                return 'Please confirm that you want to upgrade all routers in this pod to use newer template';
+                                                return 'message.confirm.upgrade.routers.pod.newtemplate';
                                             },
                                             notification: function (args) {
-                                                return 'Upgrade Router to Use Newer Template';
+                                                return 'label.upgrade.router.newer.template';
                                             }
                                         },
                                         action: function (args) {
@@ -9586,7 +9586,7 @@
                                 },
                                 tabs: {
                                     details: {
-                                        title: 'Virtual Routers group by pod',
+                                        title: 'label.virtual.routers.group.pod',
                                         fields:[ {
                                             name: {
                                                 label: 'label.pod'
@@ -9594,20 +9594,20 @@
                                         },
                                         {
                                             routerCount: {
-                                                label: 'Total of Virtual Routers'
+                                                label: 'label.total.virtual.routers'
                                             },
                                             routerRequiresUpgrade: {
-                                                label: 'Upgrade is required',
+                                                label: 'label.upgrade.required',
                                                 converter: function (args) {
                                                     if (args > 0) {
-                                                        return 'Yes';
+                                                        return 'label.yes';
                                                     } else {
-                                                        return 'No';
+                                                        return 'label.no';
                                                     }
                                                 }
                                             },
                                             numberOfRouterRequiresUpgrade: {
-                                            	label: 'Total of Virtual Routers that require upgrade'
+                                            	label: 'label.total.virtual.routers.upgrade'
                                             },
                                             zonename: {
                                                 label: 'label.zone'
@@ -9628,7 +9628,7 @@
                     routerGroupByCluster: {
                         id: 'routerGroupByCluster',
                         type: 'select',
-                        title: 'group by cluster',
+                        title: 'label.group.by.cluster',
                         listView: {
                             id: 'routerGroupByCluster',
                             label: 'label.virtual.appliances',
@@ -9637,15 +9637,15 @@
                                     label: 'label.cluster'
                                 },
                                 routerCount: {
-                                    label: 'Total of Virtual Routers'
+                                    label: 'label.total.virtual.routers'
                                 },
                                 routerRequiresUpgrade: {
-                                    label: 'Upgrade is required',
+                                    label: 'label.upgrade.required',
                                     converter: function (args) {
                                         if (args > 0) {
-                                            return 'Yes';
+                                            return 'label.yes';
                                         } else {
-                                            return 'No';
+                                            return 'label.no';
                                         }
                                     }
                                 }
@@ -9679,16 +9679,16 @@
                                 });
                             },
                             detailView: {
-                                name: 'Virtual Routers group by cluster',
+                                name: 'label.virtual.routers.group.cluster',
                                 actions: {
                                     upgradeRouterToUseNewerTemplate: {
-                                        label: 'Upgrade Router to Use Newer Template',
+                                        label: 'label.upgrade.router.newer.template',
                                         messages: {
                                             confirm: function (args) {
-                                                return 'Please confirm that you want to upgrade all routers in this cluster to use newer template';
+                                                return 'message.confirm.upgrade.routers.cluster.newtemplate';
                                             },
                                             notification: function (args) {
-                                                return 'Upgrade Router to Use Newer Template';
+                                                return 'label.upgrade.router.newer.template';
                                             }
                                         },
                                         action: function (args) {
@@ -9716,7 +9716,7 @@
                                 },
                                 tabs: {
                                     details: {
-                                        title: 'Virtual Routers group by cluster',
+                                        title: 'label.virtual.routers.group.cluster',
                                         fields:[ {
                                             name: {
                                                 label: 'label.cluster'
@@ -9724,26 +9724,26 @@
                                         },
                                         {
                                             routerCount: {
-                                                label: 'Total of Virtual Routers'
+                                                label: 'label.total.virtual.routers'
                                             },
                                             routerRequiresUpgrade: {
-                                                label: 'Upgrade is required',
+                                                label: 'label.upgrade.required',
                                                 converter: function (args) {
                                                     if (args > 0) {
-                                                        return 'Yes';
+                                                        return 'label.yes';
                                                     } else {
-                                                        return 'No';
+                                                        return 'label.no';
                                                     }
                                                 }
                                             },
                                             numberOfRouterRequiresUpgrade: {
-                                            	label: 'Total of Virtual Routers that require upgrade'
+                                            	label: 'label.total.virtual.routers that require upgrade'
                                             },
                                             podname: {
                                                 label: 'label.pod'
                                             },
                                             zonename: {
-                                                label: 'zone'
+                                                label: 'label.zone.lower'
                                             }
                                         }],
                                         dataProvider: function (args) {
@@ -9773,15 +9773,15 @@
                                     label: 'label.domain'
                                 },
                                 routerCount: {
-                                    label: 'Total of Virtual Routers'
+                                    label: 'label.total.virtual.routers'
                                 },
                                 routerRequiresUpgrade: {
-                                    label: 'Upgrade is required',
+                                    label: 'label.upgrade.required',
                                     converter: function (args) {
                                         if (args > 0) {
-                                            return 'Yes';
+                                            return 'label.yes';
                                         } else {
-                                            return 'No';
+                                            return 'label.no';
                                         }
                                     }
                                 }
@@ -9876,16 +9876,16 @@
                                 });
                             },
                             detailView: {
-                                name: 'Virtual Routers group by account',
+                                name: 'label.virtual.routers.group.account',
                                 actions: {
                                     upgradeRouterToUseNewerTemplate: {
-                                        label: 'Upgrade Router to Use Newer Template',
+                                        label: 'label.upgrade.router.newer.template',
                                         messages: {
                                             confirm: function (args) {
-                                                return 'Please confirm that you want to upgrade all routers in this account to use newer template';
+                                                return 'message.confirm.upgrade.routers.account.newtemplate';
                                             },
                                             notification: function (args) {
-                                                return 'Upgrade Router to Use Newer Template';
+                                                return 'label.upgrade.router.newer.template';
                                             }
                                         },
                                         action: function (args) {
@@ -9914,7 +9914,7 @@
                                 },
                                 tabs: {
                                     details: {
-                                        title: 'Virtual Routers group by account',
+                                        title: 'label.virtual.routers.group.account',
                                         fields:[ {
                                             name: {
                                                 label: 'label.account'
@@ -9925,20 +9925,20 @@
                                         },
                                         {
                                             routerCount: {
-                                                label: 'Total of Virtual Routers'
+                                                label: 'label.total.virtual.routers'
                                             },
                                             routerRequiresUpgrade: {
-                                                label: 'Upgrade is required',
+                                                label: 'label.upgrade.required',
                                                 converter: function (args) {
                                                     if (args > 0) {
-                                                        return 'Yes';
+                                                        return 'label.yes';
                                                     } else {
-                                                        return 'No';
+                                                        return 'label.no';
                                                     }
                                                 }
                                             },                                            
                                             numberOfRouterRequiresUpgrade: {
-                                            	label: 'Total of Virtual Routers that require upgrade'
+                                            	label: 'label.total.virtual.routers that require upgrade'
                                             }
                                         }],
                                         dataProvider: function (args) {
@@ -10041,7 +10041,7 @@
                             label: 'label.zone'
                         },
                         state: {
-                            label: 'VM state',
+                            label: 'label.vm.state',
                             converter: function (str) {
                                 // For localization
                                 return str;
@@ -10091,7 +10091,7 @@
                     },
                     
                     detailView: {
-                        name: 'System VM details',
+                        name: 'label.system.vm.details',
                         actions: {
                             start: {
                                 label: 'label.action.start.systemvm',
@@ -10327,7 +10327,7 @@
                                         var vmObj = args.jsonObj;
                                         //if (vmObj.state == 'Running' && vmObj.hypervisor == 'VMware') { //needs to wait for API fix that will return hypervisor property
                                         if (vmObj.state == 'Running') {
-                                            description = 'Please read the dynamic scaling section in the admin guide before scaling up.';
+                                            description = 'message.read.admin.guide.scaling.up';
                                         }
                                         return description;
                                     },
@@ -10390,11 +10390,11 @@
                                 },
                                 messages: {
                                     confirm: function (args) {
-                                        return 'Do you really want to scale up the system VM ?';
+                                        return 'message.confirm.scale.up.system.vm';
                                     },
                                     notification: function (args) {
                                         
-                                        return 'System VM Scaled Up';
+                                        return 'label.system.vm.scaled.up';
                                     }
                                 },
                                 notification: {
@@ -10570,15 +10570,15 @@
                                     },
                                     
                                     gslbprovider: {
-                                        label: 'GSLB service',
+                                        label: 'label.gslb.service',
                                         isBoolean: true,
                                         isChecked: false
                                     },
                                     gslbproviderpublicip: {
-                                        label: 'GSLB service Public IP'
+                                        label: 'label.gslb.service.public.ip'
                                     },
                                     gslbproviderprivateip: {
-                                        label: 'GSLB service Private IP'
+                                        label: 'label.gslb.service.private.ip'
                                     },
                                     
                                     numretries: {
@@ -10658,7 +10658,7 @@
                         }
                     },
                     detailView: {
-                        name: 'NetScaler details',
+                        name: 'label.netscaler.details',
                         actions: {
                             'remove': {
                                 label: 'label.delete.NetScaler',
@@ -10722,10 +10722,10 @@
                                         converter: cloudStack.converters.toBooleanText
                                     },
                                     gslbproviderpublicip: {
-                                        label: 'GSLB service Public IP'
+                                        label: 'label.gslb.service.public.ip'
                                     },
                                     gslbproviderprivateip: {
-                                        label: 'GSLB service Private IP'
+                                        label: 'label.gslb.service.private.ip'
                                     }
                                 }],
                                 dataProvider: function (args) {
@@ -10750,7 +10750,7 @@
             // Baremetal DHCP devices listView
             BaremetalDhcpDevices: {
                 id: 'BaremetalDhcpDevices',
-                title: 'Baremetal DHCP Devices',
+                title: 'label.baremetal.dhcp.devices',
                 listView: {
                     id: 'BaremetalDhcpDevices',
                     fields: {
@@ -10760,9 +10760,9 @@
                     },
                     actions: {
                         add: {
-                            label: 'Add Baremetal DHCP Device',
+                            label: 'label.add.baremetal.dhcp.device',
                             createForm: {
-                                title: 'Add Baremetal DHCP Device',
+                                title: 'label.add.baremetal.dhcp.device',
                                 fields: {
                                     url: {
                                         label: 'label.url',
@@ -10790,7 +10790,7 @@
                             },
                             messages: {
                                 notification: function (args) {
-                                    return 'Add Baremetal DHCP Device';
+                                    return 'label.add.baremetal.dhcp.device';
                                 }
                             },
                             notification: {
@@ -10822,7 +10822,7 @@
             // Baremetal PXE devices listView
             BaremetalPxeDevices: {
                 id: 'BaremetalPxeDevices',
-                title: 'Baremetal PXE Devices',
+                title: 'label.baremetal.pxe.devices',
                 listView: {
                     id: 'BaremetalPxeDevices',
                     fields: {
@@ -10832,9 +10832,9 @@
                     },
                     actions: {
                         add: {
-                            label: 'Add Baremetal PXE Device',
+                            label: 'label.baremetal.pxe.device',
                             createForm: {
-                                title: 'Add Baremetal PXE Device',
+                                title: 'label.baremetal.pxe.device',
                                 fields: {
                                     url: {
                                         label: 'label.url',
@@ -10856,7 +10856,7 @@
                                         }
                                     },
                                     tftpdir: {
-                                        label: 'Tftp root directory',
+                                        label: 'label.tftp.root.directory',
                                         validation: {
                                             required: true
                                         }
@@ -10868,7 +10868,7 @@
                             },
                             messages: {
                                 notification: function (args) {
-                                    return 'Add Baremetal PXE Device';
+                                    return 'label.baremetal.pxe.device';
                                 }
                             },
                             notification: {
@@ -11022,7 +11022,7 @@
                             },
                             messages: {
                                 notification: function (args) {
-                                    return 'Added new F5';
+                                    return 'label.addes.new.f5';
                                 }
                             },
                             notification: {
@@ -11048,7 +11048,7 @@
                         });
                     },
                     detailView: {
-                        name: 'F5 details',
+                        name: 'label.f5.details',
                         actions: {
                             'remove': {
                                 label: 'label.delete.F5',
@@ -11286,7 +11286,7 @@
                         });
                     },
                     detailView: {
-                        name: 'SRX details',
+                        name: 'label.srx.details',
                         actions: {
                             'remove': {
                                 label: 'label.delete.SRX',
@@ -11530,7 +11530,7 @@
                         });
                     },
                     detailView: {
-                        name: 'Palo Alto details',
+                        name: 'label.palo.alto.details',
                         actions: {
                             'remove': {
                                 label: 'label.delete.PA',
@@ -11695,7 +11695,7 @@
                             
                             messages: {
                                 notification: function (args) {
-                                    return 'Added new Nicira Nvp Controller';
+                                    return 'label.added.nicira.nvp.controller';
                                 }
                             },
                             notification: {
@@ -11721,7 +11721,7 @@
                         });
                     },
                     detailView: {
-                        name: 'Nicira Nvp details',
+                        name: 'label.nicira.nvp.details',
                         actions: {
                             'remove': {
                                 label: 'label.delete.NiciaNvp',
@@ -11857,7 +11857,7 @@
                             
                             messages: {
                                 notification: function (args) {
-                                    return 'Added new BigSwitch Vns Controller';
+                                    return 'label.added.new.bigswitch.vns.controller';
                                 }
                             },
                             notification: {
@@ -11883,7 +11883,7 @@
                         });
                     },
                     detailView: {
-                        name: 'BigSwitch Vns details',
+                        name: 'label.bigswitch.vns.details',
                         actions: {
                             'remove': {
                                 label: 'label.delete.BigSwitchVns',
@@ -12070,14 +12070,14 @@
                                     },
                                     
                                     isDedicated: {
-                                        label: 'Dedicate',
+                                        label: 'label.dedicate',
                                         isBoolean: true,
                                         isChecked: false,
                                         docID: 'helpDedicateResource'
                                     },
                                     
                                     domainId: {
-                                        label: 'Domain',
+                                        label: 'label.domain',
                                         isHidden: true,
                                         validation: {
                                             required: true
@@ -12108,7 +12108,7 @@
                                     },
                                     
                                     accountId: {
-                                        label: 'Account',
+                                        label: 'label.account',
                                         isHidden: true,
                                         dependsOn: 'isDedicated',
                                         docID: 'helpAccountForDedication',
@@ -12204,7 +12204,7 @@
                     detailView: {
                         viewAll: {
                             path: '_zone.clusters',
-                            label: 'Clusters'
+                            label: 'label.clusters'
                         },
                         tabFilter: function (args) {
                             var hiddenTabs =[];
@@ -12281,20 +12281,20 @@
                             },
                             
                             dedicate: {
-                                label: 'Dedicate Pod',
+                                label: 'label.dedicate.pod',
                                 messages: {
                                     confirm: function (args) {
-                                        return 'Do you really want to dedicate this pod to a domain/account? ';
+                                        return 'message.confirm.dedicate.pod.domain.account';
                                     },
                                     notification: function (args) {
-                                        return 'Pod Dedicated';
+                                        return 'label.pod.dedicated';
                                     }
                                 },
                                 createForm: {
-                                    title: 'Dedicate Pod',
+                                    title: 'label.dedicate.pod',
                                     fields: {
                                         domainId: {
-                                            label: 'Domain',
+                                            label: 'label.domain',
                                             validation: {
                                                 required: true
                                             },
@@ -12322,7 +12322,7 @@
                                             }
                                         },
                                         accountId: {
-                                            label: 'Account',
+                                            label: 'label.account',
                                             docID: 'helpAccountForDedication',
                                             validation: {
                                                 required: false
@@ -12362,13 +12362,13 @@
                                 }
                             },
                             release: {
-                                label: 'Release Dedicated Pod',
+                                label: 'label.release.dedicated.pod',
                                 messages: {
                                     confirm: function (args) {
-                                        return 'Do you want to release this dedicated pod ?';
+                                        return 'message.confirm.release.dedicated.pod';
                                     },
                                     notification: function (args) {
-                                        return 'Pod dedication released';
+                                        return 'message.pod.dedication.released';
                                     }
                                 },
                                 action: function (args) {
@@ -12510,10 +12510,10 @@
                                 }, {
                                     
                                     isdedicated: {
-                                        label: 'Dedicated'
+                                        label: 'label.dedicated'
                                     },
                                     domainid: {
-                                        label: 'Domain ID'
+                                        label: 'label.domain.id'
                                     }
                                 }],
                                 
@@ -12532,12 +12532,12 @@
                                                         var podItem = json.listdedicatedpodsresponse.dedicatedpod[0];
                                                         if (podItem.domainid != null) {
                                                             $.extend(item, podItem, {
-                                                                isdedicated: 'Yes'
+                                                                isdedicated: 'label.yes'
                                                             });
                                                         }
                                                     } else
                                                     $.extend(item, {
-                                                        isdedicated: 'No'
+                                                        isdedicated: 'label.no'
                                                     });
                                                     
                                                     args.response.success({
@@ -12792,7 +12792,7 @@
                                 },
                                 fields: {
                                     zoneid: {
-                                        label: 'Zone Name',
+                                        label: 'label.zone.name',
                                         docID: 'helpClusterZone',
                                         validation: {
                                             required: true
@@ -12847,7 +12847,7 @@
                                         }
                                     },
                                     podId: {
-                                        label: 'Pod Name',
+                                        label: 'label.pod.name',
                                         docID: 'helpClusterPod',
                                         dependsOn: 'zoneid',
                                         select: function (args) {
@@ -12885,14 +12885,14 @@
                                     },
                                     
                                     isDedicated: {
-                                        label: 'Dedicate',
+                                        label: 'label.dedicate',
                                         isBoolean: true,
                                         isChecked: false,
                                         docID: 'helpDedicateResource'
                                     },
                                     
                                     domainId: {
-                                        label: 'Domain',
+                                        label: 'label.domain',
                                         isHidden: true,
                                         validation: {
                                             required: true
@@ -12923,7 +12923,7 @@
                                     },
                                     
                                     accountId: {
-                                        label: 'Account',
+                                        label: 'label.account',
                                         isHidden: true,
                                         dependsOn: 'isDedicated',
                                         docID: 'helpAccountForDedication',
@@ -12964,7 +12964,7 @@
                                     },
                                     
                                     overridepublictraffic: {
-                                        label: 'Override Public-Traffic',
+                                        label: 'label.override.public.traffic',
                                         isBoolean: true,
                                         isHidden: true,
                                         isChecked: false,
@@ -12973,7 +12973,7 @@
                                     
                                     
                                     vSwitchPublicType: {
-                                        label: 'Public Traffic vSwitch Type',
+                                        label: 'label.public.traffic.vswitch.type',
                                         select: function (args) {
                                             var useNexusDvs = false;
                                             var items =[]
@@ -13026,12 +13026,12 @@
                                     },
                                     
                                     vSwitchPublicName: {
-                                        label: 'Public Traffic vSwitch Name',
+                                        label: 'label.public.traffic.vswitch.name',
                                         isHidden: true
                                     },
                                     
                                     overrideguesttraffic: {
-                                        label: 'Override Guest-Traffic',
+                                        label: 'label.override.guest.traffic',
                                         isBoolean: true,
                                         isHidden: true,
                                         isChecked: false,
@@ -13039,7 +13039,7 @@
                                     },
                                     
                                     vSwitchGuestType: {
-                                        label: 'Guest Traffic vSwitch Type',
+                                        label: 'label.guest.traffic.vswitch.type',
                                         select: function (args) {
                                             var items =[]
                                             
@@ -13094,41 +13094,41 @@
                                     },
                                     
                                     vSwitchGuestName: {
-                                        label: ' Guest Traffic vSwitch Name',
+                                        label: ' label.guest.traffic.vswitch.name',
                                         isHidden: true
                                     },
                                     
                                     
                                     vsmipaddress: {
-                                        label: 'Nexus 1000v IP Address',
+                                        label: 'label.cisco.nexus1000v.ip.address',
                                         validation: {
                                             required: false
                                         },
                                        

<TRUNCATED>

[40/50] [abbrv] Dispatcher corrections, refactoring and tests

Posted by ml...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
index 208b4a4..2fa3821 100644
--- a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
+++ b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
@@ -53,10 +53,12 @@ import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
 import org.apache.cloudstack.config.ApiServiceConfiguration;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+
 import org.apache.log4j.Logger;
 
 import com.cloud.api.ApiDBUtils;
-import com.cloud.api.ApiDispatcher;
+import com.cloud.api.dispatch.DispatchChainFactory;
+import com.cloud.api.dispatch.DispatchTask;
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenter.NetworkType;
@@ -118,14 +120,17 @@ import com.cloud.utils.db.TransactionStatus;
 import com.cloud.utils.net.NetUtils;
 import com.cloud.vm.UserVmManager;
 import com.cloud.vm.UserVmService;
+
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 
 @Local(value = {AutoScaleService.class, AutoScaleManager.class})
 public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScaleManager, AutoScaleService {
     private static final Logger s_logger = Logger.getLogger(AutoScaleManagerImpl.class);
-    private ScheduledExecutorService _executor = Executors.newScheduledThreadPool(1);
+    private final ScheduledExecutorService _executor = Executors.newScheduledThreadPool(1);
 
+    @Inject()
+    protected DispatchChainFactory dispatchChainFactory = null;
     @Inject
     EntityManager _entityMgr;
     @Inject
@@ -179,35 +184,35 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     @Inject
     LoadBalancingRulesService _loadBalancingRulesService;
 
-    public List<AutoScaleCounter> getSupportedAutoScaleCounters(long networkid) {
-        String capability = _lbRulesMgr.getLBCapability(networkid, Capability.AutoScaleCounters.getName());
+    public List<AutoScaleCounter> getSupportedAutoScaleCounters(final long networkid) {
+        final String capability = _lbRulesMgr.getLBCapability(networkid, Capability.AutoScaleCounters.getName());
         if (capability == null) {
             return null;
         }
-        Gson gson = new Gson();
-        java.lang.reflect.Type listType = new TypeToken<List<AutoScaleCounter>>() {
+        final Gson gson = new Gson();
+        final java.lang.reflect.Type listType = new TypeToken<List<AutoScaleCounter>>() {
         }.getType();
-        List<AutoScaleCounter> result = gson.fromJson(capability, listType);
+        final List<AutoScaleCounter> result = gson.fromJson(capability, listType);
         return result;
     }
 
-    public void validateAutoScaleCounters(long networkid, List<Counter> counters, List<Pair<String, String>> counterParamPassed) {
-        List<AutoScaleCounter> supportedCounters = getSupportedAutoScaleCounters(networkid);
+    public void validateAutoScaleCounters(final long networkid, final List<Counter> counters, final List<Pair<String, String>> counterParamPassed) {
+        final List<AutoScaleCounter> supportedCounters = getSupportedAutoScaleCounters(networkid);
         if (supportedCounters == null) {
             throw new InvalidParameterException("AutoScale is not supported in the network");
         }
-        for (Counter counter : counters) {
-            String counterName = counter.getSource().name().toString();
+        for (final Counter counter : counters) {
+            final String counterName = counter.getSource().name().toString();
             boolean isCounterSupported = false;
-            for (AutoScaleCounter autoScaleCounter : supportedCounters) {
+            for (final AutoScaleCounter autoScaleCounter : supportedCounters) {
                 if (autoScaleCounter.getName().equals(counterName)) {
                     isCounterSupported = true;
-                    List<AutoScaleCounterParam> counterParams = autoScaleCounter.getParamList();
-                    for (AutoScaleCounterParam autoScaleCounterParam : counterParams) {
-                        boolean isRequiredParameter = autoScaleCounterParam.getRequired();
+                    final List<AutoScaleCounterParam> counterParams = autoScaleCounter.getParamList();
+                    for (final AutoScaleCounterParam autoScaleCounterParam : counterParams) {
+                        final boolean isRequiredParameter = autoScaleCounterParam.getRequired();
                         if (isRequiredParameter) {
                             boolean isRequiredParamPresent = false;
-                            for (Pair<String, String> pair : counterParamPassed) {
+                            for (final Pair<String, String> pair : counterParamPassed) {
                                 if (pair.first().equals(autoScaleCounterParam.getParamName()))
                                     isRequiredParamPresent = true;
 
@@ -227,9 +232,9 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         }
     }
 
-    private <VO extends ControlledEntity> VO getEntityInDatabase(Account caller, String paramName, Long id, GenericDao<VO, Long> dao) {
+    private <VO extends ControlledEntity> VO getEntityInDatabase(final Account caller, final String paramName, final Long id, final GenericDao<VO, Long> dao) {
 
-        VO vo = dao.findById(id);
+        final VO vo = dao.findById(id);
 
         if (vo == null) {
             throw new InvalidParameterValueException("Unable to find " + paramName);
@@ -240,27 +245,27 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         return vo;
     }
 
-    private boolean isAutoScaleScaleUpPolicy(AutoScalePolicy policyVO) {
+    private boolean isAutoScaleScaleUpPolicy(final AutoScalePolicy policyVO) {
         return policyVO.getAction().equals("scaleup");
     }
 
-    private List<AutoScalePolicyVO> getAutoScalePolicies(String paramName, List<Long> policyIds, List<Counter> counters, int interval, boolean scaleUpPolicies) {
-        SearchBuilder<AutoScalePolicyVO> policySearch = _autoScalePolicyDao.createSearchBuilder();
+    private List<AutoScalePolicyVO> getAutoScalePolicies(final String paramName, final List<Long> policyIds, final List<Counter> counters, final int interval, final boolean scaleUpPolicies) {
+        final SearchBuilder<AutoScalePolicyVO> policySearch = _autoScalePolicyDao.createSearchBuilder();
         policySearch.and("ids", policySearch.entity().getId(), Op.IN);
         policySearch.done();
-        SearchCriteria<AutoScalePolicyVO> sc = policySearch.create();
+        final SearchCriteria<AutoScalePolicyVO> sc = policySearch.create();
 
         sc.setParameters("ids", policyIds.toArray(new Object[0]));
-        List<AutoScalePolicyVO> policies = _autoScalePolicyDao.search(sc, null);
+        final List<AutoScalePolicyVO> policies = _autoScalePolicyDao.search(sc, null);
 
         int prevQuietTime = 0;
 
-        for (AutoScalePolicyVO policy : policies) {
-            int quietTime = policy.getQuietTime();
+        for (final AutoScalePolicyVO policy : policies) {
+            final int quietTime = policy.getQuietTime();
             if (prevQuietTime == 0) {
                 prevQuietTime = quietTime;
             }
-            int duration = policy.getDuration();
+            final int duration = policy.getDuration();
             if (duration < interval) {
                 throw new InvalidParameterValueException("duration : " + duration + " specified in a policy cannot be less than vm group's interval : " + interval);
             }
@@ -278,11 +283,11 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
                     throw new InvalidParameterValueException("Only scaledown policies can be specified in scaledownpolicyids");
                 }
             }
-            List<AutoScalePolicyConditionMapVO> policyConditionMapVOs = _autoScalePolicyConditionMapDao.listByAll(policy.getId(), null);
-            for (AutoScalePolicyConditionMapVO policyConditionMapVO : policyConditionMapVOs) {
-                long conditionid = policyConditionMapVO.getConditionId();
-                Condition condition = _conditionDao.findById(conditionid);
-                Counter counter = _counterDao.findById(condition.getCounterid());
+            final List<AutoScalePolicyConditionMapVO> policyConditionMapVOs = _autoScalePolicyConditionMapDao.listByAll(policy.getId(), null);
+            for (final AutoScalePolicyConditionMapVO policyConditionMapVO : policyConditionMapVOs) {
+                final long conditionid = policyConditionMapVO.getConditionId();
+                final Condition condition = _conditionDao.findById(conditionid);
+                final Counter counter = _counterDao.findById(condition.getCounterid());
                 counters.add(counter);
             }
         }
@@ -291,11 +296,11 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
     @DB
     protected AutoScaleVmProfileVO checkValidityAndPersist(AutoScaleVmProfileVO vmProfile) {
-        long templateId = vmProfile.getTemplateId();
-        long autoscaleUserId = vmProfile.getAutoScaleUserId();
-        int destroyVmGraceperiod = vmProfile.getDestroyVmGraceperiod();
+        final long templateId = vmProfile.getTemplateId();
+        final long autoscaleUserId = vmProfile.getAutoScaleUserId();
+        final int destroyVmGraceperiod = vmProfile.getDestroyVmGraceperiod();
 
-        VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, templateId);
+        final VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, templateId);
         // Make sure a valid template ID was specified
         if (template == null) {
             throw new InvalidParameterValueException("Unable to use the given template.");
@@ -305,14 +310,14 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             throw new InvalidParameterValueException("Destroy Vm Grace Period cannot be less than 0.");
         }
 
-        User user = _userDao.findById(autoscaleUserId);
+        final User user = _userDao.findById(autoscaleUserId);
         if (user.getAccountId() != vmProfile.getAccountId()) {
             throw new InvalidParameterValueException("AutoScale User id does not belong to the same account");
         }
 
-        String apiKey = user.getApiKey();
-        String secretKey = user.getSecretKey();
-        String csUrl = ApiServiceConfiguration.ApiServletPath.value();
+        final String apiKey = user.getApiKey();
+        final String secretKey = user.getSecretKey();
+        final String csUrl = ApiServiceConfiguration.ApiServletPath.value();
 
         if (apiKey == null) {
             throw new InvalidParameterValueException("apiKey for user: " + user.getUsername() + " is empty. Please generate it");
@@ -333,39 +338,40 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMPROFILE_CREATE, eventDescription = "creating autoscale vm profile", create = true)
-    public AutoScaleVmProfile createAutoScaleVmProfile(CreateAutoScaleVmProfileCmd cmd) {
+    public AutoScaleVmProfile createAutoScaleVmProfile(final CreateAutoScaleVmProfileCmd cmd) {
 
-        Account owner = _accountDao.findById(cmd.getAccountId());
-        Account caller = CallContext.current().getCallingAccount();
+        final Account owner = _accountDao.findById(cmd.getAccountId());
+        final Account caller = CallContext.current().getCallingAccount();
         _accountMgr.checkAccess(caller, null, true, owner);
 
-        long zoneId = cmd.getZoneId();
-        long serviceOfferingId = cmd.getServiceOfferingId();
-        long autoscaleUserId = cmd.getAutoscaleUserId();
+        final long zoneId = cmd.getZoneId();
+        final long serviceOfferingId = cmd.getServiceOfferingId();
+        final long autoscaleUserId = cmd.getAutoscaleUserId();
 
-        DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
+        final DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
 
         if (zone == null) {
             throw new InvalidParameterValueException("Unable to find zone by id");
         }
 
-        ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
+        final ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
         if (serviceOffering == null) {
             throw new InvalidParameterValueException("Unable to find service offering by id");
         }
 
         // validations
-        HashMap<String, String> deployParams = cmd.getDeployParamMap();
+        final HashMap<String, String> deployParams = cmd.getDeployParamMap();
         if (deployParams.containsKey("networks") && deployParams.get("networks").length() > 0) {
             throw new InvalidParameterValueException(
                 "'networks' is not a valid parameter, network for an AutoScaled VM is chosen automatically. An autoscaled VM is deployed in the loadbalancer's network");
         }
+
         /*
          * Just for making sure the values are right in other deploy params.
          * For ex. if projectId is given as a string instead of an long value, this
          * will be throwing an error.
          */
-        ApiDispatcher.processParameters(new DeployVMCmd(), deployParams);
+        dispatchChainFactory.getStandardDispatchChain().dispatch(new DispatchTask(new DeployVMCmd(), deployParams));
 
         AutoScaleVmProfileVO profileVO =
             new AutoScaleVmProfileVO(cmd.getZoneId(), cmd.getDomainId(), cmd.getAccountId(), cmd.getServiceOfferingId(), cmd.getTemplateId(), cmd.getOtherDeployParams(),
@@ -383,13 +389,13 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMPROFILE_UPDATE, eventDescription = "updating autoscale vm profile")
-    public AutoScaleVmProfile updateAutoScaleVmProfile(UpdateAutoScaleVmProfileCmd cmd) {
-        Long profileId = cmd.getId();
-        Long templateId = cmd.getTemplateId();
-        Long autoscaleUserId = cmd.getAutoscaleUserId();
-        Map counterParamList = cmd.getCounterParamList();
+    public AutoScaleVmProfile updateAutoScaleVmProfile(final UpdateAutoScaleVmProfileCmd cmd) {
+        final Long profileId = cmd.getId();
+        final Long templateId = cmd.getTemplateId();
+        final Long autoscaleUserId = cmd.getAutoscaleUserId();
+        final Map counterParamList = cmd.getCounterParamList();
 
-        Integer destroyVmGraceperiod = cmd.getDestroyVmGraceperiod();
+        final Integer destroyVmGraceperiod = cmd.getDestroyVmGraceperiod();
 
         AutoScaleVmProfileVO vmProfile = getEntityInDatabase(CallContext.current().getCallingAccount(), "Auto Scale Vm Profile", profileId, _autoScaleVmProfileDao);
 
@@ -434,13 +440,13 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMPROFILE_DELETE, eventDescription = "deleting autoscale vm profile")
-    public boolean deleteAutoScaleVmProfile(long id) {
+    public boolean deleteAutoScaleVmProfile(final long id) {
         /* Check if entity is in database */
         getEntityInDatabase(CallContext.current().getCallingAccount(), "AutoScale Vm Profile", id, _autoScaleVmProfileDao);
         if (_autoScaleVmGroupDao.isProfileInUse(id)) {
             throw new InvalidParameterValueException("Cannot delete AutoScale Vm Profile when it is in use by one more vm groups");
         }
-        boolean success = _autoScaleVmProfileDao.remove(id);
+        final boolean success = _autoScaleVmProfileDao.remove(id);
         if (success) {
             s_logger.info("Successfully deleted AutoScale Vm Profile with Id: " + id);
         }
@@ -456,8 +462,8 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         Long zoneId = cmd.getZoneId();
         Boolean display = cmd.getDisplay();
 
-        SearchWrapper<AutoScaleVmProfileVO> searchWrapper = new SearchWrapper<AutoScaleVmProfileVO>(_autoScaleVmProfileDao, AutoScaleVmProfileVO.class, cmd, cmd.getId());
-        SearchBuilder<AutoScaleVmProfileVO> sb = searchWrapper.getSearchBuilder();
+        final SearchWrapper<AutoScaleVmProfileVO> searchWrapper = new SearchWrapper<AutoScaleVmProfileVO>(_autoScaleVmProfileDao, AutoScaleVmProfileVO.class, cmd, cmd.getId());
+        final SearchBuilder<AutoScaleVmProfileVO> sb = searchWrapper.getSearchBuilder();
 
         sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
         sb.and("templateId", sb.entity().getTemplateId(), SearchCriteria.Op.EQ);
@@ -507,19 +513,19 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
         return Transaction.execute(new TransactionCallback<AutoScalePolicyVO>() {
             @Override
-            public AutoScalePolicyVO doInTransaction(TransactionStatus status) {
-                AutoScalePolicyVO autoScalePolicyVO = _autoScalePolicyDao.persist(autoScalePolicyVOFinal);
+            public AutoScalePolicyVO doInTransaction(final TransactionStatus status) {
+                final AutoScalePolicyVO autoScalePolicyVO = _autoScalePolicyDao.persist(autoScalePolicyVOFinal);
 
                 if (conditionIds != null) {
-                    SearchBuilder<ConditionVO> conditionsSearch = _conditionDao.createSearchBuilder();
+                    final SearchBuilder<ConditionVO> conditionsSearch = _conditionDao.createSearchBuilder();
                     conditionsSearch.and("ids", conditionsSearch.entity().getId(), Op.IN);
                     conditionsSearch.done();
-                    SearchCriteria<ConditionVO> sc = conditionsSearch.create();
+                    final SearchCriteria<ConditionVO> sc = conditionsSearch.create();
 
                     sc.setParameters("ids", conditionIds.toArray(new Object[0]));
-                    List<ConditionVO> conditions = _conditionDao.search(sc, null);
+                    final List<ConditionVO> conditions = _conditionDao.search(sc, null);
 
-                    ControlledEntity[] sameOwnerEntities = conditions.toArray(new ControlledEntity[conditions.size() + 1]);
+                    final ControlledEntity[] sameOwnerEntities = conditions.toArray(new ControlledEntity[conditions.size() + 1]);
                     sameOwnerEntities[sameOwnerEntities.length - 1] = autoScalePolicyVO;
                     _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, sameOwnerEntities);
 
@@ -528,8 +534,8 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
                         throw new InvalidParameterValueException("Unable to find the condition specified");
                     }
 
-                    ArrayList<Long> counterIds = new ArrayList<Long>();
-                    for (ConditionVO condition : conditions) {
+                    final ArrayList<Long> counterIds = new ArrayList<Long>();
+                    for (final ConditionVO condition : conditions) {
                         if (counterIds.contains(condition.getCounterid())) {
                             throw new InvalidParameterValueException(
                                 "atleast two conditions in the conditionids have the same counter. It is not right to apply two different conditions for the same counter");
@@ -540,8 +546,8 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
                     /* For update case remove the existing mappings and create fresh ones */
                     _autoScalePolicyConditionMapDao.removeByAutoScalePolicyId(autoScalePolicyVO.getId());
 
-                    for (Long conditionId : conditionIds) {
-                        AutoScalePolicyConditionMapVO policyConditionMapVO = new AutoScalePolicyConditionMapVO(autoScalePolicyVO.getId(), conditionId);
+                    for (final Long conditionId : conditionIds) {
+                        final AutoScalePolicyConditionMapVO policyConditionMapVO = new AutoScalePolicyConditionMapVO(autoScalePolicyVO.getId(), conditionId);
                         _autoScalePolicyConditionMapDao.persist(policyConditionMapVO);
                     }
                 }
@@ -553,9 +559,9 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEPOLICY_CREATE, eventDescription = "creating autoscale policy", create = true)
-    public AutoScalePolicy createAutoScalePolicy(CreateAutoScalePolicyCmd cmd) {
+    public AutoScalePolicy createAutoScalePolicy(final CreateAutoScalePolicyCmd cmd) {
 
-        int duration = cmd.getDuration();
+        final int duration = cmd.getDuration();
         Integer quietTime = cmd.getQuietTime();
         String action = cmd.getAction();
 
@@ -588,7 +594,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
         return Transaction.execute(new TransactionCallback<Boolean>() {
             @Override
-            public Boolean doInTransaction(TransactionStatus status) {
+            public Boolean doInTransaction(final TransactionStatus status) {
                 boolean success = true;
                 success = _autoScalePolicyDao.remove(id);
                 if (!success) {
@@ -607,11 +613,11 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         });
     }
 
-    public void checkCallerAccess(String accountName, Long domainId) {
-        Account caller = CallContext.current().getCallingAccount();
-        Account owner = _accountDao.findActiveAccount(accountName, domainId);
+    public void checkCallerAccess(final String accountName, final Long domainId) {
+        final Account caller = CallContext.current().getCallingAccount();
+        final Account owner = _accountDao.findActiveAccount(accountName, domainId);
         if (owner == null) {
-            List<String> idList = new ArrayList<String>();
+            final List<String> idList = new ArrayList<String>();
             idList.add(ApiDBUtils.findDomainById(domainId).getUuid());
             throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain with specifed domainId");
         }
@@ -628,23 +634,23 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         ListProjectResourcesCriteria listProjectResourcesCriteria;
         Filter searchFilter;
 
-        public SearchWrapper(GenericDao<VO, Long> dao, Class<VO> entityClass, BaseListAccountResourcesCmd cmd, Long id) {
+        public SearchWrapper(final GenericDao<VO, Long> dao, final Class<VO> entityClass, final BaseListAccountResourcesCmd cmd, final Long id) {
             this.dao = dao;
             this.searchBuilder = dao.createSearchBuilder();
             domainId = cmd.getDomainId();
-            String accountName = cmd.getAccountName();
+            final String accountName = cmd.getAccountName();
             isRecursive = cmd.isRecursive();
-            boolean listAll = cmd.listAll();
-            long startIndex = cmd.getStartIndex();
-            long pageSizeVal = cmd.getPageSizeVal();
-            Account caller = CallContext.current().getCallingAccount();
+            final boolean listAll = cmd.listAll();
+            final long startIndex = cmd.getStartIndex();
+            final long pageSizeVal = cmd.getPageSizeVal();
+            final Account caller = CallContext.current().getCallingAccount();
 
-            Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject =
+            final Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject =
                 new Ternary<Long, Boolean, ListProjectResourcesCriteria>(domainId, isRecursive, null);
             _accountMgr.buildACLSearchParameters(caller, id, accountName, null, permittedAccounts, domainIdRecursiveListProject, listAll, false);
             domainId = domainIdRecursiveListProject.first();
             isRecursive = domainIdRecursiveListProject.second();
-            ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
+            final ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
             _accountMgr.buildACLSearchBuilder(searchBuilder, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
             searchFilter = new Filter(entityClass, "id", false, startIndex, pageSizeVal);
         }
@@ -665,30 +671,30 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     }
 
     @Override
-    public List<? extends AutoScalePolicy> listAutoScalePolicies(ListAutoScalePoliciesCmd cmd) {
-        SearchWrapper<AutoScalePolicyVO> searchWrapper = new SearchWrapper<AutoScalePolicyVO>(_autoScalePolicyDao, AutoScalePolicyVO.class, cmd, cmd.getId());
-        SearchBuilder<AutoScalePolicyVO> sb = searchWrapper.getSearchBuilder();
-        Long id = cmd.getId();
-        Long conditionId = cmd.getConditionId();
-        String action = cmd.getAction();
-        Long vmGroupId = cmd.getVmGroupId();
+    public List<? extends AutoScalePolicy> listAutoScalePolicies(final ListAutoScalePoliciesCmd cmd) {
+        final SearchWrapper<AutoScalePolicyVO> searchWrapper = new SearchWrapper<AutoScalePolicyVO>(_autoScalePolicyDao, AutoScalePolicyVO.class, cmd, cmd.getId());
+        final SearchBuilder<AutoScalePolicyVO> sb = searchWrapper.getSearchBuilder();
+        final Long id = cmd.getId();
+        final Long conditionId = cmd.getConditionId();
+        final String action = cmd.getAction();
+        final Long vmGroupId = cmd.getVmGroupId();
 
         sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
         sb.and("action", sb.entity().getAction(), SearchCriteria.Op.EQ);
 
         if (conditionId != null) {
-            SearchBuilder<AutoScalePolicyConditionMapVO> asPolicyConditionSearch = _autoScalePolicyConditionMapDao.createSearchBuilder();
+            final SearchBuilder<AutoScalePolicyConditionMapVO> asPolicyConditionSearch = _autoScalePolicyConditionMapDao.createSearchBuilder();
             asPolicyConditionSearch.and("conditionId", asPolicyConditionSearch.entity().getConditionId(), SearchCriteria.Op.EQ);
             sb.join("asPolicyConditionSearch", asPolicyConditionSearch, sb.entity().getId(), asPolicyConditionSearch.entity().getPolicyId(), JoinBuilder.JoinType.INNER);
         }
 
         if (vmGroupId != null) {
-            SearchBuilder<AutoScaleVmGroupPolicyMapVO> asVmGroupPolicySearch = _autoScaleVmGroupPolicyMapDao.createSearchBuilder();
+            final SearchBuilder<AutoScaleVmGroupPolicyMapVO> asVmGroupPolicySearch = _autoScaleVmGroupPolicyMapDao.createSearchBuilder();
             asVmGroupPolicySearch.and("vmGroupId", asVmGroupPolicySearch.entity().getVmGroupId(), SearchCriteria.Op.EQ);
             sb.join("asVmGroupPolicySearch", asVmGroupPolicySearch, sb.entity().getId(), asVmGroupPolicySearch.entity().getPolicyId(), JoinBuilder.JoinType.INNER);
         }
 
-        SearchCriteria<AutoScalePolicyVO> sc = searchWrapper.buildSearchCriteria();
+        final SearchCriteria<AutoScalePolicyVO> sc = searchWrapper.buildSearchCriteria();
 
         if (id != null) {
             sc.setParameters("id", id);
@@ -711,11 +717,11 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEPOLICY_UPDATE, eventDescription = "updating autoscale policy")
-    public AutoScalePolicy updateAutoScalePolicy(UpdateAutoScalePolicyCmd cmd) {
-        Long policyId = cmd.getId();
-        Integer duration = cmd.getDuration();
-        Integer quietTime = cmd.getQuietTime();
-        List<Long> conditionIds = cmd.getConditionIds();
+    public AutoScalePolicy updateAutoScalePolicy(final UpdateAutoScalePolicyCmd cmd) {
+        final Long policyId = cmd.getId();
+        final Integer duration = cmd.getDuration();
+        final Integer quietTime = cmd.getQuietTime();
+        final List<Long> conditionIds = cmd.getConditionIds();
         AutoScalePolicyVO policy = getEntityInDatabase(CallContext.current().getCallingAccount(), "Auto Scale Policy", policyId, _autoScalePolicyDao);
 
         if (duration != null) {
@@ -726,9 +732,9 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             policy.setQuietTime(quietTime);
         }
 
-        List<AutoScaleVmGroupPolicyMapVO> vmGroupPolicyList = _autoScaleVmGroupPolicyMapDao.listByPolicyId(policyId);
-        for (AutoScaleVmGroupPolicyMapVO vmGroupPolicy : vmGroupPolicyList) {
-            AutoScaleVmGroupVO vmGroupVO = _autoScaleVmGroupDao.findById(vmGroupPolicy.getVmGroupId());
+        final List<AutoScaleVmGroupPolicyMapVO> vmGroupPolicyList = _autoScaleVmGroupPolicyMapDao.listByPolicyId(policyId);
+        for (final AutoScaleVmGroupPolicyMapVO vmGroupPolicy : vmGroupPolicyList) {
+            final AutoScaleVmGroupVO vmGroupVO = _autoScaleVmGroupDao.findById(vmGroupPolicy.getVmGroupId());
             if (vmGroupVO == null) {
                 s_logger.warn("Stale database entry! There is an entry in VmGroupPolicyMap but the vmGroup is missing:" + vmGroupPolicy.getVmGroupId());
 
@@ -750,9 +756,9 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMGROUP_CREATE, eventDescription = "creating autoscale vm group", create = true)
-    public AutoScaleVmGroup createAutoScaleVmGroup(CreateAutoScaleVmGroupCmd cmd) {
-        int minMembers = cmd.getMinMembers();
-        int maxMembers = cmd.getMaxMembers();
+    public AutoScaleVmGroup createAutoScaleVmGroup(final CreateAutoScaleVmGroupCmd cmd) {
+        final int minMembers = cmd.getMinMembers();
+        final int maxMembers = cmd.getMaxMembers();
         Integer interval = cmd.getInterval();
         Boolean forDisplay = cmd.getDisplay();
 
@@ -760,9 +766,9 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             interval = NetUtils.DEFAULT_AUTOSCALE_POLICY_INTERVAL_TIME;
         }
 
-        LoadBalancerVO loadBalancer = getEntityInDatabase(CallContext.current().getCallingAccount(), ApiConstants.LBID, cmd.getLbRuleId(), _lbDao);
+        final LoadBalancerVO loadBalancer = getEntityInDatabase(CallContext.current().getCallingAccount(), ApiConstants.LBID, cmd.getLbRuleId(), _lbDao);
 
-        Long zoneId = _ipAddressDao.findById(loadBalancer.getSourceIpAddressId()).getDataCenterId();
+        final Long zoneId = _ipAddressDao.findById(loadBalancer.getSourceIpAddressId()).getDataCenterId();
 
         if (_autoScaleVmGroupDao.isAutoScaleLoadBalancer(loadBalancer.getId())) {
             throw new InvalidParameterValueException("an AutoScaleVmGroup is already attached to the lb rule, the existing vm group has to be first deleted");
@@ -787,23 +793,23 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     }
 
     @Override
-    public boolean configureAutoScaleVmGroup(CreateAutoScaleVmGroupCmd cmd) throws ResourceUnavailableException {
+    public boolean configureAutoScaleVmGroup(final CreateAutoScaleVmGroupCmd cmd) throws ResourceUnavailableException {
         return configureAutoScaleVmGroup(cmd.getEntityId(), AutoScaleVmGroup.State_New);
     }
 
-    public boolean isLoadBalancerBasedAutoScaleVmGroup(AutoScaleVmGroup vmGroup) {
+    public boolean isLoadBalancerBasedAutoScaleVmGroup(final AutoScaleVmGroup vmGroup) {
         return vmGroup.getLoadBalancerId() != null;
     }
 
-    private boolean configureAutoScaleVmGroup(long vmGroupid, String currentState) throws ResourceUnavailableException {
-        AutoScaleVmGroup vmGroup = _autoScaleVmGroupDao.findById(vmGroupid);
+    private boolean configureAutoScaleVmGroup(final long vmGroupid, final String currentState) throws ResourceUnavailableException {
+        final AutoScaleVmGroup vmGroup = _autoScaleVmGroupDao.findById(vmGroupid);
 
         if (isLoadBalancerBasedAutoScaleVmGroup(vmGroup)) {
             try {
                 return _lbRulesMgr.configureLbAutoScaleVmGroup(vmGroupid, currentState);
-            } catch (ResourceUnavailableException re) {
+            } catch (final ResourceUnavailableException re) {
                 throw re;
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 s_logger.warn("Exception during configureLbAutoScaleVmGroup in lb rules manager", e);
                 return false;
             }
@@ -817,20 +823,20 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMGROUP_DELETE, eventDescription = "deleting autoscale vm group")
     public boolean deleteAutoScaleVmGroup(final long id) {
-        AutoScaleVmGroupVO autoScaleVmGroupVO = getEntityInDatabase(CallContext.current().getCallingAccount(), "AutoScale Vm Group", id, _autoScaleVmGroupDao);
+        final AutoScaleVmGroupVO autoScaleVmGroupVO = getEntityInDatabase(CallContext.current().getCallingAccount(), "AutoScale Vm Group", id, _autoScaleVmGroupDao);
 
         if (autoScaleVmGroupVO.getState().equals(AutoScaleVmGroup.State_New)) {
             /* This condition is for handling failures during creation command */
             return _autoScaleVmGroupDao.remove(id);
         }
-        String bakupState = autoScaleVmGroupVO.getState();
+        final String bakupState = autoScaleVmGroupVO.getState();
         autoScaleVmGroupVO.setState(AutoScaleVmGroup.State_Revoke);
         _autoScaleVmGroupDao.persist(autoScaleVmGroupVO);
         boolean success = false;
 
         try {
             success = configureAutoScaleVmGroup(id, bakupState);
-        } catch (ResourceUnavailableException e) {
+        } catch (final ResourceUnavailableException e) {
             autoScaleVmGroupVO.setState(bakupState);
             _autoScaleVmGroupDao.persist(autoScaleVmGroupVO);
         } finally {
@@ -842,7 +848,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
         return Transaction.execute(new TransactionCallback<Boolean>() {
             @Override
-            public Boolean doInTransaction(TransactionStatus status) {
+            public Boolean doInTransaction(final TransactionStatus status) {
                 boolean success = _autoScaleVmGroupDao.remove(id);
 
                 if (!success) {
@@ -872,8 +878,8 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         Long zoneId = cmd.getZoneId();
         Boolean forDisplay = cmd.getDisplay();
 
-        SearchWrapper<AutoScaleVmGroupVO> searchWrapper = new SearchWrapper<AutoScaleVmGroupVO>(_autoScaleVmGroupDao, AutoScaleVmGroupVO.class, cmd, cmd.getId());
-        SearchBuilder<AutoScaleVmGroupVO> sb = searchWrapper.getSearchBuilder();
+        final SearchWrapper<AutoScaleVmGroupVO> searchWrapper = new SearchWrapper<AutoScaleVmGroupVO>(_autoScaleVmGroupDao, AutoScaleVmGroupVO.class, cmd, cmd.getId());
+        final SearchBuilder<AutoScaleVmGroupVO> sb = searchWrapper.getSearchBuilder();
 
         sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
         sb.and("loadBalancerId", sb.entity().getLoadBalancerId(), SearchCriteria.Op.EQ);
@@ -882,12 +888,12 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         sb.and("display", sb.entity().isDisplay(), SearchCriteria.Op.EQ);
 
         if (policyId != null) {
-            SearchBuilder<AutoScaleVmGroupPolicyMapVO> asVmGroupPolicySearch = _autoScaleVmGroupPolicyMapDao.createSearchBuilder();
+            final SearchBuilder<AutoScaleVmGroupPolicyMapVO> asVmGroupPolicySearch = _autoScaleVmGroupPolicyMapDao.createSearchBuilder();
             asVmGroupPolicySearch.and("policyId", asVmGroupPolicySearch.entity().getPolicyId(), SearchCriteria.Op.EQ);
             sb.join("asVmGroupPolicySearch", asVmGroupPolicySearch, sb.entity().getId(), asVmGroupPolicySearch.entity().getVmGroupId(), JoinBuilder.JoinType.INNER);
         }
 
-        SearchCriteria<AutoScaleVmGroupVO> sc = searchWrapper.buildSearchCriteria();
+        final SearchCriteria<AutoScaleVmGroupVO> sc = searchWrapper.buildSearchCriteria();
         if (id != null) {
             sc.setParameters("id", id);
         }
@@ -912,14 +918,14 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     @DB
     protected AutoScaleVmGroupVO checkValidityAndPersist(final AutoScaleVmGroupVO vmGroup, final List<Long> passedScaleUpPolicyIds,
         final List<Long> passedScaleDownPolicyIds) {
-        int minMembers = vmGroup.getMinMembers();
-        int maxMembers = vmGroup.getMaxMembers();
-        int interval = vmGroup.getInterval();
-        List<Counter> counters = new ArrayList<Counter>();
-        List<AutoScalePolicyVO> policies = new ArrayList<AutoScalePolicyVO>();
+        final int minMembers = vmGroup.getMinMembers();
+        final int maxMembers = vmGroup.getMaxMembers();
+        final int interval = vmGroup.getInterval();
+        final List<Counter> counters = new ArrayList<Counter>();
+        final List<AutoScalePolicyVO> policies = new ArrayList<AutoScalePolicyVO>();
         final List<Long> policyIds = new ArrayList<Long>();
-        List<Long> currentScaleUpPolicyIds = new ArrayList<Long>();
-        List<Long> currentScaleDownPolicyIds = new ArrayList<Long>();
+        final List<Long> currentScaleUpPolicyIds = new ArrayList<Long>();
+        final List<Long> currentScaleDownPolicyIds = new ArrayList<Long>();
         if (vmGroup.getCreated() != null) {
             ApiDBUtils.getAutoScaleVmGroupPolicyIds(vmGroup.getId(), currentScaleUpPolicyIds, currentScaleDownPolicyIds);
         }
@@ -958,26 +964,26 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             getAutoScalePolicies("scaledownpolicyid", currentScaleDownPolicyIds, counters, interval, false);
             policyIds.addAll(currentScaleDownPolicyIds);
         }
-        AutoScaleVmProfileVO profileVO =
+        final AutoScaleVmProfileVO profileVO =
             getEntityInDatabase(CallContext.current().getCallingAccount(), ApiConstants.VMPROFILE_ID, vmGroup.getProfileId(), _autoScaleVmProfileDao);
 
-        LoadBalancerVO loadBalancer = getEntityInDatabase(CallContext.current().getCallingAccount(), ApiConstants.LBID, vmGroup.getLoadBalancerId(), _lbDao);
+        final LoadBalancerVO loadBalancer = getEntityInDatabase(CallContext.current().getCallingAccount(), ApiConstants.LBID, vmGroup.getLoadBalancerId(), _lbDao);
         validateAutoScaleCounters(loadBalancer.getNetworkId(), counters, profileVO.getCounterParams());
 
-        ControlledEntity[] sameOwnerEntities = policies.toArray(new ControlledEntity[policies.size() + 2]);
+        final ControlledEntity[] sameOwnerEntities = policies.toArray(new ControlledEntity[policies.size() + 2]);
         sameOwnerEntities[sameOwnerEntities.length - 2] = loadBalancer;
         sameOwnerEntities[sameOwnerEntities.length - 1] = profileVO;
         _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, sameOwnerEntities);
 
         return Transaction.execute(new TransactionCallback<AutoScaleVmGroupVO>() {
             @Override
-            public AutoScaleVmGroupVO doInTransaction(TransactionStatus status) {
-                AutoScaleVmGroupVO vmGroupNew = _autoScaleVmGroupDao.persist(vmGroup);
+            public AutoScaleVmGroupVO doInTransaction(final TransactionStatus status) {
+                final AutoScaleVmGroupVO vmGroupNew = _autoScaleVmGroupDao.persist(vmGroup);
 
                 if (passedScaleUpPolicyIds != null || passedScaleDownPolicyIds != null) {
                     _autoScaleVmGroupPolicyMapDao.removeByGroupId(vmGroupNew.getId());
 
-                    for (Long policyId : policyIds) {
+                    for (final Long policyId : policyIds) {
                         _autoScaleVmGroupPolicyMapDao.persist(new AutoScaleVmGroupPolicyMapVO(vmGroupNew.getId(), policyId));
                     }
                 }
@@ -990,15 +996,15 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMGROUP_UPDATE, eventDescription = "updating autoscale vm group")
-    public AutoScaleVmGroup updateAutoScaleVmGroup(UpdateAutoScaleVmGroupCmd cmd) {
-        Long vmGroupId = cmd.getId();
-        Integer minMembers = cmd.getMinMembers();
-        Integer maxMembers = cmd.getMaxMembers();
-        Integer interval = cmd.getInterval();
-        Boolean forDisplay = cmd.getDisplay();
+    public AutoScaleVmGroup updateAutoScaleVmGroup(final UpdateAutoScaleVmGroupCmd cmd) {
+        final Long vmGroupId = cmd.getId();
+        final Integer minMembers = cmd.getMinMembers();
+        final Integer maxMembers = cmd.getMaxMembers();
+        final Integer interval = cmd.getInterval();
+        final Boolean forDisplay = cmd.getDisplay();
 
-        List<Long> scaleUpPolicyIds = cmd.getScaleUpPolicyIds();
-        List<Long> scaleDownPolicyIds = cmd.getScaleDownPolicyIds();
+        final List<Long> scaleUpPolicyIds = cmd.getScaleUpPolicyIds();
+        final List<Long> scaleDownPolicyIds = cmd.getScaleDownPolicyIds();
 
         AutoScaleVmGroupVO vmGroupVO = getEntityInDatabase(CallContext.current().getCallingAccount(), "AutoScale Vm Group", vmGroupId, _autoScaleVmGroupDao);
 
@@ -1039,7 +1045,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     @Override
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMGROUP_ENABLE, eventDescription = "enabling autoscale vm group")
-    public AutoScaleVmGroup enableAutoScaleVmGroup(Long id) {
+    public AutoScaleVmGroup enableAutoScaleVmGroup(final Long id) {
         AutoScaleVmGroupVO vmGroup = getEntityInDatabase(CallContext.current().getCallingAccount(), "AutoScale Vm Group", id, _autoScaleVmGroupDao);
         boolean success = false;
         if (!vmGroup.getState().equals(AutoScaleVmGroup.State_Disabled)) {
@@ -1050,7 +1056,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             vmGroup.setState(AutoScaleVmGroup.State_Enabled);
             vmGroup = _autoScaleVmGroupDao.persist(vmGroup);
             success = configureAutoScaleVmGroup(id, AutoScaleVmGroup.State_Disabled);
-        } catch (ResourceUnavailableException e) {
+        } catch (final ResourceUnavailableException e) {
             vmGroup.setState(AutoScaleVmGroup.State_Disabled);
             _autoScaleVmGroupDao.persist(vmGroup);
         } finally {
@@ -1066,7 +1072,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMGROUP_DISABLE, eventDescription = "disabling autoscale vm group")
     @DB
-    public AutoScaleVmGroup disableAutoScaleVmGroup(Long id) {
+    public AutoScaleVmGroup disableAutoScaleVmGroup(final Long id) {
         AutoScaleVmGroupVO vmGroup = getEntityInDatabase(CallContext.current().getCallingAccount(), "AutoScale Vm Group", id, _autoScaleVmGroupDao);
         boolean success = false;
         if (!vmGroup.getState().equals(AutoScaleVmGroup.State_Enabled)) {
@@ -1077,7 +1083,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             vmGroup.setState(AutoScaleVmGroup.State_Disabled);
             vmGroup = _autoScaleVmGroupDao.persist(vmGroup);
             success = configureAutoScaleVmGroup(id, AutoScaleVmGroup.State_Enabled);
-        } catch (ResourceUnavailableException e) {
+        } catch (final ResourceUnavailableException e) {
             vmGroup.setState(AutoScaleVmGroup.State_Enabled);
             _autoScaleVmGroupDao.persist(vmGroup);
         } finally {
@@ -1093,14 +1099,14 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_COUNTER_CREATE, eventDescription = "Counter", create = true)
     @DB
-    public Counter createCounter(CreateCounterCmd cmd) {
-        String source = cmd.getSource().toLowerCase();
-        String name = cmd.getName();
+    public Counter createCounter(final CreateCounterCmd cmd) {
+        final String source = cmd.getSource().toLowerCase();
+        final String name = cmd.getName();
         Counter.Source src;
         // Validate Source
         try {
             src = Counter.Source.valueOf(source);
-        } catch (Exception ex) {
+        } catch (final Exception ex) {
             throw new InvalidParameterValueException("The Source " + source + " does not exist; Unable to create Counter");
         }
 
@@ -1115,21 +1121,21 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_CONDITION_CREATE, eventDescription = "Condition", create = true)
-    public Condition createCondition(CreateConditionCmd cmd) {
+    public Condition createCondition(final CreateConditionCmd cmd) {
         checkCallerAccess(cmd.getAccountName(), cmd.getDomainId());
-        String opr = cmd.getRelationalOperator().toUpperCase();
-        long cid = cmd.getCounterId();
-        long threshold = cmd.getThreshold();
+        final String opr = cmd.getRelationalOperator().toUpperCase();
+        final long cid = cmd.getCounterId();
+        final long threshold = cmd.getThreshold();
         Condition.Operator op;
         // Validate Relational Operator
         try {
             op = Condition.Operator.valueOf(opr);
-        } catch (IllegalArgumentException ex) {
+        } catch (final IllegalArgumentException ex) {
             throw new InvalidParameterValueException("The Operator " + opr + " does not exist; Unable to create Condition.");
         }
         // TODO - Validate threshold
 
-        CounterVO counter = _counterDao.findById(cid);
+        final CounterVO counter = _counterDao.findById(cid);
 
         if (counter == null) {
             throw new InvalidParameterValueException("Unable to find counter");
@@ -1144,29 +1150,29 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     }
 
     @Override
-    public List<? extends Counter> listCounters(ListCountersCmd cmd) {
-        String name = cmd.getName();
-        Long id = cmd.getId();
+    public List<? extends Counter> listCounters(final ListCountersCmd cmd) {
+        final String name = cmd.getName();
+        final Long id = cmd.getId();
         String source = cmd.getSource();
         if (source != null)
             source = source.toLowerCase();
 
-        Filter searchFilter = new Filter(CounterVO.class, "created", false, cmd.getStartIndex(), cmd.getPageSizeVal());
+        final Filter searchFilter = new Filter(CounterVO.class, "created", false, cmd.getStartIndex(), cmd.getPageSizeVal());
 
-        List<CounterVO> counters = _counterDao.listCounters(id, name, source, cmd.getKeyword(), searchFilter);
+        final List<CounterVO> counters = _counterDao.listCounters(id, name, source, cmd.getKeyword(), searchFilter);
 
         return counters;
     }
 
     @Override
-    public List<? extends Condition> listConditions(ListConditionsCmd cmd) {
-        Long id = cmd.getId();
-        Long counterId = cmd.getCounterId();
-        Long policyId = cmd.getPolicyId();
-        SearchWrapper<ConditionVO> searchWrapper = new SearchWrapper<ConditionVO>(_conditionDao, ConditionVO.class, cmd, cmd.getId());
-        SearchBuilder<ConditionVO> sb = searchWrapper.getSearchBuilder();
+    public List<? extends Condition> listConditions(final ListConditionsCmd cmd) {
+        final Long id = cmd.getId();
+        final Long counterId = cmd.getCounterId();
+        final Long policyId = cmd.getPolicyId();
+        final SearchWrapper<ConditionVO> searchWrapper = new SearchWrapper<ConditionVO>(_conditionDao, ConditionVO.class, cmd, cmd.getId());
+        final SearchBuilder<ConditionVO> sb = searchWrapper.getSearchBuilder();
         if (policyId != null) {
-            SearchBuilder<AutoScalePolicyConditionMapVO> asPolicyConditionSearch = _autoScalePolicyConditionMapDao.createSearchBuilder();
+            final SearchBuilder<AutoScalePolicyConditionMapVO> asPolicyConditionSearch = _autoScalePolicyConditionMapDao.createSearchBuilder();
             asPolicyConditionSearch.and("policyId", asPolicyConditionSearch.entity().getPolicyId(), SearchCriteria.Op.EQ);
             sb.join("asPolicyConditionSearch", asPolicyConditionSearch, sb.entity().getId(), asPolicyConditionSearch.entity().getConditionId(),
                 JoinBuilder.JoinType.INNER);
@@ -1176,7 +1182,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         sb.and("counterId", sb.entity().getCounterid(), SearchCriteria.Op.EQ);
 
         // now set the SC criteria...
-        SearchCriteria<ConditionVO> sc = searchWrapper.buildSearchCriteria();
+        final SearchCriteria<ConditionVO> sc = searchWrapper.buildSearchCriteria();
 
         if (id != null) {
             sc.setParameters("id", id);
@@ -1195,22 +1201,22 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_COUNTER_DELETE, eventDescription = "counter")
-    public boolean deleteCounter(long counterId) throws ResourceInUseException {
+    public boolean deleteCounter(final long counterId) throws ResourceInUseException {
         // Verify Counter id
-        CounterVO counter = _counterDao.findById(counterId);
+        final CounterVO counter = _counterDao.findById(counterId);
         if (counter == null) {
             throw new InvalidParameterValueException("Unable to find Counter");
         }
 
         // Verify if it is used in any Condition
 
-        ConditionVO condition = _conditionDao.findByCounterId(counterId);
+        final ConditionVO condition = _conditionDao.findByCounterId(counterId);
         if (condition != null) {
             s_logger.info("Cannot delete counter " + counter.getName() + " as it is being used in a condition.");
             throw new ResourceInUseException("Counter is in use.");
         }
 
-        boolean success = _counterDao.remove(counterId);
+        final boolean success = _counterDao.remove(counterId);
         if (success) {
             s_logger.info("Successfully deleted counter with Id: " + counterId);
         }
@@ -1220,9 +1226,9 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_CONDITION_DELETE, eventDescription = "condition")
-    public boolean deleteCondition(long conditionId) throws ResourceInUseException {
+    public boolean deleteCondition(final long conditionId) throws ResourceInUseException {
         /* Check if entity is in database */
-        ConditionVO condition = getEntityInDatabase(CallContext.current().getCallingAccount(), "Condition", conditionId, _conditionDao);
+        final ConditionVO condition = getEntityInDatabase(CallContext.current().getCallingAccount(), "Condition", conditionId, _conditionDao);
         if (condition == null) {
             throw new InvalidParameterValueException("Unable to find Condition");
         }
@@ -1232,7 +1238,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             s_logger.info("Cannot delete condition " + conditionId + " as it is being used in a condition.");
             throw new ResourceInUseException("Cannot delete Condition when it is in use by one or more AutoScale Policies.");
         }
-        boolean success = _conditionDao.remove(conditionId);
+        final boolean success = _conditionDao.remove(conditionId);
         if (success) {
             s_logger.info("Successfully deleted condition " + condition.getId());
         }
@@ -1240,7 +1246,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     }
 
     @Override
-    public void cleanUpAutoScaleResources(Long accountId) {
+    public void cleanUpAutoScaleResources(final Long accountId) {
         // cleans Autoscale VmProfiles, AutoScale Policies and Conditions belonging to an account
         int count = 0;
         count = _autoScaleVmProfileDao.removeByAccountId(accountId);
@@ -1257,10 +1263,10 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         }
     }
 
-    private boolean checkConditionUp(AutoScaleVmGroupVO asGroup, Integer numVm) {
+    private boolean checkConditionUp(final AutoScaleVmGroupVO asGroup, final Integer numVm) {
         // check maximum
-        Integer currentVM = _autoScaleVmGroupVmMapDao.countByGroup(asGroup.getId());
-        Integer maxVm = asGroup.getMaxMembers();
+        final Integer currentVM = _autoScaleVmGroupVmMapDao.countByGroup(asGroup.getId());
+        final Integer maxVm = asGroup.getMaxMembers();
         if (currentVM + numVm > maxVm) {
             s_logger.warn("number of VM will greater than the maximum in this group if scaling up, so do nothing more");
             return false;
@@ -1268,9 +1274,9 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         return true;
     }
 
-    private boolean checkConditionDown(AutoScaleVmGroupVO asGroup) {
-        Integer currentVM = _autoScaleVmGroupVmMapDao.countByGroup(asGroup.getId());
-        Integer minVm = asGroup.getMinMembers();
+    private boolean checkConditionDown(final AutoScaleVmGroupVO asGroup) {
+        final Integer currentVM = _autoScaleVmGroupVmMapDao.countByGroup(asGroup.getId());
+        final Integer minVm = asGroup.getMinMembers();
         if (currentVM - 1 < minVm) {
             s_logger.warn("number of VM will less than the minimum in this group if scaling down, so do nothing more");
             return false;
@@ -1278,29 +1284,29 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         return true;
     }
 
-    private long createNewVM(AutoScaleVmGroupVO asGroup) {
-        AutoScaleVmProfileVO profileVo = _autoScaleVmProfileDao.findById(asGroup.getProfileId());
-        long templateId = profileVo.getTemplateId();
-        long serviceOfferingId = profileVo.getServiceOfferingId();
+    private long createNewVM(final AutoScaleVmGroupVO asGroup) {
+        final AutoScaleVmProfileVO profileVo = _autoScaleVmProfileDao.findById(asGroup.getProfileId());
+        final long templateId = profileVo.getTemplateId();
+        final long serviceOfferingId = profileVo.getServiceOfferingId();
         if (templateId == -1) {
             return -1;
         }
         // create new VM into DB
         try {
             //Verify that all objects exist before passing them to the service
-            Account owner = _accountService.getActiveAccountById(profileVo.getAccountId());
+            final Account owner = _accountService.getActiveAccountById(profileVo.getAccountId());
 
-            DataCenter zone = _entityMgr.findById(DataCenter.class, profileVo.getZoneId());
+            final DataCenter zone = _entityMgr.findById(DataCenter.class, profileVo.getZoneId());
             if (zone == null) {
                 throw new InvalidParameterValueException("Unable to find zone by id=" + profileVo.getZoneId());
             }
 
-            ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
+            final ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
             if (serviceOffering == null) {
                 throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
             }
 
-            VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, templateId);
+            final VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, templateId);
             // Make sure a valid template ID was specified
             if (template == null) {
                 throw new InvalidParameterValueException("Unable to use template " + templateId);
@@ -1313,7 +1319,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             }
 
             UserVm vm = null;
-            IpAddresses addrs = new IpAddresses(null, null);
+            final IpAddresses addrs = new IpAddresses(null, null);
             if (zone.getNetworkType() == NetworkType.Basic) {
                 vm = _userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, null, owner, "autoScaleVm-" + asGroup.getId() + "-" +
                     getCurrentTimeStampString(),
@@ -1339,41 +1345,41 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             } else {
                 return -1;
             }
-        } catch (InsufficientCapacityException ex) {
+        } catch (final InsufficientCapacityException ex) {
             s_logger.info(ex);
             s_logger.trace(ex.getMessage(), ex);
             throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
-        } catch (ResourceUnavailableException ex) {
+        } catch (final ResourceUnavailableException ex) {
             s_logger.warn("Exception: ", ex);
             throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
-        } catch (ConcurrentOperationException ex) {
+        } catch (final ConcurrentOperationException ex) {
             s_logger.warn("Exception: ", ex);
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
-        } catch (ResourceAllocationException ex) {
+        } catch (final ResourceAllocationException ex) {
             s_logger.warn("Exception: ", ex);
             throw new ServerApiException(ApiErrorCode.RESOURCE_ALLOCATION_ERROR, ex.getMessage());
         }
     }
 
     private String getCurrentTimeStampString() {
-        Date current = new Date();
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+        final Date current = new Date();
+        final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
 
         return sdf.format(current);
     }
 
-    private boolean startNewVM(long vmId) {
+    private boolean startNewVM(final long vmId) {
         try {
             CallContext.current().setEventDetails("Vm Id: " + vmId);
             _userVmManager.startVirtualMachine(vmId, null, null);
-        } catch (ResourceUnavailableException ex) {
+        } catch (final ResourceUnavailableException ex) {
             s_logger.warn("Exception: ", ex);
             throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
-        } catch (ConcurrentOperationException ex) {
+        } catch (final ConcurrentOperationException ex) {
             s_logger.warn("Exception: ", ex);
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
-        } catch (InsufficientCapacityException ex) {
-            StringBuilder message = new StringBuilder(ex.getMessage());
+        } catch (final InsufficientCapacityException ex) {
+            final StringBuilder message = new StringBuilder(ex.getMessage());
             if (ex instanceof InsufficientServerCapacityException) {
                 if (((InsufficientServerCapacityException)ex).isAffinityApplied()) {
                     message.append(", Please check the affinity groups provided, there may not be sufficient capacity to follow them");
@@ -1386,14 +1392,14 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         return true;
     }
 
-    private boolean assignLBruleToNewVm(long vmId, AutoScaleVmGroupVO asGroup) {
-        List<Long> lstVmId = new ArrayList<Long>();
-        long lbId = asGroup.getLoadBalancerId();
+    private boolean assignLBruleToNewVm(final long vmId, final AutoScaleVmGroupVO asGroup) {
+        final List<Long> lstVmId = new ArrayList<Long>();
+        final long lbId = asGroup.getLoadBalancerId();
 
-        List<LoadBalancerVMMapVO> LbVmMapVos = _lbVmMapDao.listByLoadBalancerId(lbId);
+        final List<LoadBalancerVMMapVO> LbVmMapVos = _lbVmMapDao.listByLoadBalancerId(lbId);
         if ((LbVmMapVos != null) && (LbVmMapVos.size() > 0)) {
-            for (LoadBalancerVMMapVO LbVmMapVo : LbVmMapVos) {
-                long instanceId = LbVmMapVo.getInstanceId();
+            for (final LoadBalancerVMMapVO LbVmMapVo : LbVmMapVos) {
+                final long instanceId = LbVmMapVo.getInstanceId();
                 if (instanceId == vmId) {
                     s_logger.warn("the new VM is already mapped to LB rule. What's wrong?");
                     return true;
@@ -1405,17 +1411,17 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
     }
 
-    private long removeLBrule(AutoScaleVmGroupVO asGroup) {
-        long lbId = asGroup.getLoadBalancerId();
+    private long removeLBrule(final AutoScaleVmGroupVO asGroup) {
+        final long lbId = asGroup.getLoadBalancerId();
         long instanceId = -1;
-        List<LoadBalancerVMMapVO> LbVmMapVos = _lbVmMapDao.listByLoadBalancerId(lbId);
+        final List<LoadBalancerVMMapVO> LbVmMapVos = _lbVmMapDao.listByLoadBalancerId(lbId);
         if ((LbVmMapVos != null) && (LbVmMapVos.size() > 0)) {
-            for (LoadBalancerVMMapVO LbVmMapVo : LbVmMapVos) {
+            for (final LoadBalancerVMMapVO LbVmMapVo : LbVmMapVos) {
                 instanceId = LbVmMapVo.getInstanceId();
             }
         }
         // take last VM out of the list
-        List<Long> lstVmId = new ArrayList<Long>();
+        final List<Long> lstVmId = new ArrayList<Long>();
         if (instanceId != -1)
             lstVmId.add(instanceId);
         if (_loadBalancingRulesService.removeFromLoadBalancer(lbId, lstVmId))
@@ -1425,8 +1431,8 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     }
 
     @Override
-    public void doScaleUp(long groupId, Integer numVm) {
-        AutoScaleVmGroupVO asGroup = _autoScaleVmGroupDao.findById(groupId);
+    public void doScaleUp(final long groupId, final Integer numVm) {
+        final AutoScaleVmGroupVO asGroup = _autoScaleVmGroupDao.findById(groupId);
         if (asGroup == null) {
             s_logger.error("Can not find the groupid " + groupId + " for scaling up");
             return;
@@ -1435,7 +1441,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             return;
         }
         for (int i = 0; i < numVm; i++) {
-            long vmId = createNewVM(asGroup);
+            final long vmId = createNewVM(asGroup);
             if (vmId == -1) {
                 s_logger.error("Can not deploy new VM for scaling up in the group "
                     + asGroup.getId() + ". Waiting for next round");
@@ -1444,14 +1450,14 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             if (startNewVM(vmId)) {
                 if (assignLBruleToNewVm(vmId, asGroup)) {
                     // persist to DB
-                    AutoScaleVmGroupVmMapVO GroupVmVO = new AutoScaleVmGroupVmMapVO(
+                    final AutoScaleVmGroupVmMapVO GroupVmVO = new AutoScaleVmGroupVmMapVO(
                         asGroup.getId(), vmId);
                     _autoScaleVmGroupVmMapDao.persist(GroupVmVO);
                     // update last_quiettime
-                    List<AutoScaleVmGroupPolicyMapVO> GroupPolicyVOs = _autoScaleVmGroupPolicyMapDao
+                    final List<AutoScaleVmGroupPolicyMapVO> GroupPolicyVOs = _autoScaleVmGroupPolicyMapDao
                         .listByVmGroupId(groupId);
-                    for (AutoScaleVmGroupPolicyMapVO GroupPolicyVO : GroupPolicyVOs) {
-                        AutoScalePolicyVO vo = _autoScalePolicyDao
+                    for (final AutoScaleVmGroupPolicyMapVO GroupPolicyVO : GroupPolicyVOs) {
+                        final AutoScalePolicyVO vo = _autoScalePolicyDao
                             .findById(GroupPolicyVO.getPolicyId());
                         if (vo.getAction().equals("scaleup")) {
                             vo.setLastQuiteTime(new Date());
@@ -1473,7 +1479,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
     @Override
     public void doScaleDown(final long groupId) {
-        AutoScaleVmGroupVO asGroup = _autoScaleVmGroupDao.findById(groupId);
+        final AutoScaleVmGroupVO asGroup = _autoScaleVmGroupDao.findById(groupId);
         if (asGroup == null) {
             s_logger.error("Can not find the groupid " + groupId + " for scaling up");
             return;
@@ -1483,14 +1489,14 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         }
         final long vmId = removeLBrule(asGroup);
         if (vmId != -1) {
-            long profileId = asGroup.getProfileId();
+            final long profileId = asGroup.getProfileId();
 
             // update group-vm mapping
             _autoScaleVmGroupVmMapDao.remove(groupId, vmId);
             // update last_quiettime
-            List<AutoScaleVmGroupPolicyMapVO> GroupPolicyVOs = _autoScaleVmGroupPolicyMapDao.listByVmGroupId(groupId);
-            for (AutoScaleVmGroupPolicyMapVO GroupPolicyVO : GroupPolicyVOs) {
-                AutoScalePolicyVO vo = _autoScalePolicyDao.findById(GroupPolicyVO.getPolicyId());
+            final List<AutoScaleVmGroupPolicyMapVO> GroupPolicyVOs = _autoScaleVmGroupPolicyMapDao.listByVmGroupId(groupId);
+            for (final AutoScaleVmGroupPolicyMapVO GroupPolicyVO : GroupPolicyVOs) {
+                final AutoScalePolicyVO vo = _autoScalePolicyDao.findById(GroupPolicyVO.getPolicyId());
                 if (vo.getAction().equals("scaledown")) {
                     vo.setLastQuiteTime(new Date());
                     _autoScalePolicyDao.persist(vo);
@@ -1499,8 +1505,8 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             }
 
             // get destroyvmgrace param
-            AutoScaleVmProfileVO asProfile = _autoScaleVmProfileDao.findById(profileId);
-            Integer destroyVmGracePeriod = asProfile.getDestroyVmGraceperiod();
+            final AutoScaleVmProfileVO asProfile = _autoScaleVmProfileDao.findById(profileId);
+            final Integer destroyVmGracePeriod = asProfile.getDestroyVmGraceperiod();
             if (destroyVmGracePeriod >= 0) {
                 _executor.schedule(new Runnable() {
                     @Override
@@ -1509,9 +1515,9 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
                             _userVmManager.destroyVm(vmId);
 
-                        } catch (ResourceUnavailableException e) {
+                        } catch (final ResourceUnavailableException e) {
                             e.printStackTrace();
-                        } catch (ConcurrentOperationException e) {
+                        } catch (final ConcurrentOperationException e) {
                             e.printStackTrace();
                         }
                     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 8486f06..3c99867 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -105,7 +105,6 @@ import com.cloud.agent.api.to.StaticNatRuleTO;
 import com.cloud.agent.manager.Commands;
 import com.cloud.alert.AlertManager;
 import com.cloud.api.ApiAsyncJobDispatcher;
-import com.cloud.api.ApiDispatcher;
 import com.cloud.api.ApiGsonHelper;
 import com.cloud.cluster.ManagementServerHostVO;
 import com.cloud.cluster.dao.ManagementServerHostDao;
@@ -4195,7 +4194,6 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
         for(DomainRouterVO router: routers){
             if(!checkRouterVersion(router)){
                     s_logger.debug("Upgrading template for router: "+router.getId());
-                    ApiDispatcher.getInstance();
                     Map<String, String> params = new HashMap<String, String>();
                     params.put("ctxUserId", "1");
                     params.put("ctxAccountId", "" + router.getAccountId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c211f0bb/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java
index a85c052..447697f 100644
--- a/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java
@@ -82,6 +82,8 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
     protected VolumeDao _volsDao;
     @Inject
     protected ConfigurationDao _configDao;
+    @Inject
+    protected ApiDispatcher _dispatcher;
 
     protected AsyncJobDispatcher _asyncDispatcher;
 
@@ -95,21 +97,21 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
         return _asyncDispatcher;
     }
 
-    public void setAsyncJobDispatcher(AsyncJobDispatcher dispatcher) {
+    public void setAsyncJobDispatcher(final AsyncJobDispatcher dispatcher) {
         _asyncDispatcher = dispatcher;
     }
 
-    private Date getNextScheduledTime(long policyId, Date currentTimestamp) {
-        SnapshotPolicyVO policy = _snapshotPolicyDao.findById(policyId);
+    private Date getNextScheduledTime(final long policyId, final Date currentTimestamp) {
+        final SnapshotPolicyVO policy = _snapshotPolicyDao.findById(policyId);
         Date nextTimestamp = null;
         if (policy != null) {
-            short intervalType = policy.getInterval();
-            IntervalType type = DateUtil.getIntervalType(intervalType);
-            String schedule = policy.getSchedule();
-            String timezone = policy.getTimezone();
+            final short intervalType = policy.getInterval();
+            final IntervalType type = DateUtil.getIntervalType(intervalType);
+            final String schedule = policy.getSchedule();
+            final String timezone = policy.getTimezone();
             nextTimestamp = DateUtil.getNextRunTime(type, schedule, timezone, currentTimestamp);
-            String currentTime = DateUtil.displayDateInTimezone(DateUtil.GMT_TIMEZONE, currentTimestamp);
-            String nextScheduledTime = DateUtil.displayDateInTimezone(DateUtil.GMT_TIMEZONE, nextTimestamp);
+            final String currentTime = DateUtil.displayDateInTimezone(DateUtil.GMT_TIMEZONE, currentTimestamp);
+            final String nextScheduledTime = DateUtil.displayDateInTimezone(DateUtil.GMT_TIMEZONE, nextTimestamp);
             s_logger.debug("Current time is " + currentTime + ". NextScheduledTime of policyId " + policyId + " is " + nextScheduledTime);
         }
         return nextTimestamp;
@@ -119,7 +121,7 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
      * {@inheritDoc}
      */
     @Override
-    public void poll(Date currentTimestamp) {
+    public void poll(final Date currentTimestamp) {
         // We don't maintain the time. The timer task does.
         _currentTimestamp = currentTimestamp;
 
@@ -151,12 +153,12 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
     }
 
     private void checkStatusOfCurrentlyExecutingSnapshots() {
-        SearchCriteria<SnapshotScheduleVO> sc = _snapshotScheduleDao.createSearchCriteria();
+        final SearchCriteria<SnapshotScheduleVO> sc = _snapshotScheduleDao.createSearchCriteria();
         sc.addAnd("asyncJobId", SearchCriteria.Op.NNULL);
-        List<SnapshotScheduleVO> snapshotSchedules = _snapshotScheduleDao.search(sc, null);
-        for (SnapshotScheduleVO snapshotSchedule : snapshotSchedules) {
-            Long asyncJobId = snapshotSchedule.getAsyncJobId();
-            AsyncJobVO asyncJob = _asyncJobDao.findById(asyncJobId);
+        final List<SnapshotScheduleVO> snapshotSchedules = _snapshotScheduleDao.search(sc, null);
+        for (final SnapshotScheduleVO snapshotSchedule : snapshotSchedules) {
+            final Long asyncJobId = snapshotSchedule.getAsyncJobId();
+            final AsyncJobVO asyncJob = _asyncJobDao.findById(asyncJobId);
             switch (asyncJob.getStatus()) {
                 case SUCCEEDED:
                     // The snapshot has been successfully backed up.
@@ -167,7 +169,7 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
                     break;
                 case FAILED:
                     // Check the snapshot status.
-                    Long snapshotId = snapshotSchedule.getSnapshotId();
+                    final Long snapshotId = snapshotSchedule.getSnapshotId();
                     if (snapshotId == null) {
                         // createSnapshotAsync exited, successfully or unsuccessfully,
                         // even before creating a snapshot record
@@ -175,7 +177,7 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
                         // Schedule the next snapshot.
                         scheduleNextSnapshotJob(snapshotSchedule);
                     } else {
-                        SnapshotVO snapshot = _snapshotDao.findById(snapshotId);
+                        final SnapshotVO snapshot = _snapshotDao.findById(snapshotId);
                         if (snapshot == null || snapshot.getRemoved() != null) {
                             // This snapshot has been deleted successfully from the primary storage
                             // Again no cleanup needs to be done.
@@ -219,16 +221,16 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
         String displayTime = DateUtil.displayDateInTimezone(DateUtil.GMT_TIMEZONE, _currentTimestamp);
         s_logger.debug("Snapshot scheduler.poll is being called at " + displayTime);
 
-        List<SnapshotScheduleVO> snapshotsToBeExecuted = _snapshotScheduleDao.getSchedulesToExecute(_currentTimestamp);
+        final List<SnapshotScheduleVO> snapshotsToBeExecuted = _snapshotScheduleDao.getSchedulesToExecute(_currentTimestamp);
         s_logger.debug("Got " + snapshotsToBeExecuted.size() + " snapshots to be executed at " + displayTime);
 
-        for (SnapshotScheduleVO snapshotToBeExecuted : snapshotsToBeExecuted) {
+        for (final SnapshotScheduleVO snapshotToBeExecuted : snapshotsToBeExecuted) {
             SnapshotScheduleVO tmpSnapshotScheduleVO = null;
-            long snapshotScheId = snapshotToBeExecuted.getId();
-            long policyId = snapshotToBeExecuted.getPolicyId();
-            long volumeId = snapshotToBeExecuted.getVolumeId();
+            final long snapshotScheId = snapshotToBeExecuted.getId();
+            final long policyId = snapshotToBeExecuted.getPolicyId();
+            final long volumeId = snapshotToBeExecuted.getVolumeId();
             try {
-                VolumeVO volume = _volsDao.findById(volumeId);
+                final VolumeVO volume = _volsDao.findById(volumeId);
                 if (volume.getPoolId() == null) {
                     // this volume is not attached
                     continue;
@@ -237,26 +239,26 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
                     _snapshotScheduleDao.remove(snapshotToBeExecuted.getId());
                 }
                 if (s_logger.isDebugEnabled()) {
-                    Date scheduledTimestamp = snapshotToBeExecuted.getScheduledTimestamp();
+                    final Date scheduledTimestamp = snapshotToBeExecuted.getScheduledTimestamp();
                     displayTime = DateUtil.displayDateInTimezone(DateUtil.GMT_TIMEZONE, scheduledTimestamp);
                     s_logger.debug("Scheduling 1 snapshot for volume " + volumeId + " for schedule id: " + snapshotToBeExecuted.getId() + " at " + displayTime);
                 }
 
                 tmpSnapshotScheduleVO = _snapshotScheduleDao.acquireInLockTable(snapshotScheId);
-                Long eventId =
+                final Long eventId =
                     ActionEventUtils.onScheduledActionEvent(User.UID_SYSTEM, volume.getAccountId(), EventTypes.EVENT_SNAPSHOT_CREATE, "creating snapshot for volume Id:" +
                         volumeId, true, 0);
 
-                Map<String, String> params = new HashMap<String, String>();
+                final Map<String, String> params = new HashMap<String, String>();
                 params.put(ApiConstants.VOLUME_ID, "" + volumeId);
                 params.put(ApiConstants.POLICY_ID, "" + policyId);
                 params.put("ctxUserId", "1");
                 params.put("ctxAccountId", "" + volume.getAccountId());
                 params.put("ctxStartEventId", String.valueOf(eventId));
 
-                CreateSnapshotCmd cmd = new CreateSnapshotCmd();
+                final CreateSnapshotCmd cmd = new CreateSnapshotCmd();
                 ComponentContext.inject(cmd);
-                ApiDispatcher.getInstance().dispatchCreateCmd(cmd, params);
+                _dispatcher.dispatchCreateCmd(cmd, params);
                 params.put("id", "" + cmd.getEntityId());
                 params.put("ctxStartEventId", "1");
 
@@ -265,11 +267,12 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
                         cmd.getInstanceType() != null ? cmd.getInstanceType().toString() : null);
                 job.setDispatcher(_asyncDispatcher.getName());
 
-                long jobId = _asyncMgr.submitAsyncJob(job);
+                final long jobId = _asyncMgr.submitAsyncJob(job);
 
                 tmpSnapshotScheduleVO.setAsyncJobId(jobId);
                 _snapshotScheduleDao.update(snapshotScheId, tmpSnapshotScheduleVO);
-            } catch (Exception e) {
+            } catch (final Exception e) {
+                // TODO Logging this exception is enough?
                 s_logger.warn("Scheduling snapshot failed due to " + e.toString());
             } finally {
                 if (tmpSnapshotScheduleVO != null) {
@@ -279,16 +282,16 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
         }
     }
 
-    private Date scheduleNextSnapshotJob(SnapshotScheduleVO snapshotSchedule) {
+    private Date scheduleNextSnapshotJob(final SnapshotScheduleVO snapshotSchedule) {
         if (snapshotSchedule == null) {
             return null;
         }
-        Long policyId = snapshotSchedule.getPolicyId();
+        final Long policyId = snapshotSchedule.getPolicyId();
         if (policyId.longValue() == Snapshot.MANUAL_POLICY_ID) {
             // Don't need to schedule the next job for this.
             return null;
         }
-        SnapshotPolicyVO snapshotPolicy = _snapshotPolicyDao.findById(policyId);
+        final SnapshotPolicyVO snapshotPolicy = _snapshotPolicyDao.findById(policyId);
         if (snapshotPolicy == null) {
             _snapshotScheduleDao.expunge(snapshotSchedule.getId());
         }
@@ -297,15 +300,15 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
 
     @Override
     @DB
-    public Date scheduleNextSnapshotJob(SnapshotPolicyVO policy) {
+    public Date scheduleNextSnapshotJob(final SnapshotPolicyVO policy) {
         if (policy == null) {
             return null;
         }
-        long policyId = policy.getId();
+        final long policyId = policy.getId();
         if (policyId == Snapshot.MANUAL_POLICY_ID) {
             return null;
         }
-        Date nextSnapshotTimestamp = getNextScheduledTime(policyId, _currentTimestamp);
+        final Date nextSnapshotTimestamp = getNextScheduledTime(policyId, _currentTimestamp);
         SnapshotScheduleVO spstSchedVO = _snapshotScheduleDao.findOneByVolumePolicy(policy.getVolumeId(), policy.getId());
         if (spstSchedVO == null) {
             spstSchedVO = new SnapshotScheduleVO(policy.getVolumeId(), policyId, nextSnapshotTimestamp);
@@ -329,9 +332,9 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
 
     @Override
     @DB
-    public boolean removeSchedule(Long volumeId, Long policyId) {
+    public boolean removeSchedule(final Long volumeId, final Long policyId) {
         // We can only remove schedules which are in the future. Not which are already executed in the past.
-        SnapshotScheduleVO schedule = _snapshotScheduleDao.getCurrentSchedule(volumeId, policyId, false);
+        final SnapshotScheduleVO schedule = _snapshotScheduleDao.getCurrentSchedule(volumeId, policyId, false);
         boolean success = true;
         if (schedule != null) {
             success = _snapshotScheduleDao.remove(schedule.getId());
@@ -343,18 +346,18 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
     }
 
     @Override
-    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+    public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
 
         _snapshotPollInterval = NumbersUtil.parseInt(_configDao.getValue("snapshot.poll.interval"), 300);
-        boolean snapshotsRecurringTest = Boolean.parseBoolean(_configDao.getValue("snapshot.recurring.test"));
+        final boolean snapshotsRecurringTest = Boolean.parseBoolean(_configDao.getValue("snapshot.recurring.test"));
         if (snapshotsRecurringTest) {
             // look for some test values in the configuration table so that snapshots can be taken more frequently (QA test code)
-            int minutesPerHour = NumbersUtil.parseInt(_configDao.getValue("snapshot.test.minutes.per.hour"), 60);
-            int hoursPerDay = NumbersUtil.parseInt(_configDao.getValue("snapshot.test.hours.per.day"), 24);
-            int daysPerWeek = NumbersUtil.parseInt(_configDao.getValue("snapshot.test.days.per.week"), 7);
-            int daysPerMonth = NumbersUtil.parseInt(_configDao.getValue("snapshot.test.days.per.month"), 30);
-            int weeksPerMonth = NumbersUtil.parseInt(_configDao.getValue("snapshot.test.weeks.per.month"), 4);
-            int monthsPerYear = NumbersUtil.parseInt(_configDao.getValue("snapshot.test.months.per.year"), 12);
+            final int minutesPerHour = NumbersUtil.parseInt(_configDao.getValue("snapshot.test.minutes.per.hour"), 60);
+            final int hoursPerDay = NumbersUtil.parseInt(_configDao.getValue("snapshot.test.hours.per.day"), 24);
+            final int daysPerWeek = NumbersUtil.parseInt(_configDao.getValue("snapshot.test.days.per.week"), 7);
+            final int daysPerMonth = NumbersUtil.parseInt(_configDao.getValue("snapshot.test.days.per.month"), 30);
+            final int weeksPerMonth = NumbersUtil.parseInt(_configDao.getValue("snapshot.test.weeks.per.month"), 4);
+            final int monthsPerYear = NumbersUtil.parseInt(_configDao.getValue("snapshot.test.months.per.year"), 12);
 
             _testTimerTask = new TestClock(this, minutesPerHour, hoursPerDay, daysPerWeek, daysPerMonth, weeksPerMonth, monthsPerYear);
         }
@@ -369,8 +372,8 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
     @DB
     public boolean start() {
         // reschedule all policies after management restart
-        List<SnapshotPolicyVO> policyInstances = _snapshotPolicyDao.listAll();
-        for (SnapshotPolicyVO policyInstance : policyInstances) {
+        final List<SnapshotPolicyVO> policyInstances = _snapshotPolicyDao.listAll();
+        for (final SnapshotPolicyVO policyInstance : policyInstances) {
             if (policyInstance.getId() != Snapshot.MANUAL_POLICY_ID) {
                 scheduleNextSnapshotJob(policyInstance);
             }
@@ -381,13 +384,13 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
             // Else it becomes too confusing.
             _testClockTimer.schedule(_testTimerTask, 100 * 1000L, 60 * 1000L);
         } else {
-            TimerTask timerTask = new ManagedContextTimerTask() {
+            final TimerTask timerTask = new ManagedContextTimerTask() {
                 @Override
                 protected void runInContext() {
                     try {
-                        Date currentTimestamp = new Date();
+                        final Date currentTimestamp = new Date();
                         poll(currentTimestamp);
-                    } catch (Throwable t) {
+                    } catch (final Throwable t) {
                         s_logger.warn("Catch throwable in snapshot scheduler ", t);
                     }
                 }