Beispiel #1
0
    def parse(cls, system_attr_xml):
        """Parses XML and creates SystemIntegerAttribute object"""

        system_attr = SystemAttribute.parse(cls.namespace, system_attr_xml)
        lower_bound = utils.get_wsman_resource_attr(system_attr_xml,
                                                    cls.namespace,
                                                    'LowerBound',
                                                    nullable=True)
        upper_bound = utils.get_wsman_resource_attr(system_attr_xml,
                                                    cls.namespace,
                                                    'UpperBound',
                                                    nullable=True)

        if system_attr.current_value:
            system_attr.current_value = int(system_attr.current_value)
        if system_attr.pending_value:
            system_attr.pending_value = int(system_attr.pending_value)

        if lower_bound:
            lower_bound = int(lower_bound)
        if upper_bound:
            upper_bound = int(upper_bound)
        return cls(system_attr.name, system_attr.instance_id,
                   system_attr.current_value, system_attr.pending_value,
                   system_attr.read_only, system_attr.fqdd,
                   system_attr.group_id, lower_bound, upper_bound)
Beispiel #2
0
    def parse(cls, nic_attr_xml):
        """Parse XML and create a NICIntegerAttribute object."""

        nic_attr = NICAttribute.parse(cls.namespace, nic_attr_xml)
        lower_bound = utils.get_wsman_resource_attr(nic_attr_xml,
                                                    cls.namespace,
                                                    'LowerBound')
        upper_bound = utils.get_wsman_resource_attr(nic_attr_xml,
                                                    cls.namespace,
                                                    'UpperBound')

        if nic_attr.current_value:
            nic_attr.current_value = int(nic_attr.current_value)

        if nic_attr.pending_value:
            nic_attr.pending_value = int(nic_attr.pending_value)

        return cls(nic_attr.name,
                   nic_attr.instance_id,
                   nic_attr.current_value,
                   nic_attr.pending_value,
                   nic_attr.read_only,
                   nic_attr.fqdd,
                   int(lower_bound),
                   int(upper_bound))
Beispiel #3
0
    def parse(cls, namespace, bios_attr_xml):
        """Parses XML and creates BIOSAttribute object"""

        name = utils.get_wsman_resource_attr(bios_attr_xml, namespace, "AttributeName")
        current_value = utils.get_wsman_resource_attr(bios_attr_xml, namespace, "CurrentValue", nullable=True)
        pending_value = utils.get_wsman_resource_attr(bios_attr_xml, namespace, "PendingValue", nullable=True)
        read_only = utils.get_wsman_resource_attr(bios_attr_xml, namespace, "IsReadOnly")

        return cls(name, current_value, pending_value, (read_only == "true"))
Beispiel #4
0
    def parse(cls, lifecycle_attr_xml):
        """Parses XML and creates LCStringAttribute object"""

        lifecycle_attr = LCAttribute.parse(cls.namespace, lifecycle_attr_xml)
        min_length = int(utils.get_wsman_resource_attr(
            lifecycle_attr_xml, cls.namespace, 'MinLength'))
        max_length = int(utils.get_wsman_resource_attr(
            lifecycle_attr_xml, cls.namespace, 'MaxLength'))

        return cls(lifecycle_attr.name, lifecycle_attr.instance_id,
                   lifecycle_attr.current_value, lifecycle_attr.pending_value,
                   lifecycle_attr.read_only, min_length, max_length)
Beispiel #5
0
    def parse(cls, namespace, bios_attr_xml):
        """Parses XML and creates BIOSAttribute object"""

        name = utils.get_wsman_resource_attr(
            bios_attr_xml, namespace, 'AttributeName')
        current_value = utils.get_wsman_resource_attr(
            bios_attr_xml, namespace, 'CurrentValue', nullable=True)
        pending_value = utils.get_wsman_resource_attr(
            bios_attr_xml, namespace, 'PendingValue', nullable=True)
        read_only = utils.get_wsman_resource_attr(
            bios_attr_xml, namespace, 'IsReadOnly')

        return cls(name, current_value, pending_value, (read_only == 'true'))
Beispiel #6
0
    def parse(cls, idrac_attr_xml):
        """Parses XML and creates iDRACCardStringAttribute object"""

        idrac_attr = iDRACCardAttribute.parse(cls.namespace, idrac_attr_xml)
        min_length = int(utils.get_wsman_resource_attr(
            idrac_attr_xml, cls.namespace, 'MinLength'))
        max_length = int(utils.get_wsman_resource_attr(
            idrac_attr_xml, cls.namespace, 'MaxLength'))

        return cls(idrac_attr.name, idrac_attr.instance_id,
                   idrac_attr.current_value, idrac_attr.pending_value,
                   idrac_attr.read_only, idrac_attr.fqdd, idrac_attr.group_id,
                   min_length, max_length)
