summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBin Yang <bin.yang@windriver.com>2018-05-16 10:20:30 +0800
committerBin Yang <bin.yang@windriver.com>2018-05-16 10:20:30 +0800
commit8e08c9dc1f6303827a07294e4792d3d49fbbac3c (patch)
tree2d33c69f562d0c1510ba90b9095519b4715edecf
parentbe067e5c7c253ad4509aa173d4fc5782209fe288 (diff)
Fix bugs for GET API and tasks
Change-Id: If1748109359b9180aac46e14d3e4261def171460 Issue-ID: Issue-ID: MULTICLOUD-232 Signed-off-by: Bin Yang <bin.yang@windriver.com>
-rw-r--r--windriver/titanium_cloud/vesagent/tasks.py2
-rw-r--r--windriver/titanium_cloud/vesagent/vesagent_ctrl.py14
-rw-r--r--windriver/titanium_cloud/vesagent/vespublish.py2
3 files changed, 11 insertions, 7 deletions
diff --git a/windriver/titanium_cloud/vesagent/tasks.py b/windriver/titanium_cloud/vesagent/tasks.py
index 35ccfcaf..ac760ece 100644
--- a/windriver/titanium_cloud/vesagent/tasks.py
+++ b/windriver/titanium_cloud/vesagent/tasks.py
@@ -30,7 +30,7 @@ logger = logging.getLogger(__name__)
@app.task(bind=True)
def scheduleBacklogs(self, vimid):
# make sure only one task runs here
- logger.info("schedule with vimid:%" % (vimid))
+ # cannot get vimid ? logger.info("schedule with vimid:%" % (vimid))
logger.debug("scheduleBacklogs starts")
backlog_count, next_time_slot = processBacklogs()
diff --git a/windriver/titanium_cloud/vesagent/vesagent_ctrl.py b/windriver/titanium_cloud/vesagent/vesagent_ctrl.py
index fdc9f71a..7049aee0 100644
--- a/windriver/titanium_cloud/vesagent/vesagent_ctrl.py
+++ b/windriver/titanium_cloud/vesagent/vesagent_ctrl.py
@@ -164,10 +164,15 @@ class VesAgentCtrl(APIView):
self._logger.debug("with META: %s" % request.META)
try:
# get vesagent_config from cloud region
- viminfo = extsys.get_vim_by_id(vimid)
- cloud_extra_info_str = viminfo.get('cloud_extra_info', None)
- cloud_extra_info = json.loads(cloud_extra_info_str) if cloud_extra_info_str is not None else None
- vesagent_config = cloud_extra_info.get("vesagent_config", None) if cloud_extra_info is not None else None
+ try:
+ viminfo = extsys.get_vim_by_id(vimid)
+ cloud_extra_info_str = viminfo.get('cloud_extra_info', '')
+ cloud_extra_info = json.loads(cloud_extra_info_str) if cloud_extra_info_str != '' else None
+ vesagent_config = cloud_extra_info.get("vesagent_config", None) if cloud_extra_info is not None else None
+ except Exception as e:
+ #ignore this error
+ self._logger.warn("cloud extra info is provided with data in bad format: %s" % cloud_extra_info_str)
+ pass
vesagent_backlogs = self.getBacklogsOneVIM(vimid)
@@ -363,7 +368,6 @@ class VesAgentCtrl(APIView):
if VesAgentBacklogsVimListStr is not None:
VesAgentBacklogsVimList = json.loads(VesAgentBacklogsVimListStr)
VesAgentBacklogsVimList = [v for v in VesAgentBacklogsVimList if v != vimid]
- VesAgentBacklogsVimList = self.vimid_
VesAgentBacklogsVimList.append(vimid)
logger.info("VesAgentBacklogs.vimlist is %s" % VesAgentBacklogsVimList)
diff --git a/windriver/titanium_cloud/vesagent/vespublish.py b/windriver/titanium_cloud/vesagent/vespublish.py
index df77e30b..ab0155c2 100644
--- a/windriver/titanium_cloud/vesagent/vespublish.py
+++ b/windriver/titanium_cloud/vesagent/vespublish.py
@@ -29,7 +29,7 @@ def publishAnyEventToVES(ves_subscription, event):
if endpoint:
try:
- logger.info("publish event to VES: %s", )
+ logger.info("publish event to VES: %s", endpoint)
headers = {'Content-Type': 'application/json'}
request = urllib2.Request(url=endpoint, headers=headers, data=json.dumps(event))
time.sleep(1)