Пример #1
0
def init_shell(exe_string, parser, username='', userid=''):
    parser.arguments.pop('version', None)
    shell = Shell()
    shell.set_prompt(exe_string)
    from kamaki import __version__ as version
    shell.greet(version, username, userid)
    shell.do_EOF = shell.do_exit
    from kamaki.cli.cmdtree import CommandTree
    shell.cmd_tree = CommandTree('kamaki',
                                 'A command line tool for poking clouds')
    return shell
Пример #2
0
from kamaki.cli import command
from kamaki.clients.astakos import LoggedAstakosClient, ClientError
from kamaki.cli.cmds import (CommandInit, NameFilter, OptionalOutput, errors,
                             client_log)
from kamaki.cli.cmdtree import CommandTree
from kamaki.cli.errors import (CLIBaseUrlError, CLISyntaxError, CLIError,
                               CLIInvalidArgument)
from kamaki.cli.argument import (FlagArgument, ValueArgument, IntArgument,
                                 CommaSeparatedListArgument, KeyValueArgument,
                                 DateArgument, BooleanArgument,
                                 UserAccountArgument, RepeatableArgument)
from kamaki.cli.utils import format_size, filter_dicts_by_dict

#  Mandatory

user_cmds = CommandTree('user', 'Astakos/Identity API commands')
quota_cmds = CommandTree('quota', 'Astakos/Account API commands for quotas')
resource_cmds = CommandTree('resource',
                            'Astakos/Account API commands for resources')
project_cmds = CommandTree('project', 'Astakos project API commands')
membership_cmds = CommandTree('membership',
                              'Astakos project membership API commands')

#  Optional

endpoint_cmds = CommandTree('endpoint',
                            'Astakos/Account API commands for endpoints')
service_cmds = CommandTree('service', 'Astakos API commands for services')
commission_cmds = CommandTree('commission',
                              'Astakos API commands for commissions')
Пример #3
0
from kamaki.cli import command
from kamaki.cli.cmdtree import CommandTree
from kamaki.cli.utils import remove_from_items, filter_dicts_by_dict
from kamaki.cli.errors import CLIError, CLISyntaxError, CLIInvalidArgument
from kamaki.clients.cyclades import (
    CycladesComputeClient, ClientError, CycladesNetworkClient)
from kamaki.cli.argument import (
    FlagArgument, ValueArgument, KeyValueArgument, RepeatableArgument,
    DateArgument, IntArgument, StatusArgument)
from kamaki.cli.cmds import (
    CommandInit, fall_back, OptionalOutput, NameFilter, IDFilter, Wait, errors,
    client_log)


server_cmds = CommandTree('server', 'Cyclades/Compute API server commands')
flavor_cmds = CommandTree('flavor', 'Cyclades/Compute API flavor commands')
keypair_cmds = CommandTree('keypair', 'Cyclades/Compute API keypair commands')
namespaces = [server_cmds, flavor_cmds, keypair_cmds]

howto_personality = [
    'Defines a file to be injected to virtual servers file system.',
    'syntax:  PATH,[SERVER_PATH,[OWNER,[GROUP,[MODE]]]]',
    '  [local-path=]PATH: local file to be injected (relative or absolute)',
    '  [server-path=]SERVER_PATH: destination location inside server Image',
    '  [owner=]OWNER: virtual servers user id for the remote file',
    '  [group=]GROUP: virtual servers group id or name for the remote file',
    '  [mode=]MODE: permission in octal (e.g., 0777)',
    'e.g., -p /tmp/my.file,owner=root,mode=0777']

server_states = ('BUILD', 'ACTIVE', 'STOPPED', 'REBOOT', 'ERROR')
Пример #4
0
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.command

from kamaki.cli import command
from kamaki.cli.errors import CLIInvalidArgument
from kamaki.cli.cmdtree import CommandTree
from kamaki.cli.cmds import (CommandInit, errors, client_log, OptionalOutput,
                             Wait)
from kamaki.clients.cyclades import CycladesBlockStorageClient, ClientError
from kamaki.cli import argument

volume_cmds = CommandTree('volume', 'Block Storage API volume commands')
snapshot_cmds = CommandTree('snapshot', 'Block Storage API snapshot commands')
namespaces = [volume_cmds, snapshot_cmds]
_commands = namespaces

