This file is indexed.

/usr/bin/pb-api-shell is in profitbricks-api-tools 4.1.1-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/python3

# Copyright (C) 2015-2017, ProfitBricks GmbH
# Authors: Benjamin Drung <benjamin.drung@profitbricks.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# pylint: disable=invalid-name

"""Interactive Python shell for the ProfitBricks REST API"""

import argparse
import code
import logging

import profitbricks
import profitbricks.client


def main():
    """Main function of the interactive Python shell for the ProfitBricks REST API"""
    parser = argparse.ArgumentParser()
    parser.add_argument('-b', '--base-uri', default=profitbricks.API_HOST,
                        help="Base URI for the REST API (default: %(default)s)")
    parser.add_argument('-c', dest="cmd", help="program passed in as string")
    parser.add_argument('-u', '--username',
                        help="ProfitBricks user name (i.e. email address, "
                             "default: read from config)")
    args = parser.parse_args()

    logging.getLogger("requests").setLevel(logging.WARNING)
    logger = logging.getLogger("pb-api-shell")
    client = profitbricks.client.ProfitBricksService(
        username=args.username, host_base=args.base_uri, client_user_agent='pb-api-shell/1.0')

    if args.cmd is None:
        banner = ("The ProfitBricks client can be accessed through the 'client' object.\n"
                  "Other available objects: Datacenter, FirewallRule, Group, IPBlock, LAN,\n"
                  "                         LoadBalancer, NIC, Server, Snapshot, User, Volume")
        variables = {
            'client': client,
            'Datacenter': profitbricks.client.Datacenter,
            'FirewallRule': profitbricks.client.FirewallRule,
            'Group': profitbricks.client.Group,
            'IPBlock': profitbricks.client.IPBlock,
            'LAN': profitbricks.client.LAN,
            'LoadBalancer': profitbricks.client.LoadBalancer,
            'NIC': profitbricks.client.NIC,
            'Server': profitbricks.client.Server,
            'Snapshot': profitbricks.client.Snapshot,
            'User': profitbricks.client.User,
            'Volume': profitbricks.client.Volume,
        }

        shell = None
        try:
            from IPython.terminal.embed import InteractiveShellEmbed
            shell = InteractiveShellEmbed(banner2=banner, user_ns=variables)

        except ImportError:
            logger.warning("IPython not available. Using normal Python shell.")

        if shell:
            shell()
        else:
            try:
                import readline
            except ImportError:
                logger.info("readline module not available. No tab-completion enabled.")
            else:
                import rlcompleter  # noqa, pylint: disable=unused-variable
                readline.parse_and_bind("tab: complete")
            console = code.InteractiveConsole(locals=variables)
            console.interact(banner)
    else:
        eval(args.cmd)  # pylint: disable=eval-used


if __name__ == '__main__':
    main()