Updated Branches:
  refs/heads/master b86d45b00 -> 11c5574b0

CLOUDSTACK-5966 enable/disable global setting for service monitor in VR


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

Branch: refs/heads/master
Commit: 11c5574b054005d3b97d1835876514fd734d1337
Parents: b86d45b
Author: Jayapal <jaya...@apache.org>
Authored: Tue Feb 11 15:35:02 2014 +0530
Committer: Jayapal <jaya...@apache.org>
Committed: Tue Feb 11 15:35:02 2014 +0530

----------------------------------------------------------------------
 .../api/routing/NetworkElementCommand.java      |  1 +
 .../virtualnetwork/VirtualRoutingResource.java  |  6 +++++
 server/src/com/cloud/configuration/Config.java  |  6 +++++
 .../router/VirtualNetworkApplianceManager.java  |  4 +++
 .../VirtualNetworkApplianceManagerImpl.java     | 20 ++++++++++++---
 setup/db/db/schema-430to440.sql                 |  3 +++
 .../config/opt/cloud/bin/monitor_service.sh     | 27 ++++++++++++++++++--
 7 files changed, 62 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/11c5574b/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java 
b/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
index 217e962..205784b 100644
--- a/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
+++ b/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
@@ -34,6 +34,7 @@ public abstract class NetworkElementCommand extends Command {
     public static final String GUEST_BRIDGE = "guest.bridge";
     public static final String VPC_PRIVATE_GATEWAY = "vpc.gateway.private";
     public static final String FIREWALL_EGRESS_DEFAULT = 
"firewall.egress.default";
+    public static final String ROUTER_MONITORING_ENABLE = 
"router.monitor.enable";
 
     private String routerAccessIp;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/11c5574b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git 
a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java 
b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index a11261e..3efbe33 100755
--- 
a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ 
b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -605,8 +605,14 @@ public class VirtualRoutingResource {
 
     protected Answer execute(SetMonitorServiceCommand cmd) {
         String config = cmd.getConfiguration();
+        String disableMonitoring =  
cmd.getAccessDetail(NetworkElementCommand.ROUTER_MONITORING_ENABLE);
+
 
         String args = " -c " + config;
+        if (disableMonitoring != null) {
+            args = args + " -d";
+        }
+
         ExecutionResult result = 
_vrDeployer.executeInVR(cmd.getRouterAccessIp(), "monitor_service.sh", args);
 
         if (!result.isSuccess()) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/11c5574b/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java 
b/server/src/com/cloud/configuration/Config.java
index 975eecd..98e5d34 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -407,6 +407,12 @@ public enum Config {
             "vm.network.nic.max.secondary.ipaddresses", "256",
             "Specify the number of secondary ip addresses per nic per vm", 
null),
 
+    EnableServiceMonitoring(
+            "Network", ManagementServer.class, Boolean.class,
+            "network.router.enableserviceMonitoring", "false",
+            "service monitoring in router enable/disable option, default 
false", null),
+
+
     // Console Proxy
     ConsoleProxyCapacityStandby(
             "Console Proxy",

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/11c5574b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java
----------------------------------------------------------------------
diff --git 
a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java 
b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java
index e838530..9097b87 100644
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java
@@ -50,6 +50,7 @@ public interface VirtualNetworkApplianceManager extends 
Manager, VirtualNetworkA
     static final String RouterTemplateVmwareCK = "router.template.vmware";
     static final String RouterTemplateHyperVCK = "router.template.hyperv";
     static final String RouterTemplateLxcCK = "router.template.lxc";
+    static final String SetServiceMonitorCK = 
"network.router.EnableServiceMonitoring";
 
     static final ConfigKey<String> RouterTemplateXen = new 
ConfigKey<String>(String.class, RouterTemplateXenCK, "Advanced", "SystemVM 
Template (XenServer)",
         "Name of the default router template on Xenserver.", true, 
ConfigKey.Scope.Zone, null);
@@ -62,6 +63,9 @@ public interface VirtualNetworkApplianceManager extends 
Manager, VirtualNetworkA
     static final ConfigKey<String> RouterTemplateLxc = new 
ConfigKey<String>(String.class, RouterTemplateLxcCK, "Advanced", "SystemVM 
Template (LXC)",
         "Name of the default router template on LXC.", true, 
ConfigKey.Scope.Zone, null);
 
+    static final ConfigKey<String> SetServiceMonitor = new 
ConfigKey<String>(String.class, SetServiceMonitorCK, "Advanced", "true",
+            "service monitoring in router enable/disable option, default 
true", true, ConfigKey.Scope.Zone, null);
+
     public static final int DEFAULT_ROUTER_VM_RAMSIZE = 128;            // 128M
     public static final int DEFAULT_ROUTER_CPU_MHZ = 500;                // 
500 MHz
     public static final boolean USE_POD_VLAN = false;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/11c5574b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java 
b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 734fc5b..c241aac 100755
--- 
a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ 
b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -2327,12 +2327,23 @@ Listener, Configurable {
 
             finalizeUserDataAndDhcpOnStart(cmds, router, provider, 
guestNetworkId);
         }
-        finalizeMonitorServiceOnStrat(cmds, profile, router, provider, 
routerGuestNtwkIds.get(0));
+
+
+        String serviceMonitringSet = 
SetServiceMonitor.valueIn(router.getDataCenterId());
+        //String serviceMonitringSet = 
_configDao.getValue(Config.EnableServiceMonitoring.key());
+
+        if (serviceMonitringSet != null && 
serviceMonitringSet.equalsIgnoreCase("true")) {
+            finalizeMonitorServiceOnStrat(cmds, profile, router, provider, 
routerGuestNtwkIds.get(0), true);
+        } else {
+            finalizeMonitorServiceOnStrat(cmds, profile, router, provider, 
routerGuestNtwkIds.get(0), false);
+        }
+
+
 
         return true;
     }
 
-    private void finalizeMonitorServiceOnStrat(final Commands cmds, final 
VirtualMachineProfile profile, final DomainRouterVO router, final Provider 
provider, final long networkId) {
+    private void finalizeMonitorServiceOnStrat(Commands cmds, 
VirtualMachineProfile profile, DomainRouterVO router, Provider provider, long 
networkId, Boolean add) {
 
         final NetworkVO network = _networkDao.findById(networkId);
 
@@ -2373,6 +2384,9 @@ Listener, Configurable {
         command.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, 
getRouterIpInNetwork(networkId, router.getId()));
         command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, 
router.getInstanceName());
 
+        if (!add) {
+            
command.setAccessDetail(NetworkElementCommand.ROUTER_MONITORING_ENABLE, 
add.toString());
+        }
         cmds.addCommand("monitor", command);
     }
 
@@ -4212,6 +4226,6 @@ Listener, Configurable {
 
     @Override
     public ConfigKey<?>[] getConfigKeys() {
-        return new ConfigKey<?>[] {UseExternalDnsServers, 
routerVersionCheckEnabled};
+        return new ConfigKey<?>[] {UseExternalDnsServers, 
routerVersionCheckEnabled, SetServiceMonitor};
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/11c5574b/setup/db/db/schema-430to440.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-430to440.sql b/setup/db/db/schema-430to440.sql
index d1d0d06..c584836 100644
--- a/setup/db/db/schema-430to440.sql
+++ b/setup/db/db/schema-430to440.sql
@@ -468,6 +468,7 @@ CREATE TABLE `cloud`.`autoscale_vmgroup_details` (
   CONSTRAINT `fk_autoscale_vmgroup_details__autoscale_vmgroup_id` FOREIGN KEY 
`fk_autoscale_vmgroup_details__autoscale_vmgroup_id`(`autoscale_vmgroup_id`) 
REFERENCES `autoscale_vmgroups`(`id`) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+<<<<<<< Updated upstream
 ALTER TABLE `cloud`.`snapshot_details` ADD COLUMN `display` tinyint(1) NOT 
NULL DEFAULT '1' COMMENT 'True if the detail can be displayed to the end user';
 ALTER TABLE `cloud`.`vm_snapshot_details` ADD COLUMN `display` tinyint(1) NOT 
NULL DEFAULT '1' COMMENT 'True if the detail can be displayed to the end user';
 
@@ -527,3 +528,5 @@ UPDATE `cloud`.`vpc_details` set `display`=1 where id> 0;
 
 ALTER TABLE `cloud`.`vpc_gateway_details` CHANGE `display` `display` 
tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the detail can be displayed to 
the end user';
 UPDATE `cloud`.`vpc_gateway_details` set `display`=1 where id> 0;
+=======
+>>>>>>> Stashed changes

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/11c5574b/systemvm/patches/debian/config/opt/cloud/bin/monitor_service.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/monitor_service.sh 
b/systemvm/patches/debian/config/opt/cloud/bin/monitor_service.sh
index 51b6923..a5e704d 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/monitor_service.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/monitor_service.sh
@@ -57,14 +57,37 @@ done
 }
 
 config=$2
+if [ -n "$3" ]
+then
 
 #delete cron job before updating config file
-crontab -l | grep -v  monitorServices.py | crontab -
+crontab -l|grep "monitorServices.py"
+
+if [ $? -eq 0 ]
+then
+    t=`date +%s`;
+    touch /tmp/monitor-$t.txt;
+    conf=/tmp/monitor-$t.txt
+    crontab -l >$conf
+    sed -i /#monitoringConfig/,+3d $conf
+    crontab $conf
+    rm $conf
+fi
+
+
+logger -t cloud "deleted crontab entry for monitoring services"
+unlock_exit 0 $lock $locked
+fi
 
 create_config $config
 
 #add cron job
-(crontab -l ;echo -e 
"SHELL=/bin/bash\nPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin\n
 */3 * * * * /usr/bin/python /root/monitorServices.py") | crontab -
+crontab -l|grep "monitorServices.py"
+if [ $? -ne 0 ]
+   then
+      (crontab -l ;echo -e 
"#monitoringConfig\nSHELL=/bin/bash\nPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin\n
 */3 * * * * /usr/bin/python /root/monitorServices.py") | crontab -
+      logger -t cloud "added crontab entry for monitoring services"
+fi
 
 
 unlock_exit 0 $lock $locked

Reply via email to