當前位置: 首頁>>代碼示例>>Python>>正文


Python PlacementController.set_autosave_filename方法代碼示例

本文整理匯總了Python中cloudinstall.placement.controller.PlacementController.set_autosave_filename方法的典型用法代碼示例。如果您正苦於以下問題:Python PlacementController.set_autosave_filename方法的具體用法?Python PlacementController.set_autosave_filename怎麽用?Python PlacementController.set_autosave_filename使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cloudinstall.placement.controller.PlacementController的用法示例。


在下文中一共展示了PlacementController.set_autosave_filename方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from cloudinstall.placement.controller import PlacementController [as 別名]
# 或者: from cloudinstall.placement.controller.PlacementController import set_autosave_filename [as 別名]

#.........這裏部分代碼省略.........
            self.maas_state, self.config)

        if path.exists(self.config.placements_filename):
            try:
                with open(self.config.placements_filename, 'r') as pf:
                    self.placement_controller.load(pf)
            except Exception:
                log.exception("Exception loading placement")
                raise Exception("Could not load "
                                "{}.".format(self.config.placements_filename))
            self.ui.status_info_message("Loaded placements from file")
            log.info("Loaded placements from "
                     "'{}'".format(self.config.placements_filename))

            # If we have no machines (so we are a fresh install) but
            # are reading a placements.yaml from a previous install,
            # so it has no assignments, only deployments, tell the
            # controller to use the deployments in the file as
            # assignments:
            if len(self.placement_controller.machines_pending()) == 0 and \
               len(self.juju_state.machines()) == 0:
                self.placement_controller.set_assignments_from_deployments()
                log.info("Using deployments saved from previous install"
                         " as new assignments.")
        else:
            if self.config.is_multi():
                def_assignments = self.placement_controller.gen_defaults()
            else:
                def_assignments = self.placement_controller.gen_single()

            self.placement_controller.set_all_assignments(def_assignments)

        pfn = self.config.placements_filename
        self.placement_controller.set_autosave_filename(pfn)
        self.placement_controller.do_autosave()

        if self.config.is_single():
            if self.config.getopt('headless'):
                self.begin_deployment()
            else:
                async.submit(self.begin_deployment,
                             self.ui.show_exception_message)
            return

        if self.config.getopt('edit_placement') or \
           not self.placement_controller.can_deploy():
            self.config.setopt(
                'current_state', ControllerState.PLACEMENT.value)
        else:
            if self.config.getopt('headless'):
                self.begin_deployment()
            else:
                async.submit(self.begin_deployment,
                             self.ui.show_exception_message)

    def commit_placement(self):
        self.config.setopt('current_state', ControllerState.SERVICES.value)
        self.ui.render_services_view(self.nodes, self.juju_state,
                                     self.maas_state, self.config)
        self.loop.redraw_screen()
        if self.config.getopt('headless'):
            self.begin_deployment()
        else:
            async.submit(self.begin_deployment,
                         self.ui.show_exception_message)
開發者ID:Ubuntu-Solutions-Engineering,項目名稱:openstack-installer,代碼行數:69,代碼來源:core.py

示例2: __init__

# 需要導入模塊: from cloudinstall.placement.controller import PlacementController [as 別名]
# 或者: from cloudinstall.placement.controller.PlacementController import set_autosave_filename [as 別名]

#.........這裏部分代碼省略.........
            if self.config.is_multi():
                creds = self.config.getopt('maascreds')
                self.maas, self.maas_state = connect_to_maas(creds)

        self.placement_controller = PlacementController(
            self.maas_state, self.config)

        if path.exists(self.config.placements_filename):
            with open(self.config.placements_filename, 'r') as pf:
                self.placement_controller.load(pf)
            self.ui.status_info_message("Loaded placements from file.")
            log.info("Loaded placements from "
                     "'{}'".format(self.config.placements_filename))

            # If we have no machines (so we are a fresh install) but
            # are reading a placements.yaml from a previous install,
            # so it has no assignments, only deployments, tell the
            # controller to use the deployments in the file as
            # assignments:
            if len(self.placement_controller.machines_pending()) == 0 and \
               len(self.juju_state.machines()) == 0:
                self.placement_controller.set_assignments_from_deployments()
                log.info("Using deployments saved from previous install"
                         " as new assignments.")
        else:
            if self.config.is_multi():
                def_assignments = self.placement_controller.gen_defaults()
            else:
                def_assignments = self.placement_controller.gen_single()

            self.placement_controller.set_all_assignments(def_assignments)

        pfn = self.config.placements_filename
        self.placement_controller.set_autosave_filename(pfn)
        self.placement_controller.do_autosave()

        if self.config.is_single():
            if self.config.getopt('headless'):
                self.begin_deployment()
            else:
                self.begin_deployment_async()
            return

        if self.config.getopt('edit_placement') or \
           not self.placement_controller.can_deploy():
            self.config.setopt(
                'current_state', ControllerState.PLACEMENT.value)
        else:
            if self.config.getopt('headless'):
                self.begin_deployment()
            else:
                self.begin_deployment_async()

    @utils.async
    def wait_for_maas_async(self):
        """ explicit async method
        """
        self.wait_for_maas()

    def wait_for_maas(self):
        """ install and configure maas """
        random_status = ["Packages are being installed to a MAAS container.",
                         "There's a few packages, it'll take just a minute",
                         "Checkout http://maas.ubuntu.com/ while you wait."]
        is_connected = False
        count = 0
