| 58 | import com.google.gson.Gson; |
| 59 | |
| 60 | @Entity |
| 61 | @Table(name = "vm_instance") |
| 62 | @Inheritance(strategy = InheritanceType.JOINED) |
| 63 | @DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING, length = 32) |
| 64 | public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, VirtualMachine.Event> { |
| 65 | protected transient Logger logger = LogManager.getLogger(getClass()); |
| 66 | @Id |
| 67 | @TableGenerator(name = "vm_instance_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "vm_instance_seq", allocationSize = 1) |
| 68 | @Column(name = "id", updatable = false, nullable = false) |
| 69 | protected long id; |
| 70 | |
| 71 | @Column(name = "name", nullable = false, length = 255) |
| 72 | protected String hostName = null; |
| 73 | |
| 74 | @Encrypt |
| 75 | @Column(name = "vnc_password", updatable = true, nullable = false, length = 255) |
| 76 | protected String vncPassword; |
| 77 | |
| 78 | @Column(name = "proxy_id", updatable = true, nullable = true) |
| 79 | protected Long proxyId; |
| 80 | |
| 81 | @Temporal(TemporalType.TIMESTAMP) |
| 82 | @Column(name = "proxy_assign_time", updatable = true, nullable = true) |
| 83 | protected Date proxyAssignTime; |
| 84 | |
| 85 | /** |
| 86 | * Note that state is intentionally missing the setter. Any updates to |
| 87 | * the state machine needs to go through the DAO object because someone |
| 88 | * else could be updating it as well. |
| 89 | */ |
| 90 | @Enumerated(value = EnumType.STRING) |
| 91 | @StateMachine(state = State.class, event = Event.class) |
| 92 | @Column(name = "state", updatable = true, nullable = false, length = 32) |
| 93 | protected State state = null; |
| 94 | |
| 95 | @Column(name = "private_ip_address", updatable = true) |
| 96 | protected String privateIpAddress; |
| 97 | |
| 98 | @Column(name = "instance_name", updatable = true, nullable = false) |
| 99 | protected String instanceName; |
| 100 | |
| 101 | @Column(name = "vm_template_id", updatable = true, nullable = true, length = 17) |
| 102 | protected Long templateId = new Long(-1); |
| 103 | |
| 104 | @Column(name = "guest_os_id", nullable = false, length = 17) |
| 105 | protected long guestOSId; |
| 106 | |
| 107 | @Column(name = "host_id", updatable = true, nullable = true) |
| 108 | protected Long hostId; |
| 109 | |
| 110 | @Column(name = "last_host_id", updatable = true, nullable = true) |
| 111 | protected Long lastHostId; |
| 112 | |
| 113 | @Column(name = "pod_id", updatable = true, nullable = false) |
| 114 | protected Long podIdToDeployIn; |
| 115 | |
| 116 | @Column(name = "private_mac_address", updatable = true, nullable = true) |
| 117 | protected String privateMacAddress; |