@@ -444,37 +444,21 @@ public VirtualRouter upgradeRouter(UpgradeRouterCmd cmd) {
444444 }
445445
446446 @ Override
447- public boolean savePasswordToRouter (Network network , NicProfile nic , VirtualMachineProfile <UserVm > profile , List <? extends VirtualRouter > routers ) throws ResourceUnavailableException {
448- if (routers == null || routers .isEmpty ()) {
449- s_logger .warn ("Unable save password, router doesn't exist in network " + network .getId ());
450- throw new CloudRuntimeException ("Unable to save password to router" );
451- }
452-
453- UserVm userVm = profile .getVirtualMachine ();
454- String password = (String ) profile .getParameter (Param .VmPassword );
455- String encodedPassword = PasswordGenerator .rot13 (password );
456- DataCenter dc = _dcDao .findById (userVm .getDataCenterIdToDeployIn ());
457-
458- boolean result = true ;
459- for (VirtualRouter router : routers ) {
460- boolean sendPassword = true ;
461- if (dc .getNetworkType () == NetworkType .Basic && userVm .getPodIdToDeployIn ().longValue () != router .getPodIdToDeployIn ().longValue ()) {
462- sendPassword = false ;
463- }
447+ public boolean savePasswordToRouter (Network network , final NicProfile nic , VirtualMachineProfile <UserVm > profile , List <? extends VirtualRouter > routers ) throws ResourceUnavailableException {
448+ _userVmDao .loadDetails ((UserVmVO ) profile .getVirtualMachine ());
464449
465- if (sendPassword ) {
466- Commands cmds = new Commands (OnError .Continue );
467- SavePasswordCommand cmd = new SavePasswordCommand (encodedPassword , nic .getIp4Address (), userVm .getHostName ());
468- cmd .setAccessDetail (NetworkElementCommand .ROUTER_IP , getRouterControlIp (router .getId ()));
469- cmd .setAccessDetail (NetworkElementCommand .ROUTER_NAME , router .getInstanceName ());
470- DataCenterVO dcVo = _dcDao .findById (router .getDataCenterIdToDeployIn ());
471- cmd .setAccessDetail (NetworkElementCommand .ZONE_NETWORK_TYPE , dcVo .getNetworkType ().toString ());
472- cmds .addCommand ("password" , cmd );
450+ final VirtualMachineProfile <UserVm > updatedProfile = profile ;
473451
474- result = result && sendCommandsToRouter (router , cmds );
452+ return applyRules (network , routers , "save password entry" , false , null , false , new RuleApplier () {
453+ @ Override
454+ public boolean execute (Network network , VirtualRouter router ) throws ResourceUnavailableException {
455+ // for basic zone, send vm data/password information only to the router in the same pod
456+ Commands cmds = new Commands (OnError .Stop );
457+ NicVO nicVo = _nicDao .findById (nic .getId ());
458+ createPasswordCommand (router , updatedProfile , nicVo , cmds );
459+ return sendCommandsToRouter (router , cmds );
475460 }
476- }
477- return result ;
461+ });
478462 }
479463
480464 @ Override @ ActionEvent (eventType = EventTypes .EVENT_ROUTER_STOP , eventDescription = "stopping router Vm" , async = true )
0 commit comments