Esempio n. 1
0
 def do_init(self, rwlog_ctx):
     self.log.addHandler(
         rwlogger.RwLogger(
             category="rw-cal-log",
             subcategory="aws",
             log_hdl=rwlog_ctx,
         ))
Esempio n. 2
0
 def do_init(self, rwlog_ctx):
     if not any(isinstance(h, rwlogger.RwLogger) for h in logger.handlers):
         logger.addHandler(
             rwlogger.RwLogger(
                 subcategory="sdnsim",
                 log_hdl=rwlog_ctx,
             ))
Esempio n. 3
0
    def _add_root_logger_handling(self):
        """
        Create a scheduler hook to set the root logger for this
        tasklet on entry.  This enables us to capture the logs
        used by libraries without having to manually find
        the library's logger and set the handler.
        """
        root_logger = logging.getLogger()
        root_logger.setLevel(logging.DEBUG)
        root_rwlog_handler = rwlogger.RwLogger(log_hdl=self._log_hdl, )

        # We need to filter this handler by the core CFRunLoop thread id
        # so only messages being logged specifically during this tasklets
        # scheduler invocation are logged using it's handler.
        root_rwlog_handler.addFilter(rwlogger.ThreadFilter.from_current())

        def add_root_logger_handler():
            """ Set the root logger's handler to this tasklets rwlog handler """

            # Clone the current category/subcategory assignment for the tasklet
            root_rwlog_handler.set_category(self._rwlog_handler.category)
            root_rwlog_handler.set_subcategory(self._rwlog_handler.subcategory)

            root_logger.addHandler(root_rwlog_handler)

        def remove_root_logger_handler():
            """ Remove the root logger's handler to this tasklets rwlog handler """
            root_logger.removeHandler(root_rwlog_handler)

        self._loop.register_tick_enter_hook(add_root_logger_handler)
        self._loop.register_tick_exit_hook(remove_root_logger_handler)
Esempio n. 4
0
    def __init__(self, tasklet_info):
        """
        Create a Tasklet object

        Tasklets are not directly created by the user, but are created by the
        associated Component class via VCS.

        @param tasklet_info - info relevant to this tasklet

        """
        self._tasklet_info = tasklet_info

        self._log = logger_from_tasklet_info(tasklet_info)
        self._log.setLevel(logging.DEBUG)

        self._log_hdl = tasklet_info.get_rwlog_ctx()
        self._rwlog_handler = rwlogger.RwLogger(log_hdl=self._log_hdl)
        self._log.addHandler(self._rwlog_handler)

        # We want set up the root logger to log to this tasklets rwlog handler
        # in order to catch any logs emitted via third party libraries.
        # Because of this, we want to ensure that any logs sent to this logger do
        # not propogate to the root logger which would cause the messages to get
        # logged twice.
        self._log.propagate = False

        self._loop = StackedEventLoop(self._tasklet_info.rwsched_instance,
                                      self._tasklet_info.rwsched_tasklet,
                                      self._log)

        self._add_root_logger_handling()
Esempio n. 5
0
    def do_instance_alloc(self, component_handle, tasklet_info, instance_url):
        """This function is called for each new instance of the tasklet.
        The tasklet specific information such as scheduler instance,
        trace context, logging context are passed in 'tasklet_info' variable.
        This function stores the tasklet information locally.
        """
        logger.debug("RwdtstaskletPython: do_instance_alloc function called")

        self.taskletinfo = tasklet_info

        # Save the scheduler instance and tasklet instance objects
        #self.rwsched = tasklet_info.rwsched_instance
        #self.tasklet = tasklet_info.rwsched_tasklet_info
        #self.rwlog_instance = tasklet_info.rwlog_instance


        tasklet_logger = rwlogger.RwLogger(subcategory="rw-vcs",
                                           log_hdl=self.taskletinfo.rwlog_ctx)
        logger.addHandler(tasklet_logger)

        # After this point, all logger calls will log events to rw_vcs using
        # the tasklets rwlog handle
        logger.debug("Added rwlogger handler to tasklet logger")

        instance_handle = RwTaskletPlugin.InstanceHandle()
        return instance_handle
Esempio n. 6
0
 def do_init(self, rwlog_ctx):
     if not any(isinstance(h, rwlogger.RwLogger) for h in logger.handlers):
         logger.addHandler(
             rwlogger.RwLogger(
                 category="rw-cal-log",
                 subcategory="cloudsim",
                 log_hdl=rwlog_ctx,
             ))
 def do_init(self, rwlog_ctx):
     if not any(isinstance(h, rwlogger.RwLogger) for h in logger.handlers):
         logger.addHandler(
             rwlogger.RwLogger(
                 category="rw-cal-log",
                 subcategory="openmano_vimconnector",
                 log_hdl=rwlog_ctx,
             ))
Esempio n. 8
0
    def do_init(self, rwlog_ctx):
        self._rwlog_handler = rwlogger.RwLogger(category="rw-cal-log",
                                                subcategory="kubernetes",
                                                log_hdl=rwlog_ctx,)
        self.log.addHandler(self._rwlog_handler)
        self.log.propagate = False

        self.auth_url = account.kubernetes.auth_url
