summaryrefslogtreecommitdiff
path: root/doc/source/admin/configuration/hypervisor-hyper-v.rst
blob: 8ce9c2ebb4117f95d6d187b053901f0c358bd14a (plain)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
===============================
Hyper-V virtualization platform
===============================

.. todo:: This is really installation guide material and should probably be
     moved.

It is possible to use Hyper-V as a compute node within an OpenStack Deployment.
The ``nova-compute`` service runs as ``openstack-compute``, a 32-bit service
directly upon the Windows platform with the Hyper-V role enabled. The necessary
Python components as well as the ``nova-compute`` service are installed
directly onto the Windows platform. Windows Clustering Services are not needed
for functionality within the OpenStack infrastructure.  The use of the Windows
Server 2012 platform is recommend for the best experience and is the platform
for active development.  The following Windows platforms have been tested as
compute nodes:

- Windows Server 2012
- Windows Server 2012 R2 Server and Core (with the Hyper-V role enabled)
- Hyper-V Server


Hyper-V configuration
---------------------

The only OpenStack services required on a Hyper-V node are ``nova-compute`` and
``neutron-hyperv-agent``. Regarding the resources needed for this host you have
to consider that Hyper-V will require 16 GB - 20 GB of disk space for the OS
itself, including updates. Two NICs are required, one connected to the
management network and one to the guest data network.

The following sections discuss how to prepare the Windows Hyper-V node for
operation as an OpenStack compute node. Unless stated otherwise, any
configuration information should work for the Windows 2012 and 2012 R2
platforms.

Local storage considerations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The Hyper-V compute node needs to have ample storage for storing the virtual
machine images running on the compute nodes. You may use a single volume for
all, or partition it into an OS volume and VM volume.

.. _configure-ntp-windows:

Configure NTP
~~~~~~~~~~~~~

Network time services must be configured to ensure proper operation of the
OpenStack nodes. To set network time on your Windows host you must run the
following commands:

.. code-block:: bat

   C:\>net stop w32time
   C:\>w32tm /config "/manualpeerlist:pool.ntp.org,0x8" /syncfromflags:MANUAL
   C:\>net start w32time

Keep in mind that the node will have to be time synchronized with the other
nodes of your OpenStack environment, so it is important to use the same NTP
server. Note that in case of an Active Directory environment, you may do this
only for the AD Domain Controller.

Configure Hyper-V virtual switching
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Information regarding the Hyper-V virtual Switch can be found in the `Hyper-V
Virtual Switch Overview`__.

To quickly enable an interface to be used as a Virtual Interface the
following PowerShell may be used:

.. code-block:: none

   PS C:\> $if = Get-NetIPAddress -IPAddress 192* | Get-NetIPInterface
   PS C:\> New-VMSwitch -NetAdapterName $if.ifAlias -Name YOUR_BRIDGE_NAME -AllowManagementOS $false

.. note::

   It is very important to make sure that when you are using a Hyper-V node
   with only 1 NIC the -AllowManagementOS option is set on ``True``, otherwise
   you will lose connectivity to the Hyper-V node.

__ https://technet.microsoft.com/en-us/library/hh831823.aspx

Enable iSCSI initiator service
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To prepare the Hyper-V node to be able to attach to volumes provided by cinder
you must first make sure the Windows iSCSI initiator service is running and
started automatically.

.. code-block:: none

   PS C:\> Set-Service -Name MSiSCSI -StartupType Automatic
   PS C:\> Start-Service MSiSCSI

Configure shared nothing live migration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Detailed information on the configuration of live migration can be found in
`this guide`__

The following outlines the steps of shared nothing live migration.

#. The target host ensures that live migration is enabled and properly
   configured in Hyper-V.

#. The target host checks if the image to be migrated requires a base VHD and
   pulls it from the Image service if not already available on the target host.

#. The source host ensures that live migration is enabled and properly
   configured in Hyper-V.

#. The source host initiates a Hyper-V live migration.

#. The source host communicates to the manager the outcome of the operation.

The following three configuration options are needed in order to support
Hyper-V live migration and must be added to your ``nova.conf`` on the Hyper-V
compute node:

* This is needed to support shared nothing Hyper-V live migrations.  It is used
  in ``nova/compute/manager.py``.

  .. code-block:: ini

     instances_shared_storage = False

* This flag is needed to support live migration to hosts with different CPU
  features. This flag is checked during instance creation in order to limit the
  CPU features used by the VM.

  .. code-block:: ini

     limit_cpu_features = True

* This option is used to specify where instances are stored on disk.

  .. code-block:: ini

     instances_path = DRIVELETTER:\PATH\TO\YOUR\INSTANCES

Additional Requirements:

