コード例 #1
0
ファイル: image.py プロジェクト: MUSABALOYI/cloudcafe
    def _xml_ele_to_obj(cls, element):
        image_dict = element.attrib
        if 'minDisk' in image_dict:
            image_dict['minDisk'] = (image_dict.get('minDisk')
                                     and int(image_dict.get('minDisk')))
        if 'progress' in image_dict:
            image_dict['progress'] = (image_dict.get('progress')
                                      and int(image_dict.get('progress')))
        if 'minRam' in image_dict:
            image_dict['minRam'] = (image_dict.get('minRam')
                                    and int(image_dict.get('minRam')))

        links = None
        metadata = None
        server = None
        if element.find('link') is not None:
            links = Links._xml_ele_to_obj(element)
        if element.find('metadata') is not None:
            metadata = Metadata._xml_ele_to_obj(element.find('metadata'))
        if element.find('server') is not None:
            # Prevents circular import issue import just in time
            from cloudcafe.compute.servers_api.models.servers import ServerMin
            server = ServerMin._xml_ele_to_obj(element)

        image = Image(
            disk_config=image_dict.get('diskConfig'),
            size=image_dict.get('size'), id=image_dict.get('id'),
            name=image_dict.get('name'), status=image_dict.get('status'),
            updated=image_dict.get('updated'),
            created=image_dict.get('created'),
            min_disk=image_dict.get('minDisk'),
            min_ram=image_dict.get('minRam'),
            progress=image_dict.get('progress'),
            links=links, metadata=metadata, server=server)
        return image
コード例 #2
0
ファイル: image.py プロジェクト: MUSABALOYI/cloudcafe
    def _dict_to_obj(cls, json_dict):

        links = None
        metadata = None
        server = None
        if 'links' in json_dict:
            links = Links._dict_to_obj(json_dict['links'])
        if 'metadata' in json_dict:
            metadata = Metadata._dict_to_obj(json_dict['metadata'])
        if 'server' in json_dict:
            # Prevents circular import issue import just in time
            from cloudcafe.compute.servers_api.models.servers import ServerMin
            server = ServerMin._dict_to_obj(json_dict['server'])

        image = Image(
            disk_config=json_dict.get('OS-DCF:diskConfig'),
            size=json_dict.get('OS-EXT-IMG-SIZE:size'),
            id=json_dict.get('id'), name=json_dict.get('name'),
            status=json_dict.get('status'),
            updated=json_dict.get('updated'),
            created=json_dict.get('created'),
            min_disk=json_dict.get('minDisk'),
            min_ram=json_dict.get('minRam'),
            progress=json_dict.get('progress'),
            links=links, metadata=metadata, server=server)
        return image
コード例 #3
0
    def _dict_to_obj(cls, json_dict):

        links = None
        metadata = None
        server = None
        if 'links' in json_dict:
            links = Links._dict_to_obj(json_dict['links'])
        if 'metadata' in json_dict:
            metadata = Metadata._dict_to_obj(json_dict['metadata'])
        if 'server' in json_dict:
            # Prevents circular import issue import just in time
            from cloudcafe.compute.servers_api.models.servers import ServerMin
            server = ServerMin._dict_to_obj(json_dict['server'])

        image = Image(disk_config=json_dict.get('OS-DCF:diskConfig'),
                      size=json_dict.get('OS-EXT-IMG-SIZE:size'),
                      id=json_dict.get('id'),
                      name=json_dict.get('name'),
                      status=json_dict.get('status'),
                      updated=json_dict.get('updated'),
                      created=json_dict.get('created'),
                      min_disk=json_dict.get('minDisk'),
                      min_ram=json_dict.get('minRam'),
                      progress=json_dict.get('progress'),
                      links=links,
                      metadata=metadata,
                      server=server)
        return image
