Revision 1b696c26 snf-cyclades-app/synnefo/api/servers.py

b/snf-cyclades-app/synnefo/api/servers.py
126 126

  
127 127
def vm_to_dict(vm, detail=False):
128 128
    d = dict(id=vm.id, name=vm.name)
129
    d['links'] = util.vm_to_links(vm.id)
129 130
    if detail:
130 131
        d['status'] = get_rsapi_state(vm)
131 132
        d['progress'] = 100 if get_rsapi_state(vm) == 'ACTIVE' \
......
133 134
        d['hostId'] = vm.hostid
134 135
        d['updated'] = utils.isoformat(vm.updated)
135 136
        d['created'] = utils.isoformat(vm.created)
136
        d['flavor'] = vm.flavor.id
137
        d['image'] = vm.imageid
137
        d['flavor'] = {"id": vm.flavor.id,
138
                       "links": util.flavor_to_links(vm.flavor.id)}
139
        d['image'] = {"id": vm.imageid,
140
                      "links": util.image_to_links(vm.imageid)}
138 141
        d['suspended'] = vm.suspended
139 142

  
140 143
        metadata = dict((m.meta_key, m.meta_value) for m in vm.metadata.all())
141
        if metadata:
142
            d['metadata'] = metadata
144
        d['metadata'] = metadata
143 145

  
144 146
        vm_nics = vm.nics.filter(state="ACTIVE").order_by("index")
145 147
        attachments = map(nic_to_dict, vm_nics)
......
149 151
        diagnostic = vm.get_last_diagnostic()
150 152
        if diagnostic:
151 153
            d['diagnostics'] = diagnostics_to_dict([diagnostic])
154
        else:
155
            d['diagnostics'] = []
152 156

  
153 157
    return d
154 158

  

Also available in: Unified diff