Change the location for the temporary json files to /var/cache/cloud

This commit is contained in:
Hugo Trippaers 2014-08-12 11:59:16 +02:00 committed by wilderrodrigues
parent ca2ff2946e
commit 58919dcf50
2 changed files with 16 additions and 2 deletions

View File

@ -20,7 +20,7 @@
package com.cloud.agent.resource.virtualnetwork;
public class VRScripts {
protected final static String CONFIG_PERSIST_LOCATION = "/etc/cloudstack/";
protected final static String CONFIG_PERSIST_LOCATION = "/var/cache/cloud/";
protected final static String IP_ASSOCIATION_CONFIG = "ip_associations.json";
protected final static String GUEST_NETWORK_CONFIG = "guest_network.json";
protected final static String NETWORK_ACL_CONFIG = "network_acl.json";
@ -31,6 +31,7 @@ public class VRScripts {
protected static final String VPN_USER_LIST_CONFIG = "vpn_user_list.json";
protected static final String STATICNAT_RULES_CONFIG = "staticnat_rules.json";
protected static final String SITE_2_SITE_VPN_CONFIG = "site_2_site_vpn.json";
protected static final String STATIC_ROUTES_CONFIG = "static_routes.json";
protected final static String CONFIG_CACHE_LOCATION = "/var/cache/cloud/";
protected final static int DEFAULT_EXECUTEINVR_TIMEOUT = 120; //Seconds

View File

@ -2,6 +2,7 @@
import json
import os
import time
import logging
import cs_ip
import cs_guestnetwork
@ -125,6 +126,8 @@ class loadQueueFile:
fileName = ''
dpath = "/etc/cloudstack"
configCache = "/var/cache/cloud"
keep = True
data = {}
def load(self, data):
@ -133,7 +136,7 @@ class loadQueueFile:
self.type = self.data["type"]
proc = updateDataBag(self)
return
fn = self.dpath + '/' + self.fileName
fn = self.configCache + '/' + self.fileName
try:
handle = open(fn)
except IOError:
@ -142,6 +145,10 @@ class loadQueueFile:
self.data = json.load(handle)
self.type = self.data["type"]
handle.close()
if self.keep:
self.__moveFile(fn, self.configCache + "/processed")
else:
os.remove(fn)
proc = updateDataBag(self)
def setFile(self, name):
@ -156,3 +163,9 @@ class loadQueueFile:
def setPath(self, path):
self.dpath = path
def __moveFile(self, origPath, path):
if not os.path.exists(path):
os.makedirs(path)
timestamp = str(round(time.time()))
os.rename(origPath, path + "/" + self.fileName + "." + timestamp)