Beispiel #7
0
    def parse(cls, raid_attr_xml):
        """Parses XML and creates RAIDStringAttribute object"""

        raid_attr = RAIDAttribute.parse(cls.namespace, raid_attr_xml)
        min_length = int(utils.get_wsman_resource_attr(
            raid_attr_xml, cls.namespace, 'MinLength'))
        max_length = int(utils.get_wsman_resource_attr(
            raid_attr_xml, cls.namespace, 'MaxLength'))

        return cls(raid_attr.name, raid_attr.instance_id,
                   raid_attr.current_value, raid_attr.pending_value,
                   raid_attr.read_only, raid_attr.fqdd,
                   min_length, max_length)
Beispiel #8
0
    def parse(cls, namespace, lifecycle_attr_xml):
        """Parses XML and creates LCAttribute object"""

        registered_name = utils.get_wsman_resource_attr(
            lifecycle_attr_xml, namespace, 'RegisteredName')
        registered_version = utils.get_wsman_resource_attr(
            lifecycle_attr_xml, namespace, 'RegisteredVersion')
        registered_orginization = utils.get_wsman_resource_attr(
            lifecycle_attr_xml, namespace, 'RegisteredOrganization')
        other_registered_orginization = utils.get_wsman_resource_attr(
            lifecycle_attr_xml, namespace, 'OtherRegisteredOrganization')

        return cls(registered_name, registered_version,
                   registered_orginization, other_registered_orginization)
Beispiel #9
0
    def parse(cls, bios_attr_xml):
        """Parses XML and creates BIOSStringAttribute object"""

        bios_attr = BIOSAttribute.parse(cls.namespace, bios_attr_xml)
        min_length = int(utils.get_wsman_resource_attr(
            bios_attr_xml, cls.namespace, 'MinLength'))
        max_length = int(utils.get_wsman_resource_attr(
            bios_attr_xml, cls.namespace, 'MaxLength'))
        pcre_regex = utils.get_wsman_resource_attr(
            bios_attr_xml, cls.namespace, 'ValueExpression', nullable=True)

        return cls(bios_attr.name, bios_attr.current_value,
                   bios_attr.pending_value, bios_attr.read_only,
                   min_length, max_length, pcre_regex)
Beispiel #10
0
    def parse(cls, system_attr_xml):
        """Parses XML and creates SystemStringAttribute object"""

        system_attr = SystemAttribute.parse(cls.namespace, system_attr_xml)
        min_length = int(
            utils.get_wsman_resource_attr(system_attr_xml, cls.namespace,
                                          'MinLength'))
        max_length = int(
            utils.get_wsman_resource_attr(system_attr_xml, cls.namespace,
                                          'MaxLength'))

        return cls(system_attr.name, system_attr.instance_id,
                   system_attr.current_value, system_attr.pending_value,
                   system_attr.read_only, system_attr.fqdd,
                   system_attr.group_id, min_length, max_length)
Beispiel #11
0
    def parse(cls, namespace, bios_attr_xml):
        """Parses XML and creates BIOSAttribute object"""

        name = utils.get_wsman_resource_attr(
            bios_attr_xml, namespace, 'AttributeName')
        instance_id = utils.get_wsman_resource_attr(
            bios_attr_xml, namespace, 'InstanceID')
        current_value = utils.get_wsman_resource_attr(
            bios_attr_xml, namespace, 'CurrentValue', nullable=True)
        pending_value = utils.get_wsman_resource_attr(
            bios_attr_xml, namespace, 'PendingValue', nullable=True)
        read_only = utils.get_wsman_resource_attr(
            bios_attr_xml, namespace, 'IsReadOnly')

        return cls(name, instance_id, current_value, pending_value,
                   (read_only == 'true'))
