コード例 #1
0
        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);
        }
コード例 #2
0
 private static void MergeProperty(ToscaProperty overridingProperty, ToscaProperty mergedProperty)
 {
     if (overridingProperty.Default != null)
     {
         mergedProperty.Default = overridingProperty.Default;
     }
     if (overridingProperty.Description != null)
     {
         mergedProperty.Description = overridingProperty.Description;
     }
     if (overridingProperty.Constraints != null && overridingProperty.Constraints.Any())
     {
         var mergedConstraints   = mergedProperty.GetConstraintsDictionary();
         var overringConstraints = overridingProperty.GetConstraintsDictionary();
         foreach (var overringConstraint in overringConstraints)
         {
             mergedConstraints[overringConstraint.Key] = overringConstraint.Value;
         }
         mergedProperty.SetConstraints(mergedConstraints);
     }
     if (overridingProperty.Tags != null && overridingProperty.Tags.Any())
     {
         mergedProperty.Tags = overridingProperty.Tags;
     }
     mergedProperty.Required = overridingProperty.Required;
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        private static ToscaNodeType CreateBlockStorageNodeType()
        {
            var blockStorageNodeType = new ToscaNodeType {
                DerivedFrom = "tosca.nodes.Root"
            };
            var sizeProperty = new ToscaProperty {
                Type = "scalar-unit.size"
            };

            sizeProperty.AddConstraint("greater_or_equal", "1 MB");
            blockStorageNodeType.Properties.Add("size", sizeProperty);
            blockStorageNodeType.Properties.Add("volume_id", new ToscaProperty {
                Type = "string", Required = false
            });
            blockStorageNodeType.Properties.Add("snapshot_id", new ToscaProperty {
                Type = "string", Required = false
            });
            blockStorageNodeType.Capabilities.Add("attachment", new ToscaCapability {
                Type = "tosca.capabilities.Attachment"
            });
            return(blockStorageNodeType);
        }