def __init__(self):
self.config = Config("/etc/planetlab/plc_config")
+ self.slice = None
+
# this was only for debugging, no need to log all method calls here -baris
# self.log = open("/var/log/omf/plc_slice_calls.log", "a")
self.log = None
slice_name_or_id = None
node_ids = None
- # DeleteSlice shall be handled before the actual method call;
- # after the call we won't be able to acess the slice.
- if api_method_name == "DeleteSlice":
- slice_name_or_id = args[1]
- else: # ignore the rest
- return
-
- slice = self.get_slice(wobj.api, slice_name_or_id)
- if not slice:
- return
-
- if api_method_name == "DeleteSlice":
- self.delete_slice(slice['name'])
-
- self.logit(wobj.name, args, kwargs, data, slice)
-
- # aspect method
- def after(self, wobj, data, *args, **kwargs):
- api_method_name = wobj.name
- slice_name_or_id = None
- node_ids = None
if api_method_name == "AddSlice":
slice_name_or_id = args[1]['name']
elif api_method_name == "AddSliceToNodes" or api_method_name == "DeleteSliceFromNodes":
node_ids = args[2]
elif api_method_name == "AddSliceTag":
slice_name_or_id = args[1]
+ elif api_method_name == "DeleteSlice":
+ slice_name_or_id = args[1]
else: # ignore the rest
#self.logit(wobj.name, args, kwargs, data, "SLICE")
+ self.slice = None
+ return
+
+ self.slice = self.get_slice(wobj.api, slice_name_or_id)
+
+ self.logit(wobj.name, args, kwargs, data, slice)
+
+ # aspect method
+ def after(self, wobj, data, *args, **kwargs):
+ if not self.slice:
return
- slice = self.get_slice(wobj.api, slice_name_or_id)
- if not slice:
+ if data.has_key("method_return_value") and data['method_return_value'] == 1:
+ # return value 1 means that API call was successful, we can go on.
+ pass
+ else:
return
+ api_method_name = wobj.name
+
if api_method_name == "AddSlice":
self.create_slice(slice['name'])
elif api_method_name == "AddSliceToNodes":
for node_id in node_ids:
node_hostname = self.get_node_hostname(wobj.api, node_id)
self.add_resource(slice['name'], node_hostname)
+ elif api_method_name == "DeleteSlice":
+ self.delete_slice(slice['name'])
elif api_method_name == "DeleteSliceFromNodes":
for node_id in node_ids:
node_hostname = self.get_node_hostname(wobj.api, node_id)
slice_tag['value'] = u'dotsshmount'
slice_tag.sync()
-
self.logit(wobj.name, args, kwargs, data, slice)