1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.jclouds.trmk.vcloud_0_8.domain;
20
21 import static com.google.common.base.Preconditions.checkArgument;
22
23 import java.util.List;
24
25 import org.jclouds.util.Preconditions2;
26
27 import com.google.common.collect.Lists;
28
29
30
31
32
33
34 public class VAppConfiguration {
35 private String name = null;
36 private Integer processorCount = null;
37 private Long memory = null;
38 private List<Long> disks = Lists.newArrayList();
39 private List<Integer> disksToDelete = Lists.newArrayList();
40
41
42
43
44
45 public VAppConfiguration changeNameTo(String name) {
46 Preconditions2.checkNotEmpty(name, "name must be specified");
47 this.name = name;
48 return this;
49 }
50
51
52
53
54 public VAppConfiguration changeProcessorCountTo(int cpus) {
55 checkArgument(cpus >= 1, "cpu count must be positive");
56 this.processorCount = cpus;
57 return this;
58 }
59
60
61
62
63 public VAppConfiguration changeMemoryTo(long megabytes) {
64 checkArgument(megabytes >= 1, "megabytes must be positive");
65 this.memory = megabytes;
66 return this;
67 }
68
69
70
71
72
73 public VAppConfiguration addDisk(long kilobytes) {
74 checkArgument(kilobytes > 0, "kilobytes must be positive");
75 checkArgument(kilobytes % 1048576 == 0, "disk must be an interval of 1048576");
76 this.disks.add(kilobytes);
77 return this;
78 }
79
80
81
82
83
84
85
86
87
88
89
90
91
92 public VAppConfiguration deleteDiskWithAddressOnParent(int addressOnParent) {
93 checkArgument(addressOnParent > 0, "you cannot delete the system disk");
94 disksToDelete.add(addressOnParent);
95 return this;
96 }
97
98 public static class Builder {
99
100
101
102
103 public static VAppConfiguration changeNameTo(String name) {
104 VAppConfiguration options = new VAppConfiguration();
105 return options.changeNameTo(name);
106 }
107
108
109
110
111 public static VAppConfiguration changeProcessorCountTo(int cpus) {
112 VAppConfiguration options = new VAppConfiguration();
113 return options.changeProcessorCountTo(cpus);
114 }
115
116
117
118
119 public static VAppConfiguration changeMemoryTo(long megabytes) {
120 VAppConfiguration options = new VAppConfiguration();
121 return options.changeMemoryTo(megabytes);
122 }
123
124
125
126
127 public static VAppConfiguration addDisk(long kilobytes) {
128 VAppConfiguration options = new VAppConfiguration();
129 return options.addDisk(kilobytes);
130 }
131
132
133
134
135 public static VAppConfiguration deleteDiskWithAddressOnParent(int addressOnParent) {
136 VAppConfiguration options = new VAppConfiguration();
137 return options.deleteDiskWithAddressOnParent(addressOnParent);
138 }
139
140 }
141
142 public Integer getProcessorCount() {
143 return processorCount;
144 }
145
146 public Long getMemory() {
147 return memory;
148 }
149
150 public List<Long> getDisks() {
151 return disks;
152 }
153
154 public String getName() {
155 return name;
156 }
157
158 public List<Integer> getDisksToDelete() {
159 return disksToDelete;
160 }
161 }