本文整理汇总了C#中NodeLocation类的典型用法代码示例。如果您正苦于以下问题:C# NodeLocation类的具体用法?C# NodeLocation怎么用?C# NodeLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodeLocation类属于命名空间,在下文中一共展示了NodeLocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNode
public override Node CreateNode(string name, NodeSize size, NodeImage image, NodeLocation location, NodeAuth auth, NodeOptions options)
{
LinodeNodeOptions ops = options as LinodeNodeOptions;
if (ops == null && options != null)
throw new Exception ("Only LinodeNodeOptions can be used as NodeOptions for creating Linode Nodes.");
else if (ops == null)
ops = new LinodeNodeOptions ();
return API.CreateNode (name, size, image, location, auth, ops);
}
示例2: CreateNode
public Node CreateNode(string name, NodeSize size, NodeImage image, NodeLocation location, NodeAuth auth, LinodeNodeOptions options)
{
int rsize = size.Disk - options.SwapSize;
string kernel = FindKernel (options);
LinodeRequest request = new LinodeRequest ("linode.create", new Dictionary<string,object> {
{"DatacenterID", location.Id}, {"PlanID", size.Id},
{"PaymentTerm", (int) options.PaymentTerm}});
LinodeResponse response = Execute (request);
JObject node = response.Data [0];
string id = node ["LinodeID"].ToString ();
string root_pass;
if (auth.Type == NodeAuthType.Password)
root_pass = auth.Secret;
else
root_pass = GenerateRandomPassword ();
request = new LinodeRequest ("linode.disk.createfromdistribution", new Dictionary<string,object> {
{"LinodeID", id}, {"DistributionID", image.Id}, {"Label", name}, {"Size", rsize},
{"rootPass", root_pass}});
if (auth.Type == NodeAuthType.SSHKey)
request.Parameters.Add ("rootSSHKey", auth.Secret);
response = Execute (request);
JObject distro = response.Data [0];
string root_disk = distro ["DiskID"].ToString ();
request = new LinodeRequest ("linode.disk.create", new Dictionary<string,object> {
{"LinodeID", id}, {"Label", "Swap"}, {"Type", "swap"}, {"Size", options.SwapSize}});
response = Execute (request);
string swap_disk = response.Data [0] ["DiskID"].ToString ();
string disks = String.Format ("{0},{1},,,,,,,", root_disk, swap_disk);
request = new LinodeRequest ("linode.config.create", new Dictionary<string,object> {
{"LinodeID", id}, {"KernelID", kernel}, {"Label", "mcloud config"}, {"DiskList", disks}});
response = Execute (request);
string config = response.Data [0]["ConfigID"].ToString ();
request = new LinodeRequest ("linode.boot", new Dictionary<string,object> {
{"LinodeID", id}, {"ConfigID", config}});
response = Execute (request);
request = new LinodeRequest ("linode.list", new Dictionary<string,object> {{"LinodeID", id}});
response = Execute (request);
return LinodeNode.FromData (response.Data [0], driver);
}
示例3: CreateNode
public Node CreateNode(string name, NodeSize size, NodeImage image, NodeLocation location, int swap=128)
{
int rsize = size.Disk - swap;
string kernel = FindKernel ();
Console.WriteLine ("USING KERNEL: {0}", kernel);
LinodeRequest request = new LinodeRequest ("linode.create", new Dictionary<string,object> {
{"DatacenterID", location.Id}, {"PlanID", size.Id},
{"PaymentTerm", (int) driver.PaymentTerm}});
LinodeResponse response = Execute (request);
JObject node = response.Data [0];
string id = node ["LinodeID"].ToString ();
request = new LinodeRequest ("linode.disk.createfromdistribution", new Dictionary<string,object> {
{"LinodeID", id}, {"DistributionID", image.Id}, {"Label", name}, {"Size", size.Disk},
{"rootPass", "F23444sd"}});
response = Execute (request);
JObject distro = response.Data [0];
string root_disk = distro ["DiskID"].ToString ();
request = new LinodeRequest ("linode.disk.create", new Dictionary<string,object> {
{"LinodeID", id}, {"Label", "Swap"}, {"Type", "swap"}, {"Size", swap}});
response = Execute (request);
string swap_disk = response.Data [0] ["DiskID"].ToString ();
string disks = String.Format ("{0},{1},,,,,,,", root_disk, swap_disk);
request = new LinodeRequest ("linode.config.create", new Dictionary<string,object> {
{"LinodeID", id}, {"KernelID", kernel}, {"Label", "mcloud config"}, {"DiskList", disks}});
response = Execute (request);
string config = response.Data [0]["ConfigID"].ToString ();
request = new LinodeRequest ("linode.boot", new Dictionary<string,object> {
{"LinodeID", id}, {"ConfigID", config}});
response = Execute (request);
return null;
}
示例4: CreateNode
public override Node CreateNode(string name, NodeSize size, NodeImage image, NodeLocation location, NodeAuth auth, NodeOptions options)
{
EC2NodeOptions ops = options as EC2NodeOptions;
if (ops == null && options != null)
throw new Exception ("Only EC2NodeOptions can be used as NodeOptions for creating EC2 Nodes.");
else if (ops == null)
ops = new EC2NodeOptions ();
RunInstancesRequest request = new RunInstancesRequest () {
InstanceType = size.Id,
ImageId = image.Id,
MinCount = 1,
MaxCount = 1,
KeyName = auth.UserName,
};
RunInstancesResponse response = Client.RunInstances (request);
foreach (var i in response.RunInstancesResult.Reservation.RunningInstance) {
return EC2Node.FromRunningInstance (i, this);
}
return null;
}
示例5: Element
public Element Element(Combinator combinator, Node value, NodeLocation location)
{
return new Element(combinator, value) { Location = location };
}
示例6: Directive
public Directive Directive(string name, string identifier, NodeList rules, NodeLocation location)
{
return new Directive(name, identifier, rules) { Location = location };
}
示例7: MixinDefinition
public MixinDefinition MixinDefinition(string name, NodeList<Rule> parameters, NodeList rules, Condition condition, bool variadic, NodeLocation location)
{
return new MixinDefinition(name, parameters, rules, condition, variadic) { Location = location };
}
示例8: Selector
public Selector Selector(NodeList<Element> elements, NodeLocation location)
{
return new Selector(elements) { Location = location };
}
示例9: KeyFrame
public KeyFrame KeyFrame(string identifier, NodeList rules, NodeLocation location)
{
return new KeyFrame(identifier, rules) { Location = location };
}
示例10: Media
public Media Media(NodeList rules, Value features, NodeLocation location)
{
return new Media(features, rules) { Location = location };
}
示例11: Assignment
public Assignment Assignment(string key, Node value, NodeLocation location)
{
return new Assignment(key, value);
}
示例12: Call
public Call Call(string name, NodeList<Node> arguments, NodeLocation location)
{
return new Call(name, arguments) { Location = location };
}
示例13: Value
public Value Value(IEnumerable<Node> values, string important, NodeLocation location)
{
return new Value(values, important) { Location = location };
}
示例14: Variable
public Variable Variable(string name, NodeLocation location)
{
return new Variable(name) { Location = location };
}
示例15: Url
public Url Url(Node value, IImporter importer, NodeLocation location)
{
return new Url(value, importer) { Location = location };
}