def _populate(self, json): """ Override the populate method to map user_defined_fields to fancy values """ Base._populate(self, json) mapped_udfs = [] for udf in self.user_defined_fields: t = UserDefinedFieldType.text choices = None if hasattr(udf, 'oneof'): t = UserDefinedFieldType.select_one choices = udf.oneof.split(',') elif hasattr(udf, 'manyof'): t = UserDefinedFieldType.select_many choices = udf.manyof.split(',') mapped_udfs.append( UserDefinedField( udf.name, udf.label if hasattr(udf, 'label') else None, udf.example if hasattr(udf, 'example') else None, t, choices=choices)) self._set('user_defined_fields', mapped_udfs) ndist = [Image(self._client, d) for d in self.images] self._set('images', ndist)
def _populate(self, json): """ Override the populate method to map user_defined_fields to fancy values """ Base._populate(self, json) mapped_udfs = [] for udf in self.user_defined_fields: t = UserDefinedFieldType.text choices = None if hasattr(udf, 'oneof'): t = UserDefinedFieldType.select_one choices = udf.oneof.split(',') elif hasattr(udf, 'manyof'): t = UserDefinedFieldType.select_many choices = udf.manyof.split(',') mapped_udfs.append(UserDefinedField(udf.name, udf.label if hasattr(udf, 'label') else None, udf.example if hasattr(udf, 'example') else None, t, choices=choices)) self._set('user_defined_fields', mapped_udfs) ndist = [ Image(self._client, d) for d in self.images ] self._set('images', ndist)
def _populate(self, json): if json is not None: # fixes ipv4 and ipv6 attribute of json to make base._populate work if 'ipv4' in json and 'address' in json['ipv4']: json['ipv4']['id'] = json['ipv4']['address'] if 'ipv6' in json and isinstance(json['ipv6'], list): for j in json['ipv6']: j['id'] = j['range'] Base._populate(self, json)