def translate_etcd_result(etcd_result, model_type): """Translate etcd unicode result to etcd models.""" try: data = json.loads(etcd_result.value) ret = None if model_type == 'container': ret = models.Container(data) elif model_type == 'zun_service': ret = models.ZunService(data) elif model_type == 'image': ret = models.Image(data) elif model_type == 'resource_class': ret = models.ResourceClass(data) elif model_type == 'compute_node': ret = models.ComputeNode(data) elif model_type == 'capsule': ret = models.Capsule(data) elif model_type == 'pcidevice': ret = models.PciDevice(data) elif model_type == 'volume_mapping': ret = models.VolumeMapping(data) elif model_type == 'container_action': ret = models.ContainerAction(data) elif model_type == 'container_action_event': ret = models.ContainerActionEvent(data) else: raise exception.InvalidParameterValue( _('The model_type value: %s is invalid.'), model_type) return ret except (ValueError, TypeError) as e: LOG.error("Error occurred while translating etcd result: %s", six.text_type(e)) raise
def translate_etcd_result(etcd_result, model_type): """Translate etcd unicode result to etcd models.""" try: data = json.loads(etcd_result.value) ret = None if model_type == 'container': ret = models.Container(data) elif model_type == 'zun_service': ret = models.ZunService(data) elif model_type == 'image': ret = models.Image(data) else: raise exception.InvalidParameterValue( _('The model_type value: %s is invalid.'), model_type) return ret except (ValueError, TypeError) as e: LOG.error(_LE("Error occurred while translating etcd result: %s"), six.text_type(e)) raise
def create_zun_service(self, values): values['created_at'] = datetime.isoformat(timeutils.utcnow()) zun_service = models.ZunService(values) zun_service.save() return zun_service
def create_zun_service(self, values): values['created_at'] = timeutils.isotime() zun_service = models.ZunService(values) zun_service.save() return zun_service