Revision e873317a lib/cmdlib.py

b/lib/cmdlib.py
2007 2007
  HPATH = "instance-start"
2008 2008
  HTYPE = constants.HTYPE_INSTANCE
2009 2009
  _OP_REQP = ["instance_name", "force"]
2010
  REQ_BGL = False
2011

  
2012
  def ExpandNames(self):
2013
    self._ExpandAndLockInstance()
2014
    self.needed_locks[locking.LEVEL_NODE] = []
2015
    self.recalculate_locks[locking.LEVEL_NODE] = 'replace'
2016

  
2017
  def DeclareLocks(self, level):
2018
    if level == locking.LEVEL_NODE:
2019
      self._LockInstancesNodes()
2010 2020

  
2011 2021
  def BuildHooksEnv(self):
2012 2022
    """Build hooks env.
......
2028 2038
    This checks that the instance is in the cluster.
2029 2039

  
2030 2040
    """
2031
    instance = self.cfg.GetInstanceInfo(
2032
      self.cfg.ExpandInstanceName(self.op.instance_name))
2033
    if instance is None:
2034
      raise errors.OpPrereqError("Instance '%s' not known" %
2035
                                 self.op.instance_name)
2041
    self.instance = instance = self.cfg.GetInstanceInfo(self.op.instance_name)
2042
    assert self.instance is not None, \
2043
      "Cannot retrieve locked instance %s" % self.op.instance_name
2036 2044

  
2037 2045
    # check bridges existance
2038 2046
    _CheckInstanceBridgesExist(instance)
......
2041 2049
                         "starting instance %s" % instance.name,
2042 2050
                         instance.memory)
2043 2051

  
2044
    self.instance = instance
2045
    self.op.instance_name = instance.name
2046

  
2047 2052
  def Exec(self, feedback_fn):
2048 2053
    """Start the instance.
2049 2054

  
......
2070 2075
  HPATH = "instance-reboot"
2071 2076
  HTYPE = constants.HTYPE_INSTANCE
2072 2077
  _OP_REQP = ["instance_name", "ignore_secondaries", "reboot_type"]
2078
  REQ_BGL = False
2079

  
2080
  def ExpandNames(self):
2081
    self._ExpandAndLockInstance()
2082
    self.needed_locks[locking.LEVEL_NODE] = []
2083
    self.recalculate_locks[locking.LEVEL_NODE] = 'replace'
2084

  
2085
  def DeclareLocks(self, level):
2086
    if level == locking.LEVEL_NODE:
2087
      self._LockInstancesNodes()
2073 2088

  
2074 2089
  def BuildHooksEnv(self):
2075 2090
    """Build hooks env.
......
2091 2106
    This checks that the instance is in the cluster.
2092 2107

  
2093 2108
    """
2094
    instance = self.cfg.GetInstanceInfo(
2095
      self.cfg.ExpandInstanceName(self.op.instance_name))
2096
    if instance is None:
2097
      raise errors.OpPrereqError("Instance '%s' not known" %
2098
                                 self.op.instance_name)
2109
    self.instance = instance = self.cfg.GetInstanceInfo(self.op.instance_name)
2110
    assert self.instance is not None, \
2111
      "Cannot retrieve locked instance %s" % self.op.instance_name
2099 2112

  
2100 2113
    # check bridges existance
2101 2114
    _CheckInstanceBridgesExist(instance)
2102 2115

  
2103
    self.instance = instance
2104
    self.op.instance_name = instance.name
2105

  
2106 2116
  def Exec(self, feedback_fn):
2107 2117
    """Reboot the instance.
2108 2118

  
......
2146 2156
  HPATH = "instance-stop"
2147 2157
  HTYPE = constants.HTYPE_INSTANCE
2148 2158
  _OP_REQP = ["instance_name"]
2159
  REQ_BGL = False
2160

  
2161
  def ExpandNames(self):
2162
    self._ExpandAndLockInstance()
2163
    self.needed_locks[locking.LEVEL_NODE] = []
2164
    self.recalculate_locks[locking.LEVEL_NODE] = 'replace'
2165

  
2166
  def DeclareLocks(self, level):
2167
    if level == locking.LEVEL_NODE:
2168
      self._LockInstancesNodes()
2149 2169

  
2150 2170
  def BuildHooksEnv(self):
2151 2171
    """Build hooks env.
......
2164 2184
    This checks that the instance is in the cluster.
2165 2185

  
2166 2186
    """
2167
    instance = self.cfg.GetInstanceInfo(
2168
      self.cfg.ExpandInstanceName(self.op.instance_name))
2169
    if instance is None:
2170
      raise errors.OpPrereqError("Instance '%s' not known" %
2171
                                 self.op.instance_name)
2172
    self.instance = instance
2187
    self.instance = self.cfg.GetInstanceInfo(self.op.instance_name)
2188
    assert self.instance is not None, \
2189
      "Cannot retrieve locked instance %s" % self.op.instance_name
2173 2190

  
2174 2191
  def Exec(self, feedback_fn):
2175 2192
    """Shutdown the instance.

Also available in: Unified diff