Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
22 changes: 22 additions & 0 deletions ui_extensions/azure_patches/actions/scan_for_patches.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from common.methods import set_progress
from utilities.logger import ThreadLogger
from xui.azure_patches.views import scan_vm_for_patches, apply_all_vm_patches

logger = ThreadLogger(__name__)

def run(job, server, **kwargs):
logger.debug("Starting Azure Patch operation")
operation = kwargs['operation']
if not operation:
return "FAILURE", "No operation specified", ""
set_progress(f"Starting patch scan operation for server: {server.hostname}")
if operation == "scan_vm_for_patches":
scan_vm_for_patches(server)
msg = "Azure Scan operation completed successfully."

if operation == "apply_all_vm_patches":
apply_all_vm_patches(server)
msg = "Azure Patch operation completed successfully."

set_progress(msg)
return "SUCCESS", msg, ""
Binary file added ui_extensions/azure_patches/images/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions ui_extensions/azure_patches/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Azure Patches UI Extension
This CloudBolt UI Extension adds a custom "Patching" tab to the VM details page for an Azure Virtual Machine

## Features
- Displays a list of available patches for the selected Azure VM
- Allows users to initiate scan and patching operations directly from the UI
- Provides real-time status updates on patching progress
- Integrates with Azure Update Management to fetch patch information

## Prerequisites
- Service principal used for the Resource Handler where the server lives should have appropriate permissions to query Azure Patching data
- Server you are working with must be an Azure Virtual Machine
- VM must have the Azure VM Agent installed and running

## Installation
1. Copy the azure_patches directory to the `/var/opt/cloudbolt/proserv/xui/` directory on your CloudBolt server.
2. Restart Apache on the CloudBolt server to load the new extension:
```
sudo systemctl restart httpd
```
3. Navigate to a VM details page in the CloudBolt UI to see the new "Patching" tab.

### Patching Tab
![img.png](images/img.png)
55 changes: 55 additions & 0 deletions ui_extensions/azure_patches/templates/server_patches.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{% load helper_tags %}
{% load tab_tags %}
{% load i18n %}

<div class="container-fluid">
<div class="panel panel-default">
<div class="panel-body">
<div class="btn-toolbar">
<strong>Currently Available Patches for Azure Server: <i>{{ server.hostname }}</i></strong>
<span class="pull-right">
<a class="btn open-dialog cb-btn-primary"
title="Scan {{server.hostname}} for Patches"
href="{% url 'az_scan_for_patches' server.id %}">
<i class="fas fa-search"></i> Scan for Patches
</a>
<a class="btn open-dialog cb-btn-primary"
title="Apply all patches to {{server.hostname}} "
href="{% url 'az_apply_all_patches' server.id %}">
<i class="fas fa-plus-square"></i> Apply all Patches
</a>
</span>
</div>
<p>
If no patches are listed, first run the "Scan for Patches" action to search for currently available patches.
</p>
<table id="virtual-machine-azure-patches-table"
data-table
data-table-no-auto-init
data-table-source="{% url 'az_patches_inventory_json' server.id %}"
>
<thead>
<tr>
<th>{% trans 'Update Name' %}</th>
<th>{% trans 'Classifications' %}</th>
{% if server.os_family.name == 'Windows' %}
<th>{% trans 'KB ID' %}</th>
<th>{% trans 'Reboot Required' %}</th>
<th>{% trans 'Published Date' %}</th>
{% else %}
<th>{% trans 'Version' %}</th>
{% endif %}
</tr>
</thead>
<tbody>
{# content is loaded asynchronously #}
</tbody>
</table>
</div>
</div>
</div>
<script>
$(function(){
c2.dataTables.init('#virtual-machine-azure-patches-table');
});
</script>
20 changes: 20 additions & 0 deletions ui_extensions/azure_patches/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.conf.urls import url
from . import views

xui_urlpatterns = [
url(
r"^azure-patches/(?P<server_id>\d+)/inventory-json/$",
views.inventory_json,
name="az_patches_inventory_json",
),
url(
r"^azure-patches/(?P<server_id>\d+)/patches/scan/$",
views.scan_for_patches,
name="az_scan_for_patches",
),
url(
r"^azure-patches/(?P<server_id>\d+)/patches/apply/$",
views.apply_all_patches,
name="az_apply_all_patches",
),
]
Loading