Example #1
0
    def instances_management_menu(self):
        """
        Show instances management menu.
        """
        cp = self.print_menu(*self.cloud_provider_menu_desc)
        if cp == 1:
            deploy = awsde.AmazonCP(self.protocol_config)
            menu_color = 'red'
        elif cp == 2:
            deploy = sde.ScalewayCP(self.protocol_config)
            menu_color = 'magenta'
        elif cp == 3:
            deploy = mde.MultiCP(self.protocol_config)
            menu_color = 'blue'
        elif cp == 4:
            return

        selection = self.print_menu(*self.deploy_menu_desc, menu_color)

        if selection == 1:
            deploy.deploy_instances()
        elif selection == 2:
            deploy.create_key_pair()
        elif selection == 3:
            deploy.create_security_group()
        elif selection == 4:
            deploy.get_network_details()
        elif selection == 5:
            deploy.terminate_instances()
        elif selection == 6:
            deploy.change_instance_types()
        elif selection == 7:
            deploy.start_instances()
        elif selection == 8:
            deploy.stop_instances()
Example #2
0
    def instances_management_menu(self):
        """
        Show instances management menu.
        """
        cp = list(self.protocol_config['cloudProviders'].keys())
        if len(cp) > 1:
            deploy = mde.MultiCP(self.protocol_config)
            menu_color = 'blue'

        elif 'Azure' in cp:
            menu_color = 'azure'
            deploy = azde.AzureCP(self.protocol_config)
        elif 'AWS' in cp:
            deploy = awsde.AmazonCP(self.protocol_config)
            menu_color = 'red'
        elif 'local' in cp or 'servers' in cp:
            deploy = de.DeployCP(self.protocol_config)
            menu_color = 'blue'
        else:
            return

        selection = self.print_menu(*self.deploy_menu_desc, menu_color)

        try:
            if selection == 1:
                deploy.deploy_instances()
            elif selection == 2:
                deploy.create_key_pair()
            elif selection == 3:
                deploy.create_security_group()
            elif selection == 4:
                deploy.get_network_details()
            elif selection == 5:
                deploy.terminate_instances()
            elif selection == 6:
                deploy.change_instance_types()
            elif selection == 7:
                deploy.start_instances()
            elif selection == 8:
                deploy.stop_instances()
            elif selection == 9:
                deploy.cancel_spot_requests()
            elif selection == 10:
                deploy.copy_ami()
        except NotImplementedError:
            MatrixMenu.color_print(
                "Selected action '{}' is not implemented for the chosen deployment '{}'"
                .format(self.deploy_menu_desc[1][selection - 1],
                        self.cloud_provider_menu_desc[1][cp - 1]), menu_color)
            self.instances_management_menu()