* Hyper-V 2012 R2 or Windows Server 2012 R2 with Hyper-V role enabled

* A Windows domain controller with the Hyper-V compute nodes as domain members

* The instances_path command-line option/flag needs to be the same on all hosts

* The ``openstack-compute`` service deployed with the setup must run with
  domain credentials. You can set the service credentials with:

.. code-block:: bat

   C:\>sc config openstack-compute obj="DOMAIN\username" password="password"

__ https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/manage/Use-live-migration-without-Failover-Clustering-to-move-a-virtual-machine

How to setup live migration on Hyper-V
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To enable 'shared nothing live' migration, run the 3 instructions below on each
Hyper-V host:

.. code-block:: none

   PS C:\> Enable-VMMigration
   PS C:\> Set-VMMigrationNetwork IP_ADDRESS
   PS C:\> Set-VMHost -VirtualMachineMigrationAuthenticationTypeKerberos

.. note::

   Replace the ``IP_ADDRESS`` with the address of the interface which will
   provide live migration.

Additional Reading
~~~~~~~~~~~~~~~~~~

This article clarifies the various live migration options in Hyper-V:

`Hyper-V Live Migration of Yesterday
<https://ariessysadmin.blogspot.ro/2012/04/hyper-v-live-migration-of-windows.html>`_


Install nova-compute using OpenStack Hyper-V installer
------------------------------------------------------

In case you want to avoid all the manual setup, you can use Cloudbase
Solutions' installer. You can find it here:

`HyperVNovaCompute_Beta download
<https://www.cloudbase.it/downloads/HyperVNovaCompute_Beta.msi>`_

The tool installs an independent Python environment in order to avoid conflicts
with existing applications, and dynamically generates a ``nova.conf`` file
based on the parameters provided by you.

The tool can also be used for an automated and unattended mode for deployments
on a massive number of servers. More details about how to use the installer and
its features can be found here:

`Cloudbase <https://www.cloudbase.it>`_


.. _windows-requirements:

Requirements
------------

Python
~~~~~~

**Setting up Python prerequisites**