Esempio n. 9
0
 def do_init(self, rwlog_ctx):
     if not any(isinstance(h, rwlogger.RwLogger) for h in logger.handlers):
         logger.addHandler(
             rwlogger.RwLogger(
                 category="rw-monitor-log",
                 subcategory="ceilometer",
                 log_hdl=rwlog_ctx,
             ))
Esempio n. 10
0
 def do_init(self, rwlog_ctx):
     self._rwlog_handler = rwlogger.RwLogger(
         category="rw-cal-log",
         subcategory="openstack",
         log_hdl=rwlog_ctx,
     )
     self.log.addHandler(self._rwlog_handler)
     self.log.propagate = False
 def do_init(self, rwlog_ctx):
     logger.addHandler(
         rwlogger.RwLogger(
             category="rw-cal-log",
             subcategory="cloudsimproxy",
             log_hdl=rwlog_ctx,
         )
     )
Esempio n. 12
0
    def do_init(self, rwlog_ctx):
        if not any(isinstance(h, rwlogger.RwLogger) for h in logger.handlers):
            logger.addHandler(
                rwlogger.RwLogger(
                    category="rw-cal-log",
                    subcategory="rwcal.mock",
                    log_hdl=rwlog_ctx,
                ))

        account = RwcalYang.CloudAccount()
        account.name = 'mock_account'
        account.account_type = 'mock'
        account.mock.username = '******'
        self.create_default_resources(account)
Esempio n. 13
0
    def do_init(self, rwlog_ctx):
        if not any(isinstance(h, rwlogger.RwLogger) for h in logger.handlers):
            logger.addHandler(
                rwlogger.RwLogger(
                    subcategory="rwsdn.mock",
                    log_hdl=rwlog_ctx,
                ))

        account = RwsdnYang.SDNAccount()
        account.name = 'mock'
        account.account_type = 'mock'
        account.mock.username = '******'

        self.datastore = DataStore()
        self.topology = self.datastore.create_default_topology()
Esempio n. 14
0
    def do_init(self, rwlog_ctx):
        providers = {
            "sdnsim": rift.sdn.SdnSim,
            "mock": rift.sdn.Mock,
        }

        logger.addHandler(
            rwlogger.RwLogger(
                subcategory="rwsdn",
                log_hdl=rwlog_ctx,
            ))

        self._impl = {}
        for name, impl in providers.items():
            try:
                self._impl[name] = impl()

            except Exception:
                msg = "unable to load SDN implementation for {}"
                logger.exception(msg.format(name))
Esempio n. 15
0
 def setUp(self):
     self.rwlogger = rwlogger.RwLogger(subcategory="rw-appmgr-log")   # default cat
     self.logger = logging.getLogger(__name__)
     self.logger.addHandler(self.rwlogger)
Esempio n. 16
0
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#

import rift.rwcal.aws as aws_drv
import logging
import argparse
import rwlogger
import sys, os, time

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger()
rwlog_handler = rwlogger.RwLogger(
    category="rw-cal-log",
    subcategory="aws",
)
logger.addHandler(rwlog_handler)

#logger.setLevel(logging.DEBUG)


def prepare_vm_after_boot(drv, argument):
    vm_inst = drv.get_instance(argument.server_id)
    logger.info("Waiting for VM instance to get to running state")
    vm_inst.wait_until_running()
    logger.info("VM instance is now in running state")
    if argument.vdu_name:
        vm_inst.create_tags(Tags=[{'Key': 'Name', 'Value': argument.vdu_name}])
    if argument.vdu_node_id is not None:
        vm_inst.create_tags(Tags=[{
Esempio n. 17
0
gi.require_version('RwNetns', '1.0')
gi.require_version('RwNetnsLogYang', '1.0')

from gi.repository import RwNetns
import six

# Usually, just importing RwNetnsLogYang would be sufficient, but since
# some of these classes are only used in error paths, I want to
# make sure all names are resolved up front.
from gi.repository.RwNetnsLogYang import (
    EnteringNetns, ExitingNetns, MissingResolvConf, MountingResolvConf,
    MountingResolvConfFailed, UnmountingResolvConf, UnmountingResolvConfFailed,
    MultipleNetnsError, ChangeNetnsFailed, ChangeNetnsFdFailed,
    GetNetnsFdFailed)

rwlogger = rwlogger.RwLogger(subcategory="rw-netns")  # need better category?
logger = logging.getLogger(__name__)
logger.addHandler(rwlogger)


class NetworkNamespaceException(Exception):
    pass


class NetnsEnvironment(object):
    current_netns = None

    def __init__(self, netns_name, bind_resolv_conf=True):
        if not isinstance(netns_name, six.string_types):
            raise TypeError("netns is expected to be a string: %s", netns_name)
Esempio n. 18
0
#   limitations under the License.
#

import rift.rwcal.openstack as openstack_drv
import logging
import argparse
import sys, os, time
import rwlogger
import yaml
import random
import fcntl

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger()
rwlog_handler = rwlogger.RwLogger(
    category="rw-cal-log",
    subcategory="openstack",
)
logger.addHandler(rwlog_handler)
#logger.setLevel(logging.DEBUG)


class FileLock:
    FILE_LOCK = '/tmp/_openstack_prepare_vm.lock'

    def __init__(self):
        # This will create it if it does not exist already
        self.filename = FileLock.FILE_LOCK
        self.handle = None

    # Bitwise OR fcntl.LOCK_NB if you need a non-blocking lock
    def acquire(self):