http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/org/apache/cloudstack/api/admin/host/command/UpdateHostCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/admin/host/command/UpdateHostCmd.java b/api/src/org/apache/cloudstack/api/admin/host/command/UpdateHostCmd.java new file mode 100755 index 0000000..bbb3b6f --- /dev/null +++ b/api/src/org/apache/cloudstack/api/admin/host/command/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.admin.host.command; + +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/2a7fa674/api/src/org/apache/cloudstack/api/admin/host/command/UpdateHostPasswordCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/admin/host/command/UpdateHostPasswordCmd.java b/api/src/org/apache/cloudstack/api/admin/host/command/UpdateHostPasswordCmd.java new file mode 100644 index 0000000..2ace248 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/admin/host/command/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.admin.host.command; + +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/2a7fa674/api/test/src/com/cloud/api/commands/test/AddHostCmdTest.java ---------------------------------------------------------------------- diff --git a/api/test/src/com/cloud/api/commands/test/AddHostCmdTest.java b/api/test/src/com/cloud/api/commands/test/AddHostCmdTest.java index 4d8e5ea..75c40d2 100644 --- a/api/test/src/com/cloud/api/commands/test/AddHostCmdTest.java +++ b/api/test/src/com/cloud/api/commands/test/AddHostCmdTest.java @@ -19,6 +19,7 @@ package src.com.cloud.api.commands.test; import junit.framework.Assert; import junit.framework.TestCase; +import org.apache.cloudstack.api.admin.host.command.AddHostCmd; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -27,7 +28,6 @@ import org.mockito.Mockito; import org.apache.cloudstack.api.ResponseGenerator; import org.apache.cloudstack.api.ServerApiException; -import com.cloud.api.commands.AddHostCmd; import com.cloud.api.response.HostResponse; import com.cloud.api.response.ListResponse; import com.cloud.exception.DiscoveryException; http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/test/src/com/cloud/api/commands/test/AddSecondaryStorageCmdTest.java ---------------------------------------------------------------------- diff --git a/api/test/src/com/cloud/api/commands/test/AddSecondaryStorageCmdTest.java b/api/test/src/com/cloud/api/commands/test/AddSecondaryStorageCmdTest.java index 87e03fa..9b73b0c 100644 --- a/api/test/src/com/cloud/api/commands/test/AddSecondaryStorageCmdTest.java +++ b/api/test/src/com/cloud/api/commands/test/AddSecondaryStorageCmdTest.java @@ -19,6 +19,7 @@ package src.com.cloud.api.commands.test; import junit.framework.Assert; import junit.framework.TestCase; +import org.apache.cloudstack.api.admin.host.command.AddSecondaryStorageCmd; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -27,7 +28,6 @@ import org.mockito.Mockito; import org.apache.cloudstack.api.ResponseGenerator; import org.apache.cloudstack.api.ServerApiException; -import com.cloud.api.commands.AddSecondaryStorageCmd; import com.cloud.api.response.HostResponse; import com.cloud.host.Host; import com.cloud.resource.ResourceService; http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/client/tomcatconf/commands.properties.in ---------------------------------------------------------------------- diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index 441271b..a0ac700 100755 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -229,18 +229,18 @@ addSwift=com.cloud.api.commands.AddSwiftCmd;1 listSwifts=com.cloud.api.commands.ListSwiftsCmd;1 #### host commands -addHost=com.cloud.api.commands.AddHostCmd;3 +addHost=org.apache.cloudstack.api.admin.host.command.AddHostCmd;3 addCluster=com.cloud.api.commands.AddClusterCmd;1 deleteCluster=com.cloud.api.commands.DeleteClusterCmd;1 updateCluster=com.cloud.api.commands.UpdateClusterCmd;1 -reconnectHost=com.cloud.api.commands.ReconnectHostCmd;1 -updateHost=com.cloud.api.commands.UpdateHostCmd;1 -deleteHost=com.cloud.api.commands.DeleteHostCmd;3 -prepareHostForMaintenance=com.cloud.api.commands.PrepareForMaintenanceCmd;1 -cancelHostMaintenance=com.cloud.api.commands.CancelMaintenanceCmd;1 -listHosts=com.cloud.api.commands.ListHostsCmd;3 -addSecondaryStorage=com.cloud.api.commands.AddSecondaryStorageCmd;1 -updateHostPassword=com.cloud.api.commands.UpdateHostPasswordCmd;1 +reconnectHost=org.apache.cloudstack.api.admin.host.command.ReconnectHostCmd;1 +updateHost=org.apache.cloudstack.api.admin.host.command.UpdateHostCmd;1 +deleteHost=org.apache.cloudstack.api.admin.host.command.DeleteHostCmd;3 +prepareHostForMaintenance=org.apache.cloudstack.api.admin.host.command.PrepareForMaintenanceCmd;1 +cancelHostMaintenance=org.apache.cloudstack.api.admin.host.command.CancelMaintenanceCmd;1 +listHosts=org.apache.cloudstack.api.admin.host.command.ListHostsCmd;3 +addSecondaryStorage=org.apache.cloudstack.api.admin.host.command.AddSecondaryStorageCmd;1 +updateHostPassword=org.apache.cloudstack.api.admin.host.command.UpdateHostPasswordCmd;1 #### volume commands attachVolume=org.apache.cloudstack.api.user.volume.command.AttachVolumeCmd;15 http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/server/src/com/cloud/resource/ResourceManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java index f3afd90..da6539c 100755 --- a/server/src/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/com/cloud/resource/ResourceManagerImpl.java @@ -30,6 +30,7 @@ import java.util.Set; import javax.ejb.Local; import javax.naming.ConfigurationException; +import org.apache.cloudstack.api.admin.host.command.*; import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; @@ -49,16 +50,14 @@ import com.cloud.agent.transport.Request; import org.apache.cloudstack.api.ApiConstants; import com.cloud.api.ApiDBUtils; import com.cloud.api.commands.AddClusterCmd; -import com.cloud.api.commands.AddHostCmd; -import com.cloud.api.commands.AddSecondaryStorageCmd; +import org.apache.cloudstack.api.admin.host.command.AddHostCmd; +import org.apache.cloudstack.api.admin.host.command.AddSecondaryStorageCmd; import com.cloud.api.commands.AddSwiftCmd; -import com.cloud.api.commands.CancelMaintenanceCmd; +import org.apache.cloudstack.api.admin.host.command.CancelMaintenanceCmd; import com.cloud.api.commands.DeleteClusterCmd; import com.cloud.api.commands.ListSwiftsCmd; -import com.cloud.api.commands.PrepareForMaintenanceCmd; -import com.cloud.api.commands.ReconnectHostCmd; -import com.cloud.api.commands.UpdateHostCmd; -import com.cloud.api.commands.UpdateHostPasswordCmd; +import org.apache.cloudstack.api.admin.host.command.PrepareForMaintenanceCmd; +import org.apache.cloudstack.api.admin.host.command.UpdateHostCmd; import com.cloud.capacity.Capacity; import com.cloud.capacity.CapacityVO; import com.cloud.capacity.dao.CapacityDao; http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/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 cced763..d39dd23 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -80,7 +80,7 @@ import com.cloud.api.commands.ListCapacityCmd; import com.cloud.api.commands.ListCfgsByCmd; import com.cloud.api.commands.ListClustersCmd; import org.apache.cloudstack.api.user.event.command.ListEventsCmd; -import com.cloud.api.commands.ListHostsCmd; +import org.apache.cloudstack.api.admin.host.command.ListHostsCmd; import com.cloud.api.commands.ListPodsByCmd; import org.apache.cloudstack.api.user.address.command.ListPublicIpAddressesCmd; import org.apache.cloudstack.api.user.ssh.command.ListSSHKeyPairsCmd; @@ -91,7 +91,7 @@ import org.apache.cloudstack.api.user.datacenter.command.ListZonesByCmd; import com.cloud.api.commands.RebootSystemVmCmd; import com.cloud.api.commands.StopSystemVmCmd; import com.cloud.api.commands.UpdateDomainCmd; -import com.cloud.api.commands.UpdateHostPasswordCmd; +import org.apache.cloudstack.api.admin.host.command.UpdateHostPasswordCmd; import org.apache.cloudstack.api.user.iso.command.UpdateIsoCmd; import com.cloud.api.commands.UpdateTemplateOrIsoCmd; import org.apache.cloudstack.api.user.vmgroup.command.UpdateVMGroupCmd; @@ -99,7 +99,6 @@ import com.cloud.api.commands.UpgradeSystemVMCmd; import com.cloud.api.commands.UploadCustomCertificateCmd; import com.cloud.api.response.ExtractResponse; import com.cloud.api.view.vo.DomainRouterJoinVO; -import com.cloud.api.view.vo.UserVmJoinVO; import com.cloud.async.AsyncJob; import com.cloud.async.AsyncJobExecutor; import com.cloud.async.AsyncJobManager; @@ -171,7 +170,6 @@ import com.cloud.network.NetworkVO; import com.cloud.network.dao.IPAddressDao; import com.cloud.network.dao.LoadBalancerDao; import com.cloud.network.dao.NetworkDao; -import com.cloud.network.router.VirtualRouter; import com.cloud.org.Cluster; import com.cloud.org.Grouping.AllocationState; import com.cloud.projects.Project; @@ -250,7 +248,6 @@ import com.cloud.vm.ConsoleProxyVO; import com.cloud.vm.DomainRouterVO; import com.cloud.vm.InstanceGroup; import com.cloud.vm.InstanceGroupVO; -import com.cloud.vm.NicVO; import com.cloud.vm.SecondaryStorageVmVO; import com.cloud.vm.UserVmVO; import com.cloud.vm.VMInstanceVO;
