def create(self, context): """Create a Container record in the DB. :param context: Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don't use it. A context should be set when instantiating the object, e.g.: Container(context) """ values = self.obj_get_changes() cpuset_obj = values.pop('cpuset', None) if cpuset_obj is not None: values['cpuset'] = cpuset_obj._to_dict() annotations = values.pop('annotations', None) if annotations is not None: values['annotations'] = self.fields['annotations'].to_primitive( self, 'annotations', self.annotations) cni_metadata = values.pop('cni_metadata', None) if cni_metadata is not None: values['cni_metadata'] = self.fields['cni_metadata'].to_primitive( self, 'cni_metadata', self.cni_metadata) values['container_type'] = self.container_type db_container = dbapi.create_container(context, values) self._from_db_object(self, db_container)
def create(self, context): """Create a Container record in the DB. :param context: Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don't use it. A context should be set when instantiating the object, e.g.: Container(context) """ values = self.obj_get_changes() db_container = dbapi.create_container(context, values) self._from_db_object(self, db_container)
def create(self, context): """Create a Container record in the DB. :param context: Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don't use it. A context should be set when instantiating the object, e.g.: Container(context) """ values = self.obj_get_changes() cpuset_obj = values.pop('cpuset', None) if cpuset_obj is not None: values['cpuset'] = cpuset_obj._to_dict() values['container_type'] = self.container_type db_container = dbapi.create_container(context, values) self._from_db_object(self, db_container)