~ubuntu-branches/ubuntu/vivid/ironic/vivid-updates

« back to all changes in this revision

Viewing changes to ironic/conductor/rpcapi.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-01-05 12:21:37 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20150105122137-171bqrdpcxqipunk
Tags: 2015.1~b1-0ubuntu1
* New upstream beta release:
  - d/control: Align version requirements with upstream release.
* d/watch: Update uversionmangle to deal with kilo beta versioning
  changes.
* d/control: Bumped Standards-Version to 3.9.6, no changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
    API version history:
37
37
 
38
 
        1.0 - Initial version.
39
 
              Included get_node_power_status
40
 
        1.1 - Added update_node and start_power_state_change.
41
 
        1.2 - Added vendor_passhthru.
42
 
        1.3 - Rename start_power_state_change to change_node_power_state.
43
 
        1.4 - Added do_node_deploy and do_node_tear_down.
44
 
        1.5 - Added validate_driver_interfaces.
45
 
        1.6 - change_node_power_state, do_node_deploy and do_node_tear_down
46
 
              accept node id instead of node object.
47
 
        1.7 - Added topic parameter to RPC methods.
48
 
        1.8 - Added change_node_maintenance_mode.
49
 
        1.9 - Added destroy_node.
50
 
        1.10 - Remove get_node_power_state
51
 
        1.11 - Added get_console_information, set_console_mode.
52
 
        1.12 - validate_vendor_action, do_vendor_action replaced by single
53
 
              vendor_passthru method.
54
 
        1.13 - Added update_port.
55
 
        1.14 - Added driver_vendor_passthru.
56
 
        1.15 - Added rebuild parameter to do_node_deploy.
57
 
        1.16 - Added get_driver_properties.
58
 
        1.17 - Added set_boot_device, get_boot_device and
59
 
               get_supported_boot_devices.
 
38
    |    1.0 - Initial version.
 
39
    |          Included get_node_power_status
 
40
    |    1.1 - Added update_node and start_power_state_change.
 
41
    |    1.2 - Added vendor_passthru.
 
42
    |    1.3 - Rename start_power_state_change to change_node_power_state.
 
43
    |    1.4 - Added do_node_deploy and do_node_tear_down.
 
44
    |    1.5 - Added validate_driver_interfaces.
 
45
    |    1.6 - change_node_power_state, do_node_deploy and do_node_tear_down
 
46
    |          accept node id instead of node object.
 
47
    |    1.7 - Added topic parameter to RPC methods.
 
48
    |    1.8 - Added change_node_maintenance_mode.
 
49
    |    1.9 - Added destroy_node.
 
50
    |    1.10 - Remove get_node_power_state
 
51
    |    1.11 - Added get_console_information, set_console_mode.
 
52
    |    1.12 - validate_vendor_action, do_vendor_action replaced by single
 
53
    |          vendor_passthru method.
 
54
    |    1.13 - Added update_port.
 
55
    |    1.14 - Added driver_vendor_passthru.
 
56
    |    1.15 - Added rebuild parameter to do_node_deploy.
 
57
    |    1.16 - Added get_driver_properties.
 
58
    |    1.17 - Added set_boot_device, get_boot_device and
 
59
    |          get_supported_boot_devices.
 
60
    |    1.18 - Remove change_node_maintenance_mode.
 
61
    |    1.19 - Change return value of vendor_passthru and
 
62
    |           driver_vendor_passthru
 
63
    |    1.20 - Added http_method parameter to vendor_passthru and
 
64
    |           driver_vendor_passthru
 
65
    |    1.21 - Added get_node_vendor_passthru_methods and
 
66
    |           get_driver_vendor_passthru_methods
60
67
 
61
68
    """
62
69
 
63
70
    # NOTE(rloo): This must be in sync with manager.ConductorManager's.
64
 
    RPC_API_VERSION = '1.17'
 
71
    RPC_API_VERSION = '1.21'
65
72
 
66
73
    def __init__(self, topic=None):
67
74
        super(ConductorAPI, self).__init__()
79
86
        self.ring_manager = hash_ring.HashRingManager()
80
87
 
81
88
    def get_topic_for(self, node):
82
 
        """Get the RPC topic for the conductor service which the node
