예제 #1
0
    def start(self):

        self.log.debug("Registering with dts")

        try:
            super().start()

            self.dts = rift.tasklets.DTS(self.tasklet_info,
                                         RwLaunchpadYang.get_schema(),
                                         self.loop, self.on_dts_state_change)

            proxy = filesystem.FileSystemProxy(self.loop, self.log, self.dts)
            args = [self.log, self.dts, self.loop]

            args.append(proxy)
            self.endpoint_rpc = rpc.EndpointDiscoveryRpcHandler(*args)
            self.schema_rpc = rpc.SchemaRpcHandler(*args)
            self.delete_rpc = rpc.PackageDeleteOperationsRpcHandler(*args)

            args.append(self)
            self.pkg_op = rpc.PackageOperationsRpcHandler(*args)

            self.project_handler = ProjectHandler(
                self,
                PackageManagerProject,
                proxy=proxy,
            )
        except Exception as e:
            self.log.exception("Exception caught rwpkgmgr start: %s", str(e))
        else:
            self.log.debug("rwpkgmgr started successfully!")
예제 #2
0
    def init(self):
        self.store = store.StagingFileStore(self)

        io_loop = rift.tasklets.tornado.TaskletAsyncIOLoop(asyncio_loop=self.loop)
        self.app = StagingApplication(self.store, self.loop)

        manifest = self.tasklet_info.get_pb_manifest()
        ssl_cert = manifest.bootstrap_phase.rwsecurity.cert
        ssl_key = manifest.bootstrap_phase.rwsecurity.key
        ssl_options = {"certfile": ssl_cert, "keyfile": ssl_key}

        if manifest.bootstrap_phase.rwsecurity.use_ssl:
            self.server = tornado.httpserver.HTTPServer(
                self.app,
                max_body_size=self.app.MAX_BODY_SIZE,
                io_loop=io_loop,
                ssl_options=ssl_options)
        else:
            self.server = tornado.httpserver.HTTPServer(
                self.app,
                max_body_size=self.app.MAX_BODY_SIZE,
                io_loop=io_loop,
            )

        self.create_stg_rpc = rpc.StagingAreaCreateRpcHandler(
                self.log,
                self.dts,
                self.loop,
                self.store)
        yield from self.create_stg_rpc.register()

        self.log.debug("creating project handler")
        self.project_handler = ProjectHandler(self, StagingManagerProject)
        self.project_handler.register()
예제 #3
0
    def init(self):
        try:
            self.log.debug("creating http proxy server")

            self.http_proxy = glance_proxy_server.QuickProxyServer(
                self.log, self.loop)

            self.proxy_server = glance_proxy_server.GlanceHTTPProxyServer(
                self.log, self.loop, self.http_proxy)
            self.proxy_server.start()

            self.glance_client = glance_client.OpenstackGlanceClient.from_token(
                self.log, "127.0.0.1", "9292", "test")

            self.log.debug("Creating project handler")
            self.project_handler = ProjectHandler(self,
                                                  ImageMgrProject,
                                                  client=self.glance_client)
            self.project_handler.register()

        except Exception as e:
            self.log.exception("error during init")
예제 #4
0
    def init(self):
        try:
            io_loop = rift.tasklets.tornado.TaskletAsyncIOLoop(
                asyncio_loop=self.loop)
            self.app = uploader.UploaderApplication.from_tasklet(self)
            yield from self.app.register()

            manifest = self.tasklet_info.get_pb_manifest()
            ssl_cert = manifest.bootstrap_phase.rwsecurity.cert
            ssl_key = manifest.bootstrap_phase.rwsecurity.key
            ssl_options = {
                "certfile": ssl_cert,
                "keyfile": ssl_key,
            }

            if manifest.bootstrap_phase.rwsecurity.use_ssl:
                self.server = tornado.httpserver.HTTPServer(
                    self.app,
                    max_body_size=LaunchpadTasklet.UPLOAD_MAX_BODY_SIZE,
                    io_loop=io_loop,
                    ssl_options=ssl_options,
                )

            else:
                self.server = tornado.httpserver.HTTPServer(
                    self.app,
                    max_body_size=LaunchpadTasklet.UPLOAD_MAX_BODY_SIZE,
                    io_loop=io_loop,
                )

            self.log.debug("Registering project handler")
            self.project_handler = ProjectHandler(self,
                                                  LaunchpadProject,
                                                  app=self.app)
            self.project_handler.register()

        except Exception as e:
            self.log.error("Exception : {}".format(e))
            self.log.exception(e)