開發者ID:JamesGuthrie,項目名稱:openstack-installer,代碼行數:70,代碼來源:core.py

示例3: __init__

# 需要導入模塊: from cloudinstall.placement.controller import PlacementController [as 別名]
# 或者: from cloudinstall.placement.controller.PlacementController import set_autosave_filename [as 別名]
class DisplayController:

    """ Controller for displaying juju and maas state."""

    def __init__(self, ui=None, opts=None):
        self.ui = ui
        self.opts = opts
        self.config = Config()
        self.juju_state = None
        self.juju = None
        self.maas = None
        self.maas_state = None
        self.nodes = None
        self.placement_controller = None
        self.current_state = ControllerState.INSTALL_WAIT

    def authenticate_juju(self):
        if not len(self.config.juju_env['state-servers']) > 0:
            state_server = 'localhost:17070'
        else:
            state_server = self.config.juju_env['state-servers'][0]
        self.juju = JujuClient(
            url=path.join('wss://', state_server),
            password=self.config.juju_api_password)
        self.juju.login()
        self.juju_state = JujuState(self.juju)
        log.debug('Authenticated against juju api.')

    def initialize(self):
        """Authenticates against juju/maas and sets up placement controller."""
        if getenv("FAKE_API_DATA"):
            self.juju_state = FakeJujuState()
            self.maas_state = FakeMaasState()
        else:
            self.authenticate_juju()
            if self.config.is_multi:
                creds = self.config.maas_creds
                self.maas, self.maas_state = connect_to_maas(creds)

        self.placement_controller = PlacementController(
            self.maas_state, self.opts)

        if path.exists(self.config.placements_filename):
            with open(self.config.placements_filename, 'r') as pf:
                self.placement_controller.load(pf)
            self.info_message("Loaded placements from file.")

        else:
            if self.config.is_multi:
                def_assignments = self.placement_controller.gen_defaults()
            else:
                def_assignments = self.placement_controller.gen_single()

            self.placement_controller.set_all_assignments(def_assignments)

        pfn = self.config.placements_filename
        self.placement_controller.set_autosave_filename(pfn)
        self.placement_controller.do_autosave()

        if self.config.is_single:
            self.begin_deployment_async()
            return

        if self.opts.edit_placement or \
           not self.placement_controller.can_deploy():
            self.current_state = ControllerState.PLACEMENT
        else:
            self.begin_deployment_async()

    def begin_deployment_async(self):
        """To be overridden in subclasses."""
        pass

    def begin_deployment(self):
        """To be overridden in subclasses."""
        pass

    # overlays

    def step_info(self, message):
        with dialog_context(self):
            self.ui.show_step_info(message)

    def show_password_input(self, title, cb):
        with dialog_context(self):
            self.ui.show_password_input(title, cb)

    def show_maas_input(self, title, cb):
        with dialog_context(self):
            self.ui.show_maas_input(title, cb)

    def show_landscape_input(self, title, cb):
        with dialog_context(self):
            self.ui.show_landscape_input(title, cb)

    def show_selector_info(self, title, opts, cb):
        with dialog_context(self):
            self.ui.show_selector_info(title, opts, cb)

    def show_selector_with_desc(self, title, install_types, cb):
#.........這裏部分代碼省略.........
開發者ID:xrobau,項目名稱:openstack-installer,代碼行數:103,代碼來源:core.py


注:本文中的cloudinstall.placement.controller.PlacementController.set_autosave_filename方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。