yakumo.nova.v2.hypervisor

Package yakumo :: Package nova :: Package v2 :: Module hypervisor |
[hide private]
[frames] | no frames]

# Source Code for Module yakumo.nova.v2.hypervisor

     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  Resource class and its manager for hypervisors in Compute API v2
    18  """
    19
    20  from yakumo import base
    21  from yakumo import mapper
    22  from yakumo import utils
    23
    24
    25  ATTRIBUTE_MAPPING = [
    26      ('id', 'id', mapper.Noop),
    27      ('hostname', 'hypervisor_hostname', mapper.Noop),
    28      ('type', 'hypervisor_type', mapper.Noop),
    29      ('version', 'hypervisor_version', mapper.Noop),
    30      ('cpu_info', 'cpu_info', mapper.Noop),
    31      ('workload', 'current_workload', mapper.Noop),
    32      ('disk_available_least', 'disk_available_least', mapper.Noop),
    33      ('free_disk_gb', 'free_disk_gb', mapper.Noop),
    34      ('free_ram_mb', 'free_ram_mb', mapper.Noop),
    35      ('local_gb', 'local_gb', mapper.Noop),
    36      ('local_gb_used', 'local_gb_used', mapper.Noop),
    37      ('memory_mb', 'memory_mb', mapper.Noop),
    38      ('memory_mb_used', 'memory_mb_used', mapper.Noop),
    39      ('running_vms', 'running_vms', mapper.Noop),
    40      ('service', 'service', mapper.Noop),
    41      ('vcpus', 'vcpus', mapper.Noop),
    42      ('vcpus_used', 'vcpus_used', mapper.Noop),
    43  ]
    44
    45
    46 -class Resource(base.Resource):
    47      """Resource class for hypervisors in Compute API v2"""
    48
    49
    50 -class Manager(base.Manager):
    51      """Manager class for hypervisors in Compute API v2"""
    52
    53      resource_class = Resource
    54      service_type = 'compute'
    55      _attr_mapping = ATTRIBUTE_MAPPING
    56      _hidden_methods = ["create", "update"]
    57      _json_resource_key = 'hypervisor'
    58      _json_resources_key = 'hypervisors'
    59      _url_resource_path = '/os-hypervisors'
    60
    61 -    def get_total_stats(self):
    62          """
    63          Aquire total statistics of hypervisors
    64
    65          @return: Statistics
    66          @rtype: dict
    67          """
    68          return self._http.get(utils.join_path(self._url_resource_path,
    69                                                "statistics"))
    70
    71 -    def servers(self, host):
    72          """
    73          Aquire hypervisor hosts
    74
    75          @return: Host list
    76          @rtype: dict
    77          """
    78          return self._http.get(utils.join_path(self._url_resource_path,
    79                                                host, "servers"))
    80