83
 
        is mapped to.
 
89
        """Get the RPC topic for the conductor service the node is mapped to.
84
90
 
85
91
        :param node: a node object.
86
92
        :returns: an RPC topic string.
99
105
            raise exception.NoValidHost(reason=reason)
100
106
 
101
107
    def get_topic_for_driver(self, driver_name):
102
 
        """Get an RPC topic which will route messages to a conductor which
103
 
        supports the specified driver. A conductor is selected at
104
 
        random from the set of qualified conductors.
 
108
        """Get RPC topic name for a conductor supporting the given driver.
 
109
 
 
110
        The topic is used to route messages to the conductor supporting
 
111
        the specified driver. A conductor is selected at random from the
 
112
        set of qualified conductors.
105
113
 
106
114
        :param driver_name: the name of the driver to route to.
107
115
        :returns: an RPC topic string.
136
144
        return cctxt.call(context, 'update_node', node_obj=node_obj)
137
145
 
138
146
    def change_node_power_state(self, context, node_id, new_state, topic=None):
139
 
        """Synchronously, acquire lock and start the conductor background task
 
147
        """Change a node's power state.
 
148
 
 
149
        Synchronously, acquire lock and start the conductor background task
140
150
        to change power state of a node.
141
151
 
142
152
        :param context: request context.
151
161
        return cctxt.call(context, 'change_node_power_state', node_id=node_id,
152
162
                          new_state=new_state)
153
163
 
154
 
    def vendor_passthru(self, context, node_id, driver_method, info,
155
 
                        topic=None):
156
 
        """Synchronously, acquire lock, validate given parameters and start
157
 
        the conductor background task for specified vendor action.
 
164
    def vendor_passthru(self, context, node_id, driver_method, http_method,
 
165
                        info, topic=None):
 
166
        """Receive requests for vendor-specific actions.
 
167
 
 
168
        Synchronously validate driver specific info or get driver status,
 
169
        and if successful invokes the vendor method. If the method mode
 
170
        is async the conductor will start background worker to perform
 
171
        vendor action.
158
172
 
159
173
        :param context: request context.
160
174
        :param node_id: node id or uuid.
161
175
        :param driver_method: name of method for driver.
 
176
        :param http_method: the HTTP method used for the request.
162
177
        :param info: info for node driver.
163
178
        :param topic: RPC topic. Defaults to self.topic.
164
179
        :raises: InvalidParameterValue if supplied info is not valid.
167
182
                 vendor interface.
168
183
        :raises: NoFreeConductorWorker when there is no free worker to start
169
184
                 async task.
 
185
        :raises: NodeLocked if node is locked by another conductor.
 
186
        :returns: A tuple containing the response of the invoked method
 
187
                  and a boolean value indicating whether the method was
 
188
                  invoked asynchronously (True) or synchronously (False).
 
189
                  If invoked asynchronously the response field will be
 
190
                  always None.
170
191
 
171
192
        """
172
 
        cctxt = self.client.prepare(topic=topic or self.topic, version='1.12')
 
193
        cctxt = self.client.prepare(topic=topic or self.topic, version='1.20')
173
194
        return cctxt.call(context, 'vendor_passthru', node_id=node_id,
174
 
                          driver_method=driver_method, info=info)
 
195
                          driver_method=driver_method,
 
196
                          http_method=http_method,
 
197
                          info=info)
175
198
 
176
 
    def driver_vendor_passthru(self, context, driver_name, driver_method, info,
177
 
                        topic=None):
 
199
    def driver_vendor_passthru(self, context, driver_name, driver_method,
 
200
                               http_method, info, topic=None):