volume_states = (
    'creating',
    'available',
    'attaching',
    'detaching',
    'in_use',
    'deleting',
    'deleted',
    'error',
    'error_deleting',
    'backing_up',
Пример #5
0
from io import StringIO
from pydoc import pager

from kamaki.cli import command
from kamaki.cli.cmdtree import CommandTree
from kamaki.cli.errors import CLIInvalidArgument, raiseCLIError
from kamaki.clients.cyclades import (CycladesNetworkClient, ClientError,
                                     CycladesComputeClient)
from kamaki.cli.argument import (FlagArgument, ValueArgument,
                                 RepeatableArgument, IntArgument,
                                 StatusArgument)
from kamaki.cli.cmds import (CommandInit, OptionalOutput, NameFilter, IDFilter,
                             errors, client_log)
from kamaki.cli.cmds import Wait

network_cmds = CommandTree('network', 'Network API network commands')
port_cmds = CommandTree('port', 'Network API port commands')
subnet_cmds = CommandTree('subnet', 'Network API subnet commands')
ip_cmds = CommandTree('ip', 'Network API floatingip commands')
namespaces = [network_cmds, port_cmds, subnet_cmds, ip_cmds]

port_states = ('BUILD', 'ACTIVE', 'DOWN', 'ERROR')


class _PortWait(Wait):
    def wait_while(self, port_id, current_status, timeout=60):
        super(_PortWait, self).wait('Port',
                                    port_id,
                                    self.client.wait_port_while,
                                    current_status,
                                    timeout=timeout)
Пример #6
0
from kamaki.cli import command
from kamaki.cli.cmdtree import CommandTree
from kamaki.cli.utils import filter_dicts_by_dict, format_size
from kamaki.clients.image import ImageClient
from kamaki.clients.pithos import PithosClient
from kamaki.clients import ClientError
from kamaki.cli.argument import (
    FlagArgument, ValueArgument, RepeatableArgument, KeyValueArgument,
    IntArgument, ProgressBarArgument)
from kamaki.cli.cmds.cyclades import _CycladesInit
from kamaki.cli.errors import CLIError, raiseCLIError, CLIInvalidArgument
from kamaki.cli.cmds import (
    CommandInit, errors, client_log, OptionalOutput, NameFilter, IDFilter)


image_cmds = CommandTree('image', 'Cyclades/Plankton API image commands')
imagecompute_cmds = CommandTree(
    'imagecompute', 'Cyclades/Compute API image commands')
namespaces = [image_cmds, imagecompute_cmds]


howto_image_file = [
    'To get current user id', '  kamaki user info',
    'To list all containers', '  kamaki container list',
    'To create a new container', '  kamaki container create CONTAINER',
    'To list container contents', '  kamaki file list /CONTAINER',
    'To upload files', '  kamaki file upload FILE /CONTAINER[/PATH]',
    'To register an image',
    '  kamaki image register --name=IMAGE_NAME --location=/CONTAINER/PATH']

about_image_id = ['To list all images', '  kamaki image list']
Пример #7
0
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.

from kamaki.cli import command
from kamaki.cli.argument import FlagArgument
from kamaki.cli.cmds import CommandInit, errors
from kamaki.cli.cmdtree import CommandTree
from kamaki.cli.errors import CLIError, CLISyntaxError
from kamaki.cli.config import DOCUMENTATION

config_cmds = CommandTree('config', 'Kamaki configurations')
namespaces = [
    config_cmds,
]

about_options = '\nAbout options:\
    \n. syntax: [group.]option\
    \n. example: global.log_file\
    \n. special case: <option> is equivalent to global.<option>\
    \n. configuration file syntax:\
    \n.   [group]\
    \n.   option=value\
    \n.   (more options can be set per group)\
    \n.\
    \n. special case: named clouds.\
    \n. example: cloud.demo.url\
Пример #8
0
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.

from datetime import date

from kamaki.cli import command
from kamaki.cli.errors import CLIError
from kamaki.cli.cmdtree import CommandTree
from kamaki.cli.cmds import errors, OptionalOutput
from kamaki.cli.cmds.pithos import _PithosAccount
from kamaki.cli.argument import FlagArgument

scripts_cmds = CommandTree('scripts', 'Useful scripts')
namespaces = [
    scripts_cmds,
]


@command(scripts_cmds)
class scripts_verifyfs(_PithosAccount, OptionalOutput):
    """Verify/Fix the structure of directory objects inside a container"""

    arguments = dict(
        fix_conflicts=FlagArgument(
            'Fix conflicting names by renaming them '
            '(prepare the structure of directory objects to be consistent)',
            '--fix-conflicts'),
        fix_names=FlagArgument('Rename directory objects containing \\',
Пример #9
0
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.

from kamaki.cli.cmdtree import CommandTree
from kamaki.cli.argument import ValueArgument
from kamaki.cli.history import History
from kamaki.cli import command
from kamaki.cli.cmds import CommandInit, errors

history_cmds = CommandTree('history', 'Kamaki command history')
namespaces = [history_cmds]


class _HistoryInit(CommandInit):
    @errors.Generic.all
    @errors.History.init
    def _run(self):
        self.history = History(self.config.get('global', 'history_file'))
        self.history.limit = self.config.get('global', 'history_limit')

    def main(self):
        self._run()


@command(history_cmds)