Skip to content

Commit 652d869

Browse files
author
Alex Huang
committed
more files checked in
1 parent 25ef105 commit 652d869

21 files changed

Lines changed: 607 additions & 303 deletions
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
3+
*
4+
* This software is licensed under the GNU General Public License v3 or later.
5+
*
6+
* It is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or any later version.
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*/
18+
package com.cloud.hypervisor;
19+
20+
import com.cloud.offering.ServiceOffering;
21+
import com.cloud.utils.component.Adapter;
22+
import com.cloud.vm.VirtualMachine;
23+
import com.cloud.vm.VirtualMachineProfile;
24+
25+
public interface HypervisorGuru extends Adapter {
26+
VirtualMachineProfile design(VirtualMachine vm, ServiceOffering offering);
27+
boolean check(VirtualMachineProfile profile);
28+
}

api/src/com/cloud/vm/NicProfile.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ public class NicProfile {
2929
URI broadcastUri;
3030
ReservationStrategy strategy;
3131
String reservationId;
32+
boolean defaultNic;
33+
Integer deviceId;
34+
35+
public boolean isDefaultNic() {
36+
return defaultNic;
37+
}
3238

3339
public String getNetmask() {
3440
return netmask;
@@ -54,6 +60,10 @@ public URI getIsolationUri() {
5460
return isolationUri;
5561
}
5662

63+
public void setStrategy(ReservationStrategy strategy) {
64+
this.strategy = strategy;
65+
}
66+
5767
public BroadcastDomainType getType() {
5868
return broadcastType;
5969
}
@@ -69,6 +79,18 @@ public void setMode(Mode mode) {
6979
public void setVmId(long vmId) {
7080
this.vmId = vmId;
7181
}
82+
83+
public void setDeviceId(int deviceId) {
84+
this.deviceId = deviceId;
85+
}
86+
87+
public void setDefaultNic(boolean defaultNic) {
88+
this.defaultNic = defaultNic;
89+
}
90+
91+
public Integer getDeviceId() {
92+
return deviceId;
93+
}
7294

7395
public void setGateway(String gateway) {
7496
this.gateway = gateway;
@@ -142,7 +164,7 @@ public void setIp4Address(String ip4Address) {
142164
this.ip4Address = ip4Address;
143165
}
144166

145-
public NicProfile(Nic nic, NetworkConfiguration network) {
167+
public NicProfile(Nic nic, NetworkConfiguration network, URI broadcastUri, URI isolationUri) {
146168
this.id = nic.getId();
147169
this.gateway = network.getGateway();
148170
this.mode = network.getMode();
@@ -171,6 +193,9 @@ public NicProfile(Resource.ReservationStrategy strategy, String ip4Address, Stri
171193
this.netmask = netmask;
172194
this.strategy = strategy;
173195
}
196+
197+
public NicProfile() {
198+
}
174199

175200
public ReservationStrategy getReservationStrategy() {
176201
return strategy;

api/src/com/cloud/vm/VirtualMachineProfile.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,29 @@
2525

2626
public class VirtualMachineProfile {
2727
VirtualMachine _vm;
28-
int _cpus;
29-
int _speed; // in mhz
28+
Integer _cpus;
29+
Integer _speed; // in mhz
3030
long _ram; // in bytes
3131
HypervisorType _hypervisorType;
3232
VirtualMachine.Type _type;
3333
Map<String, String> _params;
3434
Long _templateId;
3535
List<DiskProfile> _disks;
3636
List<NicProfile> _nics;
37+
String _os;
3738

3839
public VirtualMachineProfile(VirtualMachine.Type type) {
3940
this._type = type;
4041
}
4142

43+
public String getName() {
44+
return _vm.getInstanceName();
45+
}
46+
47+
public String getOs() {
48+
return _os;
49+
}
50+
4251
public long getId() {
4352
return _vm.getId();
4453
}
@@ -51,11 +60,11 @@ public Long getTemplateId() {
5160
return _templateId;
5261
}
5362

54-
public int getCpus() {
63+
public Integer getCpus() {
5564
return _cpus;
5665
}
5766

58-
public int getSpeed() {
67+
public Integer getSpeed() {
5968
return _speed;
6069
}
6170

@@ -96,13 +105,14 @@ public VirtualMachineProfile(long id, int core, int speed, long ram, Long templa
96105
this._templateId = templateId;
97106
}
98107

99-
public VirtualMachineProfile(VirtualMachine vm, ServiceOffering offering) {
108+
public VirtualMachineProfile(VirtualMachine vm, ServiceOffering offering, String os) {
100109
this._cpus = offering.getCpu();
101110
this._speed = offering.getSpeed();
102111
this._ram = offering.getRamSize();
103112
this._templateId = vm.getTemplateId();
104113
this._type = vm.getType();
105114
this._vm = vm;
115+
this._os = os;
106116
}
107117

108118
protected VirtualMachineProfile() {

core/src/com/cloud/agent/api/Start2Command.java

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,51 +12,15 @@ public VirtualMachineTO getVirtualMachine() {
1212
return vm;
1313
}
1414

15-
/*
16-
long id;
17-
String guestIpAddress;
18-
String gateway;
19-
int ramSize;
20-
String imagePath;
21-
String guestNetworkId;
22-
String guestMacAddress;
23-
String vncPassword;
24-
String externalVlan;
25-
String externalMacAddress;
26-
int utilization;
27-
int cpuWeight;
28-
int cpu;
29-
int networkRateMbps;
30-
int networkRateMulticastMbps;
31-
String hostName;
32-
String arch;
33-
String isoPath;
34-
boolean bootFromISO;
35-
String guestOSDescription;
36-
37-
---->console proxy
38-
private ConsoleProxyVO proxy;
39-
private int proxyCmdPort;
40-
private String vncPort;
41-
private String urlPort;
42-
private String mgmt_host;
43-
private int mgmt_port;
44-
private boolean sslEnabled;
45-
46-
----->abstract
47-
protected String vmName;
48-
protected String storageHosts[] = new String[2];
49-
protected List<VolumeVO> volumes;
50-
protected boolean mirroredVols = false;
51-
protected BootloaderType bootloader = BootloaderType.PyGrub;
52-
53-
*/
54-
5515
@Override
5616
public boolean executeInSequence() {
5717
return true;
5818
}
5919

60-
public Start2Command() {
20+
protected Start2Command() {
21+
}
22+
23+
public Start2Command(VirtualMachineTO vm) {
24+
this.vm = vm;
6125
}
6226
}

core/src/com/cloud/agent/api/to/NetworkTO.java

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,27 @@
1717
*/
1818
package com.cloud.agent.api.to;
1919

20+
import java.net.URI;
21+
2022
import com.cloud.network.Network.BroadcastDomainType;
2123
import com.cloud.network.Network.TrafficType;
2224

2325
/**
2426
* Transfer object to transfer network settings.
2527
*/
2628
public class NetworkTO {
27-
private String uuid;
28-
private String ip;
29-
private String netmask;
30-
private String gateway;
31-
private String mac;
32-
private String dns1;
33-
private String dns2;
34-
private Long vlan;
35-
private BroadcastDomainType broadcastType;
36-
private TrafficType type;
29+
protected String uuid;
30+
protected String ip;
31+
protected String netmask;
32+
protected String gateway;
33+
protected String mac;
34+
protected String dns1;
35+
protected String dns2;
36+
protected Long vlan;
37+
protected BroadcastDomainType broadcastType;
38+
protected TrafficType type;
39+
protected URI broadcastUri;
40+
protected URI isolationUri;
3741

3842
public NetworkTO() {
3943
}
@@ -150,4 +154,20 @@ public String getDns2() {
150154
public TrafficType getType() {
151155
return type;
152156
}
157+
158+
public URI getBroadcastUri() {
159+
return broadcastUri;
160+
}
161+
162+
public void setBroadcastUri(URI broadcastUri) {
163+
this.broadcastUri = broadcastUri;
164+
}
165+
166+
public URI getIsolationUri() {
167+
return isolationUri;
168+
}
169+
170+
public void setIsolationuri(URI isolationUri) {
171+
this.isolationUri = isolationUri;
172+
}
153173
}

core/src/com/cloud/agent/api/to/NicTO.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ public class NicTO extends NetworkTO {
88
Integer controlPort;
99
Integer networkRateMbps;
1010
Integer networkRateMulticastMbps;
11+
String bootParams;
12+
boolean defaultNic;
1113

1214
public NicTO() {
1315
super();
@@ -33,4 +35,25 @@ public Integer getNetworkRateMbps() {
3335
public Integer getNetworkRateMulticastMbps() {
3436
return networkRateMulticastMbps;
3537
}
38+
39+
public String getBootParams() {
40+
return bootParams;
41+
}
42+
43+
public void setBootParams(String bootParams) {
44+
this.bootParams = bootParams;
45+
}
46+
47+
public boolean isDefaultNic() {
48+
return defaultNic;
49+
}
50+
51+
public void setDefaultNic(boolean defaultNic) {
52+
this.defaultNic = defaultNic;
53+
}
54+
55+
@Override
56+
public String toString() {
57+
return new StringBuilder("[Nic:").append(type).append("-").append(ip).append("-").append(broadcastUri).append("]").toString();
58+
}
3659
}

core/src/com/cloud/agent/api/to/VirtualMachineTO.java

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121

2222
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
2323
import com.cloud.vm.VirtualMachine.Type;
24+
import com.cloud.vm.VirtualMachineProfile;
2425

2526
public class VirtualMachineTO {
2627
private long id;
2728
private String name;
2829
private BootloaderType bootloader;
2930
Type type;
3031
int cpus;
31-
Integer weight;
32-
Integer utilization;
32+
Integer speed;
3333
long minRam;
3434
long maxRam;
3535
String hostName;
@@ -42,7 +42,19 @@ public class VirtualMachineTO {
4242
VolumeTO[] disks;
4343
NicTO[] nics;
4444

45-
public VirtualMachineTO() {
45+
public VirtualMachineTO(VirtualMachineProfile profile, BootloaderType bootloader) {
46+
this.id = profile.getId();
47+
this.type = profile.getType();
48+
this.cpus = profile.getCpus();
49+
this.minRam = profile.getRam();
50+
this.maxRam = profile.getRam();
51+
this.speed = profile.getSpeed();
52+
this.os = profile.getOs();
53+
this.name = profile.getName();
54+
this.bootloader = bootloader;
55+
}
56+
57+
protected VirtualMachineTO() {
4658
}
4759

4860
public long getId() {
@@ -81,22 +93,10 @@ public void setCpus(int cpus) {
8193
this.cpus = cpus;
8294
}
8395

84-
public Integer getWeight() {
85-
return weight;
86-
}
87-
88-
public void setWeight(Integer weight) {
89-
this.weight = weight;
90-
}
91-
92-
public Integer getUtilization() {
93-
return utilization;
96+
public Integer getSpeed() {
97+
return speed;
9498
}
9599

96-
public void setUtiliziation(Integer utilization) {
97-
this.utilization = utilization;
98-
}
99-
100100
public long getMinRam() {
101101
return minRam;
102102
}
@@ -133,8 +133,13 @@ public String getOs() {
133133
public void setOs(String os) {
134134
this.os = os;
135135
}
136-
136+
137137
public String getBootArgs() {
138+
StringBuilder buf = new StringBuilder(bootArgs != null ? bootArgs : "");
139+
buf.append(" ");
140+
for (NicTO nic : nics) {
141+
buf.append("");
142+
}
138143
return bootArgs;
139144
}
140145

@@ -162,12 +167,11 @@ public void setDisks(VolumeTO[] disks) {
162167
this.disks = disks;
163168
}
164169

165-
public NicTO[] getNetworks() {
170+
public NicTO[] getNics() {
166171
return nics;
167172
}
168173

169174
public void setNics(NicTO[] nics) {
170175
this.nics = nics;
171176
}
172-
173177
}

0 commit comments

Comments
 (0)