| /** |
| * |
| * This software is licensed under the GNU General Public License v3 or later. |
| * |
| * It is free software: you can redistribute it and/or modify |
| * it under the terms of the GNU General Public License as published by |
| * the Free Software Foundation, either version 3 of the License, or any later version. |
| * This program is distributed in the hope that it will be useful, |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| * GNU General Public License for more details. |
| * |
| * You should have received a copy of the GNU General Public License |
| * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| * |
| */ |
| package com.cloud.vm; |
| |
| import java.util.HashMap; |
| import java.util.List; |
| |
| import com.cloud.agent.api.VmStatsEntry; |
| import com.cloud.server.Criteria; |
| import com.cloud.user.Account; |
| import com.cloud.uservm.UserVm; |
| |
| /** |
| * |
| * UserVmManager contains all of the code to work with user VMs. |
| * |
| */ |
| public interface UserVmManager extends VirtualMachineGuru<UserVmVO>{ |
| |
| static final int MAX_USER_DATA_LENGTH_BYTES = 2048; |
| /** |
| * @param hostId get all of the virtual machines that belong to one host. |
| * @return collection of VirtualMachine. |
| */ |
| List<? extends UserVm> getVirtualMachines(long hostId); |
| |
| /** |
| * @param vmId id of the virtual machine. |
| * @return VirtualMachine |
| */ |
| UserVmVO getVirtualMachine(long vmId); |
| |
| /** |
| * Attaches an ISO to the virtual CDROM device of the specified VM. Will eject any existing virtual CDROM if isoPath is null. |
| * @param vmId |
| * @param isoId |
| * @param attach whether to attach or detach the given iso |
| * @return |
| */ |
| boolean attachISOToVM(long vmId, long isoId, boolean attach); |
| |
| /** |
| * Stops the virtual machine |
| * @param userId the id of the user performing the action |
| * @param vmId |
| * @return true if stopped; false if problems. |
| */ |
| boolean stopVirtualMachine(long userId, long vmId); |
| |
| /** |
| * Obtains statistics for a list of host or VMs; CPU and network utilization |
| * @param host ID |
| * @param host name |
| * @param list of VM IDs or host id |
| * @return GetVmStatsAnswer |
| */ |
| HashMap<Long, VmStatsEntry> getVirtualMachineStatistics(long hostId, String hostName, List<Long> vmIds); |
| |
| boolean deleteVmGroup(long groupId); |
| |
| boolean addInstanceToGroup(long userVmId, String group); |
| |
| InstanceGroupVO getGroupForVm(long vmId); |
| |
| void removeInstanceFromInstanceGroup(long vmId); |
| |
| boolean expunge(UserVmVO vm, long callerUserId, Account caller); |
| |
| /** |
| * Obtains a list of virtual machines by the specified search criteria. |
| * Can search by: "userId", "name", "state", "dataCenterId", "podId", "hostId" |
| * @param c |
| * @return List of UserVMs. |
| */ |
| List<UserVmVO> searchForUserVMs(Criteria c); |
| |
| } |