private static ToscaCapabilityType CreateContainerCapabilityType() { var containerCapabilityType = new ToscaCapabilityType { DerivedFrom = "tosca.capabilities.Root" }; var numCpusProperty = new ToscaProperty { Type = "integer", Required = false }; numCpusProperty.AddConstraint("greater_or_equal", "1"); containerCapabilityType.Properties.Add("num_cpus", numCpusProperty); var cpuFrequencyProperty = new ToscaProperty { Type = "scalar-unit.frequency", Required = false }; cpuFrequencyProperty.AddConstraint("greater_or_equal", "0.1 GHz"); containerCapabilityType.Properties.Add("cpu_frequency", cpuFrequencyProperty); var diskSizeProperty = new ToscaProperty { Type = "scalar-unit.size", Required = false }; diskSizeProperty.AddConstraint("greater_or_equal", "O MB"); containerCapabilityType.Properties.Add("disk_size", diskSizeProperty); var memSizeProperty = new ToscaProperty { Type = "scalar-unit.size", Required = false }; memSizeProperty.AddConstraint("greater_or_equal", "0 MB"); containerCapabilityType.Properties.Add("mem_size", memSizeProperty); return(containerCapabilityType); }
private static ToscaCapabilityType CreateScalableCapabilityType() { var scalableCapabilityType = new ToscaCapabilityType() { DerivedFrom = "tosca.capabilities.Root" }; scalableCapabilityType.Properties.Add("min_instances", new ToscaProperty { Type = "integer", Default = 1 }); scalableCapabilityType.Properties.Add("max_instances", new ToscaProperty { Type = "integer", Default = 1 }); scalableCapabilityType.Properties.Add("default_instances", new ToscaProperty { Type = "integer" }); return(scalableCapabilityType); }
private static ToscaCapabilityType CreateEndpointCapabilityType() { var endpointCapabilityType = new ToscaCapabilityType { DerivedFrom = "tosca.capabilities.Root" }; endpointCapabilityType.Properties.Add("protocol", new ToscaProperty { Type = "string", Default = "tcp" }); endpointCapabilityType.Properties.Add("port", new ToscaProperty { Type = "PortDef", Required = false }); endpointCapabilityType.Properties.Add("secure", new ToscaProperty { Type = "boolean", Default = false }); endpointCapabilityType.Properties.Add("url_path", new ToscaProperty { Type = "string", Required = false }); endpointCapabilityType.Properties.Add("port_name", new ToscaProperty { Type = "string", Required = false }); endpointCapabilityType.Properties.Add("network_name", new ToscaProperty { Type = "string", Required = false, Default = "PRIVATE" }); var initiatorProperty = new ToscaProperty { Type = "string", Default = "source" }; initiatorProperty.AddConstraint("valid_values", new [] { "source", "target", "peer" }); endpointCapabilityType.Properties.Add("initiator", initiatorProperty); var portsProperty = new ToscaProperty { Type = "map", Required = false, EntrySchema = new ToscaPropertyEntrySchema { Type = "PortSpec" } }; portsProperty.AddConstraint("min_length", 1); endpointCapabilityType.Properties.Add("ports", portsProperty); endpointCapabilityType.Attributes.Add("ip_address", new ToscaAttribute { Type = "string" }); return(endpointCapabilityType); }
private static ToscaCapabilityType CreateOperatingSystemCapabilityType() { var operatingSystemCapabilityType = new ToscaCapabilityType { DerivedFrom = "tosca.capabilities.Root" }; operatingSystemCapabilityType.Properties.Add("architecture", new ToscaProperty { Type = "string", Required = false, Description = ToscaCloudServiceArchive.ArchitectureDescription }); operatingSystemCapabilityType.Properties.Add("type", new ToscaProperty { Type = "string", Required = false, Description = ToscaCloudServiceArchive.OperatingSystemTypeDescription }); operatingSystemCapabilityType.Properties.Add("distribution", new ToscaProperty { Type = "string", Required = false, Description = ToscaCloudServiceArchive.OperationSystemDistributionDescription }); operatingSystemCapabilityType.Properties.Add("version", new ToscaProperty { Type = "version", Required = false, Description = ToscaCloudServiceArchive.OperatingSystemVersionDescription }); return(operatingSystemCapabilityType); }
/// <summary> /// If needed adds built-in node types and capabilities /// </summary> private void FillDefaults() { AddNodeType(ToscaDefaults.ToscaNodesRoot, ToscaDefaults.GetRootNodeType()); AddNodeType("tosca.nodes.BlockStorage", CreateBlockStorageNodeType()); AddNodeType("tosca.nodes.Compute", CreateComputeNodeType()); AddCapabilityType("tosca.capabilities.Container", CreateContainerCapabilityType()); var endpointAdminCapabilityType = new ToscaCapabilityType { DerivedFrom = "tosca.capabilities.Endpoint" }; endpointAdminCapabilityType.Properties.Add("secure", new ToscaProperty { Type = "boolean", Default = true }); AddCapabilityType("tosca.capabilities.Endpoint.Admin", endpointAdminCapabilityType); AddCapabilityType("tosca.capabilities.Endpoint", CreateEndpointCapabilityType()); AddCapabilityType("tosca.capabilities.Attachment", new ToscaCapabilityType { DerivedFrom = "tosca.capabilities.Root" }); AddCapabilityType(ToscaDefaults.ToscaCapabilitiesRoot, ToscaDefaults.GetRootCapabilityType()); AddCapabilityType(ToscaDefaults.ToscaCapabilitiesNode, ToscaDefaults.GetNodeCapabilityType()); AddCapabilityType("tosca.capabilities.OperatingSystem", CreateOperatingSystemCapabilityType()); AddCapabilityType("tosca.capabilities.Scalable", CreateScalableCapabilityType()); AddCapabilityType("tosca.capabilities.network.Bindable", CreateBindableCapabilityType()); AddDataType(ToscaDefaults.ToscaDataTypeRoot, ToscaDefaults.GetRootDataType()); AddDataType("string", new ToscaDataType { DerivedFrom = ToscaDefaults.ToscaDataTypeRoot }); AddDataType("integer", new ToscaDataType { DerivedFrom = ToscaDefaults.ToscaDataTypeRoot }); AddDataType("float", new ToscaDataType { DerivedFrom = ToscaDefaults.ToscaDataTypeRoot }); AddDataType("boolean", new ToscaDataType { DerivedFrom = ToscaDefaults.ToscaDataTypeRoot }); AddDataType("null", new ToscaDataType { DerivedFrom = ToscaDefaults.ToscaDataTypeRoot }); }
private void AddCapabilityType(string capabilityTypeName, ToscaCapabilityType capabilityType) { capabilityTypes.Add(capabilityTypeName, capabilityType); capabilityType.SetCloudServiceArchive(this); capabilityType.SetDerivedFromToRoot(capabilityTypeName); }