diff --git a/doc/source/conf.py b/doc/source/conf.py index 26ec47d8..5a1a18a1 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -23,14 +23,14 @@ # -- Project information ----------------------------------------------------- -project = u'stx-gui' -copyright = u'2018, StarlingX' -author = u'StarlingX' +project = 'stx-gui' +copyright = '2018, StarlingX' +author = 'StarlingX' # The short X.Y version -version = u'' +version = '' # The full version, including alpha/beta/rc tags -release = u'0.1' +release = '0.1' # -- General configuration --------------------------------------------------- @@ -136,8 +136,8 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'stx-gui.tex', u'stx-gui Documentation', - u'StarlingX', 'manual'), + (master_doc, 'stx-gui.tex', 'stx-gui Documentation', + 'StarlingX', 'manual'), ] @@ -146,7 +146,7 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'stx-gui', u'stx-gui Documentation', + (master_doc, 'stx-gui', 'stx-gui Documentation', [author], 1) ] @@ -157,7 +157,7 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'stx-gui', u'stx-gui Documentation', + (master_doc, 'stx-gui', 'stx-gui Documentation', author, 'stx-gui', 'StarlingX Horizon plugins for new StarlingX services.', 'Miscellaneous'), ] diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index a5a37f40..e170b9ea 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -191,8 +191,8 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'stx-guireleasenotes.tex', u'stx-gui Release Notes', - u'StarlingX', 'manual'), + ('index', 'stx-guireleasenotes.tex', 'stx-gui Release Notes', + 'StarlingX', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -221,8 +221,8 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'stx-guireleasenotes', u'stx-gui Release Notes', - [u'StarlingX'], 1) + ('index', 'stx-guireleasenotes', 'stx-gui Release Notes', + ['StarlingX'], 1) ] # If true, show URL addresses after external links. @@ -235,8 +235,8 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'stx-guiReleaseNotes', u'stx-gui Release Notes', - u'StarlingX', 'stx-guireleasenotes', + ('index', 'stx-guiReleaseNotes', 'stx-gui Release Notes', + 'StarlingX', 'stx-guireleasenotes', 'StarlingX Horizon plugins for new StarlingX services', 'Miscellaneous'), ] diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/fault_management/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/fault_management/tables.py index 3c8f3aae..ecbdbe45 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/fault_management/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/fault_management/tables.py @@ -40,10 +40,10 @@ SUPPRESSION_STATUS_CHOICES = ( ) SUPPRESSION_STATUS_DISPLAY_CHOICES = ( ("suppressed", pgettext_lazy("Indicates this type of alarm \ - is suppressed", u"suppressed")), + is suppressed", "suppressed")), ("unsuppressed", pgettext_lazy("Indicates this type of alarm \ - is unsuppressed", u"unsuppressed")), - ("None", pgettext_lazy("Indicates an event type", u"None")), + is unsuppressed", "unsuppressed")), + ("None", pgettext_lazy("Indicates an event type", "None")), ) @@ -172,16 +172,16 @@ class SuppressEvent(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Suppress Event", - u"Suppress Event", + "Suppress Event", + "Suppress Event", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Events suppressed for Alarm ID", - u"Events suppressed for Alarm ID", + "Events suppressed for Alarm ID", + "Events suppressed for Alarm ID", count ) @@ -212,16 +212,16 @@ class UnsuppressEvent(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Unsuppress Event", - u"Unsuppress Event", + "Unsuppress Event", + "Unsuppress Event", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Events unsuppressed for Alarm ID", - u"Events unsuppressed for Alarm ID", + "Events unsuppressed for Alarm ID", + "Events unsuppressed for Alarm ID", count ) diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/cpu_functions/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/cpu_functions/tables.py index 254fe11b..45d76a8f 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/cpu_functions/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/cpu_functions/tables.py @@ -69,7 +69,7 @@ class CpuFunctionsTable(tables.DataTable): verbose_name=_('Processor Logical Cores')) def get_object_id(self, datum): - return unicode(datum.allocated_function) + return str(datum.allocated_function) class Meta(object): name = "cpufunctions" diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/devices/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/devices/tables.py index f3c0eac4..1792422d 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/devices/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/devices/tables.py @@ -58,7 +58,7 @@ class DevicesTable(tables.DataTable): verbose_name=_('Enabled')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.name @@ -85,7 +85,7 @@ class UsageTable(tables.DataTable): verbose_name=_('VFs used')) def get_object_id(self, datum): - return unicode(datum.id) + return str(datum.id) def get_object_display(self, datum): return datum.host @@ -132,7 +132,7 @@ class DeviceUsageTable(tables.DataTable): verbose_name=_("VFs used")) def get_object_id(self, datum): - return unicode(datum.device_id) + return str(datum.device_id) def get_object_display(self, datum): return datum.device_name diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/address/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/address/tables.py index 4544284b..4f9f161c 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/address/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/address/tables.py @@ -32,16 +32,16 @@ class DeleteAddress(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Address", - u"Delete Addresses", + "Delete Address", + "Delete Addresses", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Address", - u"Deleted Addresses", + "Deleted Address", + "Deleted Addresses", count ) @@ -103,7 +103,7 @@ class AddressTable(tables.DataTable): verbose_name=_("DAD")) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return ("%(address)s/%(prefix)s" % diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/forms.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/forms.py index ae7955cd..cb33517d 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/forms.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/forms.py @@ -549,7 +549,7 @@ class AddInterface(forms.SelfHandlingForm): if not data['vlan_id'] or data['iftype'] != 'vlan': del data['vlan_id'] else: - data['vlan_id'] = unicode(data['vlan_id']) + data['vlan_id'] = str(data['vlan_id']) network_ids = [] network_types = [] @@ -564,7 +564,7 @@ class AddInterface(forms.SelfHandlingForm): for network_type in network_types): del data['imtu'] else: - data['imtu'] = unicode(data['imtu']) + data['imtu'] = str(data['imtu']) if data['iftype'] != 'ae': del data['txhashpolicy'] @@ -798,9 +798,9 @@ class UpdateInterface(AddInterface): if not data['vlan_id'] or data['iftype'] != 'vlan': del data['vlan_id'] else: - data['vlan_id'] = unicode(data['vlan_id']) + data['vlan_id'] = str(data['vlan_id']) - data['imtu'] = unicode(data['imtu']) + data['imtu'] = str(data['imtu']) if data['iftype'] != 'ae': del data['txhashpolicy'] @@ -826,7 +826,7 @@ class UpdateInterface(AddInterface): del data['providernetworks'] if 'sriov_numvfs' in data: - data['sriov_numvfs'] = unicode(data['sriov_numvfs']) + data['sriov_numvfs'] = str(data['sriov_numvfs']) # Explicitly set iftype when user selects pci-pt or pci-sriov ifclass = \ @@ -852,15 +852,15 @@ class UpdateInterface(AddInterface): del data['sriov_numvfs'] if data['networks']: - data['networks'] = unicode(",".join(data['networks'])) + data['networks'] = str(",".join(data['networks'])) else: del data['networks'] if data['networks_to_add']: - data['networks_to_add'] = unicode(",".join(data['networks_to_add'])) + data['networks_to_add'] = str(",".join(data['networks_to_add'])) else: del data['networks_to_add'] if data['interface_networks_to_remove']: - data['interface_networks_to_remove'] = unicode( + data['interface_networks_to_remove'] = str( ",".join(data['interface_networks_to_remove'])) else: del data['interface_networks_to_remove'] diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/tables.py index 39dedb4d..d75e4b2b 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/route/tables.py @@ -30,16 +30,16 @@ class DeleteRoute(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Route", - u"Delete Routes", + "Delete Route", + "Delete Routes", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Route", - u"Deleted Routes", + "Deleted Route", + "Deleted Routes", count ) @@ -96,7 +96,7 @@ class RouteTable(tables.DataTable): verbose_name=_("Metric")) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return ("%(network)s/%(prefix)s via %(gateway)s" % diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/tables.py index 5b2adfd8..fe167350 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/tables.py @@ -25,16 +25,16 @@ class DeleteInterface(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Interface", - u"Delete Interfaces", + "Delete Interface", + "Delete Interfaces", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Interface", - u"Deleted Interfaces", + "Deleted Interface", + "Deleted Interfaces", count ) @@ -203,7 +203,7 @@ class InterfacesTable(tables.DataTable): super(InterfacesTable, self).__init__(*args, **kwargs) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.ifname diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/lldp/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/lldp/tables.py index 11a5c3d1..fea825da 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/lldp/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/lldp/tables.py @@ -33,7 +33,7 @@ class LldpNeighboursTable(tables.DataTable): verbose_name=_('Max Frame Size')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.get_local_port_display_name() diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/memories/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/memories/tables.py index 88d02a0c..e66b1bde 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/memories/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/memories/tables.py @@ -80,7 +80,7 @@ class MemorysTable(tables.DataTable): verbose_name=_('VM Pages')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) class Meta(object): name = "memorys" diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/ports/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/ports/tables.py index fce3b940..4798d4e8 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/ports/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/ports/tables.py @@ -75,7 +75,7 @@ class PortsTable(tables.DataTable): verbose_name=_('Device Type')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.get_port_display_name() diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/sensors/forms.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/sensors/forms.py index 9a17e3b6..e6f458c3 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/sensors/forms.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/sensors/forms.py @@ -188,9 +188,9 @@ class UpdateSensorGroup(forms.SelfHandlingForm): # host_uuid = data['host_uuid'] if data['audit_interval_group']: data['audit_interval_group'] = \ - unicode(data['audit_interval_group']) + str(data['audit_interval_group']) else: - data['audit_interval_group'] = unicode("0") + data['audit_interval_group'] = str("0") del data['id'] diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/sensors/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/sensors/tables.py index bcb3fdfd..98b6a1d3 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/sensors/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/sensors/tables.py @@ -105,16 +105,16 @@ class SuppressSensorGroup(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Suppress SensorGroup", - u"Suppress SensorGroups", + "Suppress SensorGroup", + "Suppress SensorGroups", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Suppressed SensorGroup", - u"Suppressed SensorGroups", + "Suppressed SensorGroup", + "Suppressed SensorGroups", count ) @@ -140,16 +140,16 @@ class UnSuppressSensorGroup(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"UnSuppress SensorGroup", - u"UnSuppress SensorGroups", + "UnSuppress SensorGroup", + "UnSuppress SensorGroups", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"UnSuppressed SensorGroup", - u"UnSuppressed SensorGroups", + "UnSuppressed SensorGroup", + "UnSuppressed SensorGroups", count ) @@ -233,7 +233,7 @@ class SensorGroupsTable(tables.DataTable): "are suppressed.")) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.sensorgroupname @@ -291,16 +291,16 @@ class SuppressSensor(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Suppress Sensor", - u"Suppress Sensors", + "Suppress Sensor", + "Suppress Sensors", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Suppressed Sensor", - u"Suppressed Sensors", + "Suppressed Sensor", + "Suppressed Sensors", count ) @@ -325,16 +325,16 @@ class UnSuppressSensor(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"UnSuppress Sensor", - u"UnSuppress Sensors", + "UnSuppress Sensor", + "UnSuppress Sensors", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"UnSuppressed Sensor", - u"UnSuppressed Sensors", + "UnSuppressed Sensor", + "UnSuppressed Sensors", count ) @@ -383,7 +383,7 @@ class SensorsTable(tables.DataTable): verbose_name=('Sensor Group Name')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.sensorname diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/storages/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/storages/tables.py index 81b92d90..301aad9c 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/storages/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/storages/tables.py @@ -95,16 +95,16 @@ class DeletePartition(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Partition", - u"Delete Partitions", + "Delete Partition", + "Delete Partitions", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Partition", - u"Deleted Partitions", + "Deleted Partition", + "Deleted Partitions", count ) @@ -251,7 +251,7 @@ class DisksTable(tables.DataTable): verbose_name=('Model')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) class Meta(object): name = "disks" @@ -300,16 +300,16 @@ class DeleteStor(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Journal", - u"Delete Journals", + "Delete Journal", + "Delete Journals", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Journal", - u"Deleted Journals", + "Deleted Journal", + "Deleted Journals", count ) @@ -348,7 +348,7 @@ class StorageVolumesTable(tables.DataTable): verbose_name=('Journal Location')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) class Meta(object): name = "storagevolumes" @@ -413,16 +413,16 @@ class RemoveLocalVolumeGroup(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Local Volume Group", - u"Delete Local Volume Groups", + "Delete Local Volume Group", + "Delete Local Volume Groups", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Local Volume Group", - u"Deleted Local Volume Groups", + "Deleted Local Volume Group", + "Deleted Local Volume Groups", count ) @@ -472,13 +472,13 @@ class LocalVolumeGroupsTable(tables.DataTable): verbose_name=('Current Logical Volumes')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): msg = datum.uuid if datum.lvm_vg_name: msg += " (%s)" % datum.lvm_vg_name - return unicode(msg) + return str(msg) class Meta(object): name = "localvolumegroups" @@ -534,16 +534,16 @@ class RemovePhysicalVolume(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Physical Volume", - u"Delete Physical Volumes", + "Delete Physical Volume", + "Delete Physical Volumes", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Physical Volume", - u"Deleted Physical Volumes", + "Deleted Physical Volume", + "Deleted Physical Volumes", count ) @@ -591,13 +591,13 @@ class PhysicalVolumesTable(tables.DataTable): verbose_name=('LVM Volume Group Name')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): msg = datum.uuid if datum.lvm_pv_name: msg += " (%s)" % datum.lvm_pv_name - return unicode(msg) + return str(msg) class Meta(object): name = "physicalvolumes" @@ -627,13 +627,13 @@ class PartitionsTable(tables.DataTable): verbose_name=('Status')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): msg = datum.uuid if datum.device_path: msg += " (%s)" % datum.device_path - return unicode(msg) + return str(msg) class Meta(object): name = "partitions" diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/tables.py index b0401628..1d26cd18 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/tables.py @@ -134,16 +134,16 @@ class DeleteHost(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Host", - u"Delete Hosts", + "Delete Host", + "Delete Hosts", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Host", - u"Deleted Hosts", + "Deleted Host", + "Deleted Hosts", count ) @@ -164,16 +164,16 @@ class LockHost(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Lock Host", - u"Lock Hosts", + "Lock Host", + "Lock Hosts", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Locking Host", - u"Locking Hosts", + "Locking Host", + "Locking Hosts", count ) @@ -197,16 +197,16 @@ class ForceLockHost(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Force Lock Host", - u"Force Lock Hosts", + "Force Lock Host", + "Force Lock Hosts", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Forced Lock Host", - u"Forced Lock Hosts", + "Forced Lock Host", + "Forced Lock Hosts", count ) @@ -264,16 +264,16 @@ class UnlockHost(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Unlock Host", - u"Unlock Hosts", + "Unlock Host", + "Unlock Hosts", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Unlocked Host", - u"Unlocked Hosts", + "Unlocked Host", + "Unlocked Hosts", count ) @@ -298,16 +298,16 @@ class ForceUnlockHost(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Force Unlock Host", - u"Force Unlock Hosts", + "Force Unlock Host", + "Force Unlock Hosts", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Forced Unlock Host", - u"Forced Unlock Hosts", + "Forced Unlock Host", + "Forced Unlock Hosts", count ) @@ -337,16 +337,16 @@ class PowerOnHost(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Power On Host", - u"Power On Hosts", + "Power On Host", + "Power On Hosts", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Powered On Host", - u"Powered On Hosts", + "Powered On Host", + "Powered On Hosts", count ) @@ -368,16 +368,16 @@ class PowerOffHost(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Power Off Host", - u"Power Off Hosts", + "Power Off Host", + "Power Off Hosts", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Powered Off Host", - u"Powered Off Hosts", + "Powered Off Host", + "Powered Off Hosts", count ) @@ -400,16 +400,16 @@ class ResetHost(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Reset Host", - u"Reset Hosts", + "Reset Host", + "Reset Hosts", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Reset Host", - u"Reset Hosts", + "Reset Host", + "Reset Hosts", count ) @@ -431,16 +431,16 @@ class RebootHost(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Reboot Host", - u"Reboot Hosts", + "Reboot Host", + "Reboot Hosts", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Rebooted Host", - u"Rebooted Hosts", + "Rebooted Host", + "Rebooted Hosts", count ) @@ -461,16 +461,16 @@ class ReinstallHost(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Reinstall Host", - u"Reinstall Hosts", + "Reinstall Host", + "Reinstall Hosts", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Reinstalled Host", - u"Reinstalled Hosts", + "Reinstalled Host", + "Reinstalled Hosts", count ) @@ -491,16 +491,16 @@ class SwactHost(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Swact Host", - u"Swact Hosts", + "Swact Host", + "Swact Hosts", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Swact Initiated Host", - u"Swact Initiated Hosts", + "Swact Initiated Host", + "Swact Initiated Hosts", count ) @@ -521,16 +521,16 @@ class PatchInstallAsync(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Install Patch", - u"Install Patches", + "Install Patch", + "Install Patches", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Installed Patch", - u"Installed Patches", + "Installed Patch", + "Installed Patches", count ) @@ -664,7 +664,7 @@ def get_task_or_status(host): patch_current = "Not Patch Current" if host._patch_state != patch_constants.PATCH_AGENT_STATE_IDLE: - patch_state = unicode(host.patch_state) + patch_state = str(host.patch_state) if host._patch_state == patch_constants.PATCH_AGENT_STATE_INSTALLING: # Clear the other patch status fields patch_current = "" @@ -740,7 +740,7 @@ class Hosts(tables.DataTable): status_choices=TASK_STATE_CHOICES) def get_object_id(self, datum): - return unicode(datum.id) + return str(datum.id) def get_object_display(self, datum): return datum.hostname @@ -823,16 +823,16 @@ class DeleteInterfaceProfile(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Interface Profile", - u"Delete Interface Profiles", + "Delete Interface Profile", + "Delete Interface Profiles", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Interface Profile", - u"Deleted Interface Profiles", + "Deleted Interface Profile", + "Deleted Interface Profiles", count ) @@ -871,7 +871,7 @@ class InterfaceProfilesTable(tables.DataTable): verbose_name=_("Interface Configuration")) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.profilename @@ -888,16 +888,16 @@ class DeleteCpuProfile(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Cpu Profile", - u"Delete Cpu Profiles", + "Delete Cpu Profile", + "Delete Cpu Profiles", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Cpu Profile", - u"Deleted Cpu Profiles", + "Deleted Cpu Profile", + "Deleted Cpu Profiles", count ) @@ -926,7 +926,7 @@ class CpuProfilesTable(tables.DataTable): verbose_name=_("CPU Assignments")) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.profilename @@ -944,16 +944,16 @@ class DeleteDiskProfile(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Storage Profile", - u"Delete Storage Profiles", + "Delete Storage Profile", + "Delete Storage Profiles", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Storage Profile", - u"Deleted Storage Profiles", + "Deleted Storage Profile", + "Deleted Storage Profiles", count ) @@ -1022,7 +1022,7 @@ class DiskProfilesTable(tables.DataTable): verbose_name=_('Observations')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.profilename @@ -1040,16 +1040,16 @@ class DeleteMemoryProfile(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Memory Profile", - u"Delete Memory Profiles", + "Delete Memory Profile", + "Delete Memory Profiles", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Memory Profile", - u"Deleted Memory Profiles", + "Deleted Memory Profile", + "Deleted Memory Profiles", count ) @@ -1089,7 +1089,7 @@ class MemoryProfilesTable(tables.DataTable): verbose_name=_("Memory Assignments")) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.profilename diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/providernets/providernets/ranges/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/providernets/providernets/ranges/tables.py index 039bcafb..1953c275 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/providernets/providernets/ranges/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/providernets/providernets/ranges/tables.py @@ -39,16 +39,16 @@ class DeleteProviderNetworkRange(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Range", - u"Delete Ranges", + "Delete Range", + "Delete Ranges", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Range", - u"Deleted Ranges", + "Deleted Range", + "Deleted Ranges", count ) diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/providernets/providernets/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/providernets/providernets/tables.py index b8e2456a..bc72ea58 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/providernets/providernets/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/providernets/providernets/tables.py @@ -37,16 +37,16 @@ class DeleteProviderNetwork(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Provider Network", - u"Delete Provider Networks", + "Delete Provider Network", + "Delete Provider Networks", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Provider Network", - u"Deleted Provider Networks", + "Deleted Provider Network", + "Deleted Provider Networks", count ) diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/server_groups/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/server_groups/tables.py index 01caa9ad..ddaa23f4 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/server_groups/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/server_groups/tables.py @@ -1,306 +1,306 @@ -# Copyright 2014 Wind River, Inc. -# Copyright 2012 Nebula, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# Copyright (c) 2013-2017 Wind River Systems, Inc. -# - -from django.core.urlresolvers import NoReverseMatch -from django.core.urlresolvers import reverse -from django.utils import html -from django.utils import safestring -from django.utils.translation import string_concat -from django.utils.translation import ugettext_lazy as _ # noqa -from django.utils.translation import ungettext_lazy - -from horizon import exceptions -from horizon import tables - -from openstack_dashboard import api -from openstack_dashboard.api import nova -from openstack_dashboard.dashboards.project.volumes.tables \ - import get_attachment_name -from openstack_dashboard.usage import quotas - -from starlingx_dashboard.api import nova as stx_nova - -DELETABLE_STATES = ("available", "error") - - -class DeleteServerGroup(tables.DeleteAction): - @staticmethod - def action_present(count): - return ungettext_lazy( - u"Delete Server Group", - u"Delete Server Groups", - count - ) - - @staticmethod - def action_past(count): - return ungettext_lazy( - u"Deleted Server Group", - u"Deleted Server Groups", - count - ) - - def delete(self, request, obj_id): - obj = self.table.get_object_by_id(obj_id) - name = self.table.get_object_display(obj) - - try: - stx_nova.server_group_delete(request, obj_id) - except Exception: - msg = _('Unable to delete group "%s" because it is not empty. ' - 'Either delete the member instances' - ' or remove them from the group.') - exceptions.check_message(["group", "not", "empty."], msg % name) - raise - - # maybe do a precheck to see if the group is empty first? - def allowed(self, request, server_group=None): - return True - - -class CreateServerGroup(tables.LinkAction): - name = "create" - verbose_name = _("Create Server Group") - url = "horizon:admin:server_groups:create" - classes = ("ajax-modal", "btn-create") - icon = "plus" - - def allowed(self, request, volume=None): - usages = quotas.tenant_quota_usages(request) - if usages['server_groups']['available'] <= 0: - if "disabled" not in self.classes: - self.classes = [c for c in self.classes] + ['disabled'] - self.verbose_name = string_concat(self.verbose_name, ' ', - _("(Quota exceeded)")) - else: - self.verbose_name = _("Create Server Group") - classes = [c for c in self.classes if c != "disabled"] - self.classes = classes - return True - - -class EditAttachments(tables.LinkAction): - name = "attachments" - verbose_name = _("Edit Attachments") - url = "horizon:admin:server_groups:attach" - classes = ("ajax-modal", "btn-edit") - - def allowed(self, request, server_group=None): - return True # volume.status in ("available", "in-use") - - -class CreateSnapshot(tables.LinkAction): - name = "snapshots" - verbose_name = _("Create Snapshot") - url = "horizon:admin:server_groups:create_snapshot" - classes = ("ajax-modal", "btn-camera") - - def allowed(self, request, server_group=None): - return True # server_group.status == "available" - - -class UpdateRow(tables.Row): - ajax = True - - def get_data(self, request, server_group_id): - server_group = stx_nova.server_group_get(request, server_group_id) - if not server_group.name: - server_group.name = server_group_id - - return server_group - - -def get_policies(server_group): - policies = ', '.join(server_group.policies) - return policies - - -def get_metadata(server_group): - metadata_items = ['{}:{}'.format(x, y) for x, y in - server_group.metadata.items()] - metadata = ', '.join(metadata_items) - return metadata - - -def get_member_name(request, server_id): - try: - server = api.nova.server_get(request, server_id) - name = server.name - except Exception: - name = None - exceptions.handle(request, _("Unable to retrieve " - "member information.")) - # try and get a URL - try: - url = reverse("horizon:admin:instances:detail", args=(server_id,)) - instance = '%s' % (url, html.escape(name)) - except NoReverseMatch: - instance = name - return instance - - -class ProjectNameColumn(tables.Column): - """Customized column class - - Customized column class that does complex processing on the - server group. - """ - - def get_raw_data(self, server_group): - request = self.table.request - project_id = getattr(server_group, 'project_id', None) - try: - tenant = api.keystone.tenant_get(request, - project_id, - admin=True) - - project_name = getattr(tenant, "name", None) - except Exception: - project_name = "(not found)" - - return project_name - - -class MemberColumn(tables.Column): - """Customized column class - - Customized column class that does complex processing on the instances - in a server group. This was substantially copied - from the volume equivalent. - """ - - def get_raw_data(self, server_group): - request = self.table.request - link = _('%(name)s (%(id)s)') - members = [] - for member in server_group.members: - member_id = member - name = get_member_name(request, member) - vals = {"name": name, "id": member_id} - members.append(link % vals) - return safestring.mark_safe(", ".join(members)) - - -def get_server_group_type(server_group): - return server_group.volume_type if server_group.volume_type != "None" \ - else None - - -class ServerGroupsFilterAction(tables.FilterAction): - def filter(self, table, server_groups, filter_string): - """Naive case-insensitive search.""" - q = filter_string.lower() - return [group for group in server_groups - if q in group.display_name.lower()] - - -class ServerGroupsTable(tables.DataTable): - projectname = ProjectNameColumn("project_name", - verbose_name=_("Project")) - name = tables.Column("name", - verbose_name=_("Group Name"), - link="horizon:admin:server_groups:detail") - policies = tables.Column(get_policies, - verbose_name=_("Policies")) - members = MemberColumn("members", - verbose_name=_("Members")) - metadata = tables.Column(get_metadata, - verbose_name=_("Metadata")) - - class Meta(object): - name = "server_groups" - verbose_name = _("Server Groups") - row_class = UpdateRow - table_actions = ( - CreateServerGroup, DeleteServerGroup, ServerGroupsFilterAction) - row_actions = (DeleteServerGroup,) - - def get_object_display(self, obj): - return obj.name - - -class DetachServerGroup(tables.BatchAction): - name = "detach" - action_type = 'danger' - - @staticmethod - def action_present(count): - return ungettext_lazy( - u"Detach Server Group", - u"Detached Server Groups", - count - ) - - @staticmethod - def action_past(count): - return ungettext_lazy( - u"Detaching Server Group", - u"Detaching Server Groups", - count - ) - - def action(self, request, obj_id): - attachment = self.table.get_object_by_id(obj_id) - api.nova.instance_server_group_detach(request, - attachment.get('server_id', - None), - obj_id) - - def get_success_url(self, request): - return reverse('horizon:admin:server_groups:index') - - -class AttachedInstanceColumn(tables.Column): - """Customized column class - - Customized column class that does complex processing on the attachments - for a server group. - """ - - def get_raw_data(self, attachment): - request = self.table.request - return safestring.mark_safe(get_attachment_name(request, attachment, - True)) - - -class AttachmentsTable(tables.DataTable): - instance = AttachedInstanceColumn(get_member_name, - verbose_name=_("Instance")) - device = tables.Column("device", - verbose_name=_("Device")) - - def get_object_id(self, obj): - return obj['id'] - - def get_object_display(self, attachment): - instance_name = get_attachment_name(self.request, attachment, True) - vals = {"dev": attachment['device'], - "instance_name": html.strip_tags(instance_name)} - return _("%(dev)s on instance %(instance_name)s") % vals - - def get_object_by_id(self, obj_id): - for obj in self.data: - if self.get_object_id(obj) == obj_id: - return obj - raise ValueError('No match found for the id "%s".' % obj_id) - - class Meta(object): - name = "attachments" - verbose_name = _("Attachments") - table_actions = (DetachServerGroup,) - row_actions = (DetachServerGroup,) +# Copyright 2014 Wind River, Inc. +# Copyright 2012 Nebula, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Copyright (c) 2013-2017 Wind River Systems, Inc. +# + +from django.core.urlresolvers import NoReverseMatch +from django.core.urlresolvers import reverse +from django.utils import html +from django.utils import safestring +from django.utils.translation import string_concat +from django.utils.translation import ugettext_lazy as _ # noqa +from django.utils.translation import ungettext_lazy + +from horizon import exceptions +from horizon import tables + +from openstack_dashboard import api +from openstack_dashboard.api import nova +from openstack_dashboard.dashboards.project.volumes.tables \ + import get_attachment_name +from openstack_dashboard.usage import quotas + +from starlingx_dashboard.api import nova as stx_nova + +DELETABLE_STATES = ("available", "error") + + +class DeleteServerGroup(tables.DeleteAction): + @staticmethod + def action_present(count): + return ungettext_lazy( + "Delete Server Group", + "Delete Server Groups", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + "Deleted Server Group", + "Deleted Server Groups", + count + ) + + def delete(self, request, obj_id): + obj = self.table.get_object_by_id(obj_id) + name = self.table.get_object_display(obj) + + try: + stx_nova.server_group_delete(request, obj_id) + except Exception: + msg = _('Unable to delete group "%s" because it is not empty. ' + 'Either delete the member instances' + ' or remove them from the group.') + exceptions.check_message(["group", "not", "empty."], msg % name) + raise + + # maybe do a precheck to see if the group is empty first? + def allowed(self, request, server_group=None): + return True + + +class CreateServerGroup(tables.LinkAction): + name = "create" + verbose_name = _("Create Server Group") + url = "horizon:admin:server_groups:create" + classes = ("ajax-modal", "btn-create") + icon = "plus" + + def allowed(self, request, volume=None): + usages = quotas.tenant_quota_usages(request) + if usages['server_groups']['available'] <= 0: + if "disabled" not in self.classes: + self.classes = [c for c in self.classes] + ['disabled'] + self.verbose_name = string_concat(self.verbose_name, ' ', + _("(Quota exceeded)")) + else: + self.verbose_name = _("Create Server Group") + classes = [c for c in self.classes if c != "disabled"] + self.classes = classes + return True + + +class EditAttachments(tables.LinkAction): + name = "attachments" + verbose_name = _("Edit Attachments") + url = "horizon:admin:server_groups:attach" + classes = ("ajax-modal", "btn-edit") + + def allowed(self, request, server_group=None): + return True # volume.status in ("available", "in-use") + + +class CreateSnapshot(tables.LinkAction): + name = "snapshots" + verbose_name = _("Create Snapshot") + url = "horizon:admin:server_groups:create_snapshot" + classes = ("ajax-modal", "btn-camera") + + def allowed(self, request, server_group=None): + return True # server_group.status == "available" + + +class UpdateRow(tables.Row): + ajax = True + + def get_data(self, request, server_group_id): + server_group = stx_nova.server_group_get(request, server_group_id) + if not server_group.name: + server_group.name = server_group_id + + return server_group + + +def get_policies(server_group): + policies = ', '.join(server_group.policies) + return policies + + +def get_metadata(server_group): + metadata_items = ['{}:{}'.format(x, y) for x, y in + server_group.metadata.items()] + metadata = ', '.join(metadata_items) + return metadata + + +def get_member_name(request, server_id): + try: + server = api.nova.server_get(request, server_id) + name = server.name + except Exception: + name = None + exceptions.handle(request, _("Unable to retrieve " + "member information.")) + # try and get a URL + try: + url = reverse("horizon:admin:instances:detail", args=(server_id,)) + instance = '%s' % (url, html.escape(name)) + except NoReverseMatch: + instance = name + return instance + + +class ProjectNameColumn(tables.Column): + """Customized column class + + Customized column class that does complex processing on the + server group. + """ + + def get_raw_data(self, server_group): + request = self.table.request + project_id = getattr(server_group, 'project_id', None) + try: + tenant = api.keystone.tenant_get(request, + project_id, + admin=True) + + project_name = getattr(tenant, "name", None) + except Exception: + project_name = "(not found)" + + return project_name + + +class MemberColumn(tables.Column): + """Customized column class + + Customized column class that does complex processing on the instances + in a server group. This was substantially copied + from the volume equivalent. + """ + + def get_raw_data(self, server_group): + request = self.table.request + link = _('%(name)s (%(id)s)') + members = [] + for member in server_group.members: + member_id = member + name = get_member_name(request, member) + vals = {"name": name, "id": member_id} + members.append(link % vals) + return safestring.mark_safe(", ".join(members)) + + +def get_server_group_type(server_group): + return server_group.volume_type if server_group.volume_type != "None" \ + else None + + +class ServerGroupsFilterAction(tables.FilterAction): + def filter(self, table, server_groups, filter_string): + """Naive case-insensitive search.""" + q = filter_string.lower() + return [group for group in server_groups + if q in group.display_name.lower()] + + +class ServerGroupsTable(tables.DataTable): + projectname = ProjectNameColumn("project_name", + verbose_name=_("Project")) + name = tables.Column("name", + verbose_name=_("Group Name"), + link="horizon:admin:server_groups:detail") + policies = tables.Column(get_policies, + verbose_name=_("Policies")) + members = MemberColumn("members", + verbose_name=_("Members")) + metadata = tables.Column(get_metadata, + verbose_name=_("Metadata")) + + class Meta(object): + name = "server_groups" + verbose_name = _("Server Groups") + row_class = UpdateRow + table_actions = ( + CreateServerGroup, DeleteServerGroup, ServerGroupsFilterAction) + row_actions = (DeleteServerGroup,) + + def get_object_display(self, obj): + return obj.name + + +class DetachServerGroup(tables.BatchAction): + name = "detach" + action_type = 'danger' + + @staticmethod + def action_present(count): + return ungettext_lazy( + "Detach Server Group", + "Detached Server Groups", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + "Detaching Server Group", + "Detaching Server Groups", + count + ) + + def action(self, request, obj_id): + attachment = self.table.get_object_by_id(obj_id) + api.nova.instance_server_group_detach(request, + attachment.get('server_id', + None), + obj_id) + + def get_success_url(self, request): + return reverse('horizon:admin:server_groups:index') + + +class AttachedInstanceColumn(tables.Column): + """Customized column class + + Customized column class that does complex processing on the attachments + for a server group. + """ + + def get_raw_data(self, attachment): + request = self.table.request + return safestring.mark_safe(get_attachment_name(request, attachment, + True)) + + +class AttachmentsTable(tables.DataTable): + instance = AttachedInstanceColumn(get_member_name, + verbose_name=_("Instance")) + device = tables.Column("device", + verbose_name=_("Device")) + + def get_object_id(self, obj): + return obj['id'] + + def get_object_display(self, attachment): + instance_name = get_attachment_name(self.request, attachment, True) + vals = {"dev": attachment['device'], + "instance_name": html.strip_tags(instance_name)} + return _("%(dev)s on instance %(instance_name)s") % vals + + def get_object_by_id(self, obj_id): + for obj in self.data: + if self.get_object_id(obj) == obj_id: + return obj + raise ValueError('No match found for the id "%s".' % obj_id) + + class Meta(object): + name = "attachments" + verbose_name = _("Attachments") + table_actions = (DetachServerGroup,) + row_actions = (DetachServerGroup,) diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/software_management/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/software_management/tables.py index 47b508ba..7db60a2c 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/software_management/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/software_management/tables.py @@ -34,16 +34,16 @@ class ApplyPatch(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Apply Patch", - u"Apply Patches", + "Apply Patch", + "Apply Patches", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Applied Patch", - u"Applied Patches", + "Applied Patch", + "Applied Patches", count ) @@ -67,16 +67,16 @@ class RemovePatch(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Remove Patch", - u"Remove Patches", + "Remove Patch", + "Remove Patches", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Removed Patch", - u"Removed Patches", + "Removed Patch", + "Removed Patches", count ) @@ -108,16 +108,16 @@ class DeletePatch(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Patch", - u"Delete Patches", + "Delete Patch", + "Delete Patches", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Patch", - u"Deleted Patches", + "Deleted Patch", + "Deleted Patches", count ) @@ -404,16 +404,16 @@ class ApplyStage(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Apply Stage", - u"Apply Stages", + "Apply Stage", + "Apply Stages", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Applied Stage", - u"Applied Stages", + "Applied Stage", + "Applied Stages", count ) @@ -473,16 +473,16 @@ class AbortStage(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Abort Stage", - u"Abort Stages", + "Abort Stage", + "Abort Stages", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Aborted Stage", - u"Aborted Stages", + "Aborted Stage", + "Aborted Stages", count ) diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/system_config/address_pools/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/system_config/address_pools/tables.py index 70fbad19..51dcde37 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/system_config/address_pools/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/system_config/address_pools/tables.py @@ -30,16 +30,16 @@ class DeleteAddressPool(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Address Pool", - u"Delete Address Pools", + "Delete Address Pool", + "Delete Address Pools", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Address Pool", - u"Deleted Address Pools", + "Deleted Address Pool", + "Deleted Address Pools", count ) @@ -89,7 +89,7 @@ class AddressPoolsTable(tables.DataTable): ranges = tables.Column(get_ranges_column, verbose_name=_("Address Ranges")) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return ("%(network)s/%(prefix)s" % diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/system_config/forms.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/system_config/forms.py index 89d0cea2..093c5cdb 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/system_config/forms.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/system_config/forms.py @@ -864,19 +864,19 @@ class UpdateiStoragePools(forms.SelfHandlingForm): STORAGE_VALUES = {} if hasattr(storage_config, 'cinder_pool_gib'): STORAGE_VALUES['cinder_pool_gib'] = \ - unicode(storage_config._cinder_pool_gib) + str(storage_config._cinder_pool_gib) if hasattr(storage_config, 'glance_pool_gib'): STORAGE_VALUES['glance_pool_gib'] = \ - unicode(storage_config._glance_pool_gib) + str(storage_config._glance_pool_gib) if hasattr(storage_config, 'ephemeral_pool_gib'): STORAGE_VALUES['ephemeral_pool_gib'] = \ - unicode(storage_config._ephemeral_pool_gib) + str(storage_config._ephemeral_pool_gib) if hasattr(storage_config, 'object_pool_gib'): STORAGE_VALUES['object_pool_gib'] = \ - unicode(storage_config._object_pool_gib) + str(storage_config._object_pool_gib) for key in data.keys(): - data[key] = unicode(data[key]) + data[key] = str(data[key]) LOG.info("initial send_to_sysinv=%s", send_to_sysinv) if len(STORAGE_VALUES) != len(data): diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/system_config/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/system_config/tables.py index 5b678114..21dd05de 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/system_config/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/system_config/tables.py @@ -63,7 +63,7 @@ class SystemsTable(tables.DataTable): verbose_name=_("Version")) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.name @@ -141,7 +141,7 @@ class cDNSTable(tables.DataTable): verbose_name=_('DNS Server 3 IP')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.uuid @@ -183,7 +183,7 @@ class cNTPTable(tables.DataTable): verbose_name=_('NTP Server 3 Address')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.uuid @@ -221,7 +221,7 @@ class cPTPTable(tables.DataTable): verbose_name=_('PTP Delay Mechanism')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.uuid @@ -285,7 +285,7 @@ class cOAMTable(tables.DataTable): verbose_name=_('OAM End IP')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.uuid @@ -323,7 +323,7 @@ class iStorageTable(tables.DataTable): verbose_name=_('Size (GiB)')) def get_object_id(self, datum): - return unicode(datum.name) + return str(datum.name) def get_object_display(self, datum): return @@ -365,7 +365,7 @@ class iStoragePoolsTable(tables.DataTable): verbose_name=_('Ceph total space (GiB)')) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return ("%s" % datum.tier_name) @@ -385,16 +385,16 @@ class DeleteSDNController(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete SDN Controller", - u"Delete SDN Controllers", + "Delete SDN Controller", + "Delete SDN Controllers", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted SDN Controller", - u"Deleted SDN Controllers", + "Deleted SDN Controller", + "Deleted SDN Controllers", count ) @@ -447,7 +447,7 @@ class SDNControllerTable(tables.DataTable): verbose_name=_("Remote Port")) def get_object_id(self, datum): - return unicode(datum.uuid) + return str(datum.uuid) def get_object_display(self, datum): return datum.uuid diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_software_management/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_software_management/tables.py index 20ebd9da..00ef17cb 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_software_management/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_software_management/tables.py @@ -271,16 +271,16 @@ class DeleteCloudPatchConfig(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Cloud Patching Configuration", - u"Delete Cloud Patching Configurations", + "Delete Cloud Patching Configuration", + "Delete Cloud Patching Configurations", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Cloud Patching Configuration", - u"Deleted Cloud Patching Configurations", + "Deleted Cloud Patching Configuration", + "Deleted Cloud Patching Configurations", count ) diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/project/server_groups/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/project/server_groups/tables.py index f609e61d..c33f2c1a 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/project/server_groups/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/project/server_groups/tables.py @@ -45,16 +45,16 @@ class DeleteServerGroup(tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Delete Server Group", - u"Delete Server Groups", + "Delete Server Group", + "Delete Server Groups", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Server Group", - u"Deleted Server Groups", + "Deleted Server Group", + "Deleted Server Groups", count ) @@ -223,16 +223,16 @@ class DetachServerGroup(tables.BatchAction): @staticmethod def action_present(count): return ungettext_lazy( - u"Server Group", - u"Server Groups", + "Server Group", + "Server Groups", count ) @staticmethod def action_past(count): return ungettext_lazy( - u"Deleted Group", - u"Deleted Groups", + "Deleted Group", + "Deleted Groups", count )