Esempio n. 1
0
 def _platform_extra_menu(self):
     """
     Print the extra Functions Menu (specific for each platform)
     """
     while (True):
         menu_header = self.platform_name + " Extra Commands"
         menu_subheader = [
             "Region: \033[1;94m" + self._platform_get_region() + "\033[0m"
         ]
         menu_items = [
             "Promote ephimeral IP to static", "Demote a static IP",
             "List instances for all the regions",
             "List volumes for all the regions",
             "List floating ips for all the regions",
             "Back to the Main Menu"
         ]
         choice = SimpleTUI.print_menu(menu_header, menu_items,
                                       menu_subheader)
         if choice == 1:  # Promote IP
             self.promote_ephimeral_ip()
         elif choice == 2:  # Demote IP
             answer = SimpleTUI.yn_dialog(
                 "Demotion status",
                 "You can demote a static IP easily deleting it through \"Manage floating IPs\" > \"Release a reserved Floating IP\".\n"
                 +
                 "NOTE: the static IP won't be removed from the associated instance until the latter is stopped/rebooted/deleted.\n"
                 +
                 "For more infos about Ephimeral/Static IPs on GCP, please visit https://cloud.google.com/compute/docs/ip-addresses/.\n"
                 +
                 "Would you like to start the \"Release a reserved Floating IP\" wizard now?",
                 SimpleTUI.DIALOG_INFO)
             if answer:
                 self.release_floating_ip()
         elif choice == 3:  # List all the instances (Global)
             SimpleTUI.list_dialog("Instances available (Global view)",
                                   list_printer=self.print_global_instances)
         elif choice == 4:  # List all the volumes (Global)
             SimpleTUI.list_dialog("Volumes available (Global view)",
                                   list_printer=self.print_global_volumes)
         elif choice == 5:  # List all the floating ips (Global)
             SimpleTUI.list_dialog(
                 "Floating IPs available (Global view)",
                 list_printer=self.print_global_floating_ips)
         elif choice == 6:
             break
         else:
             SimpleTUI.msg_dialog("Error", "Unimplemented functionality",
                                  SimpleTUI.DIALOG_ERROR)
Esempio n. 2
0
 def _platform_extra_menu(self):
     """
     Print the extra Functions Menu (specific for each platform)
     """
     while (True):
         menu_header = self.platform_name + " Extra Commands"
         menu_subheader = [
             "Region: \033[1;94m" + self._platform_get_region() + "\033[0m"
         ]
         menu_items = ["Back to the Main Menu"]
         choice = SimpleTUI.print_menu(menu_header, menu_items,
                                       menu_subheader)
         # if choice == 1 and self._is_barebone():  # Blazar menu
         if choice == 1:
             break
         else:
             SimpleTUI.msg_dialog("Error", "Unimplemented functionality",
                                  SimpleTUI.DIALOG_ERROR)
Esempio n. 3
0
    def menu(self):
        """
        Prints the modules menu
        """
        global kill

        while True:
            # Header creation
            menu_header = "******************** EasyCloud ********************"
            # Subheader creation
            disclaimer = "\033[34;1mThis is a proof-of-concept build, not suitable\nfor production use.\033[0m\n"
            debug_status = None
            hffr_status = None
            if "LIBCLOUD_DEBUG" in environ:
                debug_status = "\033[93mLibcloud Debug Mode ON\033[0m"
            else:
                debug_status = "\033[90mLibcloud Debug Mode OFF\033[0m"
            if "LIBCLOUD_DEBUG_PRETTY_PRINT_RESPONSE" in environ and environ["LIBCLOUD_DEBUG_PRETTY_PRINT_RESPONSE"] == "1":
                hffr_status = "\033[93mLibcloud Human friendly formatted response ON\033[0m"
            else:
                hffr_status = "\033[90mLibcloud Human friendly formatted response OFF\033[0m"
            menu_subheader = [disclaimer, debug_status, hffr_status]
            # Menu items creation
            menu_items = []
            for module in self.loaded_modules:
                menu_items.append(module.platform_name)
            menu_items.append("Close application")
            # Menu print
            choice = SimpleTUI.print_menu(menu_header, menu_items,
                                          subheader_items=menu_subheader,
                                          custom_question="Select a platform")
            try:
                if(choice >= 1 and choice <= len(self.loaded_modules)):
                    return self.loaded_modules[choice - 1]  # Load a module
                elif(choice == len(self.loaded_modules) + 1):  # Close application
                    self.close(0)
                else:
                    SimpleTUI.msg_dialog("Error", "Unimplemented functionality", SimpleTUI.DIALOG_ERROR)
            except Exception as e:
                SimpleTUI.exception_dialog(e)