예제 #5
0
 def init(self):
     """ task init callback"""
     self.log.debug("creating project handler")
     self.project_handler = ProjectHandler(self, VnsProject)
     self.project_handler.register()
예제 #6
0
class VnsTasklet(rift.tasklets.Tasklet):
    """ The VNS tasklet class """
    def __init__(self, *args, **kwargs):
        super(VnsTasklet, self).__init__(*args, **kwargs)
        self.rwlog.set_category("rw-mano-log")
        self.rwlog.set_subcategory("vns")

        self._dts = None
        self._project_handler = None
        self.projects = {}

    @property
    def dts(self):
        return self._dts

    def start(self):
        super(VnsTasklet, self).start()
        self.log.info("Starting VnsTasklet")

        self.log.debug("Registering with dts")
        try:
            self._dts = rift.tasklets.DTS(self.tasklet_info,
                                          RwVnsYang.get_schema(), self.loop,
                                          self.on_dts_state_change)
        except Exception:
            self.log.exception("Caught Exception in VNS start:", e)

        self.log.debug("Created DTS Api GI Object: %s", self._dts)

    def on_instance_started(self):
        """ The task instance started callback"""
        self.log.debug("Got instance started callback")

    def stop(self):
        try:
            self._dts.deinit()
        except Exception:
            print("Caught Exception in VNS stop:", sys.exc_info()[0])
            raise

    @asyncio.coroutine
    def init(self):
        """ task init callback"""
        self.log.debug("creating project handler")
        self.project_handler = ProjectHandler(self, VnsProject)
        self.project_handler.register()

    @asyncio.coroutine
    def run(self):
        """ tasklet run callback """
        pass

    @asyncio.coroutine
    def on_dts_state_change(self, state):
        """Take action according to current dts state to transition
        application into the corresponding application state

        Arguments
            state - current dts state
        """
        switch = {
            rwdts.State.INIT: rwdts.State.REGN_COMPLETE,
            rwdts.State.CONFIG: rwdts.State.RUN,
        }

        handlers = {
            rwdts.State.INIT: self.init,
            rwdts.State.RUN: self.run,
        }

        # Transition application to next state
        handler = handlers.get(state, None)
        if handler is not None:
            yield from handler()

        # Transition dts to next state
        next_state = switch.get(state, None)
        if next_state is not None:
            self._dts.handle.set_state(next_state)
예제 #7
0
 def init(self):
     self.log.debug("creating project handler")
     self.project_handler = ProjectHandler(self, AutoScalerProject)
     self.project_handler.register()
예제 #8
0
class AutoScalerTasklet(rift.tasklets.Tasklet):
    """The main task of this Tasklet is to listen for NSR changes and once the
    NSR is configured, ScalingPolicy is created.
    """
    def __init__(self, *args, **kwargs):

        try:
            super().__init__(*args, **kwargs)
            self.rwlog.set_category("rw-mano-log")

            self._project_handler = None
            self.projects = {}

        except Exception as e:
            self.log.exception(e)

    def start(self):
        super().start()

        self.log.debug("Registering with dts")

        self.dts = rift.tasklets.DTS(self.tasklet_info,
                                     RwLaunchpadYang.get_schema(), self.loop,
                                     self.on_dts_state_change)

        self.log.debug("Created DTS Api GI Object: %s", self.dts)

    def stop(self):
        try:
            self.dts.deinit()
        except Exception as e:
            self.log.exception(e)

    @asyncio.coroutine
    def init(self):
        self.log.debug("creating project handler")
        self.project_handler = ProjectHandler(self, AutoScalerProject)
        self.project_handler.register()

    @asyncio.coroutine
    def run(self):
        pass

    @asyncio.coroutine
    def on_dts_state_change(self, state):
        """Handle DTS state change

        Take action according to current DTS state to transition application
        into the corresponding application state

        Arguments
            state - current dts state

        """
        switch = {
            rwdts.State.INIT: rwdts.State.REGN_COMPLETE,
            rwdts.State.CONFIG: rwdts.State.RUN,
        }

        handlers = {
            rwdts.State.INIT: self.init,
            rwdts.State.RUN: self.run,
        }

        # Transition application to next state
        handler = handlers.get(state, None)
        if handler is not None:
            yield from handler()

        # Transition dts to next state
        next_state = switch.get(state, None)
        if next_state is not None:
            self.dts.handle.set_state(next_state)
