11/**
22 * Copyright (C) 2011 Cloud.com, Inc. All rights reserved.
3- *
3+ *
44 * This software is licensed under the GNU General Public License v3 or later.
5- *
5+ *
66 * It is free software: you can redistribute it and/or modify
77 * it under the terms of the GNU General Public License as published by
88 * the Free Software Foundation, either version 3 of the License, or any later version.
99 * This program is distributed in the hope that it will be useful,
1010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 * GNU General Public License for more details.
13- *
13+ *
1414 * You should have received a copy of the GNU General Public License
1515 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16- *
16+ *
1717 */
1818
1919package com .cloud .agent .resource .computing ;
109109
110110/**
111111 * Pretends to be a computing resource
112- *
112+ *
113113 */
114114@ Local (value ={ServerResource .class })
115115public class FakeComputingResource extends ServerResourceBase implements ServerResource {
@@ -130,7 +130,7 @@ public Type getType() {
130130 public StartupCommand [] initialize () {
131131 Map <String , VmState > changes = null ;
132132
133-
133+
134134 final List <Object > info = getHostInfo ();
135135
136136 final StartupRoutingCommand cmd = new StartupRoutingCommand ((Integer )info .get (0 ), (Long )info .get (1 ), (Long )info .get (2 ), (Long )info .get (4 ), (String )info .get (3 ), HypervisorType .KVM , RouterPrivateIpStrategy .HostLocal , changes );
@@ -145,16 +145,16 @@ public StartupCommand[] initialize() {
145145 sscmd .setResourceType (Storage .StorageResourceType .STORAGE_POOL );
146146
147147 return new StartupCommand []{cmd , sscmd };
148-
148+
149149 }
150150
151151 private Map <String , String > getVersionStrings () {
152152 Map <String , String > result = new HashMap <String , String >();
153153 String hostOs = (String ) _params .get ("Host.OS" );
154154 String hostOsVer = (String ) _params .get ("Host.OS.Version" );
155155 String hostOsKernVer = (String ) _params .get ("Host.OS.Kernel.Version" );
156- result .put ("Host.OS" , hostOs ==null ?"Fedora" :hostOs );
157- result .put ("Host.OS.Version" , hostOsVer ==null ?"14" :hostOsVer );
156+ result .put ("Host.OS" , hostOs ==null ?"Fedora" :hostOs );
157+ result .put ("Host.OS.Version" , hostOsVer ==null ?"14" :hostOsVer );
158158 result .put ("Host.OS.Kernel.Version" , hostOsKernVer ==null ?"2.6.35.6-45.fc14.x86_64" :hostOsKernVer );
159159 return result ;
160160 }
@@ -164,29 +164,29 @@ protected void fillNetworkInformation(final StartupCommand cmd) {
164164 cmd .setPrivateIpAddress ((String )_params .get ("private.ip.address" ));
165165 cmd .setPrivateMacAddress ((String )_params .get ("private.mac.address" ));
166166 cmd .setPrivateNetmask ((String )_params .get ("private.ip.netmask" ));
167-
167+
168168 cmd .setStorageIpAddress ((String )_params .get ("private.ip.address" ));
169169 cmd .setStorageMacAddress ((String )_params .get ("private.mac.address" ));
170170 cmd .setStorageNetmask ((String )_params .get ("private.ip.netmask" ));
171171 cmd .setGatewayIpAddress ((String )_params .get ("gateway.ip.address" ));
172172
173173 }
174-
174+
175175 protected StoragePoolInfo initializeLocalStorage () {
176176 String hostIp = (String )_params .get ("private.ip.address" );
177177 String localStoragePath = (String )_params .get ("local.storage.path" );
178178 String lh = hostIp + localStoragePath ;
179179 String uuid = UUID .nameUUIDFromBytes (lh .getBytes ()).toString ();
180-
180+
181181 String capacity = (String )_params .get ("local.storage.capacity" );
182182 String available = (String )_params .get ("local.storage.avail" );
183183
184- return new StoragePoolInfo (uuid , hostIp , localStoragePath ,
185- localStoragePath , StoragePoolType .Filesystem ,
184+ return new StoragePoolInfo (uuid , hostIp , localStoragePath ,
185+ localStoragePath , StoragePoolType .Filesystem ,
186186 Long .parseLong (capacity ), Long .parseLong (available ));
187187
188188 }
189-
189+
190190 @ Override
191191 public PingCommand getCurrentStatus (long id ) {
192192 final HashMap <String , State > newStates = new HashMap <String , State >();
@@ -205,7 +205,7 @@ public Answer executeRequest(Command cmd) {
205205 return execute ((GetHostStatsCommand )cmd );
206206 } else if (cmd instanceof PrimaryStorageDownloadCommand ) {
207207 return execute ((PrimaryStorageDownloadCommand ) cmd );
208-
208+
209209 } else if (cmd instanceof StopCommand ) {
210210 return execute ((StopCommand )cmd );
211211 } else if (cmd instanceof GetVmStatsCommand ) {
@@ -295,7 +295,7 @@ private Answer execute(GetStorageStatsCommand cmd) {
295295 protected synchronized ReadyAnswer execute (ReadyCommand cmd ) {
296296 return new ReadyAnswer (cmd );
297297 }
298-
298+
299299 private Answer execute (PrimaryStorageDownloadCommand cmd ) {
300300 return new PrimaryStorageDownloadAnswer (cmd .getLocalPath (), 16000000L );
301301 }
@@ -308,23 +308,23 @@ private Answer execute(ModifySshKeysCommand cmd) {
308308 protected String getDefaultScriptsDir () {
309309 return null ;
310310 }
311-
312-
311+
312+
313313 protected String getConfiguredProperty (String key , String defaultValue ) {
314314 String val = (String )_params .get (key );
315315 return val ==null ?defaultValue :val ;
316316 }
317-
317+
318318 protected Long getConfiguredProperty (String key , Long defaultValue ) {
319319 String val = (String )_params .get (key );
320-
320+
321321 if (val != null ) {
322322 Long result = Long .parseLong (val );
323323 return result ;
324324 }
325325 return defaultValue ;
326326 }
327-
327+
328328 protected List <Object > getHostInfo () {
329329 final ArrayList <Object > info = new ArrayList <Object >();
330330 long speed = getConfiguredProperty ("cpuspeed" , 4000L ) ;
@@ -338,9 +338,9 @@ protected List<Object> getHostInfo() {
338338 info .add (speed );
339339 info .add (ram );
340340 info .add (cap );
341- info .add (dom0ram );
341+ info .add (dom0ram );
342342 return info ;
343-
343+
344344 }
345345 private Map <String , Object > getSimulatorProperties () throws ConfigurationException {
346346 final File file = PropertiesUtil .findConfigFile ("simulator.properties" );
@@ -353,20 +353,20 @@ private Map<String, Object> getSimulatorProperties() throws ConfigurationExcepti
353353 try {
354354 properties .load (new FileInputStream (file ));
355355
356-
356+
357357 final Map <String , Object > params = PropertiesUtil .toMap (properties );
358358
359-
359+
360360 return params ;
361361 } catch (final FileNotFoundException ex ) {
362362 throw new CloudRuntimeException ("Cannot find the file: " + file .getAbsolutePath (), ex );
363363 } catch (final IOException ex ) {
364364 throw new CloudRuntimeException ("IOException in reading " + file .getAbsolutePath (), ex );
365365 }
366366 }
367-
368367
369-
368+
369+
370370 @ Override
371371 public boolean configure (String name , Map <String , Object > params )
372372 throws ConfigurationException {
@@ -387,7 +387,7 @@ public Map<String, Object> getParams() {
387387 return _params ;
388388 }
389389
390-
390+
391391 protected synchronized StartAnswer execute (StartCommand cmd ) {
392392 VmMgr vmMgr = getVmManager ();
393393
@@ -404,7 +404,7 @@ protected synchronized StartAnswer execute(StartCommand cmd) {
404404 MockVm vm = vmMgr .createVmFromSpec (vmSpec );
405405 vmMgr .createVbd (vmSpec , vmName , vm );
406406 vmMgr .createVif (vmSpec , vmName , vm );
407-
407+
408408 state = State .Running ;
409409 for (NicTO nic : cmd .getVirtualMachine ().getNics ()) {
410410 if (nic .getType () == TrafficType .Guest ) {
@@ -440,7 +440,7 @@ protected synchronized StopAnswer execute(StopCommand cmd) {
440440 Long bytesReceived = null ;
441441 Long bytesSent = null ;
442442
443-
443+
444444
445445 State state = null ;
446446 synchronized (_vms ) {
@@ -471,7 +471,7 @@ protected synchronized StopAnswer execute(StopCommand cmd) {
471471 answer = new StopAnswer (cmd , result , port , bytesSent ,
472472 bytesReceived );
473473 }
474-
474+
475475 _dhcpSnooper .cleanup (vmName , null );
476476
477477 return answer ;
@@ -487,11 +487,11 @@ protected synchronized StopAnswer execute(StopCommand cmd) {
487487 protected Answer execute (final VmDataCommand cmd ) {
488488 return _vmDataServer .handleVmDataCommand (cmd );
489489 }
490-
490+
491491 protected Answer execute (final SavePasswordCommand cmd ) {
492492 return new Answer (cmd );
493493 }
494-
494+
495495 protected Answer execute (RebootCommand cmd ) {
496496 VmMgr vmMgr = getVmManager ();
497497 vmMgr .rebootVM (cmd .getVmName ());
@@ -501,15 +501,15 @@ protected Answer execute(RebootCommand cmd) {
501501 private Answer execute (PingTestCommand cmd ) {
502502 return new Answer (cmd );
503503 }
504-
504+
505505 protected GetVmStatsAnswer execute (GetVmStatsCommand cmd ) {
506506 return null ;
507507 }
508-
508+
509509 private VmMgr getVmManager () {
510510 return _vmManager ;
511511 }
512-
512+
513513 protected Answer execute (GetHostStatsCommand cmd ) {
514514 VmMgr vmMgr = getVmManager ();
515515 return new GetHostStatsAnswer (cmd , vmMgr .getHostCpuUtilization (), vmMgr
@@ -526,7 +526,7 @@ protected CheckHealthAnswer execute(CheckHealthCommand cmd) {
526526 return new CheckHealthAnswer (cmd , true );
527527 }
528528
529-
529+
530530 protected CheckVirtualMachineAnswer execute (
531531 final CheckVirtualMachineCommand cmd ) {
532532 VmMgr vmMgr = getVmManager ();
@@ -565,7 +565,7 @@ protected CreateAnswer execute(final CreateCommand cmd) {
565565 return new CreateAnswer (cmd , new Exception ("Unexpected exception" ));
566566 }
567567 }
568-
568+
569569
570570
571571 protected HashMap <String , State > sync () {
@@ -645,7 +645,7 @@ protected HashMap<String, State> sync() {
645645
646646 return changes ;
647647 }
648-
648+
649649 protected Answer execute (DestroyCommand cmd ) {
650650 return new Answer (cmd , true , null );
651651 }
0 commit comments