tiktalik-cli 1.11.0__tar.gz → 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tiktalik_cli-2.0.0/LICENSE.txt +7 -0
- {tiktalik_cli-1.11.0 → tiktalik_cli-2.0.0}/PKG-INFO +35 -7
- tiktalik_cli-2.0.0/README.md +73 -0
- {tiktalik_cli-1.11.0 → tiktalik_cli-2.0.0}/pyproject.toml +28 -12
- tiktalik_cli-2.0.0/pyproject.toml.orig +58 -0
- {tiktalik_cli-1.11.0 → tiktalik_cli-2.0.0}/src/tiktalik_cli/auth.py +9 -14
- {tiktalik_cli-1.11.0 → tiktalik_cli-2.0.0}/src/tiktalik_cli/command/auth.py +21 -7
- {tiktalik_cli-1.11.0 → tiktalik_cli-2.0.0}/src/tiktalik_cli/command/command.py +14 -10
- {tiktalik_cli-1.11.0 → tiktalik_cli-2.0.0}/src/tiktalik_cli/command/image.py +3 -3
- {tiktalik_cli-1.11.0 → tiktalik_cli-2.0.0}/src/tiktalik_cli/command/instance.py +33 -36
- {tiktalik_cli-1.11.0 → tiktalik_cli-2.0.0}/src/tiktalik_cli/command/network.py +14 -18
- tiktalik_cli-2.0.0/src/tiktalik_cli/command/util.py +66 -0
- {tiktalik_cli-1.11.0 → tiktalik_cli-2.0.0}/src/tiktalik_cli/main.py +9 -10
- tiktalik_cli-1.11.0/README.md +0 -45
- tiktalik_cli-1.11.0/src/tiktalik_cli/command/util.py +0 -140
- {tiktalik_cli-1.11.0 → tiktalik_cli-2.0.0}/src/tiktalik_cli/__init__.py +0 -0
- {tiktalik_cli-1.11.0 → tiktalik_cli-2.0.0}/src/tiktalik_cli/command/__init__.py +24 -24
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2020 Techstorage sp. z o.o.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tiktalik-cli
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: Tiktalik Computing command line interface
|
|
5
5
|
Keywords: Tiktalik,CLI,Terminal,VPS
|
|
6
6
|
Author: Techstorage sp. z o.o
|
|
7
7
|
Author-email: Techstorage sp. z o.o <kontakt@tiktalik.com>
|
|
8
8
|
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE.txt
|
|
9
10
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
15
16
|
Classifier: Development Status :: 6 - Mature
|
|
16
17
|
Classifier: Environment :: Console
|
|
17
18
|
Classifier: Intended Audience :: Developers
|
|
@@ -24,9 +25,8 @@ Classifier: Operating System :: Microsoft :: Windows
|
|
|
24
25
|
Classifier: Topic :: Internet
|
|
25
26
|
Classifier: Topic :: Utilities
|
|
26
27
|
Classifier: Topic :: System :: Systems Administration
|
|
27
|
-
|
|
28
|
-
Requires-
|
|
29
|
-
Requires-Python: >=3.10
|
|
28
|
+
Requires-Dist: tiktalik>=2.1.0,<3
|
|
29
|
+
Requires-Python: >=3.11
|
|
30
30
|
Project-URL: Homepage, https://www.tiktalik.com
|
|
31
31
|
Project-URL: Repository, https://github.com/tiktalik-cloud/tiktalik-cli.git
|
|
32
32
|
Description-Content-Type: text/markdown
|
|
@@ -39,7 +39,7 @@ user to perform core operations on the [Tiktalik Cloud Computing](http://www.tik
|
|
|
39
39
|
## Requirements
|
|
40
40
|
|
|
41
41
|
* [tiktalik-python](https://github.com/tiktalik-cloud/tiktalik-python)
|
|
42
|
-
* Python >=3.
|
|
42
|
+
* Python >=3.11
|
|
43
43
|
|
|
44
44
|
Note that package dependencies are automatically installed by pip.
|
|
45
45
|
|
|
@@ -75,4 +75,32 @@ To get a help on a specific command, run:
|
|
|
75
75
|
`$ tiktalik COMMAND --help`
|
|
76
76
|
|
|
77
77
|
We also have [a tutorial](http://articles.tiktalik.com/content/help/using-tiktalik-command-line-utility/) to quickly get
|
|
78
|
-
you started.
|
|
78
|
+
you started.
|
|
79
|
+
## Changelog
|
|
80
|
+
|
|
81
|
+
### 2.0.0
|
|
82
|
+
|
|
83
|
+
**Changes that affect scripts:**
|
|
84
|
+
|
|
85
|
+
* `tiktalik` now exits with status 1 when a command fails: API errors,
|
|
86
|
+
authentication errors, an auth file with loose permissions, and errors a
|
|
87
|
+
command reports, such as `create-instance` without `-n`. It used to print
|
|
88
|
+
the error and exit with status 0.
|
|
89
|
+
* `delete-instance` now asks for confirmation before removing an instance.
|
|
90
|
+
Pass `-f` to skip the prompt, as with `delete-image`.
|
|
91
|
+
* A confirmation prompt that gets no input, such as when stdin is closed or
|
|
92
|
+
empty, now aborts with status 1 instead of failing with a traceback.
|
|
93
|
+
|
|
94
|
+
Other changes:
|
|
95
|
+
|
|
96
|
+
* Python 3.11 or newer is required. Python 3.15 is supported; Python 3.10 is
|
|
97
|
+
no longer supported.
|
|
98
|
+
* `create-instance` prints `Instance NAME is now being installed.` instead of
|
|
99
|
+
a Python tuple.
|
|
100
|
+
* On POSIX systems, `init-auth` creates `~/.tiktalik/auth` readable by its
|
|
101
|
+
owner only from the start. It never writes into an existing file.
|
|
102
|
+
* If `~/.tiktalik/auth` can't be checked, for example because `~/.tiktalik`
|
|
103
|
+
isn't accessible, `tiktalik` reports an error instead of crashing.
|
|
104
|
+
* The `list -v` help names the right flags.
|
|
105
|
+
* Requires `tiktalik` (the SDK) below version 3.
|
|
106
|
+
* The package includes its license file.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Tiktalik Command Line Interface
|
|
2
|
+
|
|
3
|
+
This is a command line interface utility implemented in Python, which enables the
|
|
4
|
+
user to perform core operations on the [Tiktalik Cloud Computing](http://www.tiktalik.com) service.
|
|
5
|
+
|
|
6
|
+
## Requirements
|
|
7
|
+
|
|
8
|
+
* [tiktalik-python](https://github.com/tiktalik-cloud/tiktalik-python)
|
|
9
|
+
* Python >=3.11
|
|
10
|
+
|
|
11
|
+
Note that package dependencies are automatically installed by pip.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Install using pip:
|
|
16
|
+
|
|
17
|
+
`$ pip install tiktalik-cli`
|
|
18
|
+
|
|
19
|
+
## Authentication
|
|
20
|
+
|
|
21
|
+
To use the CLI you need an API key. You can generate one in your
|
|
22
|
+
[admin panel](https://tiktalik.com/panel/#apikeys). The API authentication
|
|
23
|
+
information consists of an *API key* and an *API secret*. You can save this
|
|
24
|
+
information locally by executing:
|
|
25
|
+
|
|
26
|
+
`$ tiktalik init-auth API-KEY API-SECRET`
|
|
27
|
+
|
|
28
|
+
This saves the key and secret to `~/.tiktalik/auth`
|
|
29
|
+
|
|
30
|
+
Alternatively, if you don't want to save your API key, you can use the `--key`
|
|
31
|
+
and `--secret` switches on the commandline.
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
The basic usage patterns is:
|
|
36
|
+
|
|
37
|
+
`$ tiktalik COMMAND`
|
|
38
|
+
|
|
39
|
+
You can get a list of commands by running `tiktalik` without arguments.
|
|
40
|
+
To get a help on a specific command, run:
|
|
41
|
+
|
|
42
|
+
`$ tiktalik COMMAND --help`
|
|
43
|
+
|
|
44
|
+
We also have [a tutorial](http://articles.tiktalik.com/content/help/using-tiktalik-command-line-utility/) to quickly get
|
|
45
|
+
you started.
|
|
46
|
+
## Changelog
|
|
47
|
+
|
|
48
|
+
### 2.0.0
|
|
49
|
+
|
|
50
|
+
**Changes that affect scripts:**
|
|
51
|
+
|
|
52
|
+
* `tiktalik` now exits with status 1 when a command fails: API errors,
|
|
53
|
+
authentication errors, an auth file with loose permissions, and errors a
|
|
54
|
+
command reports, such as `create-instance` without `-n`. It used to print
|
|
55
|
+
the error and exit with status 0.
|
|
56
|
+
* `delete-instance` now asks for confirmation before removing an instance.
|
|
57
|
+
Pass `-f` to skip the prompt, as with `delete-image`.
|
|
58
|
+
* A confirmation prompt that gets no input, such as when stdin is closed or
|
|
59
|
+
empty, now aborts with status 1 instead of failing with a traceback.
|
|
60
|
+
|
|
61
|
+
Other changes:
|
|
62
|
+
|
|
63
|
+
* Python 3.11 or newer is required. Python 3.15 is supported; Python 3.10 is
|
|
64
|
+
no longer supported.
|
|
65
|
+
* `create-instance` prints `Instance NAME is now being installed.` instead of
|
|
66
|
+
a Python tuple.
|
|
67
|
+
* On POSIX systems, `init-auth` creates `~/.tiktalik/auth` readable by its
|
|
68
|
+
owner only from the start. It never writes into an existing file.
|
|
69
|
+
* If `~/.tiktalik/auth` can't be checked, for example because `~/.tiktalik`
|
|
70
|
+
isn't accessible, `tiktalik` reports an error instead of crashing.
|
|
71
|
+
* The `list -v` help names the right flags.
|
|
72
|
+
* Requires `tiktalik` (the SDK) below version 3.
|
|
73
|
+
* The package includes its license file.
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "tiktalik-cli"
|
|
3
|
-
version = "
|
|
3
|
+
version = "2.0.0"
|
|
4
4
|
description = "Tiktalik Computing command line interface"
|
|
5
|
-
requires-python = ">=3.
|
|
6
|
-
authors = [
|
|
7
|
-
{name = "Techstorage sp. z o.o", email = "kontakt@tiktalik.com"}
|
|
8
|
-
]
|
|
5
|
+
requires-python = ">=3.11"
|
|
9
6
|
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE.txt"]
|
|
10
8
|
readme = "README.md"
|
|
11
|
-
keywords=[
|
|
9
|
+
keywords = [
|
|
10
|
+
"Tiktalik",
|
|
11
|
+
"CLI",
|
|
12
|
+
"Terminal",
|
|
13
|
+
"VPS",
|
|
14
|
+
]
|
|
12
15
|
classifiers = [
|
|
13
16
|
"Programming Language :: Python :: 3 :: Only",
|
|
14
|
-
"Programming Language :: Python :: 3.10",
|
|
15
17
|
"Programming Language :: Python :: 3.11",
|
|
16
18
|
"Programming Language :: Python :: 3.12",
|
|
17
19
|
"Programming Language :: Python :: 3.13",
|
|
18
20
|
"Programming Language :: Python :: 3.14",
|
|
21
|
+
"Programming Language :: Python :: 3.15",
|
|
19
22
|
"Development Status :: 6 - Mature",
|
|
20
23
|
"Environment :: Console",
|
|
21
24
|
"Intended Audience :: Developers",
|
|
@@ -28,11 +31,12 @@ classifiers = [
|
|
|
28
31
|
"Topic :: Internet",
|
|
29
32
|
"Topic :: Utilities",
|
|
30
33
|
"Topic :: System :: Systems Administration",
|
|
31
|
-
"License :: OSI Approved :: MIT License",
|
|
32
|
-
]
|
|
33
|
-
dependencies = [
|
|
34
|
-
"tiktalik>=2.0.0",
|
|
35
34
|
]
|
|
35
|
+
dependencies = ["tiktalik>=2.1.0,<3"]
|
|
36
|
+
|
|
37
|
+
[[project.authors]]
|
|
38
|
+
name = "Techstorage sp. z o.o"
|
|
39
|
+
email = "kontakt@tiktalik.com"
|
|
36
40
|
|
|
37
41
|
[project.scripts]
|
|
38
42
|
tiktalik = "tiktalik_cli:main"
|
|
@@ -42,7 +46,7 @@ Homepage = "https://www.tiktalik.com"
|
|
|
42
46
|
Repository = "https://github.com/tiktalik-cloud/tiktalik-cli.git"
|
|
43
47
|
|
|
44
48
|
[build-system]
|
|
45
|
-
requires = ["uv_build>=0.
|
|
49
|
+
requires = ["uv_build>=0.13.0,<0.14.0"]
|
|
46
50
|
build-backend = "uv_build"
|
|
47
51
|
|
|
48
52
|
[dependency-groups]
|
|
@@ -50,3 +54,15 @@ dev = [
|
|
|
50
54
|
"ruff>=0.14.0",
|
|
51
55
|
"ty>=0.0.1a21",
|
|
52
56
|
]
|
|
57
|
+
|
|
58
|
+
[tool.uv]
|
|
59
|
+
exclude-newer = "3 days"
|
|
60
|
+
|
|
61
|
+
[tool.uv.exclude-newer-package]
|
|
62
|
+
tiktalik = false
|
|
63
|
+
|
|
64
|
+
[tool.ruff.lint]
|
|
65
|
+
ignore = ["UP031"]
|
|
66
|
+
|
|
67
|
+
[tool.ruff.lint.isort]
|
|
68
|
+
combine-as-imports = true
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "tiktalik-cli"
|
|
3
|
+
version = "2.0.0"
|
|
4
|
+
description = "Tiktalik Computing command line interface"
|
|
5
|
+
requires-python = ">=3.11"
|
|
6
|
+
authors = [{ name = "Techstorage sp. z o.o", email = "kontakt@tiktalik.com" }]
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = ["LICENSE.txt"]
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
keywords = ["Tiktalik", "CLI", "Terminal", "VPS"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
13
|
+
"Programming Language :: Python :: 3.11",
|
|
14
|
+
"Programming Language :: Python :: 3.12",
|
|
15
|
+
"Programming Language :: Python :: 3.13",
|
|
16
|
+
"Programming Language :: Python :: 3.14",
|
|
17
|
+
"Programming Language :: Python :: 3.15",
|
|
18
|
+
"Development Status :: 6 - Mature",
|
|
19
|
+
"Environment :: Console",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Intended Audience :: System Administrators",
|
|
22
|
+
"Intended Audience :: Information Technology",
|
|
23
|
+
"Intended Audience :: End Users/Desktop",
|
|
24
|
+
"Natural Language :: English",
|
|
25
|
+
"Operating System :: POSIX",
|
|
26
|
+
"Operating System :: Microsoft :: Windows",
|
|
27
|
+
"Topic :: Internet",
|
|
28
|
+
"Topic :: Utilities",
|
|
29
|
+
"Topic :: System :: Systems Administration",
|
|
30
|
+
]
|
|
31
|
+
dependencies = ["tiktalik>=2.1.0,<3"]
|
|
32
|
+
|
|
33
|
+
[project.scripts]
|
|
34
|
+
tiktalik = "tiktalik_cli:main"
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://www.tiktalik.com"
|
|
38
|
+
Repository = "https://github.com/tiktalik-cloud/tiktalik-cli.git"
|
|
39
|
+
|
|
40
|
+
[build-system]
|
|
41
|
+
requires = ["uv_build>=0.13.0,<0.14.0"]
|
|
42
|
+
build-backend = "uv_build"
|
|
43
|
+
|
|
44
|
+
[dependency-groups]
|
|
45
|
+
dev = ["ruff>=0.14.0", "ty>=0.0.1a21"]
|
|
46
|
+
|
|
47
|
+
[tool.uv]
|
|
48
|
+
exclude-newer = "3 days"
|
|
49
|
+
# First-party SDK: take a new release as soon as it is on PyPI.
|
|
50
|
+
exclude-newer-package = { tiktalik = false }
|
|
51
|
+
|
|
52
|
+
[tool.ruff.lint]
|
|
53
|
+
# The code formats strings with %; rewriting ~40 calls as f-strings gains nothing.
|
|
54
|
+
ignore = ["UP031"]
|
|
55
|
+
|
|
56
|
+
[tool.ruff.lint.isort]
|
|
57
|
+
# Keep the re-export lists in command/__init__.py as one import per module.
|
|
58
|
+
combine-as-imports = true
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
19
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
20
|
|
|
21
|
-
import
|
|
21
|
+
import base64
|
|
22
|
+
import configparser
|
|
23
|
+
import errno
|
|
22
24
|
import os
|
|
25
|
+
import os.path
|
|
23
26
|
import stat
|
|
24
|
-
import errno
|
|
25
|
-
import configparser
|
|
26
|
-
import base64
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
class AuthError(Exception):
|
|
@@ -53,10 +53,8 @@ def get_credentials(args):
|
|
|
53
53
|
if args.api_key or args.api_secret:
|
|
54
54
|
if not args.api_key or not args.api_secret:
|
|
55
55
|
raise AuthError(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"when passing auth tokens from commandline."
|
|
59
|
-
)
|
|
56
|
+
"Both --key and --secret must be provided "
|
|
57
|
+
"when passing auth tokens from commandline."
|
|
60
58
|
)
|
|
61
59
|
|
|
62
60
|
return args.api_key, args.api_secret
|
|
@@ -64,10 +62,8 @@ def get_credentials(args):
|
|
|
64
62
|
key, secret = read_from_file()
|
|
65
63
|
if not key:
|
|
66
64
|
raise AuthError(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"Try `tiktalik init-auth`, or use --key and --secret."
|
|
70
|
-
)
|
|
65
|
+
"Credentials not configured. "
|
|
66
|
+
"Try `tiktalik init-auth`, or use --key and --secret."
|
|
71
67
|
)
|
|
72
68
|
|
|
73
69
|
return key, base64.b64decode(secret)
|
|
@@ -80,8 +76,7 @@ def read_from_file():
|
|
|
80
76
|
except OSError as ex:
|
|
81
77
|
if ex.errno == errno.ENOENT:
|
|
82
78
|
return None, None
|
|
83
|
-
|
|
84
|
-
print(("Unable to access %s: %s" % (CONFIG_FILE_PATH, ex)))
|
|
79
|
+
raise AuthError("Unable to access %s: %s" % (CONFIG_FILE_PATH, ex)) from ex
|
|
85
80
|
|
|
86
81
|
if (stat.S_IMODE(st.st_mode) != 0o600) and (os.name == "posix"):
|
|
87
82
|
raise SecurityError()
|
|
@@ -18,18 +18,19 @@
|
|
|
18
18
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
19
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
20
|
|
|
21
|
-
import os
|
|
22
|
-
import errno
|
|
23
21
|
import configparser
|
|
24
|
-
|
|
22
|
+
import errno
|
|
23
|
+
import os
|
|
24
|
+
|
|
25
25
|
from .. import auth
|
|
26
|
+
from .command import CommandError, GeneralCommand
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
class InitAuth(GeneralCommand):
|
|
29
30
|
"""Initialise auth"""
|
|
30
31
|
|
|
31
32
|
@classmethod
|
|
32
|
-
def add_parser(cls,
|
|
33
|
+
def add_parser(cls, parent, subparser):
|
|
33
34
|
p = subparser.add_parser(
|
|
34
35
|
"init-auth",
|
|
35
36
|
description="Store auth information locally %s" % auth.CONFIG_FILE_PATH,
|
|
@@ -40,7 +41,7 @@ class InitAuth(GeneralCommand):
|
|
|
40
41
|
return "init-auth"
|
|
41
42
|
|
|
42
43
|
def execute(self):
|
|
43
|
-
key,
|
|
44
|
+
key, _secret = auth.read_from_file()
|
|
44
45
|
if key:
|
|
45
46
|
raise CommandError(
|
|
46
47
|
"Authentication information already exists in " + auth.CONFIG_FILE_PATH
|
|
@@ -58,5 +59,18 @@ class InitAuth(GeneralCommand):
|
|
|
58
59
|
cfg.set("main", "key", self.args.key)
|
|
59
60
|
cfg.set("main", "secret", self.args.secret)
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
# Create a new owner-only file, so the secret is never readable by others
|
|
63
|
+
# and never lands in a file (or symlink) that appeared since the check above.
|
|
64
|
+
try:
|
|
65
|
+
fd = os.open(
|
|
66
|
+
auth.CONFIG_FILE_PATH, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600
|
|
67
|
+
)
|
|
68
|
+
except FileExistsError:
|
|
69
|
+
raise CommandError(
|
|
70
|
+
"Authentication information already exists in " + auth.CONFIG_FILE_PATH
|
|
71
|
+
) from None
|
|
72
|
+
with os.fdopen(fd, "w") as f:
|
|
73
|
+
if os.name == "posix":
|
|
74
|
+
# The umask may have narrowed the mode; read_from_file wants 0600.
|
|
75
|
+
os.fchmod(f.fileno(), 0o600)
|
|
76
|
+
cfg.write(f)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"""Module tiktalik_cli.command.command"""
|
|
2
2
|
|
|
3
|
-
import os
|
|
4
3
|
# Copyright (c) 2013 Techstorage sp. z o.o.
|
|
5
4
|
#
|
|
6
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
@@ -20,9 +19,9 @@ import os
|
|
|
20
19
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
21
20
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
21
|
|
|
22
|
+
import os
|
|
23
23
|
import sys
|
|
24
24
|
from abc import ABC, abstractmethod
|
|
25
|
-
from typing import Optional
|
|
26
25
|
from dataclasses import dataclass
|
|
27
26
|
|
|
28
27
|
from tiktalik import TiktalikAuthConnection
|
|
@@ -38,8 +37,8 @@ class CommandAborted(Exception):
|
|
|
38
37
|
|
|
39
38
|
@dataclass
|
|
40
39
|
class ProxyDetails:
|
|
41
|
-
http_proxy:
|
|
42
|
-
https_proxy:
|
|
40
|
+
http_proxy: str | None
|
|
41
|
+
https_proxy: str | None
|
|
43
42
|
|
|
44
43
|
|
|
45
44
|
def lookup_proxy_settings() -> ProxyDetails:
|
|
@@ -71,7 +70,7 @@ class Command(ABC):
|
|
|
71
70
|
)
|
|
72
71
|
|
|
73
72
|
@classmethod
|
|
74
|
-
def add_parser(cls,
|
|
73
|
+
def add_parser(cls, parent, subparser) -> str | None:
|
|
75
74
|
"""Parse command's args"""
|
|
76
75
|
return None
|
|
77
76
|
|
|
@@ -91,7 +90,14 @@ class Command(ABC):
|
|
|
91
90
|
|
|
92
91
|
answer = None
|
|
93
92
|
while answer not in ("yes", "no"):
|
|
94
|
-
|
|
93
|
+
try:
|
|
94
|
+
answer = input("Please answer 'yes' or 'no' > ")
|
|
95
|
+
except (EOFError, RuntimeError):
|
|
96
|
+
# No more input: stdin is at EOF, or Python started with stdin
|
|
97
|
+
# closed (sys.stdin is None and input() raises RuntimeError).
|
|
98
|
+
# Treat it as "no".
|
|
99
|
+
print()
|
|
100
|
+
answer = "no"
|
|
95
101
|
|
|
96
102
|
if answer == "yes":
|
|
97
103
|
return True
|
|
@@ -105,7 +111,7 @@ class Command(ABC):
|
|
|
105
111
|
|
|
106
112
|
class GeneralCommand(Command):
|
|
107
113
|
def __init__(self, args, keyid, secret):
|
|
108
|
-
super(
|
|
114
|
+
super().__init__(args, keyid, secret, None)
|
|
109
115
|
|
|
110
116
|
@abstractmethod
|
|
111
117
|
def execute(self):
|
|
@@ -114,9 +120,7 @@ class GeneralCommand(Command):
|
|
|
114
120
|
|
|
115
121
|
class ComputingCommand(Command):
|
|
116
122
|
def __init__(self, args, keyid, secret):
|
|
117
|
-
super(
|
|
118
|
-
args, keyid, secret, TiktalikAuthConnection
|
|
119
|
-
)
|
|
123
|
+
super().__init__(args, keyid, secret, TiktalikAuthConnection)
|
|
120
124
|
|
|
121
125
|
@abstractmethod
|
|
122
126
|
def execute(self):
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
from tiktalik import TiktalikAPIError
|
|
21
21
|
|
|
22
|
-
from .command import
|
|
22
|
+
from .command import Command, CommandError, ComputingImageCommand
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
class ListImages(ComputingImageCommand):
|
|
@@ -64,7 +64,7 @@ class RenameImage(ComputingImageCommand):
|
|
|
64
64
|
raise CommandError("Image doesn't exist in your account")
|
|
65
65
|
raise
|
|
66
66
|
|
|
67
|
-
print(
|
|
67
|
+
print("Image %s renamed to %s." % (self.args.uuid, self.args.name))
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
class DeleteImage(ComputingImageCommand):
|
|
@@ -95,4 +95,4 @@ class DeleteImage(ComputingImageCommand):
|
|
|
95
95
|
raise CommandError("Image doesn't exist in your account")
|
|
96
96
|
raise
|
|
97
97
|
|
|
98
|
-
print(
|
|
98
|
+
print("Image %s deleted." % self.args.uuid)
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
|
|
21
21
|
from tiktalik import Instance, TiktalikAPIError
|
|
22
22
|
|
|
23
|
-
from .command import ComputingCommand, CommandError, Command
|
|
24
23
|
from . import util
|
|
24
|
+
from .command import Command, CommandError, ComputingCommand
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
class ListInstances(ComputingCommand):
|
|
28
28
|
@classmethod
|
|
29
|
-
def add_parser(cls,
|
|
30
|
-
p = subparser.add_parser("list", description="List instances", parents=[
|
|
29
|
+
def add_parser(cls, parent, subparser):
|
|
30
|
+
p = subparser.add_parser("list", description="List instances", parents=[parent])
|
|
31
31
|
p.add_argument(
|
|
32
32
|
"-a",
|
|
33
33
|
action="store_true",
|
|
@@ -50,7 +50,7 @@ class ListInstances(ComputingCommand):
|
|
|
50
50
|
"-v",
|
|
51
51
|
dest="verbose",
|
|
52
52
|
action="store_true",
|
|
53
|
-
help="Print extra information (flags -a, -
|
|
53
|
+
help="Print extra information (flags -a, -c, -i yield more details)",
|
|
54
54
|
)
|
|
55
55
|
|
|
56
56
|
return "list"
|
|
@@ -65,13 +65,11 @@ class ListInstances(ComputingCommand):
|
|
|
65
65
|
for instance in sorted(instances, key=lambda x: x.hostname):
|
|
66
66
|
if not self.args.verbose:
|
|
67
67
|
print(
|
|
68
|
-
(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"Running" if instance.running else "Not running",
|
|
74
|
-
)
|
|
68
|
+
"%s (%s) - %s"
|
|
69
|
+
% (
|
|
70
|
+
instance.hostname,
|
|
71
|
+
instance.uuid,
|
|
72
|
+
"Running" if instance.running else "Not running",
|
|
75
73
|
)
|
|
76
74
|
)
|
|
77
75
|
else:
|
|
@@ -120,7 +118,7 @@ class CreateInstance(ComputingCommand):
|
|
|
120
118
|
networks = self.conn.list_networks()
|
|
121
119
|
|
|
122
120
|
# Mapping of network names->uuids
|
|
123
|
-
networks =
|
|
121
|
+
networks = {net.name: net.uuid for net in networks}
|
|
124
122
|
|
|
125
123
|
# Make sure all networks exist
|
|
126
124
|
diff = set(self.args.networks) - set(networks.keys())
|
|
@@ -169,7 +167,7 @@ class CreateInstance(ComputingCommand):
|
|
|
169
167
|
disk_size_gb=disk_size_gb,
|
|
170
168
|
)
|
|
171
169
|
|
|
172
|
-
print(
|
|
170
|
+
print("Instance", self.args.hostname, "is now being installed.")
|
|
173
171
|
|
|
174
172
|
def _parse_instance_size(self, sz):
|
|
175
173
|
"""
|
|
@@ -241,16 +239,16 @@ class InstanceCommand(ComputingCommand):
|
|
|
241
239
|
if self.args.instance:
|
|
242
240
|
instances = []
|
|
243
241
|
for i in Instance.list_all(self.conn):
|
|
244
|
-
if i.hostname.startswith(self.args.instance)
|
|
245
|
-
|
|
246
|
-
|
|
242
|
+
if i.hostname.startswith(self.args.instance) or i.uuid.startswith(
|
|
243
|
+
self.args.instance
|
|
244
|
+
):
|
|
247
245
|
instances.append(i)
|
|
248
246
|
if not instances:
|
|
249
247
|
raise CommandError("There is no such instance.")
|
|
250
248
|
if len(instances) > 1:
|
|
251
249
|
print("Matched more than one instance:")
|
|
252
250
|
for i in instances:
|
|
253
|
-
print(
|
|
251
|
+
print(" - %s (%s)" % (i.hostname, i.uuid))
|
|
254
252
|
raise CommandError("Select exactly one instance.")
|
|
255
253
|
|
|
256
254
|
instance = Instance.get_by_uuid(
|
|
@@ -297,10 +295,7 @@ class StartInstance(InstanceCommand):
|
|
|
297
295
|
instance = self._instance_from_args()
|
|
298
296
|
instance.start()
|
|
299
297
|
print(
|
|
300
|
-
(
|
|
301
|
-
"Instance %s (%s) is now being started"
|
|
302
|
-
% (instance.hostname, instance.uuid)
|
|
303
|
-
)
|
|
298
|
+
"Instance %s (%s) is now being started" % (instance.hostname, instance.uuid)
|
|
304
299
|
)
|
|
305
300
|
|
|
306
301
|
|
|
@@ -331,13 +326,11 @@ class StopInstance(InstanceCommand):
|
|
|
331
326
|
instance.stop()
|
|
332
327
|
|
|
333
328
|
print(
|
|
334
|
-
(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
" forcefuly" if self.args.force else "",
|
|
340
|
-
)
|
|
329
|
+
"Instance %s (%s) is now being stopped%s"
|
|
330
|
+
% (
|
|
331
|
+
instance.hostname,
|
|
332
|
+
instance.uuid,
|
|
333
|
+
" forcefuly" if self.args.force else "",
|
|
341
334
|
)
|
|
342
335
|
)
|
|
343
336
|
|
|
@@ -369,10 +362,8 @@ class BackupInstance(InstanceCommand):
|
|
|
369
362
|
else:
|
|
370
363
|
instance.backup()
|
|
371
364
|
print(
|
|
372
|
-
(
|
|
373
|
-
|
|
374
|
-
% (instance.hostname, instance.uuid)
|
|
375
|
-
)
|
|
365
|
+
"Instance %s (%s) is now being backed up"
|
|
366
|
+
% (instance.hostname, instance.uuid)
|
|
376
367
|
)
|
|
377
368
|
|
|
378
369
|
|
|
@@ -385,17 +376,23 @@ class DeleteInstance(InstanceCommand):
|
|
|
385
376
|
parents=[parent],
|
|
386
377
|
)
|
|
387
378
|
InstanceCommand.add_common_arguments(p)
|
|
379
|
+
p.add_argument(
|
|
380
|
+
"-f", dest="force", action="store_true", help="Don't confirm the action."
|
|
381
|
+
)
|
|
388
382
|
return "delete-instance"
|
|
389
383
|
|
|
390
384
|
def execute(self):
|
|
391
385
|
instance = self._instance_from_args()
|
|
392
386
|
|
|
393
|
-
self.
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
"Instance %s (%s) is now being removed"
|
|
387
|
+
if not self.args.force:
|
|
388
|
+
Command.yesno(
|
|
389
|
+
"Are you sure you want to permanently remove instance %s (%s)?"
|
|
397
390
|
% (instance.hostname, instance.uuid)
|
|
398
391
|
)
|
|
392
|
+
|
|
393
|
+
self.conn.delete_instance(instance.uuid)
|
|
394
|
+
print(
|
|
395
|
+
"Instance %s (%s) is now being removed" % (instance.hostname, instance.uuid)
|
|
399
396
|
)
|
|
400
397
|
|
|
401
398
|
|
|
@@ -35,15 +35,13 @@ class ListNetworks(ComputingNetworkCommand):
|
|
|
35
35
|
networks = self.conn.list_networks()
|
|
36
36
|
for net in networks:
|
|
37
37
|
print(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
net.owner,
|
|
46
|
-
)
|
|
38
|
+
"%s %s %s %s, owned by %s"
|
|
39
|
+
% (
|
|
40
|
+
net.name,
|
|
41
|
+
net.uuid,
|
|
42
|
+
net.net,
|
|
43
|
+
"public" if net.public else "private",
|
|
44
|
+
net.owner,
|
|
47
45
|
)
|
|
48
46
|
)
|
|
49
47
|
|
|
@@ -61,14 +59,12 @@ class CreateNetwork(ComputingNetworkCommand):
|
|
|
61
59
|
def execute(self):
|
|
62
60
|
network = self.conn.create_network(self.args.name)
|
|
63
61
|
print(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
network.owner,
|
|
72
|
-
)
|
|
62
|
+
"%s %s %s %s, owned by %s"
|
|
63
|
+
% (
|
|
64
|
+
network.name,
|
|
65
|
+
network.uuid,
|
|
66
|
+
network.net,
|
|
67
|
+
"public" if network.public else "private",
|
|
68
|
+
network.owner,
|
|
73
69
|
)
|
|
74
70
|
)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""Module tiktalik_cli.command.util"""
|
|
2
|
+
# Copyright (c) 2013 Techstorage sp. z o.o.
|
|
3
|
+
#
|
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
# subject to the following conditions:
|
|
10
|
+
#
|
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
# copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def print_iface(n):
|
|
23
|
+
print(
|
|
24
|
+
" eth%i addr: %s mac: %s network: %s" % (n.seq, n.ip, n.mac, n.network.name)
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def print_action(a):
|
|
29
|
+
s = "%s, started at %s" % (a.description, a.start_time)
|
|
30
|
+
if a.end_time:
|
|
31
|
+
s += ", ended at %s" % a.end_time
|
|
32
|
+
else:
|
|
33
|
+
s = "(In progress: %s%%) %s" % (a.progress, s)
|
|
34
|
+
print(" " + s)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def print_instance(i, verbose=False):
|
|
38
|
+
"""
|
|
39
|
+
Helper for printing instance details.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
print(
|
|
43
|
+
"%s (%s) - %s" % (i.hostname, i.uuid, "Running" if i.running else "Not running")
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
if verbose and i.block_devices:
|
|
47
|
+
for b in i.block_devices:
|
|
48
|
+
print(" block device %d: %.1f GB" % (b.seq, b.size_gb))
|
|
49
|
+
|
|
50
|
+
if not i.interfaces:
|
|
51
|
+
print(" no network interfaces")
|
|
52
|
+
else:
|
|
53
|
+
print(" network interfaces:")
|
|
54
|
+
list(map(print_iface, i.interfaces))
|
|
55
|
+
|
|
56
|
+
print(" default password: %s" % i.default_password)
|
|
57
|
+
|
|
58
|
+
if verbose and i.vpsimage:
|
|
59
|
+
print(" running image %s (%s)" % (i.vpsimage.name, i.vpsimage.uuid))
|
|
60
|
+
|
|
61
|
+
if verbose and i.actions:
|
|
62
|
+
print(" recent operations:")
|
|
63
|
+
list(map(print_action, i.actions))
|
|
64
|
+
|
|
65
|
+
if verbose and i.gross_cost_per_hour:
|
|
66
|
+
print(" cost per hour: %.5f PLN/h" % i.gross_cost_per_hour)
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"""Module tiktalik_cli.main"""
|
|
2
|
-
#!/usr/bin/env python
|
|
3
|
-
# -*- coding: utf8 -*-
|
|
4
2
|
|
|
5
3
|
# Copyright (c) 2013 Techstorage sp. z o.o.
|
|
6
4
|
#
|
|
@@ -22,12 +20,13 @@
|
|
|
22
20
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
21
|
|
|
24
22
|
import argparse
|
|
25
|
-
import textwrap
|
|
26
23
|
import inspect
|
|
27
24
|
import sys
|
|
25
|
+
import textwrap
|
|
28
26
|
|
|
29
27
|
from tiktalik import TiktalikAPIError
|
|
30
|
-
|
|
28
|
+
|
|
29
|
+
from . import auth, command
|
|
31
30
|
|
|
32
31
|
|
|
33
32
|
def main():
|
|
@@ -93,10 +92,10 @@ You can fix this by executing:
|
|
|
93
92
|
)
|
|
94
93
|
|
|
95
94
|
print("Security error")
|
|
96
|
-
print(
|
|
95
|
+
print(textwrap.fill(msg, 76))
|
|
97
96
|
print()
|
|
98
|
-
print(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
print(" chmod 600 %s" % auth.CONFIG_FILE_PATH)
|
|
98
|
+
sys.exit(1)
|
|
99
|
+
except (command.CommandError, TiktalikAPIError, auth.AuthError) as e:
|
|
100
|
+
print(textwrap.fill("Error: " + str(e), 76))
|
|
101
|
+
sys.exit(1)
|
tiktalik_cli-1.11.0/README.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# Tiktalik Command Line Interface
|
|
2
|
-
|
|
3
|
-
This is a command line interface utility implemented in Python, which enables the
|
|
4
|
-
user to perform core operations on the [Tiktalik Cloud Computing](http://www.tiktalik.com) service.
|
|
5
|
-
|
|
6
|
-
## Requirements
|
|
7
|
-
|
|
8
|
-
* [tiktalik-python](https://github.com/tiktalik-cloud/tiktalik-python)
|
|
9
|
-
* Python >=3.10
|
|
10
|
-
|
|
11
|
-
Note that package dependencies are automatically installed by pip.
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
Install using pip:
|
|
16
|
-
|
|
17
|
-
`$ pip install tiktalik-cli`
|
|
18
|
-
|
|
19
|
-
## Authentication
|
|
20
|
-
|
|
21
|
-
To use the CLI you need an API key. You can generate one in your
|
|
22
|
-
[admin panel](https://tiktalik.com/panel/#apikeys). The API authentication
|
|
23
|
-
information consists of an *API key* and an *API secret*. You can save this
|
|
24
|
-
information locally by executing:
|
|
25
|
-
|
|
26
|
-
`$ tiktalik init-auth API-KEY API-SECRET`
|
|
27
|
-
|
|
28
|
-
This saves the key and secret to `~/.tiktalik/auth`
|
|
29
|
-
|
|
30
|
-
Alternatively, if you don't want to save your API key, you can use the `--key`
|
|
31
|
-
and `--secret` switches on the commandline.
|
|
32
|
-
|
|
33
|
-
## Usage
|
|
34
|
-
|
|
35
|
-
The basic usage patterns is:
|
|
36
|
-
|
|
37
|
-
`$ tiktalik COMMAND`
|
|
38
|
-
|
|
39
|
-
You can get a list of commands by running `tiktalik` without arguments.
|
|
40
|
-
To get a help on a specific command, run:
|
|
41
|
-
|
|
42
|
-
`$ tiktalik COMMAND --help`
|
|
43
|
-
|
|
44
|
-
We also have [a tutorial](http://articles.tiktalik.com/content/help/using-tiktalik-command-line-utility/) to quickly get
|
|
45
|
-
you started.
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"""Module tiktalik_cli.command.util"""
|
|
2
|
-
# Copyright (c) 2013 Techstorage sp. z o.o.
|
|
3
|
-
#
|
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
|
-
# this software and associated documentation files (the "Software"), to deal in
|
|
6
|
-
# the Software without restriction, including without limitation the rights to
|
|
7
|
-
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
8
|
-
# the Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
-
# subject to the following conditions:
|
|
10
|
-
#
|
|
11
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
# copies or substantial portions of the Software.
|
|
13
|
-
#
|
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
16
|
-
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
17
|
-
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
18
|
-
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
|
-
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def print_iface(n):
|
|
23
|
-
print(
|
|
24
|
-
(
|
|
25
|
-
" eth%i addr: %s mac: %s network: %s"
|
|
26
|
-
% (n.seq, n.ip, n.mac, n.network.name)
|
|
27
|
-
)
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def print_action(a):
|
|
32
|
-
s = "%s, started at %s" % (a.description, a.start_time)
|
|
33
|
-
if a.end_time:
|
|
34
|
-
s += ", ended at %s" % a.end_time
|
|
35
|
-
else:
|
|
36
|
-
s = "(In progress: %s%%) %s" % (a.progress, s)
|
|
37
|
-
print((" " + s))
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def print_instance(i, verbose=False):
|
|
41
|
-
"""
|
|
42
|
-
Helper for printing instance details.
|
|
43
|
-
"""
|
|
44
|
-
|
|
45
|
-
print(
|
|
46
|
-
(
|
|
47
|
-
"%s (%s) - %s"
|
|
48
|
-
% (i.hostname, i.uuid, "Running" if i.running else "Not running")
|
|
49
|
-
)
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
if verbose and i.block_devices:
|
|
53
|
-
for b in i.block_devices:
|
|
54
|
-
print((" block device %d: %.1f GB" % (b.seq, b.size_gb)))
|
|
55
|
-
|
|
56
|
-
if not i.interfaces:
|
|
57
|
-
print(" no network interfaces")
|
|
58
|
-
else:
|
|
59
|
-
print(" network interfaces:")
|
|
60
|
-
list(map(print_iface, i.interfaces))
|
|
61
|
-
|
|
62
|
-
print((" default password: %s" % i.default_password))
|
|
63
|
-
|
|
64
|
-
if verbose and i.vpsimage:
|
|
65
|
-
print((" running image %s (%s)" % (i.vpsimage.name, i.vpsimage.uuid)))
|
|
66
|
-
|
|
67
|
-
if verbose and i.actions:
|
|
68
|
-
print(" recent operations:")
|
|
69
|
-
list(map(print_action, i.actions))
|
|
70
|
-
|
|
71
|
-
if verbose and i.gross_cost_per_hour:
|
|
72
|
-
print((" cost per hour: %.5f PLN/h" % i.gross_cost_per_hour))
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def print_load_balancer(w):
|
|
76
|
-
"""
|
|
77
|
-
Helper for printing LoadBalancer details.
|
|
78
|
-
"""
|
|
79
|
-
|
|
80
|
-
print(("%s (%s) %s" % (w.name, w.uuid, w.status)))
|
|
81
|
-
print((" input: %s on %s:%d" % (w.type, w.address, w.port)))
|
|
82
|
-
|
|
83
|
-
if w.type == "HTTP":
|
|
84
|
-
if not w.domains:
|
|
85
|
-
print(" no domains")
|
|
86
|
-
else:
|
|
87
|
-
print(" domains:")
|
|
88
|
-
for d in w.domains:
|
|
89
|
-
print((" %s" % d))
|
|
90
|
-
|
|
91
|
-
if w.monitor:
|
|
92
|
-
print(" health monitor:", end=" ")
|
|
93
|
-
m = w.monitor
|
|
94
|
-
if m.check_type == "tcp":
|
|
95
|
-
print(
|
|
96
|
-
(
|
|
97
|
-
"tcp-connection, interval %0.3f sec, timeout %0.3f sec"
|
|
98
|
-
% (m.interval_ms / 1000.0, m.timeout_ms / 1000.0)
|
|
99
|
-
)
|
|
100
|
-
)
|
|
101
|
-
elif m.check_type == "http":
|
|
102
|
-
print(
|
|
103
|
-
(
|
|
104
|
-
'http-request, interval %0.3f sec, timeout %0.3f sec, request "%s %s", expected %s'
|
|
105
|
-
% (
|
|
106
|
-
m.interval_ms,
|
|
107
|
-
m.timeout_ms,
|
|
108
|
-
m.http_method,
|
|
109
|
-
m.http_path,
|
|
110
|
-
",".join(m.http_expect_alive),
|
|
111
|
-
)
|
|
112
|
-
)
|
|
113
|
-
)
|
|
114
|
-
else:
|
|
115
|
-
print("unknown")
|
|
116
|
-
|
|
117
|
-
if not w.backends:
|
|
118
|
-
print(" no backends")
|
|
119
|
-
else:
|
|
120
|
-
print(" backends:")
|
|
121
|
-
for b in w.backends:
|
|
122
|
-
print((" %s:%i, weight=%i (%s)" % (b.ip, b.port, b.weight, b.uuid)))
|
|
123
|
-
|
|
124
|
-
if w.history:
|
|
125
|
-
print(" recent actions:")
|
|
126
|
-
for h in w.history:
|
|
127
|
-
print(
|
|
128
|
-
(
|
|
129
|
-
" %s: (%s %s) %s %s"
|
|
130
|
-
% (
|
|
131
|
-
h.time,
|
|
132
|
-
h.auth,
|
|
133
|
-
h.ip,
|
|
134
|
-
h.action,
|
|
135
|
-
h.arguments if h.arguments else "",
|
|
136
|
-
)
|
|
137
|
-
)
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
print()
|
|
File without changes
|
|
@@ -18,36 +18,36 @@
|
|
|
18
18
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
19
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
20
|
|
|
21
|
-
from .instance import (
|
|
22
|
-
ListInstances as ListInstances,
|
|
23
|
-
CreateInstance as CreateInstance,
|
|
24
|
-
InstanceCommand as InstanceCommand,
|
|
25
|
-
StartInstance as StartInstance,
|
|
26
|
-
StopInstance as StopInstance,
|
|
27
|
-
BackupInstance as BackupInstance,
|
|
28
|
-
DeleteInstance as DeleteInstance,
|
|
29
|
-
InstanceInfo as InstanceInfo,
|
|
30
|
-
AddInterface as AddInterface,
|
|
31
|
-
RemoveInterface as RemoveInterface,
|
|
32
|
-
)
|
|
33
|
-
from .image import (
|
|
34
|
-
ListImages as ListImages,
|
|
35
|
-
RenameImage as RenameImage,
|
|
36
|
-
DeleteImage as DeleteImage,
|
|
37
|
-
)
|
|
38
|
-
from .network import (
|
|
39
|
-
ListNetworks as ListNetworks,
|
|
40
|
-
CreateNetwork as CreateNetwork,
|
|
41
|
-
)
|
|
42
21
|
from .auth import (
|
|
43
22
|
InitAuth as InitAuth,
|
|
44
23
|
)
|
|
45
24
|
from .command import (
|
|
46
|
-
CommandError as CommandError,
|
|
47
|
-
CommandAborted as CommandAborted,
|
|
48
25
|
Command as Command,
|
|
49
|
-
|
|
26
|
+
CommandAborted as CommandAborted,
|
|
27
|
+
CommandError as CommandError,
|
|
50
28
|
ComputingCommand as ComputingCommand,
|
|
51
29
|
ComputingImageCommand as ComputingImageCommand,
|
|
52
30
|
ComputingNetworkCommand as ComputingNetworkCommand,
|
|
31
|
+
GeneralCommand as GeneralCommand,
|
|
32
|
+
)
|
|
33
|
+
from .image import (
|
|
34
|
+
DeleteImage as DeleteImage,
|
|
35
|
+
ListImages as ListImages,
|
|
36
|
+
RenameImage as RenameImage,
|
|
37
|
+
)
|
|
38
|
+
from .instance import (
|
|
39
|
+
AddInterface as AddInterface,
|
|
40
|
+
BackupInstance as BackupInstance,
|
|
41
|
+
CreateInstance as CreateInstance,
|
|
42
|
+
DeleteInstance as DeleteInstance,
|
|
43
|
+
InstanceCommand as InstanceCommand,
|
|
44
|
+
InstanceInfo as InstanceInfo,
|
|
45
|
+
ListInstances as ListInstances,
|
|
46
|
+
RemoveInterface as RemoveInterface,
|
|
47
|
+
StartInstance as StartInstance,
|
|
48
|
+
StopInstance as StopInstance,
|
|
49
|
+
)
|
|
50
|
+
from .network import (
|
|
51
|
+
CreateNetwork as CreateNetwork,
|
|
52
|
+
ListNetworks as ListNetworks,
|
|
53
53
|
)
|