libcloud/compute/drivers/dimensiondata.py [4032:4101]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            id=id,
            name=name,
            description=findtext(element, "description", TYPES_URN),
            value_required=self._str2bool(findtext(element, "valueRequired", TYPES_URN)),
            display_on_report=self._str2bool(findtext(element, "displayOnReport", TYPES_URN)),
        )

    def _to_images(self, object, el_name="osImage"):
        images = []
        locations = self.list_locations()

        # The CloudControl API will return all images
        # in the current geographic region (even ones in
        # datacenters the user's organisation does not have access to)
        #
        # We therefore need to filter out those images (since we can't
        # get a NodeLocation for them)
        location_ids = {location.id for location in locations}

        for element in object.findall(fixxpath(el_name, TYPES_URN)):
            location_id = element.get("datacenterId")
            if location_id in location_ids:
                images.append(self._to_image(element, locations))

        return images

    def _to_image(self, element, locations=None):
        location_id = element.get("datacenterId")
        if locations is None:
            locations = self.list_locations(location_id)

        location = [loc for loc in locations if loc.id == location_id][0]
        cpu_spec = self._to_cpu_spec(element.find(fixxpath("cpu", TYPES_URN)))

        if LooseVersion(self.connection.active_api_version) > LooseVersion("2.3"):
            os_el = element.find(fixxpath("guest/operatingSystem", TYPES_URN))
        else:
            os_el = element.find(fixxpath("operatingSystem", TYPES_URN))

        if element.tag.endswith("customerImage"):
            is_customer_image = True
        else:
            is_customer_image = False
        extra = {
            "description": findtext(element, "description", TYPES_URN),
            "OS_type": os_el.get("family"),
            "OS_displayName": os_el.get("displayName"),
            "cpu": cpu_spec,
            "memoryGb": findtext(element, "memoryGb", TYPES_URN),
            "osImageKey": findtext(element, "osImageKey", TYPES_URN),
            "created": findtext(element, "createTime", TYPES_URN),
            "location": location,
            "isCustomerImage": is_customer_image,
        }

        return NodeImage(
            id=element.get("id"),
            name=str(findtext(element, "name", TYPES_URN)),
            extra=extra,
            driver=self.connection.driver,
        )

    def _to_nat_rules(self, object, network_domain):
        rules = []
        for element in findall(object, "natRule", TYPES_URN):
            rules.append(self._to_nat_rule(element, network_domain))

        return rules

    def _to_nat_rule(self, element, network_domain):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



libcloud/compute/drivers/nttcis.py [5122:5194]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            id=id,
            name=name,
            description=findtext(element, "description", TYPES_URN),
            value_required=self._str2bool(findtext(element, "valueRequired", TYPES_URN)),
            display_on_report=self._str2bool(findtext(element, "displayOnReport", TYPES_URN)),
        )

    def _to_images(self, object, el_name="osImage"):
        images = []
        locations = self.list_locations()

        # The CloudControl API will return all images
        # in the current geographic region (even ones in
        # datacenters the user's organisation does not have access to)
        #
        # We therefore need to filter out those images (since we can't
        # get a NodeLocation for them)
        location_ids = {location.id for location in locations}

        for element in object.findall(fixxpath(el_name, TYPES_URN)):
            location_id = element.get("datacenterId")

            if location_id in location_ids:
                images.append(self._to_image(element, locations))

        return images

    def _to_image(self, element, locations=None):
        location_id = element.get("datacenterId")

        if locations is None:
            locations = self.list_locations(location_id)

        location = [loc for loc in locations if loc.id == location_id][0]
        cpu_spec = self._to_cpu_spec(element.find(fixxpath("cpu", TYPES_URN)))

        if LooseVersion(self.connection.active_api_version) > LooseVersion("2.3"):
            os_el = element.find(fixxpath("guest/operatingSystem", TYPES_URN))
        else:
            os_el = element.find(fixxpath("operatingSystem", TYPES_URN))

        if element.tag.endswith("customerImage"):
            is_customer_image = True
        else:
            is_customer_image = False
        extra = {
            "description": findtext(element, "description", TYPES_URN),
            "OS_type": os_el.get("family"),
            "OS_displayName": os_el.get("displayName"),
            "cpu": cpu_spec,
            "memoryGb": findtext(element, "memoryGb", TYPES_URN),
            "osImageKey": findtext(element, "osImageKey", TYPES_URN),
            "created": findtext(element, "createTime", TYPES_URN),
            "location": location,
            "isCustomerImage": is_customer_image,
        }

        return NodeImage(
            id=element.get("id"),
            name=str(findtext(element, "name", TYPES_URN)),
            extra=extra,
            driver=self.connection.driver,
        )

    def _to_nat_rules(self, object, network_domain):
        rules = []

        for element in findall(object, "natRule", TYPES_URN):
            rules.append(self._to_nat_rule(element, network_domain))

        return rules

    def _to_nat_rule(self, element, network_domain):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



