Package com.abiquo.server.core.infrastructure

Source Code of com.abiquo.server.core.infrastructure.MachineDto

/**
* Licensed to Abiquo Holdings S.L. (Abiquo) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.abiquo.server.core.infrastructure;

import java.io.Serializable;

import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.abiquo.model.doc.Desc;
import com.abiquo.model.doc.Output;
import com.abiquo.model.enumerator.HypervisorType;
import com.abiquo.model.enumerator.MachineState;
import com.abiquo.model.transport.SingleResourceTransportDto;
import com.abiquo.server.core.infrastructure.network.NetworkInterfacesDto;

@XmlRootElement(name = "machine")
public class MachineDto extends SingleResourceTransportDto implements Serializable
{
    public static final String BASE_MEDIA_TYPE = "application/vnd.abiquo.machine+xml";

    public static final String MEDIA_TYPE = BASE_MEDIA_TYPE + "; version=" + API_VERSION;

    private static final long serialVersionUID = -4971248626582072165L;

    private Integer id;

    private String name, description;

    private Integer virtualRamInMb, virtualRamUsedInMb;

    private Integer virtualCpuCores, virtualCpusUsed;

    private MachineState state;

    private String virtualSwitch;

    private Integer port;

    private String ip;

    private String ipService;

    private HypervisorType type;

    private String user;

    private String password;

    private DatastoresDto datastores;

    private NetworkInterfacesDto networkInterfaces;

    private String ipmiIP;

    private Integer ipmiPort;

    private String ipmiUser;

    private String ipmiPassword;

    private String initiatorIQN;

    /**
     * @return the port
     */
    @Desc("Connection port of the machine")
    @NotNull
    public Integer getPort()
    {
        return port;
    }

    /**
     * @param port the port to set
     */
    public void setPort(final Integer port)
    {
        this.port = port;
    }

    /**
     * @return the ip
     */
    @Desc("IP of the machine")
    @NotNull
    public String getIp()
    {
        return ip;
    }

    /**
     * @param ip the ip to set
     */
    public void setIp(final String ip)
    {
        this.ip = ip;
    }

    /**
     * @return the ipService
     */
    @Desc("IP of the hypervisor service of machine")
    @NotNull
    public String getIpService()
    {
        return ipService;
    }

    /**
     * @param ipService the ipService to set
     */
    public void setIpService(final String ipService)
    {
        this.ipService = ipService;
    }

    /**
     * @return the type
     */
    @Desc("Value of the hypervisor type supported by abiquo")
    @NotNull
    public HypervisorType getType()
    {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(final HypervisorType type)
    {
        this.type = type;
    }

    /**
     * @return the user
     */
    @Desc("Name of the user for loggon into the hypervisor service")
    @NotNull
    public String getUser()
    {
        return user;
    }

    /**
     * @param user the user to set
     */
    public void setUser(final String user)
    {
        this.user = user;
    }

    /**
     * @return the password
     */
    @Desc("Password of the user for loggon into the hypervisor service")
    @NotNull
    public String getPassword()
    {
        return password;
    }

    /**
     * @param password the password to set
     */
    public void setPassword(final String password)
    {
        this.password = password;
    }

    @Desc("Identifier of the machine")
    @Output
    public Integer getId()
    {
        return id;
    }

    public void setId(final Integer id)
    {
        this.id = id;
    }

    @Desc("State of the machine, can be one of the following {STOPPED, PROVISIONED, NOT_MANAGED, MANAGED, HALTED, UNLICENSED, HA_IN_PROGRESS, DISABLED_FOR_HA, HALTED_FOR_SAVE}")
    @Output
    public MachineState getState()
    {
        return state;
    }

    public void setState(final MachineState state)
    {
        this.state = state;
    }

    @Desc("Name of the machine")
    @NotNull
    public String getName()
    {
        return name;
    }

    public void setName(final String name)
    {
        this.name = name;
    }

    @Desc("Description of the machine")
    public String getDescription()
    {
        return description;
    }

    public void setDescription(final String description)
    {
        this.description = description;
    }

    @XmlElement(name = "ram")
    @Desc("RAM in MB of the machine")
    @NotNull
    public Integer getVirtualRamInMb()
    {
        return getDefaultMb(virtualRamInMb).intValue();
    }

    public void setVirtualRamInMb(final Integer virtualRamInMb)
    {
        this.virtualRamInMb = virtualRamInMb;
    }

    @XmlElement(name = "ramUsed")
    @Desc("Used RAM in MB of the machine")
    @NotNull
    public Integer getVirtualRamUsedInMb()
    {
        return getDefaultMb(virtualRamUsedInMb).intValue();
    }

    public void setVirtualRamUsedInMb(final Integer virtualRamUsedInMb)
    {
        this.virtualRamUsedInMb = virtualRamUsedInMb;
    }

    @XmlElement(name = "cpu")
    @Desc("Numbre of cpus of the machine")
    @NotNull
    public Integer getVirtualCpuCores()
    {
        return (Integer) getDefaultMb(virtualCpuCores);
    }

    public void setVirtualCpuCores(final Integer virtualCpuCores)
    {
        this.virtualCpuCores = virtualCpuCores;
    }

    @XmlElement(name = "cpuUsed")
    @Desc("Numbre of used cpus of the machine")
    @NotNull
    public Integer getVirtualCpusUsed()
    {
        return (Integer) getDefaultMb(virtualCpusUsed);
    }

    public void setVirtualCpusUsed(final Integer virtualCpusUsed)
    {
        this.virtualCpusUsed = virtualCpusUsed;
    }

    private Number getDefaultMb(final Number mb)
    {
        return mb == null ? 1 : mb;
    }

    /**
     * @param datastores the datastores to set
     */
    public void setDatastores(final DatastoresDto datastores)
    {
        this.datastores = datastores;
    }

    /**
     * @return the datastores
     */
    @Desc("List of datastore of the machine")
    @NotNull
    public DatastoresDto getDatastores()
    {
        if (datastores == null)
        {
            datastores = new DatastoresDto();
        }
        return datastores;
    }

    @Desc("IP of the impi service of the machine")
    public String getIpmiIP()
    {
        return ipmiIP;
    }

    public void setIpmiIP(final String ipmiIP)
    {
        this.ipmiIP = ipmiIP;
    }

    @Desc("Connection port of the impi service of the machine")
    public Integer getIpmiPort()
    {
        return ipmiPort;
    }

    public void setIpmiPort(final Integer ipmiPort)
    {
        this.ipmiPort = ipmiPort;
    }

    @Desc("Name of the user for loggon into the impi service of the machine")
    public String getIpmiUser()
    {
        return ipmiUser;
    }

    public void setIpmiUser(final String ipmiUser)
    {
        this.ipmiUser = ipmiUser;
    }

    @Desc("Password of the user for loggon into the impi service of the machine")
    public String getIpmiPassword()
    {
        return ipmiPassword;
    }

    public void setIpmiPassword(final String ipmiPassword)
    {
        this.ipmiPassword = ipmiPassword;
    }

    @Desc("Initiator IQN of the machine used to use storage devices")
    public String getInitiatorIQN()
    {
        return initiatorIQN;
    }

    public void setInitiatorIQN(final String initiatorIQN)
    {
        this.initiatorIQN = initiatorIQN;
    }

    @Override
    public String getMediaType()
    {
        return MachineDto.MEDIA_TYPE;
    }

    @Override
    public String getBaseMediaType()
    {
        return BASE_MEDIA_TYPE;
    }

    /**
     * @return the networkInterfaces
     */
    public NetworkInterfacesDto getNetworkInterfaces()
    {
        if (networkInterfaces == null)
        {
            networkInterfaces = new NetworkInterfacesDto();
        }
        return networkInterfaces;
    }

    /**
     * @param networkInterfaces the networkInterfaces to set
     */
    public void setNetworkInterfaces(final NetworkInterfacesDto networkInterfaces)
    {
        this.networkInterfaces = networkInterfaces;
    }
}
TOP

Related Classes of com.abiquo.server.core.infrastructure.MachineDto

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.