~vila/byov/trunk

« back to all changes in this revision

Viewing changes to byov/vms/scaleway.py

  • Committer: Vincent Ladeuil
  • Date: 2018-01-30 09:47:07 UTC
  • Revision ID: v.ladeuil+lp@free.fr-20180130094707-yi9wfwnhlbg0jhia
Rename to byov.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This file is part of Online Services virtual machine tools.
 
1
# This file is part of Build Your Own Virtual machine.
2
2
#
3
3
# Copyright 2018 Vincent Ladeuil.
4
4
#
26
26
except:
27
27
    from urllib import parse as urlparse
28
28
 
29
 
import olsvms
30
 
from olsvms import (
 
29
import byov
 
30
from byov import (
31
31
    errors,
32
32
    timeouts,
33
33
    vms,
34
34
)
35
35
 
36
36
# FIXME: These are dependencies that need to remain optional so the scaleway
37
 
# backend requires them but ols-vms doesn't -- vila 2018-01-14
 
37
# backend requires them but byov doesn't -- vila 2018-01-14
38
38
import requests
39
39
 
40
40
logger = logging.getLogger(__name__)
49
49
)
50
50
 
51
51
 
52
 
class ScalewayComputeException(errors.OlsVmsError):
 
52
class ScalewayComputeException(errors.ByovError):
53
53
    pass
54
54
 
55
55
 
60
60
    bits while providing a simple point for tests to override when needed.
61
61
    """
62
62
 
63
 
    user_agent = 'ols-vms-{} python {}'.format(olsvms.version(),
64
 
                                               sys.version.split()[0])
 
63
    user_agent = 'byov-{} python {}'.format(byov.version(),
 
64
                                            sys.version.split()[0])
65
65
 
66
66
    def __init__(self, conf, root_url, timeouts):
67
67
        self.conf = conf
365
365
        if public_ip:
366
366
            ip = public_ip.get('address')
367
367
        if state != 'RUNNING' or not ip:
368
 
            raise errors.OlsVmsError(
 
368
            raise errors.ByovError(
369
369
                'scaleway server {} has not provided an IP yet: {}'.format(
370
370
                    self.conf.get('vm.name'), state))
371
371
        return ip