Revision f48148c3 lib/hypervisor/hv_base.py

b/lib/hypervisor/hv_base.py
23 23

  
24 24
"""
25 25

  
26
from ganeti import errors
27

  
28

  
26 29
class BaseHypervisor(object):
27 30
  """Abstract virtualisation technology interface
28 31

  
29
  The goal is that all aspects of the virtualisation technology must
30
  be abstracted away from the rest of code.
32
  The goal is that all aspects of the virtualisation technology are
33
  abstracted away from the rest of code.
31 34

  
32 35
  """
36
  PARAMETERS = []
37

  
33 38
  def __init__(self):
34 39
    pass
35 40

  
......
106 111

  
107 112
    """
108 113
    raise NotImplementedError
114

  
115

  
116
  @classmethod
117
  def CheckParameterSyntax(cls, hvparams):
118
    """Check the given parameters for validity.
119

  
120
    This should check the passed set of parameters for
121
    validity. Classes should extend, not replace, this function.
122

  
123
    @type hvparams:  dict
124
    @param hvparams: dictionary with parameter names/value
125
    @raise errors.HypervisorError: when a parameter is not valid
126

  
127
    """
128
    for key in hvparams:
129
      if key not in cls.PARAMETERS:
130
        raise errors.HypervisorError("Hypervisor parameter '%s'"
131
                                     " not supported" % key)
132
    for key in cls.PARAMETERS:
133
      if key not in hvparams:
134
        raise errors.HypervisorError("Hypervisor parameter '%s'"
135
                                     " missing" % key)
136

  
137
  def ValidateParameters(self, hvparams):
138
    """Check the given parameters for validity.
139

  
140
    This should check the passed set of parameters for
141
    validity. Classes should extend, not replace, this function.
142

  
143
    @type hvparams:  dict
144
    @param hvparams: dictionary with parameter names/value
145
    @raise errors.HypervisorError: when a parameter is not valid
146

  
147
    """
148
    pass

Also available in: Unified diff