Beispiel #12
0
    def parse(cls, namespace, lifecycle_attr_xml):
        """Parses XML and creates LCAttribute object"""

        name = utils.get_wsman_resource_attr(
            lifecycle_attr_xml, namespace, 'AttributeName')
        instance_id = utils.get_wsman_resource_attr(
            lifecycle_attr_xml, namespace, 'InstanceID')
        current_value = utils.get_wsman_resource_attr(
            lifecycle_attr_xml, namespace, 'CurrentValue', nullable=True)
        pending_value = utils.get_wsman_resource_attr(
            lifecycle_attr_xml, namespace, 'PendingValue', nullable=True)
        read_only = utils.get_wsman_resource_attr(
            lifecycle_attr_xml, namespace, 'IsReadOnly')

        return cls(name, instance_id, current_value, pending_value,
                   (read_only == 'true'))
Beispiel #13
0
def add_pdisks_to_vdisks(bmc, vdisks):
    """Add a list of constituent physical disks to each virtual disk object.

    :param bmc: A dracclient.client.DRACClient instance
    :param vdisks: A list of dracclient.resources.raid.VirtualDisk objects.
    :returns: A list of VirtualDisk-like objects with physical disks.
    """
    doc = bmc.client.enumerate(drac_uris.DCIM_VirtualDiskView)
    vdisk_elems = drac_utils.find_xml(doc, 'DCIM_VirtualDiskView',
                                      drac_uris.DCIM_VirtualDiskView,
                                      find_all=True)
    new_fields = drac_raid.VirtualDiskTuple._fields + ('physical_disks',)
    VirtualDisk = collections.namedtuple('VirtualDisk', new_fields)
    new_vdisks = []
    for vdisk in vdisks:
        for vdisk_elem in vdisk_elems:
            vdisk_elem_id = drac_utils.get_wsman_resource_attr(
                vdisk_elem, drac_uris.DCIM_VirtualDiskView, 'FQDD')
            if vdisk_elem_id == vdisk.id:
                break
        else:
            raise VDiskLost("Unable to find a matching virtual disk in "
                            "returned XML. Has the node been rebooted during "
                            "execution of this module?")

        pdisk_elems = drac_utils.find_xml(vdisk_elem, 'PhysicalDiskIDs',
                                          drac_uris.DCIM_VirtualDiskView,
                                          find_all=True)
        pdisks = [pdisk_elem.text.strip() for pdisk_elem in pdisk_elems
                  if pdisk_elem.text]
        new_vdisk = VirtualDisk(*(vdisk + (pdisks,)))
        new_vdisks.append(new_vdisk)
    return new_vdisks
Beispiel #14
0
    def parse(cls, bios_attr_xml):
        """Parses XML and creates BIOSIntegerAttribute object"""

        bios_attr = BIOSAttribute.parse(cls.namespace, bios_attr_xml)
        lower_bound = utils.get_wsman_resource_attr(
            bios_attr_xml, cls.namespace, 'LowerBound')
        upper_bound = utils.get_wsman_resource_attr(
            bios_attr_xml, cls.namespace, 'UpperBound')

        if bios_attr.current_value:
            bios_attr.current_value = int(bios_attr.current_value)
        if bios_attr.pending_value:
            bios_attr.pending_value = int(bios_attr.pending_value)

        return cls(bios_attr.name, bios_attr.current_value,
                   bios_attr.pending_value, bios_attr.read_only,
                   int(lower_bound), int(upper_bound))
Beispiel #15
0
    def parse(cls, raid_attr_xml):
        """Parses XML and creates RAIDIntegerAttribute object"""

        raid_attr = RAIDAttribute.parse(cls.namespace, raid_attr_xml)
        lower_bound = utils.get_wsman_resource_attr(
            raid_attr_xml, cls.namespace, 'LowerBound')
        upper_bound = utils.get_wsman_resource_attr(
            raid_attr_xml, cls.namespace, 'UpperBound')

        if raid_attr.current_value:
            raid_attr.current_value = int(raid_attr.current_value[0])
        if raid_attr.pending_value:
            raid_attr.pending_value = int(raid_attr.pending_value)

        return cls(raid_attr.name, raid_attr.instance_id,
                   raid_attr.current_value, raid_attr.pending_value,
                   raid_attr.read_only, raid_attr.fqdd,
                   int(lower_bound), int(upper_bound))
Beispiel #16
0
    def parse(cls, namespace, raid_attr_xml):
        """Parses XML and creates RAIDAttribute object"""

        name = utils.get_wsman_resource_attr(
            raid_attr_xml, namespace, 'AttributeName')
        instance_id = utils.get_wsman_resource_attr(
            raid_attr_xml, namespace, 'InstanceID')
        current_value = [attr.text for attr in
                         utils.find_xml(raid_attr_xml, 'CurrentValue',
                                        namespace, find_all=True)]
        pending_value = utils.get_wsman_resource_attr(
            raid_attr_xml, namespace, 'PendingValue', nullable=True)
        read_only = utils.get_wsman_resource_attr(
            raid_attr_xml, namespace, 'IsReadOnly')
        fqdd = utils.get_wsman_resource_attr(
            raid_attr_xml, namespace, 'FQDD')

        return cls(name, instance_id, current_value, pending_value,
                   (read_only == 'true'), fqdd)
