cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anim...@apache.org
Subject [3/4] git commit: updated refs/heads/4.3 to fd39184
Date Tue, 28 Jan 2014 22:06:39 GMT
CLOUDSTACK-5966 Added enable/disable monitoring service in global config
(cherry picked from commit 782265e713d5eaa41ca3d6040d8994639ddbce10)

Signed-off-by: Animesh Chaturvedi <animesh@apache.org>


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

Branch: refs/heads/4.3
Commit: 63e839c0f8852d08ff8f08a47a45075ea8e93fb2
Parents: 3fa300b
Author: Jayapal <jayapal@apache.org>
Authored: Tue Jan 28 19:20:44 2014 +0530
Committer: Animesh Chaturvedi <animesh@apache.org>
Committed: Tue Jan 28 13:31:37 2014 -0800

----------------------------------------------------------------------
 .../api/routing/NetworkElementCommand.java      |  2 ++
 .../virtualnetwork/VirtualRoutingResource.java  |  9 ++++--
 .../vmware/resource/VmwareResource.java         |  4 +++
 .../xen/resource/CitrixResourceBase.java        |  5 ++++
 server/src/com/cloud/configuration/Config.java  |  1 +
 .../VirtualNetworkApplianceManagerImpl.java     | 16 +++++++++--
 setup/db/db/schema-421to430.sql                 |  1 +
 .../config/opt/cloud/bin/monitor_service.sh     | 29 ++++++++++++++++++--
 8 files changed, 60 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63e839c0/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 843d213..23b75fd 100644
--- a/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
+++ b/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
@@ -34,6 +34,8 @@ 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_DISABLE = "router.monitor.disable";
+
 
 
     protected NetworkElementCommand() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63e839c0/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 0eac223..035a5b3 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -821,9 +821,12 @@ public class VirtualRoutingResource implements Manager {
         return new ConsoleProxyLoadAnswer(cmd, proxyVmId, proxyVmName, success, result);
     }
 
-    public String configureMonitor(final String routerIP, final String config) {
+    public String configureMonitor(final String routerIP, final String config, final String
disable) {
 
         String args= " -c " + config;
+        if (disable != null) {
+            args = args + "-d";
+        }
         return  routerProxy("monitor_service.sh", routerIP, args);
     }
 
@@ -968,9 +971,11 @@ public class VirtualRoutingResource implements Manager {
     private Answer execute(SetMonitorServiceCommand cmd) {
 
         String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
+        String disable =  cmd.getAccessDetail(NetworkElementCommand.ROUTER_MONITORING_DISABLE);
         String config = cmd.getConfiguration();
 
-        String result = configureMonitor(routerIp, config);
+
+        String result = configureMonitor(routerIp, config, disable);
 
         if (result != null) {
             return new Answer(cmd, false, "SetMonitorServiceCommand failed");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63e839c0/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 1d4c43f..41191f9 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -806,10 +806,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
 
         String controlIp = getRouterSshControlIp(cmd);
         String config = cmd.getConfiguration();
+        String disable =  cmd.getAccessDetail(NetworkElementCommand.ROUTER_MONITORING_DISABLE);
 
         String args = "";
 
         args += " -c " + config;
+        if (disable != null) {
+            args = args + " -d ";
+        }
 
         try {
             VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63e839c0/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index aaa97bf..548223f 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -7585,6 +7585,7 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
 
         Connection conn = getConnection();
         String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
+        String disable =  cmd.getAccessDetail(NetworkElementCommand.ROUTER_MONITORING_DISABLE);
 
         if (routerIp == null) {
             return new Answer(cmd);
@@ -7592,6 +7593,10 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
 
         String args = "monitor_service.sh " + routerIp;
         args += " -c " + config;
+        if (disable != null) {
+            args += " -d ";
+        }
+
 
         String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
         if (result == null || result.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63e839c0/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 d2713c0..da79995 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -105,6 +105,7 @@ public enum Config {
 	SecurityGroupDefaultAdding("Network", ManagementServer.class, Boolean.class, "network.securitygroups.defaultadding",
"true", "If true, the user VM would be added to the default security group by default", null),
 
 	GuestOSNeedGatewayOnNonDefaultNetwork("Network", NetworkOrchestrationService.class, String.class,
"network.dhcp.nondefaultnetwork.setgateway.guestos", "Windows", "The guest OS's name start
with this fields would result in DHCP server response gateway information even when the network
it's on is not default network. Names are separated by comma.", null),
+    EnableServiceMonitoring("Network", ManagementServer.class, Boolean.class, "network.router.enableserviceMonitoring",
"false", "service monitoring in router enable/disable option, default false", null),
 
 	//VPN
 	RemoteAccessVpnPskLength("Network", AgentManager.class, Integer.class, "remote.access.vpn.psk.length",
"24", "The length of the ipsec preshared key (minimum 8, maximum 256)", null),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63e839c0/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 af7ef83..c372e7b 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -2223,12 +2223,20 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
 
             finalizeUserDataAndDhcpOnStart(cmds, router, provider, guestNetworkId);
         }
-        finalizeMonitorServiceOnStrat(cmds, profile, router, provider, routerGuestNtwkIds.get(0));
+
+        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(Commands cmds, VirtualMachineProfile profile,
DomainRouterVO router, Provider provider, long networkId) {
+    private void finalizeMonitorServiceOnStrat(Commands cmds, VirtualMachineProfile profile,
DomainRouterVO router, Provider provider, long networkId, Boolean add) {
 
         NetworkVO network = _networkDao.findById(networkId);
 
@@ -2270,6 +2278,10 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
         command.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, getRouterIpInNetwork(networkId,
router.getId()));
         command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
 
+        if (!add) {
+            command.setAccessDetail(NetworkElementCommand.ROUTER_MONITORING_DISABLE, add.toString());
+        }
+
         cmds.addCommand("monitor", command);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63e839c0/setup/db/db/schema-421to430.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-421to430.sql b/setup/db/db/schema-421to430.sql
index 4f8a52e..1ed6c6b 100644
--- a/setup/db/db/schema-421to430.sql
+++ b/setup/db/db/schema-421to430.sql
@@ -1089,4 +1089,5 @@ CREATE VIEW `cloud`.`user_vm_view` AS
            left join
         `cloud`.`user_vm_details` `custom_ram_size`  ON (((`custom_ram_size`.`vm_id` = `cloud`.`vm_instance`.`id`)
and (`custom_ram_size`.`name` = 'memory')));
 
+INSERT INTO `cloud`.`configuration`(category, instance, component, name, value, description,
default_value) VALUES ('NetworkManager', 'DEFAULT', 'management-server', 'network.router.EnableServiceMonitoring',
'false', 'service monitoring in router enable/disable option, default false', 'false') ON
DUPLICATE KEY UPDATE category='NetworkManager';
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63e839c0/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..809c5b7 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/monitor_service.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/monitor_service.sh
@@ -25,7 +25,7 @@ then
     exit 1
 fi
 
-set -x
+#set -x
 usage() {
   printf "Usage: %s: -c config string \n" $(basename $0) >&2
 }
@@ -58,13 +58,36 @@ 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


Mime
View raw message