incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [35/57] api: move and group all under command, org.apache.cloudstack.command.*
Date Sat, 08 Dec 2012 03:29:52 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/host/CancelMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/CancelMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/CancelMaintenanceCmd.java
new file mode 100644
index 0000000..74b16d8
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/CancelMaintenanceCmd.java
@@ -0,0 +1,113 @@
+// 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.admin.host;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.HostResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.host.Host;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Cancels host maintenance.", responseObject=HostResponse.class)
+public class CancelMaintenanceCmd extends BaseAsyncCmd  {
+    public static final Logger s_logger = Logger.getLogger(CancelMaintenanceCmd.class.getName());
+
+    private static final String s_name = "cancelhostmaintenanceresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="host")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the host ID")
+    private Long id;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public static String getResultObjectName() {
+        return "host";
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Account account = UserContext.current().getCaller();
+        if (account != null) {
+            return account.getId();
+        }
+
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_MAINTENANCE_CANCEL;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return  "canceling maintenance for host: " + getId();
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.Host;
+    }
+
+    @Override
+    public Long getInstanceId() {
+        return getId();
+    }
+
+    @Override
+    public void execute(){
+        Host result = _resourceService.cancelMaintenance(this);
+        if (result != null) {
+            HostResponse response = _responseGenerator.createHostResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to cancel host maintenance");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/host/DeleteHostCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/DeleteHostCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/DeleteHostCmd.java
new file mode 100644
index 0000000..cff893d
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/DeleteHostCmd.java
@@ -0,0 +1,90 @@
+// 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.admin.host;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.SuccessResponse;
+import com.cloud.user.Account;
+
+@Implementation(description = "Deletes a host.", responseObject = SuccessResponse.class)
+public class DeleteHostCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(DeleteHostCmd.class.getName());
+
+    private static final String s_name = "deletehostresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="host")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the host ID")
+    private Long id;
+
+    @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, description = "Force delete the host. All HA enabled vms running on the host will be put to HA; HA disabled ones will be stopped")
+    private Boolean forced;
+
+    @Parameter(name = ApiConstants.FORCED_DESTROY_LOCAL_STORAGE, type = CommandType.BOOLEAN, description = "Force destroy local storage on this host. All VMs created on this local storage will be destroyed")
+    private Boolean forceDestroyLocalStorage;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public boolean isForced() {
+        return (forced != null) ? forced : false;
+    }
+
+    public boolean isForceDestoryLocalStorage() {
+        return (forceDestroyLocalStorage != null) ? forceDestroyLocalStorage : true;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute() {
+        boolean result = _resourceService.deleteHost(getId(), isForced(), isForceDestoryLocalStorage());
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete host");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java
new file mode 100755
index 0000000..e163ada
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java
@@ -0,0 +1,192 @@
+// 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.admin.host;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiConstants.HostDetails;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import com.cloud.api.response.HostResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.host.Host;
+import com.cloud.utils.Pair;
+
+@Implementation(description="Lists hosts.", responseObject=HostResponse.class)
+public class ListHostsCmd extends BaseListCmd {
+    public static final Logger s_logger = Logger.getLogger(ListHostsCmd.class.getName());
+
+    private static final String s_name = "listhostsresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="cluster")
+    @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.LONG, description="lists hosts existing in particular cluster")
+    private Long clusterId;
+
+    @IdentityMapper(entityTableName="host")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the id of the host")
+    private Long id;
+
+    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the host")
+    private String hostName;
+
+    @IdentityMapper(entityTableName="host_pod_ref")
+    @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="the Pod ID for the host")
+    private Long podId;
+
+    @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="the state of the host")
+    private String state;
+
+    @Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, description="the host type")
+    private String type;
+
+    @IdentityMapper(entityTableName="data_center")
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the Zone ID for the host")
+    private Long zoneId;
+
+    @IdentityMapper(entityTableName="vm_instance")
+    @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, required=false, description="lists hosts in the same cluster as this VM and flag hosts with enough CPU/RAm to host this VM")
+    private Long virtualMachineId;
+
+    @Parameter(name=ApiConstants.RESOURCE_STATE, type=CommandType.STRING, description="list hosts by resource state. Resource state represents current state determined by admin of host, valule can be one of [Enabled, Disabled, Unmanaged, PrepareForMaintenance, ErrorInMaintenance, Maintenance, Error]")
+    private String resourceState;
+
+    @Parameter(name=ApiConstants.DETAILS, type=CommandType.LIST, collectionType=CommandType.STRING, description="comma separated list of host details requested, value can be a list of [ min, all, capacity, events, stats]" )
+    private List<String> viewDetails;
+
+    @Parameter(name=ApiConstants.HA_HOST, type=CommandType.BOOLEAN, description="if true, list only hosts dedicated to HA")
+    private Boolean haHost;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getClusterId() {
+        return clusterId;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getHostName() {
+        return hostName;
+    }
+
+    public Long getPodId() {
+        return podId;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public Boolean getHaHost() {
+        return haHost;
+    }
+
+    public Long getZoneId() {
+        return zoneId;
+    }
+
+    public Long getVirtualMachineId() {
+        return virtualMachineId;
+    }
+
+    public EnumSet<HostDetails> getDetails() throws InvalidParameterValueException {
+        EnumSet<HostDetails> dv;
+        if (viewDetails==null || viewDetails.size() <=0){
+            dv = EnumSet.of(HostDetails.all);
+        }
+        else {
+            try {
+                ArrayList<HostDetails> dc = new ArrayList<HostDetails>();
+                for (String detail: viewDetails){
+                    dc.add(HostDetails.valueOf(detail));
+                }
+                dv = EnumSet.copyOf(dc);
+            }
+            catch (IllegalArgumentException e){
+                throw new InvalidParameterValueException("The details parameter contains a non permitted value. The allowed values are " + EnumSet.allOf(HostDetails.class));
+            }
+        }
+        return dv;
+    }
+
+    public String getResourceState() {
+        return resourceState;
+    }
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.Host;
+    }
+
+    @Override
+    public void execute(){
+        List<? extends Host> result = new ArrayList<Host>();
+        List<? extends Host> hostsWithCapacity = new ArrayList<Host>();
+
+        if(getVirtualMachineId() != null){
+            Pair<List<? extends Host>, List<? extends Host>> hostsForMigration = _mgr.listHostsForMigrationOfVM(getVirtualMachineId(), this.getStartIndex(), this.getPageSizeVal());
+            result = hostsForMigration.first();
+            hostsWithCapacity = hostsForMigration.second();
+        }else{
+            result = _mgr.searchForServers(this);
+        }
+
+        ListResponse<HostResponse> response = new ListResponse<HostResponse>();
+        List<HostResponse> hostResponses = new ArrayList<HostResponse>();
+        for (Host host : result) {
+            HostResponse hostResponse = _responseGenerator.createHostResponse(host, getDetails());
+            Boolean suitableForMigration = false;
+            if(hostsWithCapacity.contains(host)){
+                suitableForMigration = true;
+            }
+            hostResponse.setSuitableForMigration(suitableForMigration);
+            hostResponse.setObjectName("host");
+            hostResponses.add(hostResponse);
+        }
+
+        response.setResponses(hostResponses);
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/host/PrepareForMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/PrepareForMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/PrepareForMaintenanceCmd.java
new file mode 100644
index 0000000..cf4326a
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/PrepareForMaintenanceCmd.java
@@ -0,0 +1,111 @@
+// 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.admin.host;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.HostResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.host.Host;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Prepares a host for maintenance.", responseObject=HostResponse.class)
+public class PrepareForMaintenanceCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(PrepareForMaintenanceCmd.class.getName());
+
+    private static final String s_name = "preparehostformaintenanceresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="host")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the host ID")
+    private Long id;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public static String getResultObjectName() {
+        return "host";
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Account account = UserContext.current().getCaller();
+        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 String getEventType() {
+        return EventTypes.EVENT_MAINTENANCE_PREPARE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return  "preparing host: " + getId() + " for maintenance";
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.Host;
+    }
+
+    @Override
+    public Long getInstanceId() {
+        return getId();
+    }
+
+    @Override
+    public void execute(){
+        Host result = _resourceService.maintain(this);
+        if (result != null){
+            HostResponse response = _responseGenerator.createHostResponse(result);
+            response.setResponseName("host");
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to prepare host for maintenance");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/host/ReconnectHostCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/ReconnectHostCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/ReconnectHostCmd.java
new file mode 100755
index 0000000..d8f245c
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/ReconnectHostCmd.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 org.apache.cloudstack.api.command.admin.host;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.HostResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.host.Host;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Reconnects a host.", responseObject=HostResponse.class)
+public class ReconnectHostCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(ReconnectHostCmd.class.getName());
+
+    private static final String s_name = "reconnecthostresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="host")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the host ID")
+    private Long id;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public static String getResultObjectName() {
+        return "host";
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Account account = UserContext.current().getCaller();
+        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 String getEventType() {
+        return EventTypes.EVENT_HOST_RECONNECT;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return  "reconnecting host: " + getId();
+    }
+
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.Host;
+    }
+
+    public Long getInstanceId() {
+        return getId();
+    }
+
+    @Override
+    public void execute(){
+        try {
+            Host result = _resourceService.reconnectHost(this);
+            if (result != null){
+                HostResponse response = _responseGenerator.createHostResponse(result);
+                response.setResponseName(getCommandName());
+                this.setResponseObject(response);
+            } else {
+                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reconnect host");
+            }
+        } catch (Exception ex) {
+            s_logger.warn("Exception: ", ex);
+            throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostCmd.java
new file mode 100755
index 0000000..07af547
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostCmd.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 org.apache.cloudstack.api.command.admin.host;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.HostResponse;
+import com.cloud.host.Host;
+import com.cloud.user.Account;
+
+@Implementation(description="Updates a host.", responseObject=HostResponse.class)
+public class UpdateHostCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(UpdateHostCmd.class.getName());
+    private static final String s_name = "updatehostresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="host")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the host to update")
+    private Long id;
+
+    @IdentityMapper(entityTableName="guest_os_category")
+    @Parameter(name=ApiConstants.OS_CATEGORY_ID, type=CommandType.LONG, description="the id of Os category to update the host with")
+    private Long osCategoryId;
+
+    @Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="Change resource state of host, valid values are [Enable, Disable]. Operation may failed if host in states not allowing Enable/Disable")
+    private String allocationState;
+
+    @Parameter(name=ApiConstants.HOST_TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="list of tags to be added to the host")
+    private List<String> hostTags;
+
+    @Parameter(name=ApiConstants.URL, type=CommandType.STRING, description="the new uri for the secondary storage: nfs://host/path")
+    private String url;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public Long getOsCategoryId() {
+        return osCategoryId;
+    }
+
+    public String getAllocationState() {
+        return allocationState;
+    }
+
+    public List<String> getHostTags() {
+        return hostTags;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public static String getResultObjectName() {
+        return "updatehost";
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        Host result;
+        try {
+            result = _resourceService.updateHost(this);
+            HostResponse hostResponse = _responseGenerator.createHostResponse(result);
+            hostResponse.setResponseName(getCommandName());
+            this.setResponseObject(hostResponse);
+        } catch (Exception e) {
+            s_logger.debug("Failed to update host:" + getId(), e);
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update host:" + getId() + "," + e.getMessage());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostPasswordCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostPasswordCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostPasswordCmd.java
new file mode 100644
index 0000000..96cdaae
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostPasswordCmd.java
@@ -0,0 +1,95 @@
+// 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.admin.host;
+
+import org.apache.log4j.Logger;
+
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import com.cloud.api.response.SuccessResponse;
+import com.cloud.user.Account;
+
+@Implementation(description = "Update password of a host/pool on management server.", responseObject = SuccessResponse.class)
+public class UpdateHostPasswordCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(UpdateHostPasswordCmd.class.getName());
+
+    private static final String s_name = "updatehostpasswordresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    // TO DO - this is of no use currently. Probably need to remove it.
+    @IdentityMapper(entityTableName="host")
+    @Parameter(name=ApiConstants.HOST_ID, type=CommandType.LONG, description="the host ID")
+    private Long hostId;
+
+    @IdentityMapper(entityTableName="cluster")
+    @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.LONG, description="the cluster ID")
+    private Long clusterId;
+
+    @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="the username for the host/cluster")
+    private String username;
+
+    @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="the new password for the host/cluster")
+    private String password;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getHostId() {
+        return hostId;
+    }
+
+    public Long getClusterId() {
+        return clusterId;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute() {
+        _mgr.updateHostPassword(this);
+        _resourceService.updateHostPassword(this);
+        this.setResponseObject(new SuccessResponse(getCommandName()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/ldap/LDAPConfigCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/ldap/LDAPConfigCmd.java b/api/src/org/apache/cloudstack/api/command/admin/ldap/LDAPConfigCmd.java
new file mode 100644
index 0000000..a84c2c4
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/ldap/LDAPConfigCmd.java
@@ -0,0 +1,149 @@
+// 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.admin.ldap;
+
+
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.LDAPConfigResponse;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+
+@Implementation(description="Configure the LDAP context for this site.", responseObject=LDAPConfigResponse.class, since="3.0.0")
+public class LDAPConfigCmd extends BaseCmd  {
+    public static final Logger s_logger = Logger.getLogger(LDAPConfigCmd.class.getName());
+
+    private static final String s_name = "ldapconfigresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.HOST_NAME, type=CommandType.STRING, required=true, description="Hostname or ip address of the ldap server eg: my.ldap.com")
+    private String hostname;
+
+    @Parameter(name=ApiConstants.PORT, type=CommandType.INTEGER, description="Specify the LDAP port if required, default is 389.")
+    private Integer port=0;
+
+    @Parameter(name=ApiConstants.USE_SSL, type=CommandType.BOOLEAN, description="Check Use SSL if the external LDAP server is configured for LDAP over SSL.")
+    private Boolean useSSL;
+
+    @Parameter(name=ApiConstants.SEARCH_BASE, type=CommandType.STRING, required=true, description="The search base defines the starting point for the search in the directory tree Example:  dc=cloud,dc=com.")
+    private String searchBase;
+
+    @Parameter(name=ApiConstants.QUERY_FILTER, type=CommandType.STRING, required=true, description="You specify a query filter here, which narrows down the users, who can be part of this domain.")
+    private String queryFilter;
+
+    @Parameter(name=ApiConstants.BIND_DN, type=CommandType.STRING, description="Specify the distinguished name of a user with the search permission on the directory.")
+    private String bindDN;
+
+    @Parameter(name=ApiConstants.BIND_PASSWORD, type=CommandType.STRING, description="Enter the password.")
+    private String bindPassword;
+
+    @Parameter(name=ApiConstants.TRUST_STORE, type=CommandType.STRING, description="Enter the path to trust certificates store.")
+    private String trustStore;
+
+    @Parameter(name=ApiConstants.TRUST_STORE_PASSWORD, type=CommandType.STRING, description="Enter the password for trust store.")
+    private String trustStorePassword;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public String getBindPassword() {
+        return bindPassword;
+    }
+
+    public String getBindDN() {
+        return bindDN;
+    }
+
+    public String getQueryFilter() {
+        return queryFilter;
+    }
+
+    public String getSearchBase() {
+        return searchBase;
+    }
+
+    public Boolean getUseSSL() {
+        return useSSL == null ? Boolean.FALSE : Boolean.TRUE;
+    }
+
+    public String getHostname() {
+        return hostname;
+    }
+
+    public Integer getPort() {
+        return port <= 0 ? 389 : port;
+    }
+
+    public String getTrustStore() {
+        return trustStore;
+    }
+
+
+    public String getTrustStorePassword() {
+        return trustStorePassword;
+    }
+
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+
+    @Override
+    public void execute() throws ResourceUnavailableException,
+            InsufficientCapacityException, ServerApiException,
+            ConcurrentOperationException, ResourceAllocationException {
+          try {
+              boolean result = _configService.updateLDAP(this);
+              if (result){
+                  LDAPConfigResponse lr = _responseGenerator.createLDAPConfigResponse(getHostname(), getPort(), getUseSSL(), getQueryFilter(), getSearchBase(), getBindDN());
+                  lr.setResponseName(getCommandName());
+                  this.setResponseObject(lr);
+              }
+          }
+          catch (NamingException ne){
+              ne.printStackTrace();
+          }
+
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/ldap/LDAPRemoveCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/ldap/LDAPRemoveCmd.java b/api/src/org/apache/cloudstack/api/command/admin/ldap/LDAPRemoveCmd.java
new file mode 100644
index 0000000..e4f713f
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/ldap/LDAPRemoveCmd.java
@@ -0,0 +1,71 @@
+// 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.admin.ldap;
+
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Implementation;
+import com.cloud.api.response.LDAPConfigResponse;
+import com.cloud.api.response.LDAPRemoveResponse;
+import com.cloud.user.Account;
+
+@Implementation(description="Remove the LDAP context for this site.", responseObject=LDAPConfigResponse.class, since="3.0.1")
+public class LDAPRemoveCmd extends BaseCmd  {
+    public static final Logger s_logger = Logger.getLogger(LDAPRemoveCmd.class.getName());
+
+    private static final String s_name = "ldapremoveresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+
+    @Override
+    public void execute(){
+          boolean result = _configService.removeLDAP(this);
+          if (result){
+              LDAPRemoveResponse lr = new LDAPRemoveResponse();
+              lr.setObjectName("ldapremove");
+              lr.setResponseName(getCommandName());
+              this.setResponseObject(lr);
+          }
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkDeviceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkDeviceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkDeviceCmd.java
new file mode 100644
index 0000000..5c0f2ff
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkDeviceCmd.java
@@ -0,0 +1,95 @@
+// 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.admin.network;
+
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Implementation;
+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.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.host.Host;
+import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
+import com.cloud.server.ManagementService;
+import org.apache.cloudstack.api.response.NetworkDeviceResponse;
+import com.cloud.utils.component.ComponentLocator;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Implementation(description="Adds a network device of one of the following types: ExternalDhcp, ExternalFirewall, ExternalLoadBalancer, PxeServer", responseObject = NetworkDeviceResponse.class)
+public class AddNetworkDeviceCmd extends BaseCmd {
+	public static final Logger s_logger = Logger.getLogger(AddNetworkDeviceCmd.class);
+	private static final String s_name = "addnetworkdeviceresponse";
+	
+	// ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+	
+	@Parameter(name = ApiConstants.NETWORK_DEVICE_TYPE, type = CommandType.STRING, description = "Network device type, now supports ExternalDhcp, PxeServer, NetscalerMPXLoadBalancer, NetscalerVPXLoadBalancer, NetscalerSDXLoadBalancer, F5BigIpLoadBalancer, JuniperSRXFirewall")
+    private String type;
+	
+	@Parameter(name = ApiConstants.NETWORK_DEVICE_PARAMETER_LIST, type = CommandType.MAP, description = "parameters for network device")
+    private Map paramList;
+	
+	
+	public String getDeviceType() {
+		return type;
+	}
+	
+	public Map getParamList() {
+		return paramList;
+	}
+	
+	@Override
+	public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+			ResourceAllocationException {
+		try {
+			ExternalNetworkDeviceManager nwDeviceMgr;
+			ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
+			nwDeviceMgr = locator.getManager(ExternalNetworkDeviceManager.class);
+			Host device = nwDeviceMgr.addNetworkDevice(this);
+			NetworkDeviceResponse response = nwDeviceMgr.getApiResponse(device);
+			response.setObjectName("networkdevice");
+			response.setResponseName(getCommandName());
+			this.setResponseObject(response);
+		} catch (InvalidParameterValueException ipve) {
+			throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
+		} catch (CloudRuntimeException cre) {
+			throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
+		}
+
+	}
+
+	@Override
+	public String getCommandName() {
+		return s_name;
+	}
+
+	@Override
+	public long getEntityOwnerId() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkServiceProviderCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkServiceProviderCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkServiceProviderCmd.java
new file mode 100644
index 0000000..f24e0d7
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/AddNetworkServiceProviderCmd.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.api.command.admin.network;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.ProviderResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.network.PhysicalNetworkServiceProvider;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Adds a network serviceProvider to a physical network", responseObject=ProviderResponse.class, since="3.0.0")
+public class AddNetworkServiceProviderCmd extends BaseAsyncCreateCmd {
+    public static final Logger s_logger = Logger.getLogger(AddNetworkServiceProviderCmd.class.getName());
+
+    private static final String s_name = "addnetworkserviceproviderresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="physical_network")
+    @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, required=true, description="the Physical Network ID to add the provider to")
+    private Long physicalNetworkId;
+
+    @IdentityMapper(entityTableName="physical_network")
+    @Parameter(name=ApiConstants.DEST_PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="the destination Physical Network ID to bridge to")
+    private Long destinationPhysicalNetworkId;
+
+    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name for the physical network service provider")
+    private String name;
+
+    @Parameter(name=ApiConstants.SERVICE_LIST, type=CommandType.LIST, collectionType = CommandType.STRING, description="the list of services to be enabled for this physical network service provider")
+    private List<String> enabledServices;
+
+    @Override
+    public String getEntityTable() {
+        return "physical_network_service_providers";
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getPhysicalNetworkId() {
+        return physicalNetworkId;
+    }
+
+    public String getProviderName() {
+        return name;
+    }
+
+    public Long getDestinationPhysicalNetworkId() {
+        return destinationPhysicalNetworkId;
+    }
+
+    public List<String> getEnabledServices() {
+        return enabledServices;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        UserContext.current().setEventDetails("Network ServiceProvider Id: "+getEntityId());
+        PhysicalNetworkServiceProvider result = _networkService.getCreatedPhysicalNetworkServiceProvider(getEntityId());
+        if (result != null) {
+            ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        }else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider to physical network");
+        }
+    }
+
+    @Override
+    public void create() throws ResourceAllocationException {
+        PhysicalNetworkServiceProvider result = _networkService.addProviderToPhysicalNetwork(getPhysicalNetworkId(), getProviderName(), getDestinationPhysicalNetworkId(), getEnabledServices());
+        if (result != null) {
+            setEntityId(result.getId());
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider entity to physical network");
+        }
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_SERVICE_PROVIDER_CREATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return  "Adding physical network ServiceProvider: " + getEntityId();
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.PhysicalNetworkServiceProvider;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java
new file mode 100644
index 0000000..c7c4e53
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java
@@ -0,0 +1,234 @@
+// 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.admin.network;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.NetworkOfferingResponse;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.network.Network.Capability;
+import com.cloud.network.Network.Service;
+import com.cloud.offering.NetworkOffering;
+import com.cloud.offering.NetworkOffering.Availability;
+import com.cloud.user.Account;
+
+@Implementation(description="Creates a network offering.", responseObject=NetworkOfferingResponse.class, since="3.0.0")
+public class CreateNetworkOfferingCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(CreateNetworkOfferingCmd.class.getName());
+    private static final String _name = "createnetworkofferingresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the network offering")
+    private String networkOfferingName;
+
+    @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the network offering")
+    private String displayText;
+
+    @Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, required=true, description="the traffic type for the network offering. Supported type in current release is GUEST only")
+    private String traffictype;
+
+    @Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="the tags for the network offering.", length=4096)
+    private String tags;
+
+    @Parameter(name=ApiConstants.SPECIFY_VLAN, type=CommandType.BOOLEAN, description="true if network offering supports vlans")
+    private Boolean specifyVlan;
+
+    @Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering. Default value is Optional")
+    private String availability;
+
+    @Parameter(name=ApiConstants.NETWORKRATE, type=CommandType.INTEGER, description="data transfer rate in megabits per second allowed")
+    private Integer networkRate;
+
+    @Parameter(name=ApiConstants.CONSERVE_MODE, type=CommandType.BOOLEAN, description="true if the network offering is IP conserve mode enabled")
+    private Boolean conserveMode;
+
+    @IdentityMapper(entityTableName="disk_offering")
+    @Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.LONG, description="the service offering ID used by virtual router provider")
+    private Long serviceOfferingId;
+
+    @Parameter(name=ApiConstants.GUEST_IP_TYPE, type=CommandType.STRING, required=true, description="guest type of the network offering: Shared or Isolated")
+    private String guestIptype;
+
+    @Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, required=true, collectionType=CommandType.STRING, description="services supported by the network offering")
+    private List<String> supportedServices;
+
+    @Parameter(name = ApiConstants.SERVICE_PROVIDER_LIST, type = CommandType.MAP, description = "provider to service mapping. If not specified, the provider for the service will be mapped to the default provider on the physical network")
+    private Map serviceProviderList;
+
+    @Parameter(name = ApiConstants.SERVICE_CAPABILITY_LIST, type = CommandType.MAP, description = "desired service capabilities as part of network offering")
+    private Map serviceCapabilitystList;
+
+    @Parameter(name=ApiConstants.SPECIFY_IP_RANGES, type=CommandType.BOOLEAN, description="true if network offering supports specifying ip ranges; defaulted to false if not specified")
+    private Boolean specifyIpRanges;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public String getNetworkOfferingName() {
+        return networkOfferingName;
+    }
+
+    public String getDisplayText() {
+        return displayText;
+    }
+
+    public String getTags() {
+        return tags;
+    }
+
+    public String getTraffictype() {
+        return traffictype;
+    }
+
+    public Boolean getSpecifyVlan() {
+        return specifyVlan == null ? false : specifyVlan;
+    }
+
+    public String getAvailability() {
+        return availability == null ? Availability.Optional.toString() : availability;
+    }
+
+    public Integer getNetworkRate() {
+        return networkRate;
+    }
+
+    public static String getName() {
+        return _name;
+    }
+
+    public Long getServiceOfferingId() {
+        return serviceOfferingId;
+    }
+
+    public List<String> getSupportedServices() {
+        return supportedServices;
+    }
+
+    public String getGuestIpType() {
+        return guestIptype;
+    }
+
+    public Boolean getSpecifyIpRanges() {
+        return specifyIpRanges == null ? false : specifyIpRanges;
+    }
+
+    public Boolean getConserveMode() {
+        if (conserveMode == null) {
+            return true;
+        }
+        return conserveMode;
+    }
+
+    public Map<String, List<String>> getServiceProviders() {
+        Map<String, List<String>> serviceProviderMap = null;
+        if (serviceProviderList != null && !serviceProviderList.isEmpty()) {
+            serviceProviderMap = new HashMap<String, List<String>>();
+            Collection servicesCollection = serviceProviderList.values();
+            Iterator iter = servicesCollection.iterator();
+            while (iter.hasNext()) {
+                HashMap<String, String> services = (HashMap<String, String>) iter.next();
+                String service = services.get("service");
+                String provider = services.get("provider");
+                List<String> providerList = null;
+                if (serviceProviderMap.containsKey(service)) {
+                    providerList = serviceProviderMap.get(service);
+                } else {
+                    providerList = new ArrayList<String>();
+                }
+                providerList.add(provider);
+                serviceProviderMap.put(service, providerList);
+            }
+        }
+
+        return serviceProviderMap;
+    }
+
+    public Map<Capability, String> getServiceCapabilities(Service service) {
+        Map<Capability, String> capabilityMap = null;
+
+        if (serviceCapabilitystList != null && !serviceCapabilitystList.isEmpty()) {
+            capabilityMap = new HashMap <Capability, String>();
+            Collection serviceCapabilityCollection = serviceCapabilitystList.values();
+            Iterator iter = serviceCapabilityCollection.iterator();
+            while (iter.hasNext()) {
+                HashMap<String, String> svcCapabilityMap = (HashMap<String, String>) iter.next();
+                Capability capability = null;
+                String svc = (String) svcCapabilityMap.get("service");
+                String capabilityName = (String) svcCapabilityMap.get("capabilitytype");
+                String capabilityValue = (String) svcCapabilityMap.get("capabilityvalue");
+
+                if (capabilityName != null) {
+                    capability = Capability.getCapability(capabilityName);
+                }
+
+                if ((capability == null) || (capabilityName == null) || (capabilityValue == null) ) {
+                    throw new InvalidParameterValueException("Invalid capability:" + capabilityName + " capability value:" + capabilityValue);
+                }
+
+                if (svc.equalsIgnoreCase(service.getName())) {
+                    capabilityMap.put(capability, capabilityValue);
+                } else {
+                    //throw new InvalidParameterValueException("Service is not equal ")
+                }
+            }
+        }
+
+        return capabilityMap;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+    @Override
+    public String getCommandName() {
+        return _name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        NetworkOffering result = _configService.createNetworkOffering(this);
+        if (result != null) {
+            NetworkOfferingResponse response = _responseGenerator.createNetworkOfferingResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create network offering");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/network/CreatePhysicalNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/CreatePhysicalNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/CreatePhysicalNetworkCmd.java
new file mode 100644
index 0000000..601d097
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/CreatePhysicalNetworkCmd.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.admin.network;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.PhysicalNetworkResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Creates a physical network", responseObject=PhysicalNetworkResponse.class, since="3.0.0")
+public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
+    public static final Logger s_logger = Logger.getLogger(CreatePhysicalNetworkCmd.class.getName());
+
+    private static final String s_name = "createphysicalnetworkresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="data_center")
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the Zone ID for the physical network")
+    private Long zoneId;
+
+    @Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the VLAN for the physical network")
+    private String vlan;
+
+    @Parameter(name=ApiConstants.NETWORK_SPEED, type=CommandType.STRING, description="the speed for the physical network[1G/10G]")
+    private String speed;
+
+    @IdentityMapper(entityTableName="domain")
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a physical network")
+    private Long domainId;
+
+    @Parameter(name=ApiConstants.BROADCAST_DOMAIN_RANGE, type=CommandType.STRING, description="the broadcast domain range for the physical network[Pod or Zone]. In Acton release it can be Zone only in Advance zone, and Pod in Basic")
+    private String broadcastDomainRange;
+
+    @Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="Tag the physical network")
+    private List<String> tags;
+
+    @Parameter(name=ApiConstants.ISOLATION_METHODS, type=CommandType.LIST, collectionType=CommandType.STRING, description="the isolation method for the physical network[VLAN/L3/GRE]")
+    private List<String> isolationMethods;
+
+    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the physical network")
+    private String networkName;
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public List<String> getTags() {
+        return tags;
+    }
+
+    @Override
+    public String getEntityTable() {
+        return "physical_network";
+    }
+
+    public Long getZoneId() {
+        return zoneId;
+    }
+
+    public String getVlan() {
+        return vlan;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public String getBroadcastDomainRange() {
+        return broadcastDomainRange;
+    }
+
+    public List<String> getIsolationMethods() {
+        return isolationMethods;
+    }
+
+    public String getNetworkSpeed() {
+        return speed;
+    }
+
+    public String getNetworkName() {
+        return networkName;
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_PHYSICAL_NETWORK_CREATE;
+    }
+
+    @Override
+    public String getCreateEventType() {
+        return EventTypes.EVENT_PHYSICAL_NETWORK_CREATE;
+    }
+
+    @Override
+    public String getCreateEventDescription() {
+        return "creating Physical Network";
+    }
+
+    @Override
+    public String getEventDescription() {
+        return  "creating Physical Network. Id: "+getEntityId();
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public void execute(){
+        UserContext.current().setEventDetails("Physical Network Id: "+getEntityId());
+        PhysicalNetwork result = _networkService.getCreatedPhysicalNetwork(getEntityId());
+        if (result != null) {
+            PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        }else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create physical network");
+        }
+    }
+
+    @Override
+    public void create() throws ResourceAllocationException {
+        PhysicalNetwork result = _networkService.createPhysicalNetwork(getZoneId(),getVlan(),getNetworkSpeed(), getIsolationMethods(),getBroadcastDomainRange(),getDomainId(), getTags(), getNetworkName());
+        if (result != null) {
+            setEntityId(result.getId());
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create physical network entity");
+        }
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.PhysicalNetwork;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/network/CreateStorageNetworkIpRangeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/CreateStorageNetworkIpRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/CreateStorageNetworkIpRangeCmd.java
new file mode 100755
index 0000000..05f68d9
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/CreateStorageNetworkIpRangeCmd.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.admin.network;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.StorageNetworkIpRangeResponse;
+import com.cloud.dc.StorageNetworkIpRange;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+
+@Implementation(description="Creates a Storage network IP range.", responseObject=StorageNetworkIpRangeResponse.class, since="3.0.0")
+public class CreateStorageNetworkIpRangeCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(CreateStorageNetworkIpRangeCmd.class);
+
+    private static final String s_name = "createstoragenetworkiprangeresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+    @IdentityMapper(entityTableName="host_pod_ref")
+    @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, required=true, description="UUID of pod where the ip range belongs to")
+    private Long podId;
+
+    @Parameter(name=ApiConstants.START_IP, type=CommandType.STRING, required=true, description="the beginning IP address")
+    private String startIp;
+
+    @Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address")
+    private String endIp;
+
+    @Parameter(name = ApiConstants.VLAN, type = CommandType.INTEGER, description = "Optional. The vlan the ip range sits on, default to Null when it is not specificed which means you network is not on any Vlan. This is mainly for Vmware as other hypervisors can directly reterive bridge from pyhsical network traffic type table")
+    private Integer vlan;
+
+    @Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, required=true, description="the netmask for storage network")
+    private String netmask;
+
+    @Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, required=true, description="the gateway for storage network")
+    private String gateway;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public String getEndIp() {
+        return endIp;
+    }
+
+    public Long getPodId() {
+        return podId;
+    }
+
+    public String getStartIp() {
+        return startIp;
+    }
+
+    public Integer getVlan() {
+        return vlan;
+    }
+
+    public String getNetmask() {
+        return netmask;
+    }
+
+    public String getGateWay() {
+        return gateway;
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_STORAGE_IP_RANGE_CREATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Creating storage ip range from " + getStartIp() + " to " + getEndIp() + " with vlan " + getVlan();
+    }
+
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+            ResourceAllocationException {
+        try {
+            StorageNetworkIpRange result = _storageNetworkService.createIpRange(this);
+            StorageNetworkIpRangeResponse response = _responseGenerator.createStorageNetworkIpRangeResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } catch (Exception e) {
+            s_logger.warn("Create storage network IP range failed", e);
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
+        }
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/network/DeleteNetworkDeviceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/DeleteNetworkDeviceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/DeleteNetworkDeviceCmd.java
new file mode 100644
index 0000000..0afe402
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/DeleteNetworkDeviceCmd.java
@@ -0,0 +1,90 @@
+// 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.admin.network;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
+import com.cloud.api.response.SuccessResponse;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.server.ManagementService;
+import com.cloud.utils.component.ComponentLocator;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Implementation(description="Deletes network device.", responseObject=SuccessResponse.class)
+public class DeleteNetworkDeviceCmd extends BaseCmd {
+	public static final Logger s_logger = Logger.getLogger(DeleteNetworkDeviceCmd.class);
+	private static final String s_name = "deletenetworkdeviceresponse";
+	
+	/////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="host")
+	@Parameter(name = ApiConstants.ID, type = CommandType.LONG, required=true, description = "Id of network device to delete")
+    private Long id;
+    
+	
+	public Long getId() {
+		return id;
+	}
+	
+	@Override
+	public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+			ResourceAllocationException {
+		try {
+			ExternalNetworkDeviceManager nwDeviceMgr;
+			ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
+			nwDeviceMgr = locator.getManager(ExternalNetworkDeviceManager.class);
+			boolean result = nwDeviceMgr.deleteNetworkDevice(this);
+			if (result) {
+				SuccessResponse response = new SuccessResponse(getCommandName());
+				response.setResponseName(getCommandName());
+				this.setResponseObject(response);
+			} else {
+				throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network device:" + getId());
+			}
+		} catch (InvalidParameterValueException ipve) {
+			throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
+		} catch (CloudRuntimeException cre) {
+			throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
+		}
+
+	}
+
+	@Override
+	public String getCommandName() {
+		return s_name;
+	}
+
+	@Override
+	public long getEntityOwnerId() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/network/DeleteNetworkOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/DeleteNetworkOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/DeleteNetworkOfferingCmd.java
new file mode 100644
index 0000000..cf76044
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/DeleteNetworkOfferingCmd.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.api.command.admin.network;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.SuccessResponse;
+import com.cloud.user.Account;
+
+@Implementation(description="Deletes a network offering.", responseObject=SuccessResponse.class, since="3.0.0")
+public class DeleteNetworkOfferingCmd extends BaseCmd{
+    public static final Logger s_logger = Logger.getLogger(DeleteNetworkOfferingCmd.class.getName());
+    private static final String s_name = "deletenetworkofferingresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="network_offerings")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the network offering")
+    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 = _configService.deleteNetworkOffering(this);
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete service offering");
+        }
+    }
+}


Mime
View raw message