예제 #9
0
class StagingManagerTasklet(rift.tasklets.Tasklet):
    """Tasklet to handle all staging related operations
    """
    def __init__(self, *args, **kwargs):
        try:
            super().__init__(*args, **kwargs)
            self._project_handler = None
            self.projects = {}

        except Exception as e:
            self.log.exception("Staging Manager tasklet init: {}".
                               format(e))

    def start(self):
        super().start()

        self.log.debug("Registering with dts")

        self.dts = rift.tasklets.DTS(
                self.tasklet_info,
                RwStagingMgmtYang.get_schema(),
                self.loop,
                self.on_dts_state_change
                )

    def stop(self):
        try:
            self.dts.deinit()
        except Exception as e:
            self.log.exception(e)

    @asyncio.coroutine
    def init(self):
        self.store = store.StagingFileStore(self)

        io_loop = rift.tasklets.tornado.TaskletAsyncIOLoop(asyncio_loop=self.loop)
        self.app = StagingApplication(self.store, self.loop)

        manifest = self.tasklet_info.get_pb_manifest()
        ssl_cert = manifest.bootstrap_phase.rwsecurity.cert
        ssl_key = manifest.bootstrap_phase.rwsecurity.key
        ssl_options = {"certfile": ssl_cert, "keyfile": ssl_key}

        if manifest.bootstrap_phase.rwsecurity.use_ssl:
            self.server = tornado.httpserver.HTTPServer(
                self.app,
                max_body_size=self.app.MAX_BODY_SIZE,
                io_loop=io_loop,
                ssl_options=ssl_options)
        else:
            self.server = tornado.httpserver.HTTPServer(
                self.app,
                max_body_size=self.app.MAX_BODY_SIZE,
                io_loop=io_loop,
            )

        self.create_stg_rpc = rpc.StagingAreaCreateRpcHandler(
                self.log,
                self.dts,
                self.loop,
                self.store)
        yield from self.create_stg_rpc.register()

        self.log.debug("creating project handler")
        self.project_handler = ProjectHandler(self, StagingManagerProject)
        self.project_handler.register()

    @asyncio.coroutine
    def run(self):
        address = rwlib.getenv("RWVM_INTERNAL_IPADDR")
        if (address is None):
            address=""
        self.server.listen(self.app.PORT, address=address)
        self.server.listen(self.app.PORT, address="127.0.0.1")

    @asyncio.coroutine
    def on_dts_state_change(self, state):
        """Handle DTS state change

        Take action according to current DTS state to transition application
        into the corresponding application state

        Arguments
            state - current dts state

        """
        switch = {
            rwdts.State.INIT: rwdts.State.REGN_COMPLETE,
            rwdts.State.CONFIG: rwdts.State.RUN,
        }

        handlers = {
            rwdts.State.INIT: self.init,
            rwdts.State.RUN: self.run,
        }

        # Transition application to next state
        handler = handlers.get(state, None)
        if handler is not None:
            yield from handler()

        # Transition dts to next state
        next_state = switch.get(state, None)
        if next_state is not None:
            self.dts.handle.set_state(next_state)
