Ejemplo n.º 1
0
 def _remove_ops_dir(self, ops_dir_path):
     # Just a sanity check.  An ops dir under the active directory
     # could be in active state, and so we should not remove it.
     ASSERT.not_equal(ops_dir_path.parent.name, _ACTIVE)
     ops_dir = self.ops_dir_type(ops_dir_path)
     ops_dir.uninstall()
     ops_dir.path.rmdir()
Ejemplo n.º 2
0
def cmd_prepare(pod_id, config_path):
    """Prepare a pod directory, or no-op if pod exists."""
    oses.assert_root_privilege()
    # Make sure that it is safe to create a pod with this ID.
    ASSERT.not_equal(
        models.pod_id_to_machine_id(pod_id),
        models.read_host_machine_id(),
    )
    # Check before really preparing the pod.
    if g1.files.lexists(_get_pod_dir_path(pod_id)):
        LOG.info('skip duplicated pod: %s', pod_id)
        return
    config = jsons.load_dataobject(models.PodConfig, config_path)
    tmp_path = _create_tmp_pod_dir()
    try:
        _prepare_pod_dir(tmp_path, pod_id, config)
        with locks.acquiring_exclusive(_get_active_path()):
            if _maybe_move_pod_dir_to_active(tmp_path, pod_id):
                tmp_path = None
            else:
                LOG.info('skip duplicated pod: %s', pod_id)
    finally:
        if tmp_path:
            _remove_pod_dir(tmp_path)
Ejemplo n.º 3
0
 def rollback_due_to_timeout(self):
     ASSERT.not_equal(self._tx_id, 0)
     self._tx.rollback()
     self._end(self._timeout_tx_ids)