#. Download and install Python 3.8 using the MSI installer from the `Python
   website`__.

   .. __: https://www.python.org/downloads/windows/

   .. code-block:: none

      PS C:\> $src = "https://www.python.org/ftp/python/3.8.8/python-3.8.8.exe"
      PS C:\> $dest = "$env:temp\python-3.8.8.exe"
      PS C:\> Invoke-WebRequest -Uri $src -OutFile $dest
      PS C:\> Unblock-File $dest
      PS C:\> Start-Process $dest

#. Make sure that the ``Python`` and ``Python\Scripts`` paths are set up in the
   ``PATH`` environment variable.

   .. code-block:: none

      PS C:\> $oldPath = [System.Environment]::GetEnvironmentVariable("Path")
      PS C:\> $newPath = $oldPath + ";C:\python38\;C:\python38\Scripts\"
      PS C:\> [System.Environment]::SetEnvironmentVariable("Path", $newPath, [System.EnvironmentVariableTarget]::User

Python dependencies
~~~~~~~~~~~~~~~~~~~

The following packages must be installed with pip:

* ``pywin32``
* ``pymysql``
* ``greenlet``
* ``pycrypto``
* ``ecdsa``
* ``amqp``
* ``wmi``

.. code-block:: none

   PS C:\> pip install ecdsa
   PS C:\> pip install amqp
   PS C:\> pip install wmi


Other dependencies
~~~~~~~~~~~~~~~~~~

``qemu-img`` is required for some of the image related operations.  You can get
it from here: http://qemu.weilnetz.de/.  You must make sure that the
``qemu-img`` path is set in the PATH environment variable.

Some Python packages need to be compiled, so you may use MinGW or Visual
Studio. You can get MinGW from here: http://sourceforge.net/projects/mingw/.
You must configure which compiler is to be used for this purpose by using the
``distutils.cfg`` file in ``$Python38\Lib\distutils``, which can contain:

.. code-block:: ini

   [build]
   compiler = mingw32

As a last step for setting up MinGW, make sure that the MinGW binaries'
directories are set up in PATH.


Install nova-compute
--------------------

Download the nova code
~~~~~~~~~~~~~~~~~~~~~~

#. Use Git to download the necessary source code.  The installer to run Git on
   Windows can be downloaded here:

   https://gitforwindows.org/

#. Download the installer. Once the download is complete, run the installer and
   follow the prompts in the installation wizard.  The default should be
   acceptable for the purposes of this guide.

#. Run the following to clone the nova code.

   .. code-block:: none

      PS C:\> git.exe clone https://opendev.org/openstack/nova

Install nova-compute service
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To install ``nova-compute``, run:

.. code-block:: none

   PS C:\> cd c:\nova
   PS C:\> python setup.py install

Configure nova-compute
~~~~~~~~~~~~~~~~~~~~~~

The ``nova.conf`` file must be placed in ``C:\nova\etc\nova`` for running OpenStack
on Hyper-V. Below is a sample ``nova.conf`` for Windows:

.. code-block:: ini

   [DEFAULT]
   auth_strategy = keystone
   image_service = nova.image.glance.GlanceImageService
   compute_driver = nova.virt.hyperv.driver.HyperVDriver
   volume_api_class = nova.volume.cinder.API
   fake_network = true
   instances_path = C:\Program Files (x86)\OpenStack\Instances
   use_cow_images = true
   force_config_drive = false
   injected_network_template = C:\Program Files (x86)\OpenStack\Nova\etc\interfaces.template
   policy_file = C:\Program Files (x86)\OpenStack\Nova\etc\policy.yaml
   mkisofs_cmd = C:\Program Files (x86)\OpenStack\Nova\bin\mkisofs.exe
   allow_resize_to_same_host = true
   running_deleted_instance_action = reap
   running_deleted_instance_poll_interval = 120
   resize_confirm_window = 5
   resume_guests_state_on_host_boot = true
   rpc_response_timeout = 1800
   lock_path = C:\Program Files (x86)\OpenStack\Log\
   rpc_backend = nova.openstack.common.rpc.impl_kombu
   rabbit_host = IP_ADDRESS
   rabbit_port = 5672
   rabbit_userid = guest
   rabbit_password = Passw0rd
   logdir = C:\Program Files (x86)\OpenStack\Log\
   logfile = nova-compute.log
   instance_usage_audit = true
   instance_usage_audit_period = hour

   [glance]
   api_servers = http://IP_ADDRESS:9292

   [neutron]
   endpoint_override = http://IP_ADDRESS:9696
   auth_strategy = keystone
   project_name = service
   username = neutron
   password = Passw0rd
   auth_url = http://IP_ADDRESS:5000/v3
   auth_type = password

   [hyperv]
   vswitch_name = newVSwitch0
   limit_cpu_features = false
   config_drive_inject_password = false
   qemu_img_cmd = C:\Program Files (x86)\OpenStack\Nova\bin\qemu-img.exe
   config_drive_cdrom = true
   dynamic_memory_ratio = 1
   enable_instance_metrics_collection = true

   [rdp]
   enabled = true
   html5_proxy_base_url = https://IP_ADDRESS:4430

Prepare images for use with Hyper-V
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hyper-V currently supports only the VHD and VHDX file format for virtual
machine instances. Detailed instructions for installing virtual machines on
Hyper-V can be found here:

`Create Virtual Machines
<http://technet.microsoft.com/en-us/library/cc772480.aspx>`_

Once you have successfully created a virtual machine, you can then upload the
image to `glance` using the `openstack-client`:

.. code-block:: none

   PS C:\> openstack image create \
             --name "VM_IMAGE_NAME" \
             --property hypervisor_type=hyperv \
             --public \
             --container-format bare \
             --disk-format vhd

.. note::

   VHD and VHDX files sizes can be bigger than their maximum internal size,
   as such you need to boot instances using a flavor with a slightly bigger
   disk size than the internal size of the disk file.
   To create VHDs, use the following PowerShell cmdlet:

   .. code-block:: none

      PS C:\> New-VHD DISK_NAME.vhd -SizeBytes VHD_SIZE

Inject interfaces and routes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The ``interfaces.template`` file describes the network interfaces and routes
available on your system and how to activate them. You can specify the location
of the file with the :oslo.config:option:`injected_network_template`
configuration option in ``nova.conf``.

.. code-block:: ini

   injected_network_template = PATH_TO_FILE

A default template exists in ``nova/virt/interfaces.template``.

Run Compute with Hyper-V
~~~~~~~~~~~~~~~~~~~~~~~~

To start the ``nova-compute`` service, run this command from a console in the
Windows server:

.. code-block:: none

   PS C:\> C:\Python38\python.exe c:\Python38\Scripts\nova-compute --config-file c:\nova\etc\nova\nova.conf


Troubleshooting
---------------

* I ran the :command:`nova-manage service list` command from my controller;
  however, I'm not seeing smiley faces for Hyper-V compute nodes, what do I do?

  Verify that you are synchronized with a network time source.  For
  instructions about how to configure NTP on your Hyper-V compute node, see
  :ref:`configure-ntp-windows`.

* How do I restart the compute service?

  .. code-block:: none

     PS C:\> net stop nova-compute && net start nova-compute

* How do I restart the iSCSI initiator service?

  .. code-block:: none

     PS C:\> net stop msiscsi && net start msiscsi