예제 #10
0
class ImageManagerTasklet(rift.tasklets.Tasklet):
    """
    The RwImageMgrTasklet provides a interface for DTS to interact with an
    instance of the Monitor class. This allows the Monitor class to remain
    independent of DTS.
    """
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.rwlog.set_category("rw-mano-log")

        self.http_proxy = None
        self.proxy_server = None
        self.dts = None
        self.glance_client = None
        self.project_handler = None

        self.projects = {}

    def start(self):
        super().start()
        self.log.info("Starting Image Manager Tasklet")

        self.log.debug("Registering with dts")
        self.dts = rift.tasklets.DTS(self.tasklet_info,
                                     RwImageMgmtYang.get_schema(), self.loop,
                                     self.on_dts_state_change)

        self.log.debug("Created DTS Api GI Object: %s", self.dts)

    def stop(self):
        try:
            self.dts.deinit()
        except Exception as e:
            self.log.exception(e)

    @asyncio.coroutine
    def init(self):
        try:
            self.log.debug("creating http proxy server")

            self.http_proxy = glance_proxy_server.QuickProxyServer(
                self.log, self.loop)

            self.proxy_server = glance_proxy_server.GlanceHTTPProxyServer(
                self.log, self.loop, self.http_proxy)
            self.proxy_server.start()

            self.glance_client = glance_client.OpenstackGlanceClient.from_token(
                self.log, "127.0.0.1", "9292", "test")

            self.log.debug("Creating project handler")
            self.project_handler = ProjectHandler(self,
                                                  ImageMgrProject,
                                                  client=self.glance_client)
            self.project_handler.register()

        except Exception as e:
            self.log.exception("error during init")

    @asyncio.coroutine
    def run(self):
        pass

    def on_instance_started(self):
        self.log.debug("Got instance started callback")

    @asyncio.coroutine
    def on_dts_state_change(self, state):
        """Handle DTS state change

        Take action according to current DTS state to transition application
        into the corresponding application state

        Arguments
            state - current dts state

        """
        switch = {
            rwdts.State.INIT: rwdts.State.REGN_COMPLETE,
            rwdts.State.CONFIG: rwdts.State.RUN,
        }

        handlers = {
            rwdts.State.INIT: self.init,
            rwdts.State.RUN: self.run,
        }

        # Transition application to next state
        handler = handlers.get(state, None)
        if handler is not None:
            yield from handler()

        # Transition dts to next state
        next_state = switch.get(state, None)
        if next_state is not None:
            self.dts.handle.set_state(next_state)
예제 #11
0
 def init(self):
     self.log.debug("creating project handler")
     self.project_handler = ProjectHandler(self, MonParamProject)
     self.project_handler.register()
예제 #12
0
class MonitoringParameterTasklet(rift.tasklets.Tasklet):
    """The main task of this Tasklet is to listen for VNFR changes and once the
    VNFR hits the running state, triggers the monitor.
    """
    def __init__(self, *args, **kwargs):
        try:
            super().__init__(*args, **kwargs)
            self.rwlog.set_category("rw-monitor-log")
        except Exception as e:
            self.log.exception(e)

        self._project_handler = None
        self.projects = {}

    def start(self):
        super().start()

        self.log.info("Starting MonitoringParameterTasklet")
        self.log.debug("Registering with dts")

        self.dts = rift.tasklets.DTS(self.tasklet_info, NsrYang.get_schema(),
                                     self.loop, self.on_dts_state_change)

    def stop(self):
        try:
            self.dts.deinit()
        except Exception as e:
            self.log.exception(e)

    @asyncio.coroutine
    def init(self):
        self.log.debug("creating project handler")
        self.project_handler = ProjectHandler(self, MonParamProject)
        self.project_handler.register()

    @asyncio.coroutine
    def run(self):
        pass

    @asyncio.coroutine
    def on_dts_state_change(self, state):
        """Handle DTS state change

        Take action according to current DTS state to transition application
        into the corresponding application state

        Arguments
            state - current dts state

        """
        switch = {
            rwdts.State.INIT: rwdts.State.REGN_COMPLETE,
            rwdts.State.CONFIG: rwdts.State.RUN,
        }

        handlers = {
            rwdts.State.INIT: self.init,
            rwdts.State.RUN: self.run,
        }

        # Transition application to next state
        handler = handlers.get(state, None)
        if handler is not None:
            yield from handler()

        # Transition dts to next state
        next_state = switch.get(state, None)
        if next_state is not None:
            self.dts.handle.set_state(next_state)
예제 #13
0
 def init(self):
     self.log.debug("creating project handler")
     self.project_handler = ProjectHandler(self, ConfigManagerProject)
     self.project_handler.register()
