示例#1
0
文件: s3.py 项目: Keisuke69/libcloud
    def _get_more(self, last_key, value_dict):
        container = value_dict['container']
        params = {}

        if last_key:
            params['marker'] = last_key

        response = self.connection.request('/%s' % (container.name),
                                           params=params)

        if response.status == httplib.OK:
            objects = self._to_objs(obj=response.object,
                                       xpath='Contents', container=container)
            is_truncated = response.object.findtext(fixxpath(xpath='IsTruncated',
                                                   namespace=self.namespace)).lower()
            exhausted = (is_truncated == 'false')

            if (len(objects) > 0):
                last_key = objects[-1].name
            else:
                last_key = None
            return objects, last_key, exhausted

        raise LibcloudError('Unexpected status code: %s' % (response.status),
                            driver=self)
示例#2
0
    def _to_network(self, element):
        multicast = False
        if findtext(element, 'multicast', NETWORK_NS) == 'true':
            multicast = True

        status = self._to_status(element.find(fixxpath('status', NETWORK_NS)))

        location_id = findtext(element, 'location', NETWORK_NS)
        location = self.ex_get_location_by_id(location_id)

        return OpsourceNetwork(id=findtext(element, 'id', NETWORK_NS),
                               name=findtext(element, 'name', NETWORK_NS),
                               description=findtext(element, 'description',
                                   NETWORK_NS),
                               location=location,
                               privateNet=findtext(element, 'privateNet',
                                   NETWORK_NS),
                               multicast=multicast,
                               status=status)
示例#3
0
    def _to_node(self, element):
        if findtext(element, 'isStarted', SERVER_NS) == 'true':
            state = NodeState.RUNNING
        else:
            state = NodeState.TERMINATED

        status = self._to_status(element.find(fixxpath('status', SERVER_NS)))

        extra = {
            'description': findtext(element, 'description', SERVER_NS),
            'sourceImageId': findtext(element, 'sourceImageId', SERVER_NS),
            'networkId': findtext(element, 'networkId', SERVER_NS),
            'machineName': findtext(element, 'machineName', SERVER_NS),
            'deployedTime': findtext(element, 'deployedTime', SERVER_NS),
            'cpuCount': findtext(element, 'machineSpecification/cpuCount',
                SERVER_NS),
            'memoryMb': findtext(element, 'machineSpecification/memoryMb',
                SERVER_NS),
            'osStorageGb': findtext(element,
                'machineSpecification/osStorageGb', SERVER_NS),
            'additionalLocalStorageGb': findtext(element,
                'machineSpecification/additionalLocalStorageGb', SERVER_NS),
            'OS_type': findtext(element,
                'machineSpecification/operatingSystem/type', SERVER_NS),
            'OS_displayName': findtext(element,
                'machineSpecification/operatingSystem/displayName', SERVER_NS),
            'status': status,
        }

        n = Node(id=findtext(element, 'id', SERVER_NS),
                 name=findtext(element, 'name', SERVER_NS),
                 state=state,
                 public_ips=[],
                 private_ips=findtext(element, 'privateIpAddress', SERVER_NS),
                 driver=self.connection.driver,
                 extra=extra)
        return n
示例#4
0
 def _to_nodes(self, object):
     node_elements = object.findall(fixxpath('DeployedServer', SERVER_NS))
     node_elements.extend(object.findall(fixxpath('PendingDeployServer',
         SERVER_NS)))
     return [self._to_node(el) for el in node_elements]
示例#5
0
    def _to_locations(self, object):
        locations = []
        for element in object.findall(fixxpath('datacenter', DATACENTER_NS)):
            locations.append(self._to_location(element))

        return locations
示例#6
0
    def _to_base_images(self, object):
        images = []
        for element in object.findall(fixxpath("ServerImage", SERVER_NS)):
            images.append(self._to_base_image(element))

        return images
示例#7
0
 def _to_containers(self, obj, xpath):
     return [ self._to_container(element) for element in \
              obj.findall(fixxpath(xpath=xpath, namespace=self.namespace))]
示例#8
0
文件: s3.py 项目: Keisuke69/libcloud
 def _to_objs(self, obj, xpath, container):
     return [ self._to_obj(element, container) for element in \
              obj.findall(fixxpath(xpath=xpath, namespace=self.namespace))]
示例#9
0
文件: ec2.py 项目: Keisuke69/libcloud
 def _to_images(self, object):
     return [
         self._to_image(el) for el in object.findall(
             fixxpath(xpath='imagesSet/item', namespace=NAMESPACE))
     ]
示例#10
0
文件: ec2.py 项目: Keisuke69/libcloud
 def _to_images(self, object):
     return [self._to_image(el)
             for el in object.findall(
         fixxpath(xpath='imagesSet/item', namespace=NAMESPACE)
     )]
示例#11
0
文件: ec2.py 项目: Keisuke69/libcloud
 def _to_nodes(self, object, xpath, groups=None):
     return [self._to_node(el, groups=groups)
             for el in object.findall(fixxpath(xpath=xpath,
                                               namespace=NAMESPACE))]
示例#12
0
 def _to_base_images(self, object):
     node_elements = object.findall(fixxpath("ServerImage", SERVER_NS))
     return [self._to_base_image(el) for el in node_elements]
示例#13
0
 def _to_nodes(self, object):
     node_elements = object.findall(fixxpath('DeployedServer', SERVER_NS))
     node_elements.extend(
         object.findall(fixxpath('PendingDeployServer', SERVER_NS)))
     return [self._to_node(el) for el in node_elements]
示例#14
0
 def _to_locations(self, object):
     node_elements = object.findall(fixxpath('datacenter', DATACENTER_NS))
     return [self._to_location(el) for el in node_elements]
示例#15
0
文件: s3.py 项目: Keisuke69/libcloud
 def _to_containers(self, obj, xpath):
     return [ self._to_container(element) for element in \
              obj.findall(fixxpath(xpath=xpath, namespace=self.namespace))]
示例#16
0
 def _to_objs(self, obj, xpath, container):
     return [ self._to_obj(element, container) for element in \
              obj.findall(fixxpath(xpath=xpath, namespace=NAMESPACE))]
示例#17
0
文件: ec2.py 项目: Keisuke69/libcloud
 def _to_nodes(self, object, xpath, groups=None):
     return [
         self._to_node(el, groups=groups) for el in object.findall(
             fixxpath(xpath=xpath, namespace=NAMESPACE))
     ]