%if 0%{?fedora} || 0%{?rhel} >= 9
Requires: python%{python3_pkgversion}-grpcio
Requires: python%{python3_pkgversion}-grpcio-tools
+Requires: python%{python3_pkgversion}-xmltodict
%endif
%if 0%{?fedora} || 0%{?rhel} || 0%{?openEuler}
Requires: python%{python3_pkgversion}-cherrypy
python3-coverage <pkg.ceph.check>,
python3-dateutil <pkg.ceph.check>,
python3-grpcio <pkg.ceph.check>,
+ python3-xmltodict <pkg.ceph.check>,
python3-openssl <pkg.ceph.check>,
python3-prettytable <pkg.ceph.check>,
python3-requests <pkg.ceph.check>,
<td><pre>{{ selection.bucket_policy | json}}</pre></td>
</tr>
<tr>
- <div>
- <td i18n
- class="bold w-25">Lifecycle
- <div *ngIf="(selection.lifecycle | json) !== '{}'"
- class="input-group">
- <button type="button"
- class="btn btn-light"
- [ngClass]="{'active': lifecycleFormat === 'json'}"
- (click)="lifecycleFormat = 'json'">
- JSON
- </button>
- <button type="button"
- class="btn btn-light"
- [ngClass]="{'active': lifecycleFormat === 'xml'}"
- (click)="lifecycleFormat = 'xml'">
- XML
- </button>
- </div>
- </td>
- </div>
+ <td i18n
+ class="bold w-25">Lifecycle
+ <div *ngIf="(selection.lifecycle | json) !== '{}'"
+ class="input-group">
+ <button type="button"
+ class="btn btn-light"
+ [ngClass]="{'active': lifecycleFormat === 'json'}"
+ (click)="updateLifecycleFormatTo('json')">
+ JSON
+ </button>
+ <button type="button"
+ class="btn btn-light"
+ [ngClass]="{'active': lifecycleFormat === 'xml'}"
+ (click)="updateLifecycleFormatTo('xml')">
+ XML
+ </button>
+ </div>
+ </td>
<td>
<pre *ngIf="lifecycleFormat === 'json'">{{selection.lifecycle | json}}</pre>
<pre *ngIf="lifecycleFormat === 'xml'">{{ (selection.lifecycle | xml:{'Rules':'Rule'}) || '-'}}</pre>
-import { Component, Input, OnChanges } from '@angular/core';
+import { ChangeDetectorRef, Component, Input, OnChanges } from '@angular/core';
import { RgwBucketService } from '~/app/shared/api/rgw-bucket.service';
aclPermissions: Record<string, string[]> = {};
replicationStatus = $localize`Disabled`;
- constructor(private rgwBucketService: RgwBucketService) {}
+ constructor(private rgwBucketService: RgwBucketService, private cd: ChangeDetectorRef) {}
ngOnChanges() {
if (this.selection) {
});
return data;
}
+
+ updateLifecycleFormatTo(format: 'json' | 'xml'): void {
+ this.lifecycleFormat = format;
+ this.cd.detectChanges();
+ }
}
grpcio==1.46.5
grpcio-tools==1.46.5
lxml==4.8.0 # to fix https://github.com/xmlsec/python-xmlsec/issues/320
+xmltodict
from enum import Enum
from subprocess import SubprocessError
+try:
+ import xmltodict
+except ModuleNotFoundError:
+ logging.error("Module 'xmltodict' is not installed.")
+
from mgr_util import build_url, name_to_config_section
from .. import mgr
@RestClient.api_get('/{bucket_name}?lifecycle')
def get_lifecycle(self, bucket_name, request=None):
# pylint: disable=unused-argument
+
+ # xmltodict parser will prepend namespace to json keys as {ns0:key}
+ def remove_namespace(xml: str):
+ """Remove namespace in given xml string."""
+ root = ET.fromstring(xml)
+ for elem in root.iter():
+ tag_elements = elem.tag.split("}") # tag: {ns}tagname
+ # Removing namespaces and attributes
+ elem.tag = tag_elements[1]
+ elem.attrib.clear()
+
+ return ET.tostring(root)
+
try:
- decoded_request = request(raw_content=True).decode("utf-8") # type: ignore
- result = {
- 'LifecycleConfiguration':
- json.loads(
- decoded_request,
- object_pairs_hook=RgwClient._handle_rules
- )
- }
+ result = request(
+ raw_content=True, headers={'Accept': 'text/xml'}).decode() # type: ignore
+ return xmltodict.parse(remove_namespace(result), process_namespaces=False)
except RequestException as e:
if e.content:
- content = json_str_to_object(e.content)
- if content.get(
- 'Code') == 'NoSuchLifecycleConfiguration':
+ root = ET.fromstring(e.content)
+ code = root.find('Code')
+ if code is not None and code.text == 'NoSuchLifecycleConfiguration':
return None
raise DashboardException(msg=str(e), component='rgw')
- return result
@staticmethod
def dict_to_xml(data):
types-requests
types-PyYAML
types-jwt
+ types-xmltodict
commands =
mypy --config-file=../../mypy.ini \
-m alerts \