예제 #14
0
class ConfigManagerTasklet(rift.tasklets.Tasklet):
    def __init__(self, *args, **kwargs):
        super(ConfigManagerTasklet, self).__init__(*args, **kwargs)
        self.rwlog.set_category("rw-conman-log")

        self._dts = None

        self.project_handler = None
        self.projects = {}

    @property
    def dts(self):
        return self._dts

    def start(self):
        super(ConfigManagerTasklet, self).start()

        self.log.debug("Registering with dts")

        self._dts = rift.tasklets.DTS(self.tasklet_info, conmanY.get_schema(),
                                      self.loop, self.on_dts_state_change)

        self.log.debug("Created DTS Api GI Object: %s", self._dts)

    def on_instance_started(self):
        self.log.debug("Got instance started callback")

    @asyncio.coroutine
    def init(self):
        self.log.debug("creating project handler")
        self.project_handler = ProjectHandler(self, ConfigManagerProject)
        self.project_handler.register()

    @asyncio.coroutine
    def run(self):
        pass

    @asyncio.coroutine
    def on_dts_state_change(self, state):
        """Take action according to current dts state to transition
        application into the corresponding application state

        Arguments
            state - current dts state
        """
        switch = {
            rwdts.State.INIT: rwdts.State.REGN_COMPLETE,
            rwdts.State.CONFIG: rwdts.State.RUN,
        }

        handlers = {
            rwdts.State.INIT: self.init,
            rwdts.State.RUN: self.run,
        }

        # Transition application to next state
        handler = handlers.get(state, None)
        if handler is not None:
            yield from handler()

        # Transition dts to next state
        next_state = switch.get(state, None)
        if next_state is not None:
            self._dts.handle.set_state(next_state)
예제 #15
0
class PackageManagerTasklet(rift.tasklets.Tasklet):
    def __init__(self, *args, **kwargs):
        try:
            super().__init__(*args, **kwargs)
            self.rwlog.set_category("rw-mano-log")
            self.endpoint_rpc = None
            self.schema_rpc = None

            self._project_handler = None
            self.projects = {}

        except Exception as e:
            self.log.exception(e)

    def start(self):

        self.log.debug("Registering with dts")

        try:
            super().start()

            self.dts = rift.tasklets.DTS(self.tasklet_info,
                                         RwLaunchpadYang.get_schema(),
                                         self.loop, self.on_dts_state_change)

            proxy = filesystem.FileSystemProxy(self.loop, self.log, self.dts)
            args = [self.log, self.dts, self.loop]

            args.append(proxy)
            self.endpoint_rpc = rpc.EndpointDiscoveryRpcHandler(*args)
            self.schema_rpc = rpc.SchemaRpcHandler(*args)
            self.delete_rpc = rpc.PackageDeleteOperationsRpcHandler(*args)

            args.append(self)
            self.pkg_op = rpc.PackageOperationsRpcHandler(*args)

            self.project_handler = ProjectHandler(
                self,
                PackageManagerProject,
                proxy=proxy,
            )
        except Exception as e:
            self.log.exception("Exception caught rwpkgmgr start: %s", str(e))
        else:
            self.log.debug("rwpkgmgr started successfully!")

    def stop(self):
        try:
            self.dts.deinit()
        except Exception as e:
            self.log.exception(e)

    @asyncio.coroutine
    def init(self):
        try:
            yield from self.endpoint_rpc.register()
            yield from self.schema_rpc.register()
            yield from self.pkg_op.register()
            yield from self.delete_rpc.register()

            self.log.debug("creating project handler")
            self.project_handler.register()
        except Exception as e:
            self.log.error("Exception caught rwpkgmgr init %s", str(e))

    @asyncio.coroutine
    def run(self):
        pass

    @asyncio.coroutine
    def on_dts_state_change(self, state):
        """Handle DTS state change

        Take action according to current DTS state to transition application
        into the corresponding application state

        Arguments
            state - current dts state

        """
        switch = {
            rwdts.State.INIT: rwdts.State.REGN_COMPLETE,
            rwdts.State.CONFIG: rwdts.State.RUN,
        }

        handlers = {
            rwdts.State.INIT: self.init,
            rwdts.State.RUN: self.run,
        }

        # Transition application to next state
        handler = handlers.get(state, None)
        if handler is not None:
            yield from handler()

        # Transition dts to next state
        next_state = switch.get(state, None)
        if next_state is not None:
            self.dts.handle.set_state(next_state)
