yakumo.nova.v2.agent

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

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

     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 agents in Compute API v2
    18  """
    19
    20  from yakumo import base
    21  from yakumo.constant import UNDEF
    22  from yakumo import mapper
    23
    24
    25  ATTRIBUTE_MAPPING = [
    26      ('id', 'agent_id', mapper.Noop),
    27      ('architecture', 'architecture', mapper.Noop),
    28      ('hypervisor', 'hypervisor', mapper.Noop),
    29      ('md5hash', 'md5hash', mapper.Noop),
    30      ('os', 'os', mapper.Noop),
    31      ('url', 'url', mapper.Noop),
    32      ('version', 'version', mapper.Noop),
    33  ]
    34
    35
    36 -class Resource(base.Resource):
    37      """Resource class for agents in Compute API v2"""
    38
    39 -    def update(self, architecture=UNDEF, hypervisor=UNDEF, os=UNDEF, url=UNDEF,
    40                 version=UNDEF):
    41          """
    42          Update properties of an agent
    43
    44          @keyword architecture: Architecture
    45          @type architecture: str
    46          @keyword hypervisor: Hypervisor
    47          @type hypervisor: str
    48          @keyword os: Operating System
    49          @type os: str
    50          @keyword url: URL
    51          @type url: str
    52          @keyword version: Version
    53          @type version: str
    54          @rtype: None
    55          """
    56          super(Resource, self).update(
    57              architecture=architecture,
    58              hypervisor=hypervisor,
    59              os=os,
    60              url=url,
    61              version=version)
    62
    63
    64 -class Manager(base.Manager):
    65      """Manager class for agents in Compute API v2"""
    66
    67      resource_class = Resource
    68      service_type = 'compute'
    69      _attr_mapping = ATTRIBUTE_MAPPING
    70      _json_resource_key = 'agent'
    71      _json_resources_key = 'agents'
    72      _url_resource_path = '/os-agents'
    73
    74 -    def create(self, architecture=UNDEF, hypervisor=UNDEF, os=UNDEF, url=UNDEF,
    75                 version=UNDEF):
    76          """
    77          Register an agent
    78
    79          @keyword architecture: Architecture
    80          @type architecture: str
    81          @keyword hypervisor: Hypervisor
    82          @type hypervisor: str
    83          @keyword os: Operating System
    84          @type os: str
    85          @keyword url: URL
    86          @type url: str
    87          @keyword version: Version
    88          @type version: str
    89          @return: Registered agent
    90          @rtype: yakumo.nova.v2.agent.Resource
    91          """
    92          return super(Manager, self).create(
    93              architecture=architecture,
    94              hypervisor=hypervisor,
    95              os=os,
    96              url=url,
    97              version=version)
    98