yakumo

Package yakumo |
[hide private]
[frames] | no frames]

# Source Code for Package yakumo

     1  # Copyright 2014-2017 by Akira Yoshiyama <akirayoshiyama@gmail.com>.
     2  # All Rights Reserved.
     3  #
     4  #   Licensed under the Apache License, Version 2.0 (the "License"); you may
     5  #   not use this file except in compliance with the License. You may obtain
     6  #   a copy of the License at
     7  #
     8  #       http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  #   Unless required by applicable law or agreed to in writing, software
    11  #   distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    12  #   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    13  #   License for the specific language governing permissions and limitations
    14  #   under the License.
    15
    16  """
    17  Client class definition
    18  """
    19
    20  import os
    21
    22  import os_client_config
    23
    24  from . import exception
    25  from . import session
    26
    27
    28 -class Client(object):
    29
    30 -    def __init__(self, **kwargs):
    31          self._session = session.get_session(**kwargs)
    32
    33          if self._session.has_endpoint('identity'):
    34              if self._session.config['identity_api_version'] == '2.0':
    35                  import yakumo.keystone.v2
    36                  self.keystone = yakumo.keystone.v2.Client(self, **kwargs)
    37              elif self._session.config['identity_api_version'] == '3':
    38                  import yakumo.keystone.v3
    39                  self.keystone = yakumo.keystone.v3.Client(self, **kwargs)
    40
    41          if self._session.has_endpoint('compute'):
    42              if self._session.config['compute_api_version'] == '2':
    43                  import yakumo.nova.v2
    44                  self.nova = yakumo.nova.v2.Client(self, **kwargs)
    45
    46          if self._session.has_endpoint('image'):
    47              if self._session.config['image_api_version'] == '1':
    48                  import yakumo.glance.v1
    49                  self.glance = yakumo.glance.v1.Client(self, **kwargs)
    50              elif self._session.config['image_api_version'] == '2':
    51                  import yakumo.glance.v2
    52                  self.glance = yakumo.glance.v2.Client(self, **kwargs)
    53
    54          if self._session.has_endpoint('volume'):
    55              if self._session.config['volume_api_version'] == '1':
    56                  import yakumo.cinder.v1
    57                  self.cinder = yakumo.cinder.v1.Client(self, **kwargs)
    58              elif self._session.config['volume_api_version'] == '2':
    59                  import yakumo.cinder.v2
    60                  self.cinder = yakumo.cinder.v2.Client(self, **kwargs)
    61
    62          if self._session.has_endpoint('network'):
    63              if self._session.config['network_api_version'] == '2':
    64                  import yakumo.neutron.v2
    65                  self.neutron = yakumo.neutron.v2.Client(self, **kwargs)
    66