<s> from nova import db <EOL> from nova import objects <EOL> from nova . objects import base <EOL> from nova . objects import fields <EOL> MAX_TAG_LENGTH = <NUM_LIT> <EOL> @ base . NovaObjectRegistry . register <EOL> class Tag ( base . NovaObject ) : <EOL> VERSION = '<STR_LIT>' <EOL> fields = { <EOL> '<STR_LIT>' : fields . StringField ( ) , <EOL> '<STR_LIT>' : fields . StringField ( ) , <EOL> } <EOL> @ staticmethod <EOL> def _from_db_object ( context , tag , db_tag ) : <EOL> for key in tag . fields : <EOL> setattr ( tag , key , db_tag [ key ] ) <EOL> tag . obj_reset_changes ( ) <EOL> tag . _context = context <EOL> return tag <EOL> @ base . remotable <EOL> def create ( self ) : <EOL> db_tag = db . instance_tag_add ( self . _context , self . resource_id , self . tag ) <EOL> self . _from_db_object ( self . _context , self , db_tag ) <EOL> @ base . remotable_classmethod <EOL> def destroy ( cls , context , resource_id , name ) : <EOL> db . instance_tag_delete ( context , resource_id , name ) <EOL> @ base . remotable_classmethod <EOL> def exists ( cls , context , resource_id , name ) : <EOL> return db . instance_tag_exists ( context , resource_id , name ) <EOL> @ base . NovaObjectRegistry . register <EOL> class TagList ( base . ObjectListBase , base . NovaObject ) : <EOL> VERSION = '<STR_LIT>' <EOL> fields = { <EOL> '<STR_LIT>' : fields . ListOfObjectsField ( '<STR_LIT>' ) , <EOL> } <EOL> @ base . remotable_classmethod <EOL> def get_by_resource_id ( cls , context , resource_id ) : <EOL> db_tags = db . instance_tag_get_by_instance_uuid ( context , resource_id ) <EOL> return base . obj_make_list ( context , cls ( ) , objects . Tag , db_tags ) <EOL> @ base . remotable_classmethod <EOL> def create ( cls , context , resource_id , tags ) : <EOL> db_tags = db . instance_tag_set ( context , resource_id , tags ) <EOL> return base . obj_make_list ( context , cls ( ) , objects . Tag , db_tags ) <EOL> @ base . remotable_classmethod <EOL> def destroy ( cls , context , resource_id ) : <EOL> db . instance_tag_delete_all ( context , resource_id ) </s>
