# NodeManager plugin - first step of handling omf_controlled slices
"""
-Overwrites the 'resctl' tag of slivers controlled by OMF so sm.py does the right thing
+Overwrites the 'resctl' tag of slivers controlled by OMF so slivermanager.py does the right thing
"""
import os
priority = 50
-def start(options, conf):
+def start():
logger.log("omf_resctl: plugin starting up...")
def GetSlivers(data, conf = None, plc = None):
- if 'accounts' not in data:
+ if 'accounts' not in data:
logger.log_missing_data("omf_resctl.GetSlivers",'accounts')
return
# xxx might need to clean up more deeply..
return
+ # as hrn is set only at AddNode-time, upgraded myplcs might still miss this
+ # clue: just overwrite the hostname of all nodes
+ # for node in GetNodes(): UpdateNode(node['node_id'],{'hostname':node['hostname']})
try:
node_hrn = data['hrn']
+ if not hrn: raise Exception,"Empty hrn"
except:
node_hrn='default # Failed to read hrn from GetSlivers, please upgrade PLCAPI'
for sliver in data['slivers']:
name=sliver['name']
+ sliver_pub_key_dir=os.path.join("/home", name, ".ssh/")
+ sliver_private_key=os.path.join(sliver_pub_key_dir, "id_rsa")
for chunk in sliver['attributes']:
if chunk['tagname']=='omf_control':
# scan all versions of omf-resctl
yaml_contents=template_contents\
.replace('@XMPP_SERVER@',xmpp_server)\
.replace('@NODE_HRN@',node_hrn)\
- .replace('@SLICE_NAME@',name)
+ .replace('@SLICE_NAME@',name)\
+ .replace('@SLIVER_PRIVATE_KEY@',sliver_private_key)\
+ .replace('@SLIVER_PUB_KEY_DIR@',sliver_pub_key_dir)
changes=tools.replace_file_with_string(yaml,yaml_contents)
if changes:
sp=subprocess.Popen(['vserver',name,'exec','service',service_name,'restart'],