cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pran...@apache.org
Subject [9/50] git commit: enable Autoscale VMs to be named as Autoscale-LB-<lbname>
Date Fri, 16 Nov 2012 10:00:31 GMT
enable Autoscale VMs to be named as Autoscale-LB-<lbname>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/35b0e086
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/35b0e086
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/35b0e086

Branch: refs/heads/master
Commit: 35b0e086d40db75094761f0aeb86aa3342244e23
Parents: 5741618
Author: Vijay Vekatachalam <vijay.venkatachalam@citrix.com>
Authored: Thu Sep 27 20:17:09 2012 +0530
Committer: Vijay Venkatachalam <vijay.venkatachalam@citrix.com>
Committed: Fri Nov 16 10:56:59 2012 +0530

----------------------------------------------------------------------
 api/src/com/cloud/agent/api/to/LoadBalancerTO.java |   14 ++++++++++----
 .../com/cloud/network/lb/LoadBalancingRule.java    |    8 +++++++-
 .../cloud/network/resource/NetscalerResource.java  |    9 +++++----
 .../network/lb/LoadBalancingRulesManagerImpl.java  |   11 +++++++----
 setup/db/create-schema.sql                         |    2 +-
 5 files changed, 30 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/35b0e086/api/src/com/cloud/agent/api/to/LoadBalancerTO.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/to/LoadBalancerTO.java b/api/src/com/cloud/agent/api/to/LoadBalancerTO.java
