-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAutoScaleManagerImpl.java
More file actions
1534 lines (1312 loc) · 68.6 KB
/
AutoScaleManagerImpl.java
File metadata and controls
1534 lines (1312 loc) · 68.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network.as;
import java.security.InvalidParameterException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.ejb.Local;
import javax.inject.Inject;
import org.apache.log4j.Logger;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd.HTTPMethod;
import org.apache.cloudstack.api.BaseListAccountResourcesCmd;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.admin.autoscale.CreateCounterCmd;
import org.apache.cloudstack.api.command.user.autoscale.CreateAutoScalePolicyCmd;
import org.apache.cloudstack.api.command.user.autoscale.CreateAutoScaleVmGroupCmd;
import org.apache.cloudstack.api.command.user.autoscale.CreateAutoScaleVmProfileCmd;
import org.apache.cloudstack.api.command.user.autoscale.CreateConditionCmd;
import org.apache.cloudstack.api.command.user.autoscale.ListAutoScalePoliciesCmd;
import org.apache.cloudstack.api.command.user.autoscale.ListAutoScaleVmGroupsCmd;
import org.apache.cloudstack.api.command.user.autoscale.ListAutoScaleVmProfilesCmd;
import org.apache.cloudstack.api.command.user.autoscale.ListConditionsCmd;
import org.apache.cloudstack.api.command.user.autoscale.ListCountersCmd;
import org.apache.cloudstack.api.command.user.autoscale.UpdateAutoScalePolicyCmd;
import org.apache.cloudstack.api.command.user.autoscale.UpdateAutoScaleVmGroupCmd;
import org.apache.cloudstack.api.command.user.autoscale.UpdateAutoScaleVmProfileCmd;
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
import org.apache.cloudstack.config.ApiServiceConfiguration;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.dispatch.DispatchChainFactory;
import com.cloud.api.dispatch.DispatchTask;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.event.ActionEvent;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientServerCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceInUseException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.Network.Capability;
import com.cloud.network.Network.IpAddresses;
import com.cloud.network.as.AutoScaleCounter.AutoScaleCounterParam;
import com.cloud.network.as.dao.AutoScalePolicyConditionMapDao;
import com.cloud.network.as.dao.AutoScalePolicyDao;
import com.cloud.network.as.dao.AutoScaleVmGroupDao;
import com.cloud.network.as.dao.AutoScaleVmGroupPolicyMapDao;
import com.cloud.network.as.dao.AutoScaleVmGroupVmMapDao;
import com.cloud.network.as.dao.AutoScaleVmProfileDao;
import com.cloud.network.as.dao.ConditionDao;
import com.cloud.network.as.dao.CounterDao;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.LoadBalancerDao;
import com.cloud.network.dao.LoadBalancerVMMapDao;
import com.cloud.network.dao.LoadBalancerVMMapVO;
import com.cloud.network.dao.LoadBalancerVO;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.lb.LoadBalancingRulesManager;
import com.cloud.network.lb.LoadBalancingRulesService;
import com.cloud.offering.ServiceOffering;
import com.cloud.projects.Project.ListProjectResourcesCriteria;
import com.cloud.template.TemplateManager;
import com.cloud.template.VirtualMachineTemplate;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.AccountService;
import com.cloud.user.User;
import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.UserDao;
import com.cloud.uservm.UserVm;
import com.cloud.utils.Pair;
import com.cloud.utils.Ternary;
import com.cloud.utils.component.ComponentContext;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.EntityManager;
import com.cloud.utils.db.Filter;
import com.cloud.utils.db.GenericDao;
import com.cloud.utils.db.JoinBuilder;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.TransactionCallback;
import com.cloud.utils.db.SearchCriteria.Op;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionStatus;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.UserVmManager;
import com.cloud.vm.UserVmService;
@Local(value = {AutoScaleService.class, AutoScaleManager.class})
public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScaleManager, AutoScaleService {
private static final Logger s_logger = Logger.getLogger(AutoScaleManagerImpl.class);
private ScheduledExecutorService _executor = Executors.newScheduledThreadPool(1);
@Inject
protected DispatchChainFactory dispatchChainFactory = null;
@Inject
EntityManager _entityMgr;
@Inject
AccountDao _accountDao;
@Inject
AccountManager _accountMgr;
@Inject
ConfigurationManager _configMgr;
@Inject
TemplateManager _templateMgr;
@Inject
LoadBalancingRulesManager _lbRulesMgr;
@Inject
NetworkDao _networkDao;
@Inject
CounterDao _counterDao;
@Inject
ConditionDao _conditionDao;
@Inject
LoadBalancerVMMapDao _lb2VmMapDao;
@Inject
LoadBalancerDao _lbDao;
@Inject
AutoScaleVmProfileDao _autoScaleVmProfileDao;
@Inject
AutoScalePolicyDao _autoScalePolicyDao;
@Inject
AutoScalePolicyConditionMapDao _autoScalePolicyConditionMapDao;
@Inject
AutoScaleVmGroupDao _autoScaleVmGroupDao;
@Inject
AutoScaleVmGroupPolicyMapDao _autoScaleVmGroupPolicyMapDao;
@Inject
AutoScaleVmGroupVmMapDao _autoScaleVmGroupVmMapDao;
@Inject
DataCenterDao _dcDao = null;
@Inject
UserDao _userDao;
@Inject
ConfigurationDao _configDao;
@Inject
IPAddressDao _ipAddressDao;
@Inject
AccountService _accountService;
@Inject
UserVmService _userVmService;
@Inject
UserVmManager _userVmManager;
@Inject
LoadBalancerVMMapDao _lbVmMapDao;
@Inject
LoadBalancingRulesService _loadBalancingRulesService;
public List<AutoScaleCounter> getSupportedAutoScaleCounters(long networkid) {
String capability = _lbRulesMgr.getLBCapability(networkid, Capability.AutoScaleCounters.getName());
if (capability == null) {
return null;
}
Gson gson = new Gson();
java.lang.reflect.Type listType = new TypeToken<List<AutoScaleCounter>>() {
}.getType();
List<AutoScaleCounter> result = gson.fromJson(capability, listType);
return result;
}
public void validateAutoScaleCounters(long networkid, List<Counter> counters, List<Pair<String, String>> counterParamPassed) {
List<AutoScaleCounter> supportedCounters = getSupportedAutoScaleCounters(networkid);
if (supportedCounters == null) {
throw new InvalidParameterException("AutoScale is not supported in the network");
}
for (Counter counter : counters) {
String counterName = counter.getSource().name().toString();
boolean isCounterSupported = false;
for (AutoScaleCounter autoScaleCounter : supportedCounters) {
if (autoScaleCounter.getName().equals(counterName)) {
isCounterSupported = true;
List<AutoScaleCounterParam> counterParams = autoScaleCounter.getParamList();
for (AutoScaleCounterParam autoScaleCounterParam : counterParams) {
boolean isRequiredParameter = autoScaleCounterParam.getRequired();
if (isRequiredParameter) {
boolean isRequiredParamPresent = false;
for (Pair<String, String> pair : counterParamPassed) {
if (pair.first().equals(autoScaleCounterParam.getParamName()))
isRequiredParamPresent = true;
}
if (!isRequiredParamPresent) {
throw new InvalidParameterException("Parameter " + autoScaleCounterParam.getParamName() + " has to be set in AutoScaleVmProfile's " +
ApiConstants.COUNTERPARAM_LIST);
}
}
}
break;
}
}
if (!isCounterSupported) {
throw new InvalidParameterException("AutoScale counter with source='" + counter.getSource().name() + "' is not supported " + "in the network");
}
}
}
private <VO extends ControlledEntity> VO getEntityInDatabase(Account caller, String paramName, Long id, GenericDao<VO, Long> dao) {
VO vo = dao.findById(id);
if (vo == null) {
throw new InvalidParameterValueException("Unable to find " + paramName);
}
_accountMgr.checkAccess(caller, null, false, (ControlledEntity)vo);
return vo;
}
private boolean isAutoScaleScaleUpPolicy(AutoScalePolicy policyVO) {
return policyVO.getAction().equals("scaleup");
}
private List<AutoScalePolicyVO> getAutoScalePolicies(String paramName, List<Long> policyIds, List<Counter> counters, int interval, boolean scaleUpPolicies) {
SearchBuilder<AutoScalePolicyVO> policySearch = _autoScalePolicyDao.createSearchBuilder();
policySearch.and("ids", policySearch.entity().getId(), Op.IN);
policySearch.done();
SearchCriteria<AutoScalePolicyVO> sc = policySearch.create();
sc.setParameters("ids", policyIds.toArray(new Object[0]));
List<AutoScalePolicyVO> policies = _autoScalePolicyDao.search(sc, null);
int prevQuietTime = 0;
for (AutoScalePolicyVO policy : policies) {
int quietTime = policy.getQuietTime();
if (prevQuietTime == 0) {
prevQuietTime = quietTime;
}
int duration = policy.getDuration();
if (duration < interval) {
throw new InvalidParameterValueException("duration : " + duration + " specified in a policy cannot be less than vm group's interval : " + interval);
}
if (quietTime != prevQuietTime) {
throw new InvalidParameterValueException("quietTime should be same for all the policies specified in " + paramName);
}
if (scaleUpPolicies) {
if (!isAutoScaleScaleUpPolicy(policy)) {
throw new InvalidParameterValueException("Only scaleup policies can be specified in scaleuppolicyids");
}
} else {
if (isAutoScaleScaleUpPolicy(policy)) {
throw new InvalidParameterValueException("Only scaledown policies can be specified in scaledownpolicyids");
}
}
List<AutoScalePolicyConditionMapVO> policyConditionMapVOs = _autoScalePolicyConditionMapDao.listByAll(policy.getId(), null);
for (AutoScalePolicyConditionMapVO policyConditionMapVO : policyConditionMapVOs) {
long conditionid = policyConditionMapVO.getConditionId();
Condition condition = _conditionDao.findById(conditionid);
Counter counter = _counterDao.findById(condition.getCounterid());
counters.add(counter);
}
}
return policies;
}
@DB
protected AutoScaleVmProfileVO checkValidityAndPersist(AutoScaleVmProfileVO vmProfile) {
long templateId = vmProfile.getTemplateId();
long autoscaleUserId = vmProfile.getAutoScaleUserId();
int destroyVmGraceperiod = vmProfile.getDestroyVmGraceperiod();
VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, templateId);
// Make sure a valid template ID was specified
if (template == null) {
throw new InvalidParameterValueException("Unable to use the given template.");
}
if (destroyVmGraceperiod < 0) {
throw new InvalidParameterValueException("Destroy Vm Grace Period cannot be less than 0.");
}
User user = _userDao.findById(autoscaleUserId);
if (user.getAccountId() != vmProfile.getAccountId()) {
throw new InvalidParameterValueException("AutoScale User id does not belong to the same account");
}
String apiKey = user.getApiKey();
String secretKey = user.getSecretKey();
String csUrl = ApiServiceConfiguration.ApiServletPath.value();
if (apiKey == null) {
throw new InvalidParameterValueException("apiKey for user: " + user.getUsername() + " is empty. Please generate it");
}
if (secretKey == null) {
throw new InvalidParameterValueException("secretKey for user: " + user.getUsername() + " is empty. Please generate it");
}
if (csUrl == null || csUrl.contains("localhost")) {
throw new InvalidParameterValueException("Global setting endpointe.url has to be set to the Management Server's API end point");
}
vmProfile = _autoScaleVmProfileDao.persist(vmProfile);
return vmProfile;
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMPROFILE_CREATE, eventDescription = "creating autoscale vm profile", create = true)
public AutoScaleVmProfile createAutoScaleVmProfile(CreateAutoScaleVmProfileCmd cmd) {
Account owner = _accountDao.findById(cmd.getAccountId());
Account caller = CallContext.current().getCallingAccount();
_accountMgr.checkAccess(caller, null, true, owner);
long zoneId = cmd.getZoneId();
long serviceOfferingId = cmd.getServiceOfferingId();
long autoscaleUserId = cmd.getAutoscaleUserId();
DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
if (zone == null) {
throw new InvalidParameterValueException("Unable to find zone by id");
}
ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
if (serviceOffering == null) {
throw new InvalidParameterValueException("Unable to find service offering by id");
}
// validations
HashMap<String, String> deployParams = cmd.getDeployParamMap();
if (deployParams.containsKey("networks") && deployParams.get("networks").length() > 0) {
throw new InvalidParameterValueException(
"'networks' is not a valid parameter, network for an AutoScaled VM is chosen automatically. An autoscaled VM is deployed in the loadbalancer's network");
}
/*
* Just for making sure the values are right in other deploy params.
* For ex. if projectId is given as a string instead of an long value, this
* will be throwing an error.
*/
dispatchChainFactory.getStandardDispatchChain().dispatch(new DispatchTask(ComponentContext.inject(DeployVMCmd.class), deployParams));
AutoScaleVmProfileVO profileVO =
new AutoScaleVmProfileVO(cmd.getZoneId(), cmd.getDomainId(), cmd.getAccountId(), cmd.getServiceOfferingId(), cmd.getTemplateId(), cmd.getOtherDeployParams(),
cmd.getCounterParamList(), cmd.getDestroyVmGraceperiod(), autoscaleUserId);
if (cmd.getDisplay() != null) {
profileVO.setDisplay(cmd.getDisplay());
}
profileVO = checkValidityAndPersist(profileVO);
s_logger.info("Successfully create AutoScale Vm Profile with Id: " + profileVO.getId());
return profileVO;
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMPROFILE_UPDATE, eventDescription = "updating autoscale vm profile")
public AutoScaleVmProfile updateAutoScaleVmProfile(UpdateAutoScaleVmProfileCmd cmd) {
Long profileId = cmd.getId();
Long templateId = cmd.getTemplateId();
Long autoscaleUserId = cmd.getAutoscaleUserId();
Map counterParamList = cmd.getCounterParamList();
Integer destroyVmGraceperiod = cmd.getDestroyVmGraceperiod();
AutoScaleVmProfileVO vmProfile = getEntityInDatabase(CallContext.current().getCallingAccount(), "Auto Scale Vm Profile", profileId, _autoScaleVmProfileDao);
boolean physicalParameterUpdate = (templateId != null || autoscaleUserId != null || counterParamList != null || destroyVmGraceperiod != null);
if (templateId != null) {
vmProfile.setTemplateId(templateId);
}
if (autoscaleUserId != null) {
vmProfile.setAutoscaleUserId(autoscaleUserId);
}
if (counterParamList != null) {
vmProfile.setCounterParamsForUpdate(counterParamList);
}
if (destroyVmGraceperiod != null) {
vmProfile.setDestroyVmGraceperiod(destroyVmGraceperiod);
}
if (cmd.getCustomId() != null) {
vmProfile.setUuid(cmd.getCustomId());
}
if (cmd.getDisplay() != null) {
vmProfile.setDisplay(cmd.getDisplay());
}
List<AutoScaleVmGroupVO> vmGroupList = _autoScaleVmGroupDao.listByAll(null, profileId);
for (AutoScaleVmGroupVO vmGroupVO : vmGroupList) {
if (physicalParameterUpdate && !vmGroupVO.getState().equals(AutoScaleVmGroup.State_Disabled)) {
throw new InvalidParameterValueException("The AutoScale Vm Profile can be updated only if the Vm Group it is associated with is disabled in state");
}
}
vmProfile = checkValidityAndPersist(vmProfile);
s_logger.info("Updated Auto Scale Vm Profile id:" + vmProfile.getId());
return vmProfile;
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMPROFILE_DELETE, eventDescription = "deleting autoscale vm profile")
public boolean deleteAutoScaleVmProfile(long id) {
/* Check if entity is in database */
getEntityInDatabase(CallContext.current().getCallingAccount(), "AutoScale Vm Profile", id, _autoScaleVmProfileDao);
if (_autoScaleVmGroupDao.isProfileInUse(id)) {
throw new InvalidParameterValueException("Cannot delete AutoScale Vm Profile when it is in use by one more vm groups");
}
boolean success = _autoScaleVmProfileDao.remove(id);
if (success) {
s_logger.info("Successfully deleted AutoScale Vm Profile with Id: " + id);
}
return success;
}
@Override
public List<? extends AutoScaleVmProfile> listAutoScaleVmProfiles(ListAutoScaleVmProfilesCmd cmd) {
Long id = cmd.getId();
Long templateId = cmd.getTemplateId();
String otherDeployParams = cmd.getOtherDeployParams();
Long serviceOffId = cmd.getServiceOfferingId();
Long zoneId = cmd.getZoneId();
Boolean display = cmd.getDisplay();
SearchWrapper<AutoScaleVmProfileVO> searchWrapper = new SearchWrapper<AutoScaleVmProfileVO>(_autoScaleVmProfileDao, AutoScaleVmProfileVO.class, cmd, cmd.getId());
SearchBuilder<AutoScaleVmProfileVO> sb = searchWrapper.getSearchBuilder();
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
sb.and("templateId", sb.entity().getTemplateId(), SearchCriteria.Op.EQ);
sb.and("serviceOfferingId", sb.entity().getServiceOfferingId(), SearchCriteria.Op.EQ);
sb.and("otherDeployParams", sb.entity().getOtherDeployParams(), SearchCriteria.Op.LIKE);
sb.and("zoneId", sb.entity().getZoneId(), SearchCriteria.Op.EQ);
sb.and("display", sb.entity().isDisplay(), SearchCriteria.Op.EQ);
SearchCriteria<AutoScaleVmProfileVO> sc = searchWrapper.buildSearchCriteria();
if (id != null) {
sc.setParameters("id", id);
}
if (templateId != null) {
sc.setParameters("templateId", templateId);
}
if (otherDeployParams != null) {
sc.addAnd("otherDeployParams", SearchCriteria.Op.LIKE, "%" + otherDeployParams + "%");
}
if (serviceOffId != null) {
sc.setParameters("serviceOfferingId", serviceOffId);
}
if (zoneId != null) {
sc.setParameters("zoneId", zoneId);
}
if (display != null) {
sc.setParameters("display", display);
}
return searchWrapper.search();
}
@DB
protected AutoScalePolicyVO checkValidityAndPersist(final AutoScalePolicyVO autoScalePolicyVOFinal, final List<Long> conditionIds) {
final int duration = autoScalePolicyVOFinal.getDuration();
final int quietTime = autoScalePolicyVOFinal.getQuietTime();
if (duration < 0) {
throw new InvalidParameterValueException("duration is an invalid value: " + duration);
}
if (quietTime < 0) {
throw new InvalidParameterValueException("quiettime is an invalid value: " + quietTime);
}
return Transaction.execute(new TransactionCallback<AutoScalePolicyVO>() {
@Override
public AutoScalePolicyVO doInTransaction(TransactionStatus status) {
AutoScalePolicyVO autoScalePolicyVO = _autoScalePolicyDao.persist(autoScalePolicyVOFinal);
if (conditionIds != null) {
SearchBuilder<ConditionVO> conditionsSearch = _conditionDao.createSearchBuilder();
conditionsSearch.and("ids", conditionsSearch.entity().getId(), Op.IN);
conditionsSearch.done();
SearchCriteria<ConditionVO> sc = conditionsSearch.create();
sc.setParameters("ids", conditionIds.toArray(new Object[0]));
List<ConditionVO> conditions = _conditionDao.search(sc, null);
ControlledEntity[] sameOwnerEntities = conditions.toArray(new ControlledEntity[conditions.size() + 1]);
sameOwnerEntities[sameOwnerEntities.length - 1] = autoScalePolicyVO;
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, sameOwnerEntities);
if (conditionIds.size() != conditions.size()) {
// TODO report the condition id which could not be found
throw new InvalidParameterValueException("Unable to find the condition specified");
}
ArrayList<Long> counterIds = new ArrayList<Long>();
for (ConditionVO condition : conditions) {
if (counterIds.contains(condition.getCounterid())) {
throw new InvalidParameterValueException(
"atleast two conditions in the conditionids have the same counter. It is not right to apply two different conditions for the same counter");
}
counterIds.add(condition.getCounterid());
}
/* For update case remove the existing mappings and create fresh ones */
_autoScalePolicyConditionMapDao.removeByAutoScalePolicyId(autoScalePolicyVO.getId());
for (Long conditionId : conditionIds) {
AutoScalePolicyConditionMapVO policyConditionMapVO = new AutoScalePolicyConditionMapVO(autoScalePolicyVO.getId(), conditionId);
_autoScalePolicyConditionMapDao.persist(policyConditionMapVO);
}
}
return autoScalePolicyVO;
}
});
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEPOLICY_CREATE, eventDescription = "creating autoscale policy", create = true)
public AutoScalePolicy createAutoScalePolicy(CreateAutoScalePolicyCmd cmd) {
int duration = cmd.getDuration();
Integer quietTime = cmd.getQuietTime();
String action = cmd.getAction();
if (quietTime == null) {
quietTime = NetUtils.DEFAULT_AUTOSCALE_POLICY_QUIET_TIME;
}
action = action.toLowerCase();
if (!NetUtils.isValidAutoScaleAction(action)) {
throw new InvalidParameterValueException("action is invalid, only 'scaleup' and 'scaledown' is supported");
}
AutoScalePolicyVO policyVO = new AutoScalePolicyVO(cmd.getDomainId(), cmd.getAccountId(), duration, quietTime, null, action);
policyVO = checkValidityAndPersist(policyVO, cmd.getConditionIds());
s_logger.info("Successfully created AutoScale Policy with Id: " + policyVO.getId());
return policyVO;
}
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEPOLICY_DELETE, eventDescription = "deleting autoscale policy")
public boolean deleteAutoScalePolicy(final long id) {
/* Check if entity is in database */
getEntityInDatabase(CallContext.current().getCallingAccount(), "AutoScale Policy", id, _autoScalePolicyDao);
if (_autoScaleVmGroupPolicyMapDao.isAutoScalePolicyInUse(id)) {
throw new InvalidParameterValueException("Cannot delete AutoScale Policy when it is in use by one or more AutoScale Vm Groups");
}
return Transaction.execute(new TransactionCallback<Boolean>() {
@Override
public Boolean doInTransaction(TransactionStatus status) {
boolean success = true;
success = _autoScalePolicyDao.remove(id);
if (!success) {
s_logger.warn("Failed to remove AutoScale Policy db object");
return false;
}
success = _autoScalePolicyConditionMapDao.removeByAutoScalePolicyId(id);
if (!success) {
s_logger.warn("Failed to remove AutoScale Policy Condition mappings");
return false;
}
s_logger.info("Successfully deleted autoscale policy id : " + id);
return success;
}
});
}
public void checkCallerAccess(String accountName, Long domainId) {
Account caller = CallContext.current().getCallingAccount();
Account owner = _accountDao.findActiveAccount(accountName, domainId);
if (owner == null) {
List<String> idList = new ArrayList<String>();
idList.add(ApiDBUtils.findDomainById(domainId).getUuid());
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain with specifed domainId");
}
_accountMgr.checkAccess(caller, null, false, owner);
}
private class SearchWrapper<VO extends ControlledEntity> {
GenericDao<VO, Long> dao;
SearchBuilder<VO> searchBuilder;
SearchCriteria<VO> searchCriteria;
Long domainId;
boolean isRecursive;
List<Long> permittedAccounts = new ArrayList<Long>();
ListProjectResourcesCriteria listProjectResourcesCriteria;
Filter searchFilter;
public SearchWrapper(GenericDao<VO, Long> dao, Class<VO> entityClass, BaseListAccountResourcesCmd cmd, Long id)
{
this.dao = dao;
this.searchBuilder = dao.createSearchBuilder();
domainId = cmd.getDomainId();
String accountName = cmd.getAccountName();
isRecursive = cmd.isRecursive();
boolean listAll = cmd.listAll();
long startIndex = cmd.getStartIndex();
long pageSizeVal = cmd.getPageSizeVal();
Account caller = CallContext.current().getCallingAccount();
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean,
ListProjectResourcesCriteria>(domainId, isRecursive, null);
_accountMgr.buildACLSearchParameters(caller, id, accountName, null, permittedAccounts, domainIdRecursiveListProject,
listAll, false);
domainId = domainIdRecursiveListProject.first();
isRecursive = domainIdRecursiveListProject.second();
ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
_accountMgr.buildACLSearchBuilder(searchBuilder, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
searchFilter = new Filter(entityClass, "id", false, startIndex, pageSizeVal);
}
public SearchBuilder<VO> getSearchBuilder() {
return searchBuilder;
}
public SearchCriteria<VO> buildSearchCriteria() {
searchCriteria = searchBuilder.create();
_accountMgr.buildACLSearchCriteria(searchCriteria, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
return searchCriteria;
}
public List<VO> search() {
return dao.search(searchCriteria, searchFilter);
}
}
@Override
public List<? extends AutoScalePolicy> listAutoScalePolicies(ListAutoScalePoliciesCmd cmd) {
SearchWrapper<AutoScalePolicyVO> searchWrapper = new SearchWrapper<AutoScalePolicyVO>(_autoScalePolicyDao, AutoScalePolicyVO.class, cmd, cmd.getId());
SearchBuilder<AutoScalePolicyVO> sb = searchWrapper.getSearchBuilder();
Long id = cmd.getId();
Long conditionId = cmd.getConditionId();
String action = cmd.getAction();
Long vmGroupId = cmd.getVmGroupId();
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
sb.and("action", sb.entity().getAction(), SearchCriteria.Op.EQ);
if (conditionId != null) {
SearchBuilder<AutoScalePolicyConditionMapVO> asPolicyConditionSearch = _autoScalePolicyConditionMapDao.createSearchBuilder();
asPolicyConditionSearch.and("conditionId", asPolicyConditionSearch.entity().getConditionId(), SearchCriteria.Op.EQ);
sb.join("asPolicyConditionSearch", asPolicyConditionSearch, sb.entity().getId(), asPolicyConditionSearch.entity().getPolicyId(), JoinBuilder.JoinType.INNER);
}
if (vmGroupId != null) {
SearchBuilder<AutoScaleVmGroupPolicyMapVO> asVmGroupPolicySearch = _autoScaleVmGroupPolicyMapDao.createSearchBuilder();
asVmGroupPolicySearch.and("vmGroupId", asVmGroupPolicySearch.entity().getVmGroupId(), SearchCriteria.Op.EQ);
sb.join("asVmGroupPolicySearch", asVmGroupPolicySearch, sb.entity().getId(), asVmGroupPolicySearch.entity().getPolicyId(), JoinBuilder.JoinType.INNER);
}
SearchCriteria<AutoScalePolicyVO> sc = searchWrapper.buildSearchCriteria();
if (id != null) {
sc.setParameters("id", id);
}
if (action != null) {
sc.setParameters("action", action);
}
if (conditionId != null) {
sc.setJoinParameters("asPolicyConditionSearch", "conditionId", conditionId);
}
if (vmGroupId != null) {
sc.setJoinParameters("asVmGroupPolicySearch", "vmGroupId", vmGroupId);
}
return searchWrapper.search();
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEPOLICY_UPDATE, eventDescription = "updating autoscale policy")
public AutoScalePolicy updateAutoScalePolicy(UpdateAutoScalePolicyCmd cmd) {
Long policyId = cmd.getId();
Integer duration = cmd.getDuration();
Integer quietTime = cmd.getQuietTime();
List<Long> conditionIds = cmd.getConditionIds();
AutoScalePolicyVO policy = getEntityInDatabase(CallContext.current().getCallingAccount(), "Auto Scale Policy", policyId, _autoScalePolicyDao);
if (duration != null) {
policy.setDuration(duration);
}
if (quietTime != null) {
policy.setQuietTime(quietTime);
}
List<AutoScaleVmGroupPolicyMapVO> vmGroupPolicyList = _autoScaleVmGroupPolicyMapDao.listByPolicyId(policyId);
for (AutoScaleVmGroupPolicyMapVO vmGroupPolicy : vmGroupPolicyList) {
AutoScaleVmGroupVO vmGroupVO = _autoScaleVmGroupDao.findById(vmGroupPolicy.getVmGroupId());
if (vmGroupVO == null) {
s_logger.warn("Stale database entry! There is an entry in VmGroupPolicyMap but the vmGroup is missing:" + vmGroupPolicy.getVmGroupId());
continue;
}
if (!vmGroupVO.getState().equals(AutoScaleVmGroup.State_Disabled)) {
throw new InvalidParameterValueException("The AutoScale Policy can be updated only if the Vm Group it is associated with is disabled in state");
}
if (policy.getDuration() < vmGroupVO.getInterval()) {
throw new InvalidParameterValueException("duration is less than the associated AutoScaleVmGroup's interval");
}
}
policy = checkValidityAndPersist(policy, conditionIds);
s_logger.info("Successfully updated Auto Scale Policy id:" + policyId);
return policy;
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMGROUP_CREATE, eventDescription = "creating autoscale vm group", create = true)
public AutoScaleVmGroup createAutoScaleVmGroup(CreateAutoScaleVmGroupCmd cmd) {
int minMembers = cmd.getMinMembers();
int maxMembers = cmd.getMaxMembers();
Integer interval = cmd.getInterval();
Boolean forDisplay = cmd.getDisplay();
if (interval == null) {
interval = NetUtils.DEFAULT_AUTOSCALE_POLICY_INTERVAL_TIME;
}
LoadBalancerVO loadBalancer = getEntityInDatabase(CallContext.current().getCallingAccount(), ApiConstants.LBID, cmd.getLbRuleId(), _lbDao);
Long zoneId = _ipAddressDao.findById(loadBalancer.getSourceIpAddressId()).getDataCenterId();
if (_autoScaleVmGroupDao.isAutoScaleLoadBalancer(loadBalancer.getId())) {
throw new InvalidParameterValueException("an AutoScaleVmGroup is already attached to the lb rule, the existing vm group has to be first deleted");
}
if (_lb2VmMapDao.isVmAttachedToLoadBalancer(loadBalancer.getId())) {
throw new InvalidParameterValueException(
"there are Vms already bound to the specified LoadBalancing Rule. User bound Vms and AutoScaled Vm Group cannot co-exist on a Load Balancing Rule");
}
AutoScaleVmGroupVO vmGroupVO = new AutoScaleVmGroupVO(cmd.getLbRuleId(), zoneId, loadBalancer.getDomainId(), loadBalancer.getAccountId(), minMembers, maxMembers,
loadBalancer.getDefaultPortStart(), interval, null, cmd.getProfileId(), AutoScaleVmGroup.State_New);
if (forDisplay != null) {
vmGroupVO.setDisplay(forDisplay);
}
vmGroupVO = checkValidityAndPersist(vmGroupVO, cmd.getScaleUpPolicyIds(), cmd.getScaleDownPolicyIds());
s_logger.info("Successfully created Autoscale Vm Group with Id: " + vmGroupVO.getId());
return vmGroupVO;
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMGROUP_CREATE, eventDescription = "creating autoscale vm group", async = true)
public boolean configureAutoScaleVmGroup(CreateAutoScaleVmGroupCmd cmd) throws ResourceUnavailableException {
return configureAutoScaleVmGroup(cmd.getEntityId(), AutoScaleVmGroup.State_New);
}
public boolean isLoadBalancerBasedAutoScaleVmGroup(AutoScaleVmGroup vmGroup) {
return vmGroup.getLoadBalancerId() != null;
}
private boolean configureAutoScaleVmGroup(long vmGroupid, String currentState) throws ResourceUnavailableException {
AutoScaleVmGroup vmGroup = _autoScaleVmGroupDao.findById(vmGroupid);
if (isLoadBalancerBasedAutoScaleVmGroup(vmGroup)) {
try {
return _lbRulesMgr.configureLbAutoScaleVmGroup(vmGroupid, currentState);
} catch (ResourceUnavailableException re) {
throw re;
} catch (Exception e) {
s_logger.warn("Exception during configureLbAutoScaleVmGroup in lb rules manager", e);
return false;
}
}
// This should never happen, because today loadbalancerruleid is manadatory for AutoScaleVmGroup.
throw new InvalidParameterValueException("Only LoadBalancer based AutoScale is supported");
}
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMGROUP_DELETE, eventDescription = "deleting autoscale vm group", async = true)
public boolean deleteAutoScaleVmGroup(final long id) {
AutoScaleVmGroupVO autoScaleVmGroupVO = getEntityInDatabase(CallContext.current().getCallingAccount(), "AutoScale Vm Group", id, _autoScaleVmGroupDao);
if (autoScaleVmGroupVO.getState().equals(AutoScaleVmGroup.State_New)) {
/* This condition is for handling failures during creation command */
return _autoScaleVmGroupDao.remove(id);
}
String bakupState = autoScaleVmGroupVO.getState();
autoScaleVmGroupVO.setState(AutoScaleVmGroup.State_Revoke);
_autoScaleVmGroupDao.persist(autoScaleVmGroupVO);
boolean success = false;
try {
success = configureAutoScaleVmGroup(id, bakupState);
} catch (ResourceUnavailableException e) {
autoScaleVmGroupVO.setState(bakupState);
_autoScaleVmGroupDao.persist(autoScaleVmGroupVO);
} finally {
if (!success) {
s_logger.warn("Could not delete AutoScale Vm Group id : " + id);
return false;
}
}
return Transaction.execute(new TransactionCallback<Boolean>() {
@Override
public Boolean doInTransaction(TransactionStatus status) {
boolean success = _autoScaleVmGroupDao.remove(id);
if (!success) {
s_logger.warn("Failed to remove AutoScale Group db object");
return false;
}
success = _autoScaleVmGroupPolicyMapDao.removeByGroupId(id);
if (!success) {
s_logger.warn("Failed to remove AutoScale Group Policy mappings");
return false;
}
s_logger.info("Successfully deleted autoscale vm group id : " + id);
return success; // Successfull
}
});
}
@Override
public List<? extends AutoScaleVmGroup> listAutoScaleVmGroups(ListAutoScaleVmGroupsCmd cmd) {
Long id = cmd.getId();
Long policyId = cmd.getPolicyId();
Long loadBalancerId = cmd.getLoadBalancerId();
Long profileId = cmd.getProfileId();
Long zoneId = cmd.getZoneId();
Boolean forDisplay = cmd.getDisplay();
SearchWrapper<AutoScaleVmGroupVO> searchWrapper = new SearchWrapper<AutoScaleVmGroupVO>(_autoScaleVmGroupDao, AutoScaleVmGroupVO.class, cmd, cmd.getId());
SearchBuilder<AutoScaleVmGroupVO> sb = searchWrapper.getSearchBuilder();
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
sb.and("loadBalancerId", sb.entity().getLoadBalancerId(), SearchCriteria.Op.EQ);
sb.and("profileId", sb.entity().getProfileId(), SearchCriteria.Op.EQ);
sb.and("zoneId", sb.entity().getZoneId(), SearchCriteria.Op.EQ);
sb.and("display", sb.entity().isDisplay(), SearchCriteria.Op.EQ);
if (policyId != null) {
SearchBuilder<AutoScaleVmGroupPolicyMapVO> asVmGroupPolicySearch = _autoScaleVmGroupPolicyMapDao.createSearchBuilder();
asVmGroupPolicySearch.and("policyId", asVmGroupPolicySearch.entity().getPolicyId(), SearchCriteria.Op.EQ);
sb.join("asVmGroupPolicySearch", asVmGroupPolicySearch, sb.entity().getId(), asVmGroupPolicySearch.entity().getVmGroupId(), JoinBuilder.JoinType.INNER);
}
SearchCriteria<AutoScaleVmGroupVO> sc = searchWrapper.buildSearchCriteria();
if (id != null) {
sc.setParameters("id", id);
}
if (loadBalancerId != null) {
sc.setParameters("loadBalancerId", loadBalancerId);
}
if (profileId != null) {
sc.setParameters("profileId", profileId);
}
if (zoneId != null) {
sc.setParameters("zoneId", zoneId);
}
if (policyId != null) {
sc.setJoinParameters("asVmGroupPolicySearch", "policyId", policyId);
}
if (forDisplay != null) {
sc.setParameters("display", forDisplay);
}
return searchWrapper.search();
}
@DB
protected AutoScaleVmGroupVO checkValidityAndPersist(final AutoScaleVmGroupVO vmGroup, final List<Long> passedScaleUpPolicyIds,
final List<Long> passedScaleDownPolicyIds) {
int minMembers = vmGroup.getMinMembers();
int maxMembers = vmGroup.getMaxMembers();
int interval = vmGroup.getInterval();
List<Counter> counters = new ArrayList<Counter>();
List<AutoScalePolicyVO> policies = new ArrayList<AutoScalePolicyVO>();
final List<Long> policyIds = new ArrayList<Long>();
List<Long> currentScaleUpPolicyIds = new ArrayList<Long>();
List<Long> currentScaleDownPolicyIds = new ArrayList<Long>();
if (vmGroup.getCreated() != null) {
ApiDBUtils.getAutoScaleVmGroupPolicyIds(vmGroup.getId(), currentScaleUpPolicyIds, currentScaleDownPolicyIds);
}
if (minMembers < 0) {
throw new InvalidParameterValueException(ApiConstants.MIN_MEMBERS + " is an invalid value: " + minMembers);
}
if (maxMembers < 0) {
throw new InvalidParameterValueException(ApiConstants.MAX_MEMBERS + " is an invalid value: " + maxMembers);
}
if (minMembers > maxMembers) {
throw new InvalidParameterValueException(ApiConstants.MIN_MEMBERS + " (" + minMembers + ")cannot be greater than " + ApiConstants.MAX_MEMBERS + " (" +
maxMembers + ")");
}
if (interval < 0) {
throw new InvalidParameterValueException("interval is an invalid value: " + interval);
}
if (passedScaleUpPolicyIds != null) {
policies.addAll(getAutoScalePolicies("scaleuppolicyid", passedScaleUpPolicyIds, counters, interval, true));
policyIds.addAll(passedScaleUpPolicyIds);
} else {
// Run the interval check for existing policies
getAutoScalePolicies("scaleuppolicyid", currentScaleUpPolicyIds, counters, interval, true);
policyIds.addAll(currentScaleUpPolicyIds);
}
if (passedScaleDownPolicyIds != null) {
policies.addAll(getAutoScalePolicies("scaledownpolicyid", passedScaleDownPolicyIds, counters, interval, false));
policyIds.addAll(passedScaleDownPolicyIds);
} else {
// Run the interval check for existing policies
getAutoScalePolicies("scaledownpolicyid", currentScaleDownPolicyIds, counters, interval, false);
policyIds.addAll(currentScaleDownPolicyIds);
}
AutoScaleVmProfileVO profileVO =
getEntityInDatabase(CallContext.current().getCallingAccount(), ApiConstants.VMPROFILE_ID, vmGroup.getProfileId(), _autoScaleVmProfileDao);
LoadBalancerVO loadBalancer = getEntityInDatabase(CallContext.current().getCallingAccount(), ApiConstants.LBID, vmGroup.getLoadBalancerId(), _lbDao);
validateAutoScaleCounters(loadBalancer.getNetworkId(), counters, profileVO.getCounterParams());
ControlledEntity[] sameOwnerEntities = policies.toArray(new ControlledEntity[policies.size() + 2]);
sameOwnerEntities[sameOwnerEntities.length - 2] = loadBalancer;
sameOwnerEntities[sameOwnerEntities.length - 1] = profileVO;
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, sameOwnerEntities);
return Transaction.execute(new TransactionCallback<AutoScaleVmGroupVO>() {
@Override
public AutoScaleVmGroupVO doInTransaction(TransactionStatus status) {
AutoScaleVmGroupVO vmGroupNew = _autoScaleVmGroupDao.persist(vmGroup);
if (passedScaleUpPolicyIds != null || passedScaleDownPolicyIds != null) {
_autoScaleVmGroupPolicyMapDao.removeByGroupId(vmGroupNew.getId());
for (Long policyId : policyIds) {
_autoScaleVmGroupPolicyMapDao.persist(new AutoScaleVmGroupPolicyMapVO(vmGroupNew.getId(), policyId));
}
}
return vmGroupNew;
}
});
}
@Override