<commit_before>#
# NodeManager plugin - first step of handling omf_controlled slices
#

"""
Overwrites the 'resctl' tag of slivers controlled by OMF so slivermanager.py does the right thing
"""

import os, os.path
import glob
import subprocess

import tools
import logger

priority = 50

def start():
    pass

### the new template for v6
# hard-wire this for now
# once the variables are expanded, this is expected to go into
config_ple_template="""---
# Example:
# _slicename_ = nicta_ruby
# _hostname_ = planetlab1.research.nicta.com.au
# _xmpp_server_ = xmpp.planet-lab.eu
 
:uid: _slicename_@_hostname_
:uri: xmpp://_slicename_-_hostname_-<%= "#{Process.pid}" %>:_slicename_-_hostname_-<%= "#{Process.pid}" %>@_xmpp_server_
:environment: production
:debug: false
 
:auth:
  :root_cert_dir: /home/_slicename_/root_certs
  :entity_cert: /home/_slicename_/entity.crt
  :entity_key: /home/_slicename_/.ssh/id_rsa
"""

# the path where the config is expected from within the sliver
yaml_slice_path="/etc/omf_rc/config.yml"
# the path for the script that we call when a change occurs
omf_rc_trigger_script="omf_rc_plc_trigger"

### this returns the kind of virtualization on the node
# either 'vs' or 'lxc'
# also caches it in /etc/planetlab/virt for next calls
# could be promoted to core nm if need be
virt_stamp="/etc/planetlab/virt"
def get_node_virt ():
    try:
        return file(virt_stamp).read().strip()
    except:
        pass
    logger.log("Computing virt..")
    vs_retcod=subprocess.call ([ 'vserver', '--help' ])
    if vs_retcod == 0:
        virt='vs'
    else:
        virt='lxc'
    with file(virt_stamp,"w") as f:
        f.write(virt)
    return virt

def command_in_slice (slicename, argv):
    # with vserver this can be done using vserver .. exec <trigger-script>
    # with lxc this is less clear as we are still discussing how lxcsu should behave
    # ideally we'd need to run lxcsu .. <trigger-script>
    virt=get_node_virt()<commit_msg>change trigger script name<commit_after>#
# NodeManager plugin - first step of handling omf_controlled slices
#

"""
Overwrites the 'resctl' tag of slivers controlled by OMF so slivermanager.py does the right thing
"""

import os, os.path
import glob
import subprocess

import tools
import logger

priority = 50

def start():
    pass

### the new template for v6
# hard-wire this for now
# once the variables are expanded, this is expected to go into
config_ple_template="""---
# Example:
# _slicename_ = nicta_ruby
# _hostname_ = planetlab1.research.nicta.com.au
# _xmpp_server_ = xmpp.planet-lab.eu
 
:uid: _slicename_@_hostname_
:uri: xmpp://_slicename_-_hostname_-<%= "#{Process.pid}" %>:_slicename_-_hostname_-<%= "#{Process.pid}" %>@_xmpp_server_
:environment: production
:debug: false
 
:auth:
  :root_cert_dir: /home/_slicename_/root_certs
  :entity_cert: /home/_slicename_/entity.crt
  :entity_key: /home/_slicename_/.ssh/id_rsa
"""

# the path where the config is expected from within the sliver
yaml_slice_path="/etc/omf_rc/config.yml"
# the path for the script that we call when a change occurs
omf_rc_trigger_script="plc_trigger_omf_rc"

### this returns the kind of virtualization on the node
# either 'vs' or 'lxc'
# also caches it in /etc/planetlab/virt for next calls
# could be promoted to core nm if need be
virt_stamp="/etc/planetlab/virt"
def get_node_virt ():
    try:
        return file(virt_stamp).read().strip()
    except:
        pass
    logger.log("Computing virt..")
    vs_retcod=subprocess.call ([ 'vserver', '--help' ])
    if vs_retcod == 0:
        virt='vs'
    else:
        virt='lxc'
    with file(virt_stamp,"w") as f:
        f.write(virt)
    return virt

def command_in_slice (slicename, argv):
    # with vserver this can be done using vserver .. exec <trigger-script>
    # with lxc this is less clear as we are still discussing how lxcsu should behave
    # ideally we'd need to run lxcsu .. <trigger-script>
    virt=get_node_virt()
{'fraction_non_alphanumeric': 0.11040769815143074, 'fraction_numerical': 0.0025322866548493288, 'mean_word_length': 3.840686274509804, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '315168', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1351, 'n_words': 412}