178
201
        """Pass vendor-specific calls which don't specify a node to a driver.
179
202
 
 
203
        Handles driver-level vendor passthru calls. These calls don't
 
204
        require a node UUID and are executed on a random conductor with
 
205
        the specified driver. If the method mode is async the conductor
 
206
        will start background worker to perform vendor action.
 
207
 
180
208
        :param context: request context.
181
209
        :param driver_name: name of the driver on which to call the method.
182
210
        :param driver_method: name of the vendor method, for use by the driver.
 
211
        :param http_method: the HTTP method used for the request.
183
212
        :param info: data to pass through to the driver.
184
213
        :param topic: RPC topic. Defaults to self.topic.
185
214
        :raises: InvalidParameterValue for parameter errors.
187
216
        :raises: UnsupportedDriverExtension if the driver doesn't have a vendor
188
217
                 interface, or if the vendor interface does not support the
189
218
                 specified driver_method.
 
219
        :raises: DriverNotFound if the supplied driver is not loaded.
 
220
        :raises: NoFreeConductorWorker when there is no free worker to start
 
221
                 async task.
 
222
        :returns: A tuple containing the response of the invoked method
 
223
                  and a boolean value indicating whether the method was
 
224
                  invoked asynchronously (True) or synchronously (False).
 
225
                  If invoked asynchronously the response field will be
 
226
                  always None.
190
227
 
191
228
        """
192
 
        cctxt = self.client.prepare(topic=topic or self.topic, version='1.14')
 
229
        cctxt = self.client.prepare(topic=topic or self.topic, version='1.20')
193
230
        return cctxt.call(context, 'driver_vendor_passthru',
194
231
                          driver_name=driver_name,
195
232
                          driver_method=driver_method,
 
233
                          http_method=http_method,
196
234
                          info=info)
197
235
 
 
236
    def get_node_vendor_passthru_methods(self, context, node_id, topic=None):
 
237
        """Retrieve information about vendor methods of the given node.
 
238
 
 
239
        :param context: an admin context.
 
240
        :param node_id: the id or uuid of a node.
 
241
        :param topic: RPC topic. Defaults to self.topic.
 
242
        :returns: dictionary of <method name>:<method metadata> entries.
 
243
 
 
244
        """
 
245
        cctxt = self.client.prepare(topic=topic or self.topic, version='1.21')
 
246
        return cctxt.call(context, 'get_node_vendor_passthru_methods',
 
247
                          node_id=node_id)
 
248
 
 
249
    def get_driver_vendor_passthru_methods(self, context, driver_name,
 
250
                                            topic=None):
 
251
        """Retrieve information about vendor methods of the given driver.
 
252
 
 
253
        :param context: an admin context.
 
254
        :param driver_name: name of the driver.
 
255
        :param topic: RPC topic. Defaults to self.topic.
 
256
        :returns: dictionary of <method name>:<method metadata> entries.
 
257
 
 
258
        """
 
259
        cctxt = self.client.prepare(topic=topic or self.topic, version='1.21')
 
260
        return cctxt.call(context, 'get_driver_vendor_passthru_methods',
 
261
                          driver_name=driver_name)
 
262
 
198
263
    def do_node_deploy(self, context, node_id, rebuild, topic=None):
199
264
        """Signal to conductor service to perform a deployment.
200
265
 
249
314
        return cctxt.call(context, 'validate_driver_interfaces',
250
315
                          node_id=node_id)
251
316
 
252
 
    def change_node_maintenance_mode(self, context, node_id, mode, topic=None):
253
 
        """Set node maintenance mode on or off.
254
 
 
255
 
        :param context: request context.
256
 
        :param node_id: node id or uuid.
257
 
        :param mode: True or False.
258
 
        :param topic: RPC topic. Defaults to self.topic.
259
 
        :returns: a node object.
260
 
        :raises: NodeMaintenanceFailure.
261
 
 
262
 
        """
263
 
        cctxt = self.client.prepare(topic=topic or self.topic, version='1.8')
264
 
        return cctxt.call(context, 'change_node_maintenance_mode',
265
 
                          node_id=node_id, mode=mode)
266
 
 
267
317
    def destroy_node(self, context, node_id, topic=None):
268
318
        """Delete a node.
269
319