Skip to content

Commit 0ab12ed

Browse files
author
Alex Huang
committed
network tagging changes
1 parent 67ff274 commit 0ab12ed

10 files changed

Lines changed: 261 additions & 258 deletions

File tree

‎core/src/com/cloud/agent/transport/Request.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ public void logT(String msg, boolean logD) {
301301
}
302302
}
303303
}
304+
305+
@Override
306+
public String toString() {
307+
return log("", true, Level.DEBUG);
308+
}
304309

305310
protected String log(String msg, boolean logContent, Level level) {
306311
StringBuilder content = new StringBuilder();

‎core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java‎

Lines changed: 91 additions & 134 deletions
Large diffs are not rendered by default.

‎core/test/com/cloud/agent/transport/RequestTest.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,13 @@ public class RequestTest extends TestCase {
4242
private static final Logger s_logger = Logger.getLogger(RequestTest.class);
4343

4444
public void testSerDeser() {
45+
s_logger.info("Testing serializing and deserializing works as expected");
46+
47+
s_logger.info("UpdateHostPasswordCommand should have two parameters that doesn't show in logging");
4548
UpdateHostPasswordCommand cmd1 = new UpdateHostPasswordCommand("abc", "def");
49+
s_logger.info("SecStorageFirewallCfgCommand has a context map that shouldn't show up in debug level");
4650
SecStorageFirewallCfgCommand cmd2 = new SecStorageFirewallCfgCommand();
51+
s_logger.info("GetHostStatsCommand should not show up at all in debug level");
4752
GetHostStatsCommand cmd3 = new GetHostStatsCommand("hostguid", "hostname", 101);
4853
cmd2.addPortConfig("abc", "24", true, "eth0");
4954
cmd2.addPortConfig("127.0.0.1", "44", false, "eth1");
@@ -113,6 +118,7 @@ public void testSerDeser() {
113118
}
114119

115120
public void testDownload() {
121+
s_logger.info("Testing Download answer");
116122
VMTemplateVO template = new VMTemplateVO(1, "templatename", ImageFormat.QCOW2, true, true, true, TemplateType.USER, "url", true, 32, 1, "chksum", "displayText", true, 30, true,
117123
HypervisorType.KVM);
118124
DownloadCommand cmd = new DownloadCommand("secUrl", template, 30000000l);
@@ -128,6 +134,7 @@ public void testDownload() {
128134
}
129135

130136
public void testLogging() {
137+
s_logger.info("Testing Logging");
131138
GetHostStatsCommand cmd3 = new GetHostStatsCommand("hostguid", "hostname", 101);
132139
Request sreq = new Request(2, 3, new Command[] { cmd3 }, true, true);
133140
sreq.setSequence(1);

‎server/src/com/cloud/agent/manager/AgentManagerImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2153,7 +2153,7 @@ protected void processRequest(final Link link, final Request request) {
21532153

21542154
Response response = null;
21552155
if (attache == null) {
2156-
s_logger.debug("Processing sequence " + request.getSequence() + ": Processing " + request.toString());
2156+
request.logD("Processing the first command ");
21572157
if (!(cmd instanceof StartupCommand)) {
21582158
s_logger.warn("Throwing away a request because it came through as the first command on a connect: " + request.toString());
21592159
return;

‎server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long cluste
280280
sql.delete(sql.length() - 4, sql.length());
281281
sql.append(DetailsSqlSuffix);
282282
Transaction txn = Transaction.currentTxn();
283-
PreparedStatement pstmt = s_initStmt;
283+
PreparedStatement pstmt = null;
284284
try {
285285
pstmt = txn.prepareAutoCloseStatement(sql.toString());
286286
int i = 1;
@@ -297,7 +297,7 @@ public List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long cluste
297297
}
298298
return pools;
299299
} catch (SQLException e) {
300-
throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
300+
throw new CloudRuntimeException("Unable to execute " + pstmt, e);
301301
}
302302
}
303303

@@ -351,7 +351,7 @@ public List<String> searchForStoragePoolDetails(long poolId, String value){
351351

352352
while (rs.next()) {
353353
tags.add(rs.getString("name"));
354-
}
354+
}
355355
return tags;
356356
} catch (SQLException e) {
357357
throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);

‎server/src/com/cloud/vm/dao/ConsoleProxyDaoImpl.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public ConsoleProxyDaoImpl() {
137137
HostUpSearch = createSearchBuilder();
138138
HostUpSearch.and("host", HostUpSearch.entity().getHostId(), SearchCriteria.Op.EQ);
139139
HostUpSearch.and("states", HostUpSearch.entity().getState(), SearchCriteria.Op.NIN);
140-
HostUpSearch.done();
140+
HostUpSearch.done();
141141

142142
StateChangeSearch = createSearchBuilder();
143143
StateChangeSearch.and("id", StateChangeSearch.entity().getId(), SearchCriteria.Op.EQ);
@@ -171,7 +171,7 @@ public boolean remove(Long id) {
171171
UpdateBuilder ub = getUpdateBuilder(proxy);
172172
ub.set(proxy, "state", State.Destroyed);
173173
ub.set(proxy, "privateIpAddress", null);
174-
update(id, ub);
174+
update(id, ub, proxy);
175175

176176
boolean result = super.remove(id);
177177
txn.commit();
@@ -204,7 +204,7 @@ public List<ConsoleProxyVO> listByHostId(long hostId) {
204204
public List<ConsoleProxyVO> listUpByHostId(long hostId) {
205205
SearchCriteria<ConsoleProxyVO> sc = HostUpSearch.create();
206206
sc.setParameters("host", hostId);
207-
sc.setParameters("states", new Object[] {State.Destroyed, State.Stopped, State.Expunging});
207+
sc.setParameters("states", new Object[] {State.Destroyed, State.Stopped, State.Expunging});
208208
return listBy(sc);
209209
}
210210

‎server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
import com.cloud.network.router.VirtualRouter.Role;
3030
import com.cloud.utils.component.ComponentLocator;
3131
import com.cloud.utils.db.GenericDaoBase;
32+
import com.cloud.utils.db.JoinBuilder.JoinType;
3233
import com.cloud.utils.db.SearchBuilder;
3334
import com.cloud.utils.db.SearchCriteria;
34-
import com.cloud.utils.db.JoinBuilder.JoinType;
3535
import com.cloud.utils.db.SearchCriteria.Op;
3636
import com.cloud.utils.db.Transaction;
3737
import com.cloud.utils.db.UpdateBuilder;
@@ -83,7 +83,7 @@ public boolean remove(Long id) {
8383
router.setPublicIpAddress(null);
8484
UpdateBuilder ub = getUpdateBuilder(router);
8585
ub.set(router, "state", State.Destroyed);
86-
update(id, ub);
86+
update(id, ub, router);
8787

8888
boolean result = super.remove(id);
8989
txn.commit();

‎server/src/com/cloud/vm/dao/SecondaryStorageVmDaoImpl.java‎

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public boolean remove(Long id) {
113113
UpdateBuilder ub = getUpdateBuilder(proxy);
114114
ub.set(proxy, "state", State.Destroyed);
115115
ub.set(proxy, "privateIpAddress", null);
116-
update(id, ub);
116+
update(id, ub, proxy);
117117

118118
boolean result = super.remove(id);
119119
txn.commit();
@@ -125,17 +125,19 @@ public List<SecondaryStorageVmVO> getSecStorageVmListInStates(SecondaryStorageVm
125125
SearchCriteria<SecondaryStorageVmVO> sc = DataCenterStatusSearch.create();
126126
sc.setParameters("states", (Object[])states);
127127
sc.setParameters("dc", dataCenterId);
128-
if(role != null)
129-
sc.setParameters("role", role);
128+
if(role != null) {
129+
sc.setParameters("role", role);
130+
}
130131
return listBy(sc);
131132
}
132133

133134
@Override
134135
public List<SecondaryStorageVmVO> getSecStorageVmListInStates(SecondaryStorageVm.Role role, State... states) {
135136
SearchCriteria<SecondaryStorageVmVO> sc = StateSearch.create();
136137
sc.setParameters("states", (Object[])states);
137-
if(role != null)
138-
sc.setParameters("role", role);
138+
if(role != null) {
139+
sc.setParameters("role", role);
140+
}
139141

140142
return listBy(sc);
141143
}
@@ -144,18 +146,20 @@ public List<SecondaryStorageVmVO> getSecStorageVmListInStates(SecondaryStorageVm
144146
public List<SecondaryStorageVmVO> listByHostId(SecondaryStorageVm.Role role, long hostId) {
145147
SearchCriteria<SecondaryStorageVmVO> sc = HostSearch.create();
146148
sc.setParameters("host", hostId);
147-
if(role != null)
148-
sc.setParameters("role", role);
149+
if(role != null) {
150+
sc.setParameters("role", role);
151+
}
149152
return listBy(sc);
150153
}
151154

152155
@Override
153156
public List<SecondaryStorageVmVO> listUpByHostId(SecondaryStorageVm.Role role, long hostId) {
154157
SearchCriteria<SecondaryStorageVmVO> sc = HostUpSearch.create();
155158
sc.setParameters("host", hostId);
156-
sc.setParameters("states", new Object[] {State.Destroyed, State.Stopped, State.Expunging});
157-
if(role != null)
158-
sc.setParameters("role", role);
159+
sc.setParameters("states", new Object[] {State.Destroyed, State.Stopped, State.Expunging});
160+
if(role != null) {
161+
sc.setParameters("role", role);
162+
}
159163
return listBy(sc);
160164
}
161165

@@ -166,12 +170,13 @@ public List<Long> getRunningSecStorageVmListByMsid(SecondaryStorageVm.Role role,
166170
PreparedStatement pstmt = null;
167171
try {
168172
String sql;
169-
if(role == null)
170-
sql = "SELECT s.id FROM secondary_storage_vm s, vm_instance v, host h " +
173+
if(role == null) {
174+
sql = "SELECT s.id FROM secondary_storage_vm s, vm_instance v, host h " +
171175
"WHERE s.id=v.id AND v.state='Running' AND v.host_id=h.id AND h.mgmt_server_id=?";
172-
else
173-
sql = "SELECT s.id FROM secondary_storage_vm s, vm_instance v, host h " +
176+
} else {
177+
sql = "SELECT s.id FROM secondary_storage_vm s, vm_instance v, host h " +
174178
"WHERE s.id=v.id AND v.state='Running' AND s.role=? AND v.host_id=h.id AND h.mgmt_server_id=?";
179+
}
175180

176181
pstmt = txn.prepareAutoCloseStatement(sql);
177182

@@ -209,8 +214,9 @@ public SecondaryStorageVmVO findByInstanceName(String instanceName) {
209214
public List<SecondaryStorageVmVO> listByZoneId(SecondaryStorageVm.Role role, long zoneId) {
210215
SearchCriteria<SecondaryStorageVmVO> sc = ZoneSearch.create();
211216
sc.setParameters("zone", zoneId);
212-
if(role != null)
213-
sc.setParameters("role", role);
217+
if(role != null) {
218+
sc.setParameters("role", role);
219+
}
214220
return listBy(sc);
215221
}
216222

@@ -219,8 +225,9 @@ public List<SecondaryStorageVmVO> listByLastHostId(SecondaryStorageVm.Role role,
219225
SearchCriteria<SecondaryStorageVmVO> sc = LastHostSearch.create();
220226
sc.setParameters("lastHost", hostId);
221227
sc.setParameters("state", State.Stopped);
222-
if(role != null)
223-
sc.setParameters("role", role);
228+
if(role != null) {
229+
sc.setParameters("role", role);
230+
}
224231

225232
return listBy(sc);
226233
}
@@ -233,10 +240,11 @@ public List<Long> listRunningSecStorageOrderByLoad(SecondaryStorageVm.Role role,
233240
PreparedStatement pstmt = null;
234241
try {
235242
String sql;
236-
if(role == null)
237-
sql = "SELECT s.id, count(l.id) as count FROM secondary_storage_vm s INNER JOIN vm_instance v ON s.id=v.id LEFT JOIN cmd_exec_log l ON s.id=l.instance_id WHERE v.state='Running' AND v.data_center_id=? GROUP BY s.id ORDER BY count";
238-
else
239-
sql = "SELECT s.id, count(l.id) as count FROM secondary_storage_vm s INNER JOIN vm_instance v ON s.id=v.id LEFT JOIN cmd_exec_log l ON s.id=l.instance_id WHERE v.state='Running' AND v.data_center_id=? AND s.role=? GROUP BY s.id ORDER BY count";
243+
if(role == null) {
244+
sql = "SELECT s.id, count(l.id) as count FROM secondary_storage_vm s INNER JOIN vm_instance v ON s.id=v.id LEFT JOIN cmd_exec_log l ON s.id=l.instance_id WHERE v.state='Running' AND v.data_center_id=? GROUP BY s.id ORDER BY count";
245+
} else {
246+
sql = "SELECT s.id, count(l.id) as count FROM secondary_storage_vm s INNER JOIN vm_instance v ON s.id=v.id LEFT JOIN cmd_exec_log l ON s.id=l.instance_id WHERE v.state='Running' AND v.data_center_id=? AND s.role=? GROUP BY s.id ORDER BY count";
247+
}
240248

241249
pstmt = txn.prepareAutoCloseStatement(sql);
242250

0 commit comments

Comments
 (0)