# Set/Unset Maintenance Mode Using the OpenStack CLI

## Problem

Toggling maintenance mode from the UI can be tedious if the operation is to be performed for multiple hosts. Since maintenance mode for a host simply involves disabling the *nova-compute* service, this can be achieved via the OpenStack CLI.

## Environment

* Platform9 Managed OpenStack - All Versions
* OpenStack CLI

## Procedure

1. Source the *admin RC* file for your environment.

{% tabs %}
{% tab title="None" %}

```none
$ source [your_rc_filename]
```

{% endtab %}
{% endtabs %}

2. Get a list of available compute services.

{% tabs %}
{% tab title="None" %}

```none
$ openstack compute service list
```

{% endtab %}
{% endtabs %}

3. Disable the *nova-compute* binary on the host you want to put in maintenance mode.

{% tabs %}
{% tab title="None" %}

```none
$ openstack compute service set --disable --disable-reason [optional_reason] [host] nova-compute
```

{% endtab %}
{% endtabs %}

4. Verify that the service is disabled.

{% tabs %}
{% tab title="None" %}

```none
$ openstack compute service list | grep [host]
```

{% endtab %}
{% endtabs %}

5. To disable maintenance mode, simply enable the ***nova-compute*** binary/service again.

{% tabs %}
{% tab title="None" %}

```none
$ openstack compute service set --enable [host] nova-compute
```

{% endtab %}
{% endtabs %}

6. **Optional:** Verify the status of the host from the UI. Login as Admin -> Infrastructure Tab

<figure><img src="/files/JPu9xWdc8CHNBmUoNJET" alt="Screen_Shot_2020-01-13_at_2.44.47_PM.png"><figcaption><p>Screen_Shot_2020-01-13_at_2.44.47_PM.png</p></figcaption></figure>

**Note:** If The maintenance mode column is not showing on the UI, click on the 'Gear icon' next to the search bar and select 'Maintenance Mode'.

## Additional Information

* [Install OpenStack CLI.](https://docs.platform9.com/support/getting-started-with-the-openstack-command-line/)
* [Managing Compute Service](https://docs.openstack.org/nova/pike/admin/services.html)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://platform9.com/kb/pmo/how-to/set-unset-maintenance-mode-using-the-openstack-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
