An authorization mechanism for connecting to a node. These can be userid/password pairs, or userid and keyfile. The default user name is "root".
コード例 #1
0
ファイル: ScriptDeployment.cs プロジェクト: aggrata/MCloud
        private void RunScript(string host, NodeAuth auth)
        {
            SshExec exec = new SshExec (host, auth.UserName);

            SetupSSH (exec, auth);

            exec.RunCommand (RemoteScriptPath);
        }
コード例 #2
0
ファイル: ScriptDeployment.cs プロジェクト: aggrata/MCloud
        private void CopyScript(string host, NodeAuth auth)
        {
            Scp scp = new Scp (host, auth.UserName);

            SetupSSH (scp, auth);

            scp.Put (LocalScriptPath, RemoteScriptPath);
            scp.Close ();
        }
コード例 #3
0
ファイル: CreateLinode.cs プロジェクト: jacksonh/MCloud
        public static void Main(string[] args)
        {
            ///
            /// To run this sample you must have a
            /// LINODE-KEY.txt file with your Linode API
            /// key in it.  See the getting started guide for
            /// info on how to get a key.
            ///
            /// Note that this sample will create a new node
            /// on your account and you will be billed at least
            /// 1 day for that node.  You can manually destroy the
            /// node when you are done at linode.com or you can
            /// make a call to node.Destroy.
            ///

            if (!File.Exists ("LINODE-KEY.txt"))
                throw new Exception ("You must have a LINODE-KEY.txt file to run this sample.");

            var key = File.ReadAllText ("LINODE-KEY.txt").Trim ();
            if (key.Length < 40)
                throw new Exception ("Your LINODE-KEY.txt file must contain a Linode API key.");

            var driver = new LinodeDriver (key);

            // Find a location in the USA
            var location = driver.ListLocations ().FirstOrDefault (l => l.Country == "US");

            // Pick the cheapest plan possible
            var size = driver.ListSizes ().OrderBy (s => s.Price).FirstOrDefault ();

            // Grab any OpenSuse image.
            var image = driver.ListImages ().FirstOrDefault (i => i.Name.Contains ("OpenSUSE"));

            Console.WriteLine ("location: {0}  size:  {1}  image:  {2}", location, size, image);

            // Create the new with a random password
            string password = System.Web.Security.Membership.GeneratePassword (10, 3);
            NodeAuth auth = new NodeAuth (NodeAuthType.Password, password);
            Node n = driver.CreateNode ("my new node", size, image, location, auth);

            Console.WriteLine ("created new node located at {0} with password {1}", n.PublicIPs [0], password);

            var deployment = new MultiStepDeployment () {
                // Create a file on the node
                new RunCommand ("touch /root/test"),
                // Upload a file to the node
                new PutFile ("CreateLinode.exe"),
            };
            n.Deploy (deployment, auth);

            Console.WriteLine ("Your node has been deployed.");
        }
コード例 #4
0
ファイル: ScriptDeployment.cs プロジェクト: aggrata/MCloud
        public override void Run(Node node, NodeAuth auth)
        {
            if (node == null)
                throw new ArgumentNullException ("node");
            if (auth == null)
                throw new ArgumentNullException ("auth");

            if (node.PublicIPs.Count < 1)
                throw new ArgumentException ("node", "No public IPs available on node.");

            string host = node.PublicIPs [0].ToString ();
            CopyScript (host, auth);

            SshExec exec = new SshExec (host, auth.UserName);
        }
コード例 #5
0
ファイル: ScriptDeployment.cs プロジェクト: aggrata/MCloud
 private void SetupSSH(SshBase ssh, NodeAuth auth)
 {
     if (auth.Type == NodeAuthType.Password)
         ssh.Password = auth.Secret;
 }
コード例 #6
0
ファイル: Deployment.cs プロジェクト: aggrata/MCloud
 public abstract void Run(Node node, NodeAuth auth);
コード例 #7
0
ファイル: MultiStepDeployment.cs プロジェクト: aggrata/MCloud
 public override void Run(Node node, NodeAuth auth)
 {
     foreach (Deployment d in Steps) {
         d.Run (node, auth);
     }
 }
コード例 #8
0
ファイル: Node.cs プロジェクト: jacksonh/MCloud
 /// <summary>
 /// Run the supplied deployment on the node.  This is a syncrhonous operation and will block until
 /// the node deployment is completed.
 /// </summary>
 public void Deploy(Deployment d, NodeAuth auth)
 {
     d.Run (this, auth);
 }
コード例 #9
0
ファイル: NodeDriver.cs プロジェクト: aggrata/MCloud
 public abstract Node CreateNode(string name, NodeSize size, NodeImage image, NodeLocation location, NodeAuth auth, NodeOptions options);
コード例 #10
0
ファイル: NodeDriver.cs プロジェクト: jacksonh/MCloud
 /// <summary>
 /// Create a new node using the default options for this node driver type.
 /// </summary>
 public Node CreateNode(string name, NodeSize size, NodeImage image, NodeLocation location, NodeAuth auth)
 {
     return CreateNode (name, size, image, location, auth, DefaultOptions);
 }