Esempio n. 1
0
        /// <summary>
        /// Adds a docker node to the hive.
        /// </summary>
        /// <param name="node">The new node.</param>
        public void AddNode(NodeDefinition node)
        {
            Covenant.Requires <ArgumentNullException>(node != null);
            Covenant.Requires <ArgumentException>(NeonHelper.DoesNotThrow(() => node.Validate(this)));

            NodeDefinitions.Add(node.Name, node);
        }
Esempio n. 2
0
        /// <summary>
        /// Parses a <see cref="NodeDefinition"/> from Docker node labels.
        /// </summary>
        /// <param name="labels">The Docker labels.</param>
        /// <returns>The parsed <see cref="NodeDefinition"/>.</returns>
        public static NodeDefinition ParseFromLabels(Dictionary <string, string> labels)
        {
            var node = new NodeDefinition();

            node.Labels.Parse(labels);

            return(node);
        }
Esempio n. 3
0
        /// <summary>
        /// Returns a clone of the current instance.
        /// </summary>
        /// <param name="parentNode">The cloned parent node.</param>
        /// <returns>The clone.</returns>
        public NodeLabels Clone(NodeDefinition parentNode)
        {
            Covenant.Requires <ArgumentNullException>(parentNode != null);

            var clone = new NodeLabels(parentNode);

            this.CopyTo(clone);

            return(clone);
        }
Esempio n. 4
0
 /// <summary>
 /// Returns the name to use for naming the virtual machine hosting the node.
 /// </summary>
 /// <param name="node">The target node.</param>
 /// <returns>The virtual machine name.</returns>
 private string GetVmName(NodeDefinition node)
 {
     return($"{hive.Definition.Hosting.GetVmNamePrefix(hive.Definition)}{node.Name}");
 }
Esempio n. 5
0
 /// <summary>
 /// Returns the hostname for a registry cache instance hosted on a manager node.
 /// </summary>
 /// <param name="manager">The manager node.</param>
 /// <returns>The hostname.</returns>
 public string GetRegistryCacheHost(NodeDefinition manager)
 {
     return($"{manager.Name}.{Hostnames.RegistryCache}");
 }
Esempio n. 6
0
        private NodeDefinition node;     // The parent node

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        public NodeLabels(NodeDefinition parentNode)
        {
            Covenant.Requires <ArgumentNullException>(parentNode != null);

            this.node = parentNode;
        }