Beispiel #17
0
 def _get_physical_disk_attr(self,
                             drac_disk,
                             attr_name,
                             uri,
                             allow_missing=False):
     return utils.get_wsman_resource_attr(drac_disk,
                                          uri,
                                          attr_name,
                                          nullable=True,
                                          allow_missing=allow_missing)
Beispiel #18
0
    def parse(cls, idrac_attr_xml):
        """Parses XML and creates iDRACCardIntegerAttribute object"""

        idrac_attr = iDRACCardAttribute.parse(cls.namespace, idrac_attr_xml)
        lower_bound = utils.get_wsman_resource_attr(idrac_attr_xml,
                                                    cls.namespace,
                                                    'LowerBound')
        upper_bound = utils.get_wsman_resource_attr(idrac_attr_xml,
                                                    cls.namespace,
                                                    'UpperBound')

        if idrac_attr.current_value:
            idrac_attr.current_value = int(idrac_attr.current_value)
        if idrac_attr.pending_value:
            idrac_attr.pending_value = int(idrac_attr.pending_value)

        return cls(idrac_attr.name, idrac_attr.instance_id,
                   idrac_attr.current_value, idrac_attr.pending_value,
                   idrac_attr.read_only, idrac_attr.fqdd, idrac_attr.group_id,
                   int(lower_bound), int(upper_bound))
    def test_get_wsman_resource_attr(self):
        doc = etree.fromstring(
            test_utils.InventoryEnumerations[uris.DCIM_CPUView]['ok'])
        cpus = utils.find_xml(doc, 'DCIM_CPUView', uris.DCIM_CPUView,
                              find_all=True)

        val = utils.get_wsman_resource_attr(
            cpus[0], uris.DCIM_CPUView, 'HyperThreadingEnabled',
            allow_missing=False)

        self.assertEqual('1', val)
Beispiel #20
0
    def test_get_wsman_resource_attr_missing_text_allowed(self):
        doc = etree.fromstring(
            test_utils.RAIDEnumerations[uris.DCIM_ControllerView]['ok'])
        controllers = utils.find_xml(doc,
                                     'DCIM_ControllerView',
                                     uris.DCIM_ControllerView,
                                     find_all=True)

        result = utils.get_wsman_resource_attr(controllers[0],
                                               uris.DCIM_ControllerView,
                                               'DriverVersion',
                                               allow_missing=False,
                                               nullable=True)
        self.assertIsNone(result)
Beispiel #21
0
    def test_get_wsman_resource_attr_missing_attr_allowed(self):
        doc = etree.fromstring(test_utils.InventoryEnumerations[
            uris.DCIM_CPUView]['missing_flags'])
        cpus = utils.find_xml(doc,
                              'DCIM_CPUView',
                              uris.DCIM_CPUView,
                              find_all=True)

        val = utils.get_wsman_resource_attr(cpus[0],
                                            uris.DCIM_CPUView,
                                            'HyperThreadingEnabled',
                                            allow_missing=True)

        self.assertIsNone(val)
Beispiel #22
0
    def parse(cls, nic_attr_xml):
        """Parse XML and create a NICStringAttribute object."""

        nic_attr = NICAttribute.parse(cls.namespace, nic_attr_xml)
        min_length = int(utils.get_wsman_resource_attr(nic_attr_xml,
                                                       cls.namespace,
                                                       'MinLength'))
        max_length = int(utils.get_wsman_resource_attr(nic_attr_xml,
                                                       cls.namespace,
                                                       'MaxLength'))
        pcre_regex = utils.get_wsman_resource_attr(nic_attr_xml,
                                                   cls.namespace,
                                                   'ValueExpression',
                                                   nullable=True)

        return cls(nic_attr.name,
                   nic_attr.instance_id,
                   nic_attr.current_value,
                   nic_attr.pending_value,
                   nic_attr.read_only,
                   nic_attr.fqdd,
                   min_length,
                   max_length,
                   pcre_regex)
