class BaseArtifact(definitions.ArtifactType): __type_version__ = "1.0" prop1 = definitions.String() prop2 = definitions.Integer() int_list = definitions.Array( item_type=definitions.Integer(max_value=10, min_value=1)) depends_on = definitions.ArtifactReference(type_name='MyArtifact') references = definitions.ArtifactReferenceList() image_file = definitions.BinaryObject() screenshots = definitions.BinaryObjectList()
class MuranoPackage(definitions.ArtifactType): __endpoint__ = 'murano' type = definitions.String(allowed_values=['Application', 'Library'], required=True, mutable=False) author = definitions.String(required=False, mutable=False) display_name = definitions.String(required=True, mutable=True) enabled = definitions.Boolean(default=True) categories = definitions.Array(default=[], mutable=True) class_definitions = definitions.Array(unique=True, default=[], mutable=False) inherits = definitions.Dict(default={}, properties=definitions.Array(), mutable=False) keywords = definitions.Array(default=[], mutable=True) logo = definitions.BinaryObject() archive = definitions.BinaryObject() ui_definition = definitions.BinaryObject()
class ImageAsAnArtifact(v1_1.ImageAsAnArtifact): __type_version__ = '2.0' file = definitions.BinaryObject(required=False) legacy_image_id = definitions.String(required=False, mutable=False, pattern=R'[0-9a-f]{8}-[0-9a-f]{4}' R'-4[0-9a-f]{3}-[89ab]' R'[0-9a-f]{3}-[0-9a-f]{12}') def __pre_publish__(self, context, *args, **kwargs): super(ImageAsAnArtifact, self).__pre_publish__(*args, **kwargs) if self.file is None and self.legacy_image_id is None: raise exception.InvalidArtifactPropertyValue( message=_("Either a file or a legacy_image_id has to be " "specified")) if self.file is not None and self.legacy_image_id is not None: raise exception.InvalidArtifactPropertyValue( message=_("Both file and legacy_image_id may not be " "specified at the same time")) if self.legacy_image_id: glance_endpoint = next(service['endpoints'][0]['publicURL'] for service in context.service_catalog if service['name'] == 'glance') try: client = glanceclient.Client(version=2, endpoint=glance_endpoint, token=context.auth_token) legacy_image = client.images.get(self.legacy_image_id) except Exception: raise exception.InvalidArtifactPropertyValue( message=_('Unable to get legacy image')) if legacy_image is not None: self.file = definitions.Blob(size=legacy_image.size, locations=[{ "status": "active", "value": legacy_image.direct_url }], checksum=legacy_image.checksum, item_key=legacy_image.id) else: raise exception.InvalidArtifactPropertyValue( message=_("Legacy image was not found"))
class SerTestType(defs.ArtifactType): some_string = defs.String() some_text = defs.Text() some_version = defs.SemVerString() some_int = defs.Integer() some_numeric = defs.Numeric() some_bool = defs.Boolean() some_array = defs.Array() another_array = defs.Array( item_type=[defs.Integer(), defs.Numeric(), defs.Boolean()]) some_dict = defs.Dict() another_dict = defs.Dict( properties={'foo': defs.Integer(), 'bar': defs.Boolean()}) some_ref = defs.ArtifactReference() some_ref_list = defs.ArtifactReferenceList() some_blob = defs.BinaryObject() some_blob_list = defs.BinaryObjectList()
class ImageAsAnArtifact(definitions.ArtifactType): __type_name__ = 'Image' __endpoint__ = 'images' file = definitions.BinaryObject(required=True) disk_format = definitions.String(allowed_values=[ 'ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2', 'vdi', 'iso' ], required=True, mutable=False) container_format = definitions.String( allowed_values=['ami', 'ari', 'aki', 'bare', 'ovf', 'ova', 'docker'], required=True, mutable=False) min_disk = definitions.Integer(min_value=0, default=0) min_ram = definitions.Integer(min_value=0, default=0) virtual_size = definitions.Integer(min_value=0)
class TestType(defs.ArtifactType): required_blob = defs.BinaryObject(required=True) optional_blob = defs.BinaryObject()
class TestType(defs.ArtifactType): image_file = defs.BinaryObject(max_file_size=201054, min_locations=1, max_locations=5) screen_shots = defs.BinaryObjectList( objects=defs.BinaryObject(min_file_size=100), min_count=1)
class ArtifactStub(definitions.ArtifactType): file = definitions.BinaryObject() file_list = definitions.BinaryObjectList()