Example #1
0
    def tear_down(self, infra_id):
        """
        Tear down an infrastructure.

        This method tears down a running, but unmanaged infrastructure. For
        this purpose, an Infrastructure Processor is created, so this method
        does not rely on the Enactor's ability (non-existent at the time of
        writing) to tear down an infrastructure.

        If the infrastructure is being provisioned (the manager is attached),
        this method will fail, and *not* call :meth:`stop_provisioning`
        implicitly.

        :param str infra_id: The identifier of the infrastructure.
        :raise ValueError: if the infrastructure is being maintained by this
            manager. Call :meth:`stop_provisioning` first, explicitly.
        """

        if infra_id in self.process_table:
            raise ValueError(
                'Cannot tear down an infrastructure while it\'s '
                'being maintained.', infra_id)

        log.debug('Tearing down infrastructure %s', infra_id)

        from occo.infraprocessor import InfraProcessor
        ip = InfraProcessor.instantiate(protocol='basic',
                                        process_strategy=self.process_strategy)

        import occo.api.occoapp as occoapp
        occoapp.teardown(infra_id, ip)
Example #2
0
    def tear_down(self, infra_id):
        """
        Tear down an infrastructure.

        This method tears down a running, but unmanaged infrastructure. For
        this purpose, an Infrastructure Processor is created, so this method
        does not rely on the Enactor's ability (non-existent at the time of
        writing) to tear down an infrastructure.

        If the infrastructure is being provisioned (the manager is attached),
        this method will fail, and *not* call :meth:`stop_provisioning`
        implicitly.

        :param str infra_id: The identifier of the infrastructure.
        :raise ValueError: if the infrastructure is being maintained by this
            manager. Call :meth:`stop_provisioning` first, explicitly.
        """

        if infra_id in self.process_table:
            raise ValueError(
                'Cannot tear down an infrastructure while it\'s '
                'being maintained.', infra_id)

        log.debug('Tearing down infrastructure %r', infra_id)

        from occo.infraprocessor import InfraProcessor
        ip = InfraProcessor.instantiate(protocol='basic',
                                        process_strategy=self.process_strategy)

        import occo.api.occoapp as occoapp
        occoapp.teardown(infra_id, ip)
Example #3
0
    def __call__(self):
        log.info('Starting maintenance process for %r', self.infra_id)

        from occo.enactor import Enactor
        from occo.infraprocessor import InfraProcessor

        infraprocessor = InfraProcessor.instantiate(
                                        protocol='basic',
                                        process_strategy=self.process_strategy)
        enactor = Enactor(self.infra_id, infraprocessor)
        try:
            while True:
                enactor.make_a_pass()
                time.sleep(self.enactor_interval)
        except KeyboardInterrupt:
            log.info('Ctrl+C - exiting.')
            infraprocessor.cancel_pending()
        except:
            log.exception('Unexpected error:')
            exit(1)
Example #4
0
    def __call__(self):
        log.info('Starting maintenance process for %s', self.infra_id)

        from occo.enactor import Enactor
        from occo.infraprocessor import InfraProcessor

        infraprocessor = InfraProcessor.instantiate(
                                        protocol='basic',
                                        process_strategy=self.process_strategy)
        enactor = Enactor(self.infra_id, infraprocessor)
        while True:
            try:
                enactor.make_a_pass()
                time.sleep(self.enactor_interval)
            except KeyboardInterrupt:
                log.info('Ctrl+C - exiting.')
                infraprocessor.cancel_pending()
                return 1
            except Exception as ex:
                log.error('Unexpected error:')
                log.debug(traceback.format_exc())
                log.error(str(ex))
                time.sleep(self.enactor_interval)