forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
concierge_client.h
106 lines (85 loc) · 3.89 KB
/
concierge_client.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_DBUS_CONCIERGE_CLIENT_H_
#define CHROMEOS_DBUS_CONCIERGE_CLIENT_H_
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/concierge/service.pb.h"
#include "chromeos/dbus/dbus_client.h"
#include "chromeos/dbus/dbus_method_call_status.h"
#include "dbus/object_proxy.h"
namespace chromeos {
// ConciergeClient is used to communicate with Concierge, which is used to
// start and stop VMs.
class CHROMEOS_EXPORT ConciergeClient : public DBusClient {
public:
class Observer {
public:
// OnContainerStartupFailed is signaled by Concierge after the long-running
// container startup process's failure is detected. Note the signal protocol
// buffer type is the same as in OnContainerStarted.
virtual void OnContainerStartupFailed(
const vm_tools::concierge::ContainerStartedSignal& signal) = 0;
protected:
virtual ~Observer() = default;
};
// Adds an observer.
virtual void AddObserver(Observer* observer) = 0;
// Removes an observer if added.
virtual void RemoveObserver(Observer* observer) = 0;
// IsContainerStartupFailedSignalConnected must return true before
// StartContainer is called.
virtual bool IsContainerStartupFailedSignalConnected() = 0;
// Creates a disk image for the Termina VM.
// |callback| is called after the method call finishes.
virtual void CreateDiskImage(
const vm_tools::concierge::CreateDiskImageRequest& request,
DBusMethodCallback<vm_tools::concierge::CreateDiskImageResponse>
callback) = 0;
// Destroys a Termina VM and removes its disk image.
// |callback| is called after the method call finishes.
virtual void DestroyDiskImage(
const vm_tools::concierge::DestroyDiskImageRequest& request,
DBusMethodCallback<vm_tools::concierge::DestroyDiskImageResponse>
callback) = 0;
// Lists the Termina VMs.
// |callback| is called after the method call finishes.
virtual void ListVmDisks(
const vm_tools::concierge::ListVmDisksRequest& request,
DBusMethodCallback<vm_tools::concierge::ListVmDisksResponse>
callback) = 0;
// Starts a Termina VM if there is not alread one running.
// |callback| is called after the method call finishes.
virtual void StartTerminaVm(
const vm_tools::concierge::StartVmRequest& request,
DBusMethodCallback<vm_tools::concierge::StartVmResponse> callback) = 0;
// Stops the named Termina VM if it is running.
// |callback| is called after the method call finishes.
virtual void StopVm(
const vm_tools::concierge::StopVmRequest& request,
DBusMethodCallback<vm_tools::concierge::StopVmResponse> callback) = 0;
// Registers |callback| to run when the Concierge service becomes available.
// If the service is already available, or if connecting to the name-owner-
// changed signal fails, |callback| will be run once asynchronously.
// Otherwise, |callback| will be run once in the future after the service
// becomes available.
virtual void WaitForServiceToBeAvailable(
dbus::ObjectProxy::WaitForServiceToBeAvailableCallback callback) = 0;
// Gets SSH server public key of container and trusted SSH client private key
// which can be used to connect to the container.
// |callback| is called after the method call finishes.
virtual void GetContainerSshKeys(
const vm_tools::concierge::ContainerSshKeysRequest& request,
DBusMethodCallback<vm_tools::concierge::ContainerSshKeysResponse>
callback) = 0;
// Creates an instance of ConciergeClient.
static ConciergeClient* Create();
~ConciergeClient() override;
protected:
// Create() should be used instead.
ConciergeClient();
private:
DISALLOW_COPY_AND_ASSIGN(ConciergeClient);
};
} // namespace chromeos
#endif // CHROMEOS_DBUS_CONCIERGE_CLIENT_H_