[cloudstack] 10/22: CLOUDSTACK-10013: Make the generated VR/json files unique (ports #1470)
This is an automated email from the ASF dual-hosted git repository. rohit pushed a commit to branch debian9-systemvmtemplate in repository https://gitbox.apache.org/repos/asf/cloudstack.git commit 551e11cf3ef6e386deaac075ff9afdff93d1cd40 Author: Remi BergsmaAuthorDate: Sat Dec 2 23:19:14 2017 +0530 CLOUDSTACK-10013: Make the generated VR/json files unique (ports #1470) This ports PR #1470 by @remibergsma. Make the generated json files unique to prevent concurrency issues: The json files now have UUIDs to prevent them from getting overwritten before they've been executed. Prevents config to be pushed to the wrong router. 2016-02-25 18:32:23,797 DEBUG [c.c.a.t.Request] (AgentManager-Handler-1:null) (logid:) Seq 2-4684025087442026584: Processing: { Ans: , MgmtId: 90520732674657, via: 2, Ver: v1, Flags: 10, [{"com.cloud.agent.api.routing.GroupA nswer":{"results":["null - success: null","null - success: [INFO] update_config.py :: Processing incoming file => vm_dhcp_entry.json.4ea45061-2efb-4467-8eaa-db3d77fb0a7b\n[INFO] Processing JSON file vm_dhcp_entry.json.4ea4506 1-2efb-4467-8eaa-db3d77fb0a7b\n"],"result":true,"wait":0}}] } On the router: 2016-02-25 18:32:23,416 merge.py __moveFile:298 Processed file written to /var/cache/cloud/processed/vm_dhcp_entry.json.4ea45061-2efb-4467-8eaa-db3d77fb0a7b.gz Signed-off-by: Rohit Yadav --- .../facade/AbstractConfigItemFacade.java | 21 +- .../kvm/resource/LibvirtComputingResource.java | 5 + systemvm/patches/debian/etc/rc.local | 9 - systemvm/patches/debian/opt/cloud/bin/configure.py | 221 + systemvm/patches/debian/opt/cloud/bin/merge.py | 37 ++-- .../patches/debian/opt/cloud/bin/update_config.py | 22 +- 6 files changed, 160 insertions(+), 155 deletions(-) diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java b/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java index f017384..a083012 100644 --- a/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java +++ b/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java @@ -22,6 +22,8 @@ package com.cloud.agent.resource.virtualnetwork.facade; import java.util.Hashtable; import java.util.LinkedList; import java.util.List; +import java.util.UUID; +import org.apache.log4j.Logger; import com.cloud.agent.api.BumpUpPriorityCommand; import com.cloud.agent.api.SetupGuestNetworkCommand; @@ -58,6 +60,8 @@ import com.google.gson.GsonBuilder; public abstract class AbstractConfigItemFacade { +private static final Logger s_logger = Logger.getLogger(AbstractConfigItemFacade.class); + private final static Gson gson; private static Hashtable flyweight = new Hashtable (); @@ -104,13 +108,26 @@ public abstract class AbstractConfigItemFacade { return instance; } +private static String appendUuidToJsonFiles(final String filename) { +String remoteFileName = new String(filename); +if (remoteFileName.endsWith("json")) { +remoteFileName += "." + UUID.randomUUID().toString(); +} +return remoteFileName; +} + protected List generateConfigItems(final ConfigBase configuration) { final List cfg = new LinkedList<>(); -final ConfigItem configFile = new FileConfigItem(VRScripts.CONFIG_PERSIST_LOCATION, destinationFile, gson.toJson(configuration)); +final String remoteFilename = appendUuidToJsonFiles(destinationFile); +if (s_logger.isDebugEnabled()) { +s_logger.debug("Transformed filename: " + destinationFile + " to: " + remoteFilename); +} + +final ConfigItem configFile = new FileConfigItem(VRScripts.CONFIG_PERSIST_LOCATION, remoteFilename, gson.toJson(configuration)); cfg.add(configFile); -final ConfigItem updateCommand = new ScriptConfigItem(VRScripts.UPDATE_CONFIG, destinationFile); +final ConfigItem updateCommand = new ScriptConfigItem(VRScripts.UPDATE_CONFIG, remoteFilename); cfg.add(updateCommand); return cfg; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index d2cbcba..7e68ed3 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -332,6 +332,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv if (details == null) { details = parser.getLines(); } + +
[cloudstack] 10/22: CLOUDSTACK-10013: Make the generated VR/json files unique (ports #1470)
This is an automated email from the ASF dual-hosted git repository. rohit pushed a commit to branch debian9-systemvmtemplate in repository https://gitbox.apache.org/repos/asf/cloudstack.git commit b9dc9fa5ab85564c500a8ae2f86b7aabeb93c50a Author: Remi BergsmaAuthorDate: Sat Dec 2 23:19:14 2017 +0530 CLOUDSTACK-10013: Make the generated VR/json files unique (ports #1470) This ports PR #1470 by @remibergsma. Make the generated json files unique to prevent concurrency issues: The json files now have UUIDs to prevent them from getting overwritten before they've been executed. Prevents config to be pushed to the wrong router. 2016-02-25 18:32:23,797 DEBUG [c.c.a.t.Request] (AgentManager-Handler-1:null) (logid:) Seq 2-4684025087442026584: Processing: { Ans: , MgmtId: 90520732674657, via: 2, Ver: v1, Flags: 10, [{"com.cloud.agent.api.routing.GroupA nswer":{"results":["null - success: null","null - success: [INFO] update_config.py :: Processing incoming file => vm_dhcp_entry.json.4ea45061-2efb-4467-8eaa-db3d77fb0a7b\n[INFO] Processing JSON file vm_dhcp_entry.json.4ea4506 1-2efb-4467-8eaa-db3d77fb0a7b\n"],"result":true,"wait":0}}] } On the router: 2016-02-25 18:32:23,416 merge.py __moveFile:298 Processed file written to /var/cache/cloud/processed/vm_dhcp_entry.json.4ea45061-2efb-4467-8eaa-db3d77fb0a7b.gz Signed-off-by: Rohit Yadav --- .../facade/AbstractConfigItemFacade.java | 21 +- .../kvm/resource/LibvirtComputingResource.java | 5 + systemvm/patches/debian/etc/rc.local | 9 - systemvm/patches/debian/opt/cloud/bin/configure.py | 220 + systemvm/patches/debian/opt/cloud/bin/merge.py | 37 ++-- .../patches/debian/opt/cloud/bin/update_config.py | 22 ++- 6 files changed, 159 insertions(+), 155 deletions(-) diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java b/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java index f017384..a083012 100644 --- a/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java +++ b/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java @@ -22,6 +22,8 @@ package com.cloud.agent.resource.virtualnetwork.facade; import java.util.Hashtable; import java.util.LinkedList; import java.util.List; +import java.util.UUID; +import org.apache.log4j.Logger; import com.cloud.agent.api.BumpUpPriorityCommand; import com.cloud.agent.api.SetupGuestNetworkCommand; @@ -58,6 +60,8 @@ import com.google.gson.GsonBuilder; public abstract class AbstractConfigItemFacade { +private static final Logger s_logger = Logger.getLogger(AbstractConfigItemFacade.class); + private final static Gson gson; private static Hashtable flyweight = new Hashtable (); @@ -104,13 +108,26 @@ public abstract class AbstractConfigItemFacade { return instance; } +private static String appendUuidToJsonFiles(final String filename) { +String remoteFileName = new String(filename); +if (remoteFileName.endsWith("json")) { +remoteFileName += "." + UUID.randomUUID().toString(); +} +return remoteFileName; +} + protected List generateConfigItems(final ConfigBase configuration) { final List cfg = new LinkedList<>(); -final ConfigItem configFile = new FileConfigItem(VRScripts.CONFIG_PERSIST_LOCATION, destinationFile, gson.toJson(configuration)); +final String remoteFilename = appendUuidToJsonFiles(destinationFile); +if (s_logger.isDebugEnabled()) { +s_logger.debug("Transformed filename: " + destinationFile + " to: " + remoteFilename); +} + +final ConfigItem configFile = new FileConfigItem(VRScripts.CONFIG_PERSIST_LOCATION, remoteFilename, gson.toJson(configuration)); cfg.add(configFile); -final ConfigItem updateCommand = new ScriptConfigItem(VRScripts.UPDATE_CONFIG, destinationFile); +final ConfigItem updateCommand = new ScriptConfigItem(VRScripts.UPDATE_CONFIG, remoteFilename); cfg.add(updateCommand); return cfg; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 51b9737..ebd36bd 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -330,6 +330,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv if (details == null) { details = parser.getLines(); } + +
[cloudstack] 10/22: CLOUDSTACK-10013: Make the generated VR/json files unique (ports #1470)
This is an automated email from the ASF dual-hosted git repository. rohit pushed a commit to branch debian9-systemvmtemplate in repository https://gitbox.apache.org/repos/asf/cloudstack.git commit 2cf50788bc7f700c545f30ec88c38007fa394ef3 Author: Remi BergsmaAuthorDate: Sat Dec 2 23:19:14 2017 +0530 CLOUDSTACK-10013: Make the generated VR/json files unique (ports #1470) This ports PR #1470 by @remibergsma. Make the generated json files unique to prevent concurrency issues: The json files now have UUIDs to prevent them from getting overwritten before they've been executed. Prevents config to be pushed to the wrong router. 2016-02-25 18:32:23,797 DEBUG [c.c.a.t.Request] (AgentManager-Handler-1:null) (logid:) Seq 2-4684025087442026584: Processing: { Ans: , MgmtId: 90520732674657, via: 2, Ver: v1, Flags: 10, [{"com.cloud.agent.api.routing.GroupA nswer":{"results":["null - success: null","null - success: [INFO] update_config.py :: Processing incoming file => vm_dhcp_entry.json.4ea45061-2efb-4467-8eaa-db3d77fb0a7b\n[INFO] Processing JSON file vm_dhcp_entry.json.4ea4506 1-2efb-4467-8eaa-db3d77fb0a7b\n"],"result":true,"wait":0}}] } On the router: 2016-02-25 18:32:23,416 merge.py __moveFile:298 Processed file written to /var/cache/cloud/processed/vm_dhcp_entry.json.4ea45061-2efb-4467-8eaa-db3d77fb0a7b.gz Signed-off-by: Rohit Yadav --- .../facade/AbstractConfigItemFacade.java | 21 +- .../kvm/resource/LibvirtComputingResource.java | 5 + systemvm/patches/debian/etc/rc.local | 9 - systemvm/patches/debian/opt/cloud/bin/configure.py | 220 + systemvm/patches/debian/opt/cloud/bin/merge.py | 37 ++-- .../patches/debian/opt/cloud/bin/update_config.py | 22 ++- 6 files changed, 159 insertions(+), 155 deletions(-) diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java b/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java index f017384..a083012 100644 --- a/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java +++ b/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java @@ -22,6 +22,8 @@ package com.cloud.agent.resource.virtualnetwork.facade; import java.util.Hashtable; import java.util.LinkedList; import java.util.List; +import java.util.UUID; +import org.apache.log4j.Logger; import com.cloud.agent.api.BumpUpPriorityCommand; import com.cloud.agent.api.SetupGuestNetworkCommand; @@ -58,6 +60,8 @@ import com.google.gson.GsonBuilder; public abstract class AbstractConfigItemFacade { +private static final Logger s_logger = Logger.getLogger(AbstractConfigItemFacade.class); + private final static Gson gson; private static Hashtable flyweight = new Hashtable (); @@ -104,13 +108,26 @@ public abstract class AbstractConfigItemFacade { return instance; } +private static String appendUuidToJsonFiles(final String filename) { +String remoteFileName = new String(filename); +if (remoteFileName.endsWith("json")) { +remoteFileName += "." + UUID.randomUUID().toString(); +} +return remoteFileName; +} + protected List generateConfigItems(final ConfigBase configuration) { final List cfg = new LinkedList<>(); -final ConfigItem configFile = new FileConfigItem(VRScripts.CONFIG_PERSIST_LOCATION, destinationFile, gson.toJson(configuration)); +final String remoteFilename = appendUuidToJsonFiles(destinationFile); +if (s_logger.isDebugEnabled()) { +s_logger.debug("Transformed filename: " + destinationFile + " to: " + remoteFilename); +} + +final ConfigItem configFile = new FileConfigItem(VRScripts.CONFIG_PERSIST_LOCATION, remoteFilename, gson.toJson(configuration)); cfg.add(configFile); -final ConfigItem updateCommand = new ScriptConfigItem(VRScripts.UPDATE_CONFIG, destinationFile); +final ConfigItem updateCommand = new ScriptConfigItem(VRScripts.UPDATE_CONFIG, remoteFilename); cfg.add(updateCommand); return cfg; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 51b9737..ebd36bd 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -330,6 +330,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv if (details == null) { details = parser.getLines(); } + +
[cloudstack] 10/22: CLOUDSTACK-10013: Make the generated VR/json files unique (ports #1470)
This is an automated email from the ASF dual-hosted git repository. rohit pushed a commit to branch debian9-systemvmtemplate in repository https://gitbox.apache.org/repos/asf/cloudstack.git commit e0857bbadf3cf4dd47c77ecaae4e2c347be98853 Author: Remi BergsmaAuthorDate: Sat Dec 2 23:19:14 2017 +0530 CLOUDSTACK-10013: Make the generated VR/json files unique (ports #1470) This ports PR #1470 by @remibergsma. Make the generated json files unique to prevent concurrency issues: The json files now have UUIDs to prevent them from getting overwritten before they've been executed. Prevents config to be pushed to the wrong router. 2016-02-25 18:32:23,797 DEBUG [c.c.a.t.Request] (AgentManager-Handler-1:null) (logid:) Seq 2-4684025087442026584: Processing: { Ans: , MgmtId: 90520732674657, via: 2, Ver: v1, Flags: 10, [{"com.cloud.agent.api.routing.GroupA nswer":{"results":["null - success: null","null - success: [INFO] update_config.py :: Processing incoming file => vm_dhcp_entry.json.4ea45061-2efb-4467-8eaa-db3d77fb0a7b\n[INFO] Processing JSON file vm_dhcp_entry.json.4ea4506 1-2efb-4467-8eaa-db3d77fb0a7b\n"],"result":true,"wait":0}}] } On the router: 2016-02-25 18:32:23,416 merge.py __moveFile:298 Processed file written to /var/cache/cloud/processed/vm_dhcp_entry.json.4ea45061-2efb-4467-8eaa-db3d77fb0a7b.gz Signed-off-by: Rohit Yadav --- .../facade/AbstractConfigItemFacade.java | 21 +- .../kvm/resource/LibvirtComputingResource.java | 5 + systemvm/patches/debian/etc/rc.local | 9 - systemvm/patches/debian/opt/cloud/bin/configure.py | 220 + systemvm/patches/debian/opt/cloud/bin/merge.py | 37 ++-- .../patches/debian/opt/cloud/bin/update_config.py | 22 ++- 6 files changed, 159 insertions(+), 155 deletions(-) diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java b/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java index f017384..a083012 100644 --- a/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java +++ b/core/src/com/cloud/agent/resource/virtualnetwork/facade/AbstractConfigItemFacade.java @@ -22,6 +22,8 @@ package com.cloud.agent.resource.virtualnetwork.facade; import java.util.Hashtable; import java.util.LinkedList; import java.util.List; +import java.util.UUID; +import org.apache.log4j.Logger; import com.cloud.agent.api.BumpUpPriorityCommand; import com.cloud.agent.api.SetupGuestNetworkCommand; @@ -58,6 +60,8 @@ import com.google.gson.GsonBuilder; public abstract class AbstractConfigItemFacade { +private static final Logger s_logger = Logger.getLogger(AbstractConfigItemFacade.class); + private final static Gson gson; private static Hashtable flyweight = new Hashtable (); @@ -104,13 +108,26 @@ public abstract class AbstractConfigItemFacade { return instance; } +private static String appendUuidToJsonFiles(final String filename) { +String remoteFileName = new String(filename); +if (remoteFileName.endsWith("json")) { +remoteFileName += "." + UUID.randomUUID().toString(); +} +return remoteFileName; +} + protected List generateConfigItems(final ConfigBase configuration) { final List cfg = new LinkedList<>(); -final ConfigItem configFile = new FileConfigItem(VRScripts.CONFIG_PERSIST_LOCATION, destinationFile, gson.toJson(configuration)); +final String remoteFilename = appendUuidToJsonFiles(destinationFile); +if (s_logger.isDebugEnabled()) { +s_logger.debug("Transformed filename: " + destinationFile + " to: " + remoteFilename); +} + +final ConfigItem configFile = new FileConfigItem(VRScripts.CONFIG_PERSIST_LOCATION, remoteFilename, gson.toJson(configuration)); cfg.add(configFile); -final ConfigItem updateCommand = new ScriptConfigItem(VRScripts.UPDATE_CONFIG, destinationFile); +final ConfigItem updateCommand = new ScriptConfigItem(VRScripts.UPDATE_CONFIG, remoteFilename); cfg.add(updateCommand); return cfg; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 51b9737..ebd36bd 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -330,6 +330,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv if (details == null) { details = parser.getLines(); } + +