Beispiel #23
0
    def parse(cls, namespace, idrac_attr_xml):
        """Parses XML and creates iDRACCardAttribute object"""

        name = utils.get_wsman_resource_attr(
            idrac_attr_xml, namespace, 'AttributeName')
        instance_id = utils.get_wsman_resource_attr(
            idrac_attr_xml, namespace, 'InstanceID')
        current_value = utils.get_wsman_resource_attr(
            idrac_attr_xml, namespace, 'CurrentValue', nullable=True)
        pending_value = utils.get_wsman_resource_attr(
            idrac_attr_xml, namespace, 'PendingValue', nullable=True)
        read_only = utils.get_wsman_resource_attr(
            idrac_attr_xml, namespace, 'IsReadOnly').lower()
        fqdd = utils.get_wsman_resource_attr(
            idrac_attr_xml, namespace, 'FQDD')
        group_id = utils.get_wsman_resource_attr(
            idrac_attr_xml, namespace, 'GroupID')

        return cls(name, instance_id, current_value, pending_value,
                   (read_only == 'true'), fqdd, group_id)
Beispiel #24
0
 def _get_job_attr(self, drac_job, attr_name):
     return utils.get_wsman_resource_attr(drac_job, uris.DCIM_LifecycleJob,
                                          attr_name)
Beispiel #25
0
 def _get_system_attr(self, drac_system, attr_name):
     return utils.get_wsman_resource_attr(drac_system, uris.DCIM_SystemView,
                                          attr_name)
Beispiel #26
0
 def _get_raid_controller_attr(self, drac_controller, attr_name):
     return utils.get_wsman_resource_attr(drac_controller,
                                          uris.DCIM_ControllerView,
                                          attr_name)
Beispiel #27
0
 def _get_physical_disk_attr(self, drac_disk, attr_name):
     return utils.get_wsman_resource_attr(drac_disk,
                                          uris.DCIM_PhysicalDiskView,
                                          attr_name)
Beispiel #28
0
 def _get_boot_mode_attr(self, drac_boot_mode, attr_name):
     return utils.get_wsman_resource_attr(drac_boot_mode,
                                          uris.DCIM_BootConfigSetting,
                                          attr_name)
Beispiel #29
0
 def _get_job_attr(self, drac_job, attr_name):
     return utils.get_wsman_resource_attr(drac_job, uris.DCIM_LifecycleJob,
                                          attr_name)
Beispiel #30
0
 def _get_physical_disk_attr(self, drac_disk, attr_name):
     return utils.get_wsman_resource_attr(
         drac_disk, uris.DCIM_PhysicalDiskView, attr_name, nullable=True)
Beispiel #31
0
 def _get_virtual_disk_attr(self, drac_disk, attr_name, nullable=False):
     return utils.get_wsman_resource_attr(
         drac_disk, uris.DCIM_VirtualDiskView, attr_name,
         nullable=nullable)
Beispiel #32
0
 def _get_raid_controller_attr(self, drac_controller, attr_name):
     return utils.get_wsman_resource_attr(
         drac_controller, uris.DCIM_ControllerView, attr_name,
         nullable=True)
Beispiel #33
0
 def _get_nic_attr(self, drac_nic, attr_name):
     return utils.get_wsman_resource_attr(drac_nic, uris.DCIM_NICView,
                                          attr_name)
Beispiel #34
0
 def _get_cpu_attr(self, cpu, attr_name, allow_missing=False):
     return utils.get_wsman_resource_attr(cpu,
                                          uris.DCIM_CPUView,
                                          attr_name,
                                          allow_missing=allow_missing)
Beispiel #35
0
 def _get_boot_device_attr(self, drac_boot_device, attr_name):
     return utils.get_wsman_resource_attr(drac_boot_device,
                                          uris.DCIM_BootSourceSetting,
                                          attr_name)
Beispiel #36
0
 def _get_memory_attr(self, memory, attr_name):
     return utils.get_wsman_resource_attr(memory, uris.DCIM_MemoryView,
                                          attr_name)
Beispiel #37
0
 def _get_cpu_attr(self, cpu, attr_name):
     return utils.get_wsman_resource_attr(
         cpu, uris.DCIM_CPUView, attr_name)
Beispiel #38
0
 def _get_system_inventory_attr(self, item, attr_name):
     return utils.get_wsman_resource_attr(item, uris.DCIM_SystemView,
                                          attr_name)
Beispiel #39
0
 def _get_memory_attr(self, memory, attr_name):
     return utils.get_wsman_resource_attr(memory, uris.DCIM_MemoryView,
                                          attr_name)