Skip to content
This repository was archived by the owner on Sep 15, 2020. It is now read-only.

Commit e89199a

Browse files
authored
deprecate package (#9)
1 parent 60b6400 commit e89199a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+12
-4599
lines changed

.github/workflows/flake8.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/pythonpublish.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.gitlab-ci.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1 @@
1-
![license](https://img.shields.io/pypi/l/cloudscale.svg)
2-
![python versions](https://img.shields.io/pypi/pyversions/cloudscale.svg)
3-
![status](https://img.shields.io/pypi/status/cloudscale.svg)
4-
[![pypi version](https://img.shields.io/pypi/v/cloudscale.svg)](https://pypi.org/project/cloudscale/)
5-
![PyPI - Downloads](https://img.shields.io/pypi/dw/cloudscale)
6-
[![codecov](https://codecov.io/gh/cloudscale-ch/python-cloudscale/branch/master/graph/badge.svg)](https://codecov.io/gh/resmo/python-cloudscale)
7-
8-
# Python Cloudscale
9-
10-
A [cloudscale.ch](https://www.cloudscale.ch) API client for Python3 and your command line.
11-
12-
## Install / Update
13-
14-
~~~shell
15-
pip3 install -U cloudscale --user
16-
export PATH=$PATH:$HOME/.local/bin
17-
cloudscale-cli --version
18-
~~~
19-
20-
## Documentation
21-
22-
Please visit https://cloudscale-ch.github.io/python-cloudscale/.
23-
24-
## Development
25-
26-
### Run tests with coverage
27-
28-
~~~shell
29-
tox -e coverage
30-
~~~
1+
__*** Deprecated: Please install [`cloudscale-cli`](https://pypi.org/project/cloudscale-cli/) for the CLI or [`cloudscale-sdk`](https://pypi.org/project/cloudscale-sdk/) for the SDK only ***__

cloudscale/__init__.py

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +0,0 @@
1-
import os
2-
import configparser
3-
import logging
4-
5-
from .client import RestAPI
6-
from .lib.server import Server
7-
from .lib.server_group import ServerGroup
8-
from .lib.volume import Volume
9-
from .lib.flavor import Flavor
10-
from .lib.floating_ip import FloatingIp
11-
from .lib.image import Image
12-
from .lib.region import Region
13-
from .lib.network import Network
14-
from .lib.subnet import Subnet
15-
from .lib.objects_user import ObjectsUser
16-
17-
from .log import logger
18-
from .error import CloudscaleException, CloudscaleApiException # noqa F401
19-
20-
from .version import __version__
21-
22-
APP_NAME = 'cloudscale-cli'
23-
CLOUDSCALE_API_ENDPOINT = 'https://api.cloudscale.ch/v1'
24-
CLOUDSCALE_CONFIG = 'cloudscale.ini'
25-
26-
27-
class Cloudscale:
28-
29-
def __init__(self, api_token=None, profile=None, debug=False):
30-
31-
if debug:
32-
logger.setLevel(logging.INFO)
33-
34-
logger.info(f"Started, version: {__version__}")
35-
36-
if api_token and profile:
37-
raise CloudscaleException("API token and profile are mutually exclusive")
38-
39-
# Read ini configs
40-
self.config = self._read_from_configfile(profile=profile)
41-
42-
if api_token:
43-
self.api_token = api_token
44-
else:
45-
self.api_token = self.config.get('api_token')
46-
47-
if not self.api_token:
48-
raise CloudscaleException("Missing API key: see -h for help")
49-
50-
logger.info(f"API Token used: {self.api_token[:4]}...")
51-
52-
# Configre requests timeout
53-
self.timeout = self.config.get('timeout', 60)
54-
logger.debug(f"Timeout is: {self.timeout}")
55-
56-
self.service_classes = {
57-
'server': Server,
58-
'server_group': ServerGroup,
59-
'volume': Volume,
60-
'flavor': Flavor,
61-
'floating_ip': FloatingIp,
62-
'image': Image,
63-
'region': Region,
64-
'network': Network,
65-
'subnet': Subnet,
66-
'objects_user': ObjectsUser,
67-
}
68-
69-
70-
def _read_from_configfile(self, profile=None):
71-
72-
config_file = os.getenv('CLOUDSCALE_CONFIG', CLOUDSCALE_CONFIG)
73-
74-
paths = (
75-
os.path.join(os.path.expanduser('~'), '.{}'.format(config_file)),
76-
os.path.join(os.getcwd(), config_file),
77-
)
78-
79-
conf = configparser.ConfigParser()
80-
conf.read(paths)
81-
82-
if profile:
83-
if profile not in conf._sections:
84-
raise CloudscaleException("Profile '{}' not found in config files: ({})".format(profile, ', '. join(paths)))
85-
else:
86-
profile = os.getenv('CLOUDSCALE_PROFILE', 'default')
87-
88-
logger.info(f"Using profile {profile}")
89-
90-
if not conf._sections.get(profile):
91-
return dict()
92-
93-
return dict(conf.items(profile))
94-
95-
96-
def __getattr__(self, name):
97-
try:
98-
client = RestAPI(
99-
api_token=self.api_token,
100-
endpoint=CLOUDSCALE_API_ENDPOINT,
101-
user_agent="python-cloudscale {}".format(__version__),
102-
timeout=self.timeout,
103-
)
104-
obj = self.service_classes[name]()
105-
obj._client = client
106-
return obj
107-
except KeyError as e:
108-
msg = "{} not implemented".format(e)
109-
raise NotImplementedError(msg)

cloudscale/cli.py

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,5 @@
1-
import click
2-
from .version import __version__
3-
from .util import OrderedGroup
4-
from .commands import CloudscaleCommand, OUTPUT_FORMATS
5-
from .commands.server import server
6-
from .commands.server_group import server_group
7-
from .commands.flavor import flavor
8-
from .commands.floating_ip import floating_ip
9-
from .commands.image import image
10-
from .commands.region import region
11-
from .commands.network import network
12-
from .commands.subnet import subnet
13-
from .commands.volume import volume
14-
from .commands.objects_user import objects_user
1+
import sys
152

16-
17-
@click.group(cls=OrderedGroup, context_settings={
18-
'help_option_names': ['-h', '--help'],
19-
})
20-
@click.version_option(__version__, '--version')
21-
@click.option('--api-token', '-a', envvar='CLOUDSCALE_API_TOKEN', help="API token.")
22-
@click.option('--profile', '-p', envvar='CLOUDSCALE_PROFILE', help="Profile used in config file.")
23-
@click.option('--debug', envvar='CLOUDSCALE_DEBUG', is_flag=True, help='Enables debug log output.')
24-
@click.option('--output', '-o', envvar='CLOUDSCALE_OUTPUT', type=click.Choice(OUTPUT_FORMATS), default="table", help="Output format.", show_default=True)
25-
@click.pass_context
26-
def cli(ctx, profile, api_token, debug, output):
27-
ctx.obj = CloudscaleCommand(
28-
api_token=api_token,
29-
profile=profile,
30-
debug=debug,
31-
output=output,
32-
)
33-
34-
35-
cli.add_command(server)
36-
cli.add_command(server_group)
37-
cli.add_command(floating_ip)
38-
cli.add_command(flavor)
39-
cli.add_command(image)
40-
cli.add_command(region)
41-
cli.add_command(network)
42-
cli.add_command(subnet)
43-
cli.add_command(volume)
44-
cli.add_command(objects_user)
3+
def cli():
4+
sys.exit('\n*** Please install the `cloudscale-cli` or `cloudscale-sdk` package '
5+
'(instead of `cloudscale`) ***\n')

cloudscale/client.py

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)