Exemple #1
0
        /// <summary>
        /// Returns an instance of ToscaNodeType,
        /// which represents Node Type all other TOSCA base Node Types derive from
        /// </summary>
        /// <returns>The TOSCA Node Type all other TOSCA base Node Types derive from</returns>
        public static ToscaNodeType GetRootNodeType()
        {
            var rootNode = new ToscaNodeType
            {
                Description = "The TOSCA Node Type all other TOSCA base Node Types derive from"
            };

            rootNode.Attributes.Add("tosca_id", new ToscaAttribute {
                Type = "string"
            });
            rootNode.Attributes.Add("tosca_name", new ToscaAttribute {
                Type = "string"
            });
            rootNode.Attributes.Add("state", new ToscaAttribute {
                Type = "string"
            });
            rootNode.Capabilities.Add("feature", new ToscaCapability {
                Type = "tosca.capabilities.Node"
            });
            rootNode.Requirements.Add(new Dictionary <string, ToscaRequirement>
            {
                {
                    "dependency",
                    new ToscaRequirement
                    {
                        Capability   = "tosca.capabilities.Node",
                        Node         = "tosca.nodes.Root",
                        Relationship = "tosca.relationships.DependsOn",
                        Occurrences  = new object[] { "0", "UNBOUNDED" }
                    }
                }
            });

            return(rootNode);
        }
Exemple #2
0
        private static ToscaNodeType CreateComputeNodeType()
        {
            var computeNodeType = new ToscaNodeType {
                DerivedFrom = ToscaDefaults.ToscaNodesRoot
            };

            computeNodeType.Attributes.Add("private_address", new ToscaAttribute {
                Type = "string"
            });
            computeNodeType.Attributes.Add("public_address", new ToscaAttribute {
                Type = "string"
            });
            computeNodeType.Attributes.Add("networks", new ToscaAttribute
            {
                Type        = "map",
                EntrySchema = new ToscaAttribute
                {
                    Type = "tosca.datatypes.network.NetworkInfo"
                }
            });
            computeNodeType.Attributes.Add("ports", new ToscaAttribute
            {
                Type        = "map",
                EntrySchema = new ToscaAttribute
                {
                    Type = "tosca.datatypes.network.PortInfo"
                }
            });
            computeNodeType.AddRequirement("local_storage",
                                           new ToscaRequirement()
            {
                Capability   = "tosca.capabilities.Attachment",
                Node         = "tosca.nodes.BlockStorage",
                Relationship = "tosca.relationships.AttachesTo",
                Occurrences  = new object[] { 0, "UNBOUNDED" }
            });
            computeNodeType.Capabilities.Add("host",
                                             new ToscaCapability
            {
                Type             = "tosca.capabilities.Container",
                ValidSourceTypes = new[] { "tosca.nodes.SoftwareComponent" }
            });
            computeNodeType.Capabilities.Add("endpoint", new ToscaCapability {
                Type = "tosca.capabilities.Endpoint.Admin"
            });
            computeNodeType.Capabilities.Add("os", new ToscaCapability {
                Type = "tosca.capabilities.OperatingSystem"
            });
            computeNodeType.Capabilities.Add("scalable", new ToscaCapability {
                Type = "tosca.capabilities.Scalable"
            });
            computeNodeType.Capabilities.Add("binding", new ToscaCapability {
                Type = "tosca.capabilities.network.Bindable"
            });
            return(computeNodeType);
        }
Exemple #3
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);
        }
Exemple #4
0
 /// <summary>
 ///     Adds a node type with its name
 /// </summary>
 /// <param name="nodeTypeName">Node type name</param>
 /// <param name="nodeType">An instance of node type to add</param>
 /// <exception cref="ToscaArtifactNotFoundException"></exception>
 private void AddNodeType(string nodeTypeName, ToscaNodeType nodeType)
 {
     nodeTypes.Add(nodeTypeName, nodeType);
     nodeType.SetCloudServiceArchive(this);
     nodeType.SetDerivedFromToRoot(nodeTypeName);
 }