Ejemplo n.º 1
0
 def apply_snapshot(self, context, instance_id, snapshot_id, credential, auth_url):
     LOG.debug("Triggering smart agent to apply Snapshot %s on Instance %s.", snapshot_id, instance_id)
     instance = dbutils.get_instance(instance_id)
     snapshot = dbutils.get_snapshot(snapshot_id)
     rpc.cast(context, instance['remote_hostname'],
              {"method": "apply_snapshot",
               "args": {"storage_path": snapshot['storage_uri'],
                        "credential": {"user": credential['tenant_id']+":"+credential['user_name'],
                                       "key": credential['password'],
                                       "auth": auth_url}}
               })
Ejemplo n.º 2
0
    def update_snapshot_state(self, msg):
        """Update snapshot state in database_snapshots table."""
        LOG.debug("Updating snapshot state: %s", msg)

        # validate input message
        if not msg['args']['sid']:
            raise exception.NotFound("Required element/key 'sid' was not specified in phone home message.")
        if '' == msg['args']['state']:
            raise exception.NotFound("Required element/key 'state' was not specified in phone home message.")
        if not msg['args']['storage_uri']:
            raise exception.NotFound("Required element/key 'storage_uri' was not specified in phone home message.")
        if '' == msg['args']['storage_size']:
            raise exception.NotFound("Required element/key 'storage_size' was not specified in phone home message.")

        # update DB
        snapshot = dbutils.get_snapshot(msg['args']['sid'])
        LOG.debug("Updating snapshot state with ID %s", snapshot['id'])
        snapshot.update(storage_uri=msg['args']['storage_uri'],
                        storage_size=msg['args']['storage_size'],
                        state=result_state.ResultState().name(msg['args']['state']))