Revision cf695285 lib/config.py
b/lib/config.py | ||
---|---|---|
1509 | 1509 |
raise errors.ConfigurationError("Cannot add '%s': UUID %s already" |
1510 | 1510 |
" in use" % (item.name, item.uuid)) |
1511 | 1511 |
|
1512 |
def _SetInstanceStatus(self, inst_uuid, status, disks_active): |
|
1512 |
def _SetInstanceStatus(self, inst_uuid, status, disks_active, |
|
1513 |
admin_state_source): |
|
1513 | 1514 |
"""Set the instance's status to a given value. |
1514 | 1515 |
|
1515 | 1516 |
""" |
... | ... | |
1522 | 1523 |
status = instance.admin_state |
1523 | 1524 |
if disks_active is None: |
1524 | 1525 |
disks_active = instance.disks_active |
1526 |
if admin_state_source is None: |
|
1527 |
admin_state_source = instance.admin_state_source |
|
1525 | 1528 |
|
1526 | 1529 |
assert status in constants.ADMINST_ALL, \ |
1527 | 1530 |
"Invalid status '%s' passed to SetInstanceStatus" % (status,) |
1528 | 1531 |
|
1529 | 1532 |
if instance.admin_state != status or \ |
1530 |
instance.disks_active != disks_active: |
|
1533 |
instance.disks_active != disks_active or \ |
|
1534 |
instance.admin_state_source != admin_state_source: |
|
1531 | 1535 |
instance.admin_state = status |
1532 | 1536 |
instance.disks_active = disks_active |
1537 |
instance.admin_state_source = admin_state_source |
|
1533 | 1538 |
instance.serial_no += 1 |
1534 | 1539 |
instance.mtime = time.time() |
1535 | 1540 |
self._WriteConfig() |
... | ... | |
1541 | 1546 |
This also sets the instance disks active flag. |
1542 | 1547 |
|
1543 | 1548 |
""" |
1544 |
self._SetInstanceStatus(inst_uuid, constants.ADMINST_UP, True) |
|
1549 |
self._SetInstanceStatus(inst_uuid, constants.ADMINST_UP, True, |
|
1550 |
constants.ADMIN_SOURCE) |
|
1545 | 1551 |
|
1546 | 1552 |
@locking.ssynchronized(_config_lock) |
1547 | 1553 |
def MarkInstanceOffline(self, inst_uuid): |
... | ... | |
1550 | 1556 |
This also clears the instance disks active flag. |
1551 | 1557 |
|
1552 | 1558 |
""" |
1553 |
self._SetInstanceStatus(inst_uuid, constants.ADMINST_OFFLINE, False) |
|
1559 |
self._SetInstanceStatus(inst_uuid, constants.ADMINST_OFFLINE, False, |
|
1560 |
constants.ADMIN_SOURCE) |
|
1554 | 1561 |
|
1555 | 1562 |
@locking.ssynchronized(_config_lock) |
1556 | 1563 |
def RemoveInstance(self, inst_uuid): |
... | ... | |
1614 | 1621 |
can still have active disks. |
1615 | 1622 |
|
1616 | 1623 |
""" |
1617 |
self._SetInstanceStatus(inst_uuid, constants.ADMINST_DOWN, None) |
|
1624 |
self._SetInstanceStatus(inst_uuid, constants.ADMINST_DOWN, None, |
|
1625 |
constants.ADMIN_SOURCE) |
|
1626 |
|
|
1627 |
@locking.ssynchronized(_config_lock) |
|
1628 |
def MarkInstanceUserDown(self, inst_uuid): |
|
1629 |
"""Mark the status of an instance to user down in the configuration. |
|
1630 |
|
|
1631 |
This does not touch the instance disks active flag, as user shut |
|
1632 |
down instances can still have active disks. |
|
1633 |
|
|
1634 |
""" |
|
1635 |
|
|
1636 |
self._SetInstanceStatus(inst_uuid, constants.ADMINST_DOWN, None, |
|
1637 |
constants.USER_SOURCE) |
|
1618 | 1638 |
|
1619 | 1639 |
@locking.ssynchronized(_config_lock) |
1620 | 1640 |
def MarkInstanceDisksActive(self, inst_uuid): |
1621 | 1641 |
"""Mark the status of instance disks active. |
1622 | 1642 |
|
1623 | 1643 |
""" |
1624 |
self._SetInstanceStatus(inst_uuid, None, True) |
|
1644 |
self._SetInstanceStatus(inst_uuid, None, True, None)
|
|
1625 | 1645 |
|
1626 | 1646 |
@locking.ssynchronized(_config_lock) |
1627 | 1647 |
def MarkInstanceDisksInactive(self, inst_uuid): |
1628 | 1648 |
"""Mark the status of instance disks inactive. |
1629 | 1649 |
|
1630 | 1650 |
""" |
1631 |
self._SetInstanceStatus(inst_uuid, None, False) |
|
1651 |
self._SetInstanceStatus(inst_uuid, None, False, None)
|
|
1632 | 1652 |
|
1633 | 1653 |
def _UnlockedGetInstanceList(self): |
1634 | 1654 |
"""Get the list of instances. |
Also available in: Unified diff