コード例 #1
0
 def show_all(self):
     super().show_all()
     self.counter += 1
     if self._switch_to_screen is not None:
         ScreenHandler.push_screen(self._switch_to_screen)
         self._switch_to_screen = None
     elif self._replace_screen is not None:
         ScreenHandler.replace_screen(self._replace_screen)
         self._replace_screen = None
     else:
         self.close()
コード例 #2
0
    def input(self, args, key):
        """Run spokes based on the user choice."""
        if key == "1":
            ScreenHandler.push_screen(self._counter_spoke)
            # this input was processed
            return InputState.PROCESSED

        # return for outer processing
        # the basic processing is 'c' for continue, 'r' for refresh, 'q' to quit
        # otherwise the input is discarded and waiting for a new input
        return key
コード例 #3
0
ファイル: __init__.py プロジェクト: sundeep-anand/anaconda
 def _item_called(self, data):
     item = data
     ScreenHandler.push_screen(item)
コード例 #4
0
ファイル: eula.py プロジェクト: rvykydal/initial-setup
 def _show_license_screen_callback(data):
     # show license
     log.debug("showing the license")
     eula_screen = LicenseScreen()
     ScreenHandler.push_screen(eula_screen)
コード例 #5
0
ファイル: __init__.py プロジェクト: jaymzh/anaconda
 def _item_called(self, data):
     item = data
     ScreenHandler.push_screen(item)
コード例 #6
0
 def _configure_device(self, device):
     md = self._mds[device.name]
     new_spoke = ConfigureDeviceSpoke(self.data, self.storage, self.payload,
                                      self.instclass, md)
     ScreenHandler.push_screen(new_spoke)
コード例 #7
0
ファイル: storage.py プロジェクト: jstodola/anaconda
 def _configure_request(self, request):
     """Configure the given mount request."""
     spoke = ConfigureDeviceSpoke(self.data, self.storage, self.payload,
                                  self._device_tree, request)
     ScreenHandler.push_screen(spoke)
コード例 #8
0
 def _configure_mount_info(self, info):
     """Configure the given mount info."""
     spoke = ConfigureDeviceSpoke(self.data, self.storage, self.payload,
                                  *info)
     ScreenHandler.push_screen(spoke)
コード例 #9
0
    def input(self, args, key):
        if key == "1":
            kvm_conf_list = KVMConfigurationList()
            ScreenHandler.push_screen(kvm_conf_list, args=args)
            return InputState.PROCESSED

        if key == "2":
            kvm_conf_edit = KVMConfigurationViewEditList()
            ScreenHandler.push_screen(kvm_conf_edit, args=KVMHolder.kvms)
            return InputState.PROCESSED

        if key == "p":
            play_book_cloud_create = "create-vm-cloud.yml"
            play_book_ansible_bootstrap = "bootstrap-ansible.yml"
            play_book_snapshot = "create-snapshot.yml"

            date_time = datetime.now().strftime("%Y%m%d_%H%M%S")
            generated_inventory = "/tmp/hosts_{0}".format(date_time)

            prov_results = []
            ansible_bootstrap_results = []
            snapshot_results = []
            start_provisioning = True

            # Get the start time
            start_time = time.time()

            for kvm_conf in KVMHolder.kvms:
                kvm_start_time = time.time()
                r = ansible_runner.run(private_data_dir=".",
                                       playbook=play_book_cloud_create,
                                       extravars=kvm_conf)
                kvm_end_time = time.time()
                kvm_provisioning_duration = kvm_end_time - kvm_start_time
                prov_results.append({
                    "kvm": kvm_conf["vm_name"],
                    "status": r.status,
                    "rc": r.rc,
                    "provtime": kvm_provisioning_duration
                })

            for kvm_conf in KVMHolder.kvms:
                ansible_bootstrap_start_time = time.time()
                r = ansible_runner.run(private_data_dir=".",
                                       playbook=play_book_ansible_bootstrap,
                                       extravars={
                                           "vm_name":
                                           kvm_conf["vm_name"],
                                           "generated_inventory_path":
                                           generated_inventory
                                       })
                ansible_bootstrap_kvm_end_time = time.time()
                kvm_boostrap_duration = ansible_bootstrap_kvm_end_time - ansible_bootstrap_start_time
                ansible_bootstrap_results.append({
                    "kvm":
                    kvm_conf["vm_name"],
                    "status":
                    r.status,
                    "rc":
                    r.rc,
                    "bootstrap_time":
                    kvm_boostrap_duration
                })

            for kvm_conf in KVMHolder.kvms:
                snaphost_start_time = time.time()
                r = ansible_runner.run(
                    private_data_dir=".",
                    playbook=play_book_snapshot,
                    extravars={"domain_name": kvm_conf["vm_name"]})
                snapshot_end_time = time.time()
                snapshost_duration = snapshot_end_time - snaphost_start_time
                snapshot_results.append({
                    "kvm": kvm_conf["vm_name"],
                    "status": r.status,
                    "rc": r.rc,
                    "snapshot_time": snapshost_duration
                })

            # Get the end time
            end_time = time.time()

            #Calculate duration
            provisioning_duration = end_time - start_time

            # Print outcome
            print("{0}\t{1}\t{2}\t{3}".format("KVM".ljust(20),
                                              "STATUS".ljust(15),
                                              "RC".ljust(5),
                                              "PROVISIONING TIME"))
            for res in prov_results:
                print("{0}\t{1}\t{2}\t{3}(s)".format(res["kvm"].ljust(20),
                                                     res["status"].ljust(15),
                                                     str(res["rc"]).ljust(5),
                                                     int(res["provtime"])))

            print("\n")

            print("{0}\t{1}\t{2}\t{3}".format("KVM".ljust(20),
                                              "STATUS".ljust(15),
                                              "RC".ljust(5),
                                              "ANSIBLE BOOTSTRAP TIME"))
            for res in ansible_bootstrap_results:
                print("{0}\t{1}\t{2}\t{3}(s)".format(
                    res["kvm"].ljust(20), res["status"].ljust(15),
                    str(res["rc"]).ljust(5), int(res["bootstrap_time"])))

            print("\n")

            print("{0}\t{1}\t{2}\t{3}".format("KVM".ljust(20),
                                              "STATUS".ljust(15),
                                              "RC".ljust(5), "SNAPSHOT TIME"))
            for res in snapshot_results:
                print("{0}\t{1}\t{2}\t{3}(s)".format(
                    res["kvm"].ljust(20), res["status"].ljust(15),
                    str(res["rc"]).ljust(5), int(res["snapshot_time"])))

            print("")
            print("Total Provisining Time: {0}(s)".format(
                int(provisioning_duration)))
            print("You can find an auto-generated ansible inventory in {0}".
                  format(generated_inventory))
            print(
                "A snapshot named 'init' has been auto-created for each KVM. You can use this to revert the KVMs to the original provisioned state at any time :)"
            )

            return InputState.PROCESSED_AND_CLOSE

        return key
コード例 #10
0
    def _push_screen_callback(self, target_screen):
        """Push target screen as new screen.

        Target screen is passed in as an argument in the refresh() method.
        """
        ScreenHandler.push_screen(target_screen)
コード例 #11
0
ファイル: storage.py プロジェクト: rvykydal/anaconda
 def _configure_mount_info(self, info):
     """Configure the given mount info."""
     spoke = ConfigureDeviceSpoke(self.data, self.storage, self.payload, *info)
     ScreenHandler.push_screen(spoke)