index be366a1..1a8093c 100644
--- a/api/src/com/cloud/agent/api/to/LoadBalancerTO.java
+++ b/api/src/com/cloud/agent/api/to/LoadBalancerTO.java
@@ -288,10 +288,11 @@ public class LoadBalancerTO {
         private final String cloudStackApiUrl;
         private final String autoScaleUserApiKey;
         private final String autoScaleUserSecretKey;
+        private final String vmName;
         private final String networkId;
 
         public AutoScaleVmProfileTO(String zoneId, String domainId, String cloudStackApiUrl,
String autoScaleUserApiKey, String autoScaleUserSecretKey, String serviceOfferingId,
-                String templateId, String networkId, String otherDeployParams, String snmpCommunity,
Integer snmpPort, Integer destroyVmGraceperiod) {
+                String templateId, String vmName, String networkId, String otherDeployParams,
String snmpCommunity, Integer snmpPort, Integer destroyVmGraceperiod) {
             this.zoneId = zoneId;
             this.domainId = domainId;
             this.serviceOfferingId = serviceOfferingId;
@@ -303,6 +304,7 @@ public class LoadBalancerTO {
             this.cloudStackApiUrl = cloudStackApiUrl;
             this.autoScaleUserApiKey = autoScaleUserApiKey;
             this.autoScaleUserSecretKey = autoScaleUserSecretKey;
+            this.vmName = vmName;
             this.networkId = networkId;
         }
 
@@ -350,6 +352,10 @@ public class LoadBalancerTO {
             return autoScaleUserSecretKey;
         }
 
+        public String getVmName() {
+            return vmName;
+        }
+
         public String getNetworkId() {
             return networkId;
         }
@@ -434,9 +440,9 @@ public class LoadBalancerTO {
 
         AutoScaleVmProfileTO autoScaleVmProfileTO = new AutoScaleVmProfileTO(lbAutoScaleVmProfile.getZoneId(),
lbAutoScaleVmProfile.getDomainId(),
                 lbAutoScaleVmProfile.getCsUrl(), lbAutoScaleVmProfile.getAutoScaleUserApiKey(),
lbAutoScaleVmProfile.getAutoScaleUserSecretKey(),
-                lbAutoScaleVmProfile.getServiceOfferingId(), lbAutoScaleVmProfile.getTemplateId(),
lbAutoScaleVmProfile.getNetworkId(),
-                autoScaleVmProfile.getOtherDeployParams(), autoScaleVmProfile.getSnmpCommunity(),
autoScaleVmProfile.getSnmpPort(),
-                autoScaleVmProfile.getDestroyVmGraceperiod());
+                lbAutoScaleVmProfile.getServiceOfferingId(), lbAutoScaleVmProfile.getTemplateId(),
lbAutoScaleVmProfile.getVmName(),
+                lbAutoScaleVmProfile.getNetworkId(),autoScaleVmProfile.getOtherDeployParams(),
autoScaleVmProfile.getSnmpCommunity(),
+                autoScaleVmProfile.getSnmpPort(), autoScaleVmProfile.getDestroyVmGraceperiod());
 
         AutoScaleVmGroup autoScaleVmGroup = lbAutoScaleVmGroup.getVmGroup();
         autoScaleVmGroupTO = new AutoScaleVmGroupTO(autoScaleVmGroup.getMinMembers(), autoScaleVmGroup.getMaxMembers(),
autoScaleVmGroup.getMemberPort(),

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/35b0e086/api/src/com/cloud/network/lb/LoadBalancingRule.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/lb/LoadBalancingRule.java b/api/src/com/cloud/network/lb/LoadBalancingRule.java
index f262ad5..186ea56 100644
--- a/api/src/com/cloud/network/lb/LoadBalancingRule.java
+++ b/api/src/com/cloud/network/lb/LoadBalancingRule.java
@@ -307,8 +307,9 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer {
         private final String serviceOfferingId;
         private final String templateId;
         private final String networkId;
+        private final String vmName;
 
-        public LbAutoScaleVmProfile(AutoScaleVmProfile profile, String autoScaleUserApiKey,
String autoScaleUserSecretKey, String csUrl, String zoneId, String domainId, String serviceOfferingId,
String templateId, String networkId) {
+        public LbAutoScaleVmProfile(AutoScaleVmProfile profile, String autoScaleUserApiKey,
String autoScaleUserSecretKey, String csUrl, String zoneId, String domainId, String serviceOfferingId,
String templateId, String vmName, String networkId) {
             this.profile = profile;
             this.autoScaleUserApiKey = autoScaleUserApiKey;
             this.autoScaleUserSecretKey = autoScaleUserSecretKey;
@@ -317,6 +318,7 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer {
             this.domainId = domainId;
             this.serviceOfferingId = serviceOfferingId;
             this.templateId = templateId;
+            this.vmName = vmName;
             this.networkId = networkId;
         }
 
@@ -352,6 +354,10 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer
{
             return templateId;
         }
 
+        public String getVmName() {
+            return vmName;
+        }
+
         public String getNetworkId() {
             return networkId;
         }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/35b0e086/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
index fa72dfc..88e347f 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
@@ -240,11 +240,11 @@ public class NetscalerResource implements ServerResource {
     private void logout() throws ExecutionException {
         try {
             if (!_isSdx) {
-                if (_netscalerService != null) {
+                if(_netscalerService != null) {
                     _netscalerService.logout();
                 }
             } else {
-                if (_netscalerSdxService != null) {
+                if(_netscalerSdxService != null) {
                     _netscalerSdxService.logout();
                 }
             }
@@ -1569,11 +1569,11 @@ public class NetscalerResource implements ServerResource {
         String nsVirtualServerName  = generateNSVirtualServerName(srcIp, srcPort);
         String serviceGroupName = generateAutoScaleServiceGroupName(vmGroupIdentifier);
 
-        if (loadBalancerTO.getAutoScaleVmGroupTO().getCurrentState().equals("enabled")) {
+        if(loadBalancerTO.getAutoScaleVmGroupTO().getCurrentState().equals("enabled")) {
             disableAutoScaleConfig(loadBalancerTO, false);
         }
 
-        if (isServiceGroupBoundToVirtualServer(nsVirtualServerName, serviceGroupName)) {
+        if(isServiceGroupBoundToVirtualServer(nsVirtualServerName, serviceGroupName)) {
             // UnBind autoscale service group
             // unbind lb vserver lb lb_autoscaleGroup
             lbvserver_servicegroup_binding vserver_servicegroup_binding = new lbvserver_servicegroup_binding();
@@ -1713,6 +1713,7 @@ public class NetscalerResource implements ServerResource {
                 ApiConstants.ZONE_ID + "=" + profileTO.getZoneId()+ "&" +
                 ApiConstants.SERVICE_OFFERING_ID + "=" + profileTO.getServiceOfferingId()+
"&" +
                 ApiConstants.TEMPLATE_ID + "=" + profileTO.getTemplateId()+ "&" +
+                ApiConstants.DISPLAY_NAME + "=" + profileTO.getVmName()+ "&" +
                 ((profileTO.getNetworkId() == null)? "" : (ApiConstants.NETWORK_IDS + "="
+ profileTO.getNetworkId()+ "&")) +
                 ((profileTO.getOtherDeployParams() == null)? "" : (profileTO.getOtherDeployParams()
+ "&")) +
                 "lbruleid=" + loadBalancerTO.getUuid();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/35b0e086/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
index 52bb98a..49b3949 100755
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@ -251,7 +251,9 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
         }
         return null;
     }
-    private LbAutoScaleVmGroup getLbAutoScaleVmGroup(AutoScaleVmGroupVO vmGroup, String currentState,
long networkId) {
+    private LbAutoScaleVmGroup getLbAutoScaleVmGroup(AutoScaleVmGroupVO vmGroup, String currentState,
LoadBalancerVO lb) {
+        long lbNetworkId = lb.getNetworkId();
+        String lbName = lb.getName();
         List<AutoScaleVmGroupPolicyMapVO> vmGroupPolicyMapList = _autoScaleVmGroupPolicyMapDao.listByVmGroupId(vmGroup.getId());
         List<LbAutoScalePolicy> autoScalePolicies = new ArrayList<LbAutoScalePolicy>();
         for (AutoScaleVmGroupPolicyMapVO vmGroupPolicyMap : vmGroupPolicyMapList) {
@@ -275,6 +277,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
         String domainId = _domainDao.findById(autoScaleVmProfile.getDomainId()).getUuid();
         String serviceOfferingId = _offeringsDao.findById(autoScaleVmProfile.getServiceOfferingId()).getUuid();
         String templateId = _templateDao.findById(autoScaleVmProfile.getTemplateId()).getUuid();
+        String vmName = "AutoScale-LB-" + lbName;
         String lbNetworkUuid = null;
 
         DataCenter zone = _configMgr.getZone(vmGroup.getZoneId());
@@ -284,7 +287,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
             throw new InvalidParameterValueException("Unable to find zone");
         } else {
             if (zone.getNetworkType() == NetworkType.Advanced) {
-                NetworkVO lbNetwork = _networkDao.findById(networkId);
+                NetworkVO lbNetwork = _networkDao.findById(lbNetworkId);
                 lbNetworkUuid = lbNetwork.getUuid();
             }
         }
@@ -303,12 +306,12 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
         }
 
 
-        LbAutoScaleVmProfile lbAutoScaleVmProfile = new LbAutoScaleVmProfile(autoScaleVmProfile,
apiKey, secretKey, csUrl, zoneId, domainId, serviceOfferingId, templateId, lbNetworkUuid);
+        LbAutoScaleVmProfile lbAutoScaleVmProfile = new LbAutoScaleVmProfile(autoScaleVmProfile,
apiKey, secretKey, csUrl, zoneId, domainId, serviceOfferingId, templateId, vmName, lbNetworkUuid);
         return new LbAutoScaleVmGroup(vmGroup, autoScalePolicies, lbAutoScaleVmProfile, currentState);
     }
 
     private boolean applyAutoScaleConfig(LoadBalancerVO lb, AutoScaleVmGroupVO vmGroup, String
currentState) throws ResourceUnavailableException {
-        LbAutoScaleVmGroup lbAutoScaleVmGroup = getLbAutoScaleVmGroup(vmGroup, currentState,
lb.getNetworkId());
+        LbAutoScaleVmGroup lbAutoScaleVmGroup = getLbAutoScaleVmGroup(vmGroup, currentState,
lb);
         /* Regular config like destinations need not be packed for applying autoscale config
as of today.*/
         LoadBalancingRule rule = new LoadBalancingRule(lb, null, null);
         rule.setAutoScaleVmGroup(lbAutoScaleVmGroup);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/35b0e086/setup/db/create-schema.sql
----------------------------------------------------------------------
diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql
index e517cda..6997c3c 100755
--- a/setup/db/create-schema.sql
+++ b/setup/db/create-schema.sql
@@ -2508,6 +2508,6 @@ CREATE TABLE `cloud`.`autoscale_vmgroup_policy_map` (
 INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (1,'snmp','Linux User
CPU - percentage', '1.3.6.1.4.1.2021.11.9.0', now());
 INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (2,'snmp','Linux System
CPU - percentage', '1.3.6.1.4.1.2021.11.10.0', now());
 INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (3,'snmp','Linux CPU
Idle - percentage', '1.3.6.1.4.1.2021.11.11.0', now());
-INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (100,'netscaler','Response
Time - microseconds)', 'RESPTIME', now());
+INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (100,'netscaler','Response
Time - microseconds', 'RESPTIME', now());
 
 SET foreign_key_checks = 1;


Mime
View raw message