git://git.onelab.eu
/
sfa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
really fixed the redundant logging issue this time.
[sfa.git]
/
sfa
/
plc
/
network.py
diff --git
a/sfa/plc/network.py
b/sfa/plc/network.py
index
2a3e6ba
..
9276fb0
100644
(file)
--- a/
sfa/plc/network.py
+++ b/
sfa/plc/network.py
@@
-1,13
+1,14
@@
from __future__ import with_statement
from __future__ import with_statement
+import sys
import re
import socket
import re
import socket
+from StringIO import StringIO
+from lxml import etree
+from xmlbuilder import XMLBuilder
+
+from sfa.util.faults import *
from sfa.util.xrn import get_authority
from sfa.util.plxrn import hrn_to_pl_slicename, hostname_to_urn
from sfa.util.xrn import get_authority
from sfa.util.plxrn import hrn_to_pl_slicename, hostname_to_urn
-from sfa.util.faults import *
-from xmlbuilder import XMLBuilder
-from lxml import etree
-import sys
-from StringIO import StringIO
class Sliver:
def __init__(self, node):
class Sliver:
def __init__(self, node):
@@
-183,10
+184,14
@@
class Slice:
# Update a slice tag if it exists, else add it
def update_tag(self, tagname, value, node = None, role = "user"):
# Update a slice tag if it exists, else add it
def update_tag(self, tagname, value, node = None, role = "user"):
+ tag = self.get_tag(tagname, node)
+ if tag and tag.value == value:
+ return tag
+
tt = self.network.lookupTagType(tagname)
if not tt.permit_update(role):
raise InvalidRSpec("permission denied to modify '%s' tag" % tagname)
tt = self.network.lookupTagType(tagname)
if not tt.permit_update(role):
raise InvalidRSpec("permission denied to modify '%s' tag" % tagname)
- tag = self.get_tag(tagname, node)
+
if tag:
tag.change(value)
else:
if tag:
tag.change(value)
else:
@@
-343,6
+348,7
@@
class Network:
try:
val = self.sites[id]
except:
try:
val = self.sites[id]
except:
+ self.api.logger.error("Invalid RSpec: site ID %s not found" % id )
raise InvalidRSpec("site ID %s not found" % id)
return val
raise InvalidRSpec("site ID %s not found" % id)
return val
@@
-467,6
+473,10
@@
class Network:
if not relaxng(tree):
error = relaxng.error_log.last_error
message = "%s (line %s)" % (error.message, error.line)
if not relaxng(tree):
error = relaxng.error_log.last_error
message = "%s (line %s)" % (error.message, error.line)
+ self.api.logger.error("failed to validate rspec %r"%message)
+ self.api.logger.debug("---------- XML input BEG")
+ self.api.logger.debug(xml)
+ self.api.logger.debug("---------- XML input END")
raise InvalidRSpec(message)
self.rspec = rspec
raise InvalidRSpec(message)
self.rspec = rspec
@@
-562,8
+572,12
@@
class Network:
"""
tmp = []
for node in api.plshell.GetNodes(api.plauth, {'peer_id': None}):
"""
tmp = []
for node in api.plshell.GetNodes(api.plauth, {'peer_id': None}):
- t = node['node_id'], Node(self, node)
- tmp.append(t)
+ try:
+ t = node['node_id'], Node(self, node)
+ tmp.append(t)
+ except:
+ self.api.logger.error("Failed to add node %s (%s) to RSpec" % (node['hostname'], node['node_id']))
+
return dict(tmp)
def get_ifaces(self, api):
return dict(tmp)
def get_ifaces(self, api):