예제 #16
0
class LaunchpadTasklet(rift.tasklets.Tasklet):
    UPLOAD_MAX_BODY_SIZE = MAX_BODY_SIZE
    UPLOAD_MAX_BUFFER_SIZE = MAX_BUFFER_SIZE
    UPLOAD_PORT = "4567"

    def __init__(self, *args, **kwargs):
        super(LaunchpadTasklet, self).__init__(*args, **kwargs)
        self.rwlog.set_category("rw-mano-log")
        self.rwlog.set_subcategory("launchpad")

        self.dts = None
        self.project_handler = None

        self.app = None
        self.server = None
        self.projects = {}

    def _get_project(self, project=None):
        if project is None:
            project = DEFAULT_PROJECT

        if project in self.projects:
            return self.projects[project]

        msg = "Project {} not found".format(project)
        self._log.error(msg)
        raise LpProjectNotFound(msg)

    def nsd_catalog_get(self, project=None):
        return self._get_project(project=project).nsd_catalog

    def vnfd_catalog_get(self, project=None):
        return self._get_project(project=project).vnfd_catalog

    def get_cloud_accounts(self, project=None):
        return self._get_project(project=project).cloud_accounts

    def start(self):
        super(LaunchpadTasklet, self).start()
        self.log.info("Starting LaunchpadTasklet")

        self.log.debug("Registering with dts")
        self.dts = rift.tasklets.DTS(self.tasklet_info,
                                     rwlaunchpad.get_schema(), self.loop,
                                     self.on_dts_state_change)

        self.log.debug("Created DTS Api GI Object: %s", self.dts)

    def stop(self):
        try:
            self.server.stop()
            self.dts.deinit()
        except Exception:
            self.log.exception("Caught Exception in LP stop")
            raise

    def get_vnfd_catalog(self, project):
        return self.projects[project].vnfd_catalog

    def get_nsd_catalog(self, project):
        return self.projects[project].nsd_catalog

    @asyncio.coroutine
    def init(self):
        try:
            io_loop = rift.tasklets.tornado.TaskletAsyncIOLoop(
                asyncio_loop=self.loop)
            self.app = uploader.UploaderApplication.from_tasklet(self)
            yield from self.app.register()

            manifest = self.tasklet_info.get_pb_manifest()
            ssl_cert = manifest.bootstrap_phase.rwsecurity.cert
            ssl_key = manifest.bootstrap_phase.rwsecurity.key
            ssl_options = {
                "certfile": ssl_cert,
                "keyfile": ssl_key,
            }

            if manifest.bootstrap_phase.rwsecurity.use_ssl:
                self.server = tornado.httpserver.HTTPServer(
                    self.app,
                    max_body_size=LaunchpadTasklet.UPLOAD_MAX_BODY_SIZE,
                    io_loop=io_loop,
                    ssl_options=ssl_options,
                )

            else:
                self.server = tornado.httpserver.HTTPServer(
                    self.app,
                    max_body_size=LaunchpadTasklet.UPLOAD_MAX_BODY_SIZE,
                    io_loop=io_loop,
                )

            self.log.debug("Registering project handler")
            self.project_handler = ProjectHandler(self,
                                                  LaunchpadProject,
                                                  app=self.app)
            self.project_handler.register()

        except Exception as e:
            self.log.error("Exception : {}".format(e))
            self.log.exception(e)

    @asyncio.coroutine
    def run(self):
        address = rwlib.getenv("RWVM_INTERNAL_IPADDR")
        if (address is None):
            address = ""
        self.server.listen(LaunchpadTasklet.UPLOAD_PORT, address=address)
        self.server.listen(LaunchpadTasklet.UPLOAD_PORT, address="127.0.0.1")

    def on_instance_started(self):
        self.log.debug("Got instance started callback")

    @asyncio.coroutine
    def on_dts_state_change(self, state):
        """Handle DTS state change

        Take action according to current DTS state to transition application
        into the corresponding application state

        Arguments
            state - current dts state

        """
        switch = {
            rwdts.State.INIT: rwdts.State.REGN_COMPLETE,
            rwdts.State.CONFIG: rwdts.State.RUN,
        }

        handlers = {
            rwdts.State.INIT: self.init,
            rwdts.State.RUN: self.run,
        }

        # Transition application to next state
        handler = handlers.get(state, None)
        if handler is not None:
            yield from handler()

        # Transition dts to next state
        next_state = switch.get(state, None)
        if next_state is not None:
            self.dts.handle.set_state(next_state)