コード例 #4
0
ファイル: image.py プロジェクト: SamDanes/cloudcafe
    def _xml_ele_to_obj(cls, element):
        image_dict = element.attrib
        if 'minDisk' in image_dict:
            image_dict['minDisk'] = image_dict.get('minDisk') \
                and int(image_dict.get('minDisk'))
        if 'progress' in image_dict:
            image_dict['progress'] = image_dict.get('progress') \
                and int(image_dict.get('progress'))
        if 'minRam' in image_dict:
            image_dict['minRam'] = image_dict.get('minRam') \
                and int(image_dict.get('minRam'))

        links = None
        metadata = None
        server = None

        if element.find('link') is not None:
            links = Links._xml_ele_to_obj(element)
        if element.find('metadata') is not None:
            metadata = Metadata._xml_ele_to_obj(element)
        if element.find('server') is not None:
            '''To prevent circular import issue import just in time'''
            from cloudcafe.compute.servers_api.models.servers import ServerMin
            server = ServerMin._xml_ele_to_obj(element)

        image = Image(image_dict.get('diskConfig'),
                      image_dict.get('id'), image_dict.get('name'),
                      image_dict.get('status'), image_dict.get('updated'),
                      image_dict.get('created'), image_dict.get('minDisk'),
                      image_dict.get('minRam'), image_dict.get('progress'),
                      links, metadata, server)

        return image
コード例 #5
0
    def _xml_ele_to_obj(cls, element):
        image_dict = element.attrib
        if 'minDisk' in image_dict:
            image_dict['minDisk'] = image_dict.get('minDisk') \
                and int(image_dict.get('minDisk'))
        if 'progress' in image_dict:
            image_dict['progress'] = image_dict.get('progress') \
                and int(image_dict.get('progress'))
        if 'minRam' in image_dict:
            image_dict['minRam'] = image_dict.get('minRam') \
                and int(image_dict.get('minRam'))

        links = None
        metadata = None
        server = None

        if element.find('link') is not None:
            links = Links._xml_ele_to_obj(element)
        if element.find('metadata') is not None:
            metadata = Metadata._xml_ele_to_obj(element)
        if element.find('server') is not None:
            '''To prevent circular import issue import just in time'''
            from cloudcafe.compute.servers_api.models.servers import ServerMin
            server = ServerMin._xml_ele_to_obj(element)

        image = Image(image_dict.get('diskConfig'), image_dict.get('size'),
                      image_dict.get('id'), image_dict.get('name'),
                      image_dict.get('status'), image_dict.get('updated'),
                      image_dict.get('created'), image_dict.get('minDisk'),
                      image_dict.get('minRam'), image_dict.get('progress'),
                      links, metadata, server)

        return image
コード例 #6
0
ファイル: image.py プロジェクト: SamDanes/cloudcafe
 def _dict_to_obj(cls, json_dict):
     image = Image(json_dict.get('OS-DCF:diskConfig'), json_dict.get('id'),
                   json_dict.get('name'), json_dict.get('status'),
                   json_dict.get('updated'), json_dict.get('created'),
                   json_dict.get('minDisk'), json_dict.get('minRam'),
                   json_dict.get('progress'))
     if 'links' in json_dict:
         image.links = Links._dict_to_obj(json_dict['links'])
     if 'metadata' in json_dict:
         image.metadata = Metadata._dict_to_obj(json_dict['metadata'])
     if 'server' in json_dict:
         from cloudcafe.compute.servers_api.models.servers import ServerMin
         image.server = ServerMin._dict_to_obj(json_dict['server'])
     return image
コード例 #7
0
ファイル: image.py プロジェクト: kaofelix/cloudcafe
 def _dict_to_obj(cls, json_dict):
     image = Image(json_dict.get('OS-DCF:diskConfig'), json_dict.get('id'),
                   json_dict.get('name'), json_dict.get('status'),
                   json_dict.get('updated'), json_dict.get('created'),
                   json_dict.get('minDisk'), json_dict.get('minRam'),
                   json_dict.get('progress'))
     if 'links' in json_dict:
         image.links = Links._dict_to_obj(json_dict['links'])
     if 'metadata' in json_dict:
         image.metadata = Metadata._dict_to_obj(json_dict['metadata'])
     if 'server' in json_dict:
         from cloudcafe.compute.servers_api.models.servers import ServerMin
         image.server = ServerMin._dict_to_obj(json_dict['server'])
     return image