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); }
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); }
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; }
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; }
public Selector Selector(NodeList<Element> elements, NodeLocation location) { return new Selector(elements) { Location = location }; }
public MixinCall MixinCall(NodeList <Element> elements, List <NamedArgument> arguments, bool important, NodeLocation location) { return(new MixinCall(elements, arguments, important) { Location = location }); }
public Script Script(string script, NodeLocation location) { return new Script(script) { Location = location }; }
public Element Element(Combinator combinator, Node value, NodeLocation location) { return new Element(combinator, value) { Location = location }; }
public Keyword Keyword(string value, NodeLocation location) { return new Keyword(value) { Location = location }; }
public Assignment Assignment(string key, Node value, NodeLocation location) { return new Assignment(key, value); }
public Comment Comment(string value, NodeLocation location) { return new Comment(value) { Location = location }; }
public LuaJITLongLiteral(NodeLocation location) : base(location) { }
public TableAccess(NodeLocation location) : base(location) { }
public StringLiteral(NodeLocation location) : base(location) { }
public NumberLiteral(NodeLocation location) : base(location) { }
protected Node(NodeLocation location) { this.CurrentIndex = location.CurrentIndex; this.CurrentLine = location.CurrentLine; this.CurrentColumn = location.CurrentColumn; }
public UnaryOp(OpType type, IExpression expr, NodeLocation location) : base(location) { Type = type; Expression = expr; }
public BoolLiteral(NodeLocation location) : base(location) { }
public TextNode TextNode(string contents, NodeLocation location) { return new TextNode(contents) { Location = location }; }
public FunctionCall(NodeLocation location) : base(location) { }
public Value Value(IEnumerable<Node> values, string important, NodeLocation location) { return new Value(values, important) { Location = location }; }
public Entry(NodeLocation location) : base(location) { }
public Color Color(string rgb, NodeLocation location) { return new Color(rgb) { Location = location }; }
public TableConstructor(NodeLocation location) : base(location) { }
public Directive Directive(string name, string identifier, NodeList rules, NodeLocation location) { return new Directive(name, identifier, rules) { Location = location }; }
public Break(NodeLocation location) : base(location) { }
public Import Import(Quoted path, IImporter importer, Value features, bool isOnce, NodeLocation location) { return new Import(path, importer, features, isOnce) { Location = location }; }
public Return(NodeLocation location) : base(location) { }
public MixinCall MixinCall(NodeList<Element> elements, List<NamedArgument> arguments, bool important, NodeLocation location) { return new MixinCall(elements, arguments, important) { Location = location }; }
public Block(NodeLocation location) : base(location) { }
public GenericFor(NodeLocation location) : base(location) { }
public static void ExpectNodeToBeOneOf <TExpected1, TExpected2>(Node actual, object @in, NodeLocation location) where TExpected1 : Node where TExpected2 : Node { if (actual is TExpected1 || actual is TExpected2) { return; } var expected1 = typeof(TExpected1).Name.ToLowerInvariant(); var expected2 = typeof(TExpected2).Name.ToLowerInvariant(); var message = string.Format("Expected {0} or {1} in {2}, found {3}", expected1, expected2, @in, actual.ToCSS(new Env(null))); throw new ParsingException(message, location); }
public Alpha Alpha(Node value, NodeLocation location) { return new Alpha(value) { Location = location }; }
public static List <TExpected> ExpectAllNodes <TExpected>(IEnumerable <Node> actual, object @in, NodeLocation location) where TExpected : Node { return(actual.Select(node => ExpectNode <TExpected>(node, @in, location)).ToList()); }
public Shorthand Shorthand(Node first, Node second, NodeLocation location) { return new Shorthand(first, second) { Location = location }; }
/// <summary> /// Initializes a new instance of the ServiceTaskDispatcherInfo class /// </summary> /// <param name="jobId">indicating the job id</param> /// <param name="taskId">indicating the task id</param> /// <param name="capacity">indicating the capacity</param> /// <param name="machineName">indicating the machine name</param> /// <param name="machineVirtualName">indicating the machine virtual name for Azure cluster</param> /// <param name="firstCoreId">indicating the first core id</param> /// <param name="networkPrefix">indicating the network prefix</param> /// <param name="location">indicating target resource location, OnPremise or Azure</param> /// <param name="isHttp">indicating whether the service task is opening an HTTP service host</param> public ServiceTaskDispatcherInfo(string jobId, string taskId, int capacity, string machineName, string machineVirtualName, int firstCoreId, string networkPrefix, NodeLocation location, bool isHttp) : base(taskId, capacity, machineName, machineVirtualName, location) { this.jobId = jobId; this.taskId = taskId; this.firstCoreId = firstCoreId; this.networkPrefix = networkPrefix; this.isHttp = isHttp; }
public Url Url(Node value, IImporter importer, NodeLocation location) { return new Url(value, importer) { Location = location }; }
public ParsingException(string message, NodeLocation location, NodeLocation callLocation) : this(message, null, location, callLocation) { }
public Variable Variable(string name, NodeLocation location) { return new Variable(name) { Location = location }; }
public ParsingException(Exception innerException, NodeLocation location) : this(innerException, location, null) { }
public Call Call(string name, NodeList<Node> arguments, NodeLocation location) { return new Call(name, arguments) { Location = location }; }
public ParsingException(Exception innerException, NodeLocation location, NodeLocation callLocation) : this(innerException.Message, innerException, location, callLocation) { }
public Combinator Combinator(string value, NodeLocation location) { return new Combinator(value) { Location = location }; }
public ParsingException(string message, Exception innerException, NodeLocation location) : this(message, innerException, location, null) { }
public Condition Condition(Node left, string operation, Node right, bool negate, NodeLocation location) { return new Condition(left, operation, right, negate) { Location = location }; }
public ParsingException(string message, Exception innerException, NodeLocation location, NodeLocation callLocation) : base(message, innerException) { Location = location; CallLocation = callLocation; }
public Directive Directive(string name, Node value, NodeLocation location) { return new Directive(name, value) { Location = location }; }
public static NodeLocation GetReverseDirection(this NodeLocation nodeLocation) { return(nodeLocation + ((int)nodeLocation > DirectionDifference ? -1 : 1) * DirectionDifference); }
public Expression Expression(NodeList expression, NodeLocation location) { return new Expression(expression) { Location = location }; }
public NodeInfo(NodeLocation nodeLocation, int docCount, string urlPart) { mNodeLocation = nodeLocation; mDocCount = docCount; mUrlPart = urlPart; }
public KeyFrame KeyFrame(string identifier, NodeList rules, NodeLocation location) { return new KeyFrame(identifier, rules) { Location = location }; }
public override List<NodeImage> ListImages(NodeLocation location) { return API.ListImages (location); }
public Media Media(NodeList rules, Value features, NodeLocation location) { return new Media(features, rules) { Location = location }; }
public VarargsLiteral(NodeLocation location) : base(location) { }
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 }; }
static void SearchPath( object node, RouteRequestBuilder currentMatchedPath, string[] segments, List <RouteRequestBuilder> possibleRoutePaths, int depthToStart, int myDepth = -1, NodeLocation currentLocation = null, bool ignoreGlobalRoutes = true) { if (node is GlobalRouteItem && ignoreGlobalRoutes) { return; } ++myDepth; currentLocation = currentLocation ?? new NodeLocation(); currentLocation.SetNode(node); IEnumerable items = null; if (depthToStart > myDepth) { items = GetItems(node); if (items == null) { return; } foreach (var nextNode in items) { SearchPath(nextNode, null, segments, possibleRoutePaths, depthToStart, myDepth, currentLocation, ignoreGlobalRoutes); } return; } string shellSegment = GetRoute(node); string userSegment = null; if (currentMatchedPath == null) { userSegment = segments[0]; } else { userSegment = currentMatchedPath.NextSegment; } if (userSegment == null) { return; } RouteRequestBuilder builder = null; if (shellSegment == userSegment || Routing.IsImplicit(shellSegment)) { if (currentMatchedPath == null) { builder = new RouteRequestBuilder(shellSegment, userSegment, node, segments); } else { builder = new RouteRequestBuilder(currentMatchedPath); builder.AddMatch(shellSegment, userSegment, node); } if (!Routing.IsImplicit(shellSegment) || shellSegment == userSegment) { possibleRoutePaths.Add(builder); } } items = GetItems(node); if (items == null) { return; } foreach (var nextNode in items) { SearchPath(nextNode, builder, segments, possibleRoutePaths, depthToStart, myDepth, currentLocation, ignoreGlobalRoutes); } }
internal static List <RouteRequestBuilder> GenerateRoutePaths(Shell shell, Uri request, Uri originalRequest, bool enableRelativeShellRoutes) { var routeKeys = Routing.GetRouteKeys(); for (int i = 0; i < routeKeys.Length; i++) { if (routeKeys[i] == originalRequest.OriginalString) { var builder = new RouteRequestBuilder(routeKeys[i], routeKeys[i], null, new string[] { routeKeys[i] }); return(new List <RouteRequestBuilder> { builder }); } routeKeys[i] = FormatUri(routeKeys[i]); } request = FormatUri(request, shell); originalRequest = FormatUri(originalRequest, shell); List <RouteRequestBuilder> possibleRoutePaths = new List <RouteRequestBuilder>(); if (!request.IsAbsoluteUri) { request = ConvertToStandardFormat(shell, request); } string localPath = request.LocalPath; bool relativeMatch = false; if (!originalRequest.IsAbsoluteUri && !originalRequest.OriginalString.StartsWith("//", StringComparison.Ordinal)) { relativeMatch = true; } var segments = localPath.Split(_pathSeparator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (!relativeMatch) { for (int i = 0; i < routeKeys.Length; i++) { var route = routeKeys[i]; var uri = ConvertToStandardFormat(shell, CreateUri(route)); if (uri.Equals(request)) { throw new Exception($"Global routes currently cannot be the only page on the stack, so absolute routing to global routes is not supported. For now, just navigate to: {originalRequest.OriginalString.Replace("//", "")}"); //var builder = new RouteRequestBuilder(route, route, null, segments); //return new List<RouteRequestBuilder> { builder }; } } } var depthStart = 0; if (segments[0] == shell?.Route) { segments = segments.Skip(1).ToArray(); depthStart = 1; } else { depthStart = 0; } if (relativeMatch && shell?.CurrentItem != null) { // retrieve current location var currentLocation = NodeLocation.Create(shell); while (currentLocation.Shell != null) { var pureRoutesMatch = new List <RouteRequestBuilder>(); var pureGlobalRoutesMatch = new List <RouteRequestBuilder>(); //currently relative routes to shell routes isn't supported as we aren't creating navigation stacks if (enableRelativeShellRoutes) { SearchPath(currentLocation.LowestChild, null, segments, pureRoutesMatch, 0); ExpandOutGlobalRoutes(pureRoutesMatch, routeKeys); pureRoutesMatch = GetBestMatches(pureRoutesMatch); if (pureRoutesMatch.Count > 0) { return(pureRoutesMatch); } } SearchPath(currentLocation.LowestChild, null, segments, pureGlobalRoutesMatch, 0, ignoreGlobalRoutes: false); ExpandOutGlobalRoutes(pureGlobalRoutesMatch, routeKeys); pureGlobalRoutesMatch = GetBestMatches(pureGlobalRoutesMatch); if (pureGlobalRoutesMatch.Count > 0) { // currently relative routes to shell routes isn't supported as we aren't creating navigation stacks // So right now we will just throw an exception so that once this is implemented // GotoAsync doesn't start acting inconsistently and all of a suddent starts creating routes if (!enableRelativeShellRoutes && pureGlobalRoutesMatch[0].SegmentsMatched.Count > 0) { throw new Exception($"Relative routing to shell elements is currently not supported. Try prefixing your uri with ///: ///{originalRequest}"); } return(pureGlobalRoutesMatch); } currentLocation.Pop(); } string searchPath = String.Join(_pathSeparator, segments); if (routeKeys.Contains(searchPath)) { return(new List <RouteRequestBuilder> { new RouteRequestBuilder(searchPath, searchPath, null, segments) }); } RouteRequestBuilder builder = null; foreach (var segment in segments) { if (routeKeys.Contains(segment)) { if (builder == null) { builder = new RouteRequestBuilder(segment, segment, null, segments); } else { builder.AddGlobalRoute(segment, segment); } } } if (builder != null && builder.IsFullMatch) { return new List <RouteRequestBuilder> { builder } } ; } else { possibleRoutePaths.Clear(); SearchPath(shell, null, segments, possibleRoutePaths, depthStart); var bestMatches = GetBestMatches(possibleRoutePaths); if (bestMatches.Count > 0) { return(bestMatches); } bestMatches.Clear(); ExpandOutGlobalRoutes(possibleRoutePaths, routeKeys); } possibleRoutePaths = GetBestMatches(possibleRoutePaths); return(possibleRoutePaths); }
public NumericFor(NodeLocation location) : base(location) { }
public override List<NodeSize> ListSizes(NodeLocation location) { return API.ListSizes (location); }
static List <RouteRequestBuilder> ProcessRelativeRoute( Shell shell, string[] routeKeys, string[] segments, bool enableRelativeShellRoutes, Uri originalRequest) { // retrieve current location var currentLocation = NodeLocation.Create(shell); while (currentLocation.Shell != null) { var pureRoutesMatch = new List <RouteRequestBuilder>(); var pureGlobalRoutesMatch = new List <RouteRequestBuilder>(); //currently relative routes to shell routes isn't supported as we aren't creating navigation stacks if (enableRelativeShellRoutes) { SearchPath(currentLocation.LowestChild, null, segments, pureRoutesMatch, 0); ExpandOutGlobalRoutes(pureRoutesMatch, routeKeys); pureRoutesMatch = GetBestMatches(pureRoutesMatch); if (pureRoutesMatch.Count > 0) { return(pureRoutesMatch); } } SearchPath(currentLocation.LowestChild, null, segments, pureGlobalRoutesMatch, 0, ignoreGlobalRoutes: false); ExpandOutGlobalRoutes(pureGlobalRoutesMatch, routeKeys); if (currentLocation.Content != null && pureGlobalRoutesMatch.Count == 0) { var matches = SearchForGlobalRoutes(segments, shell.CurrentState.FullLocation, currentLocation, routeKeys); pureGlobalRoutesMatch.AddRange(matches); } pureGlobalRoutesMatch = GetBestMatches(pureGlobalRoutesMatch); if (pureGlobalRoutesMatch.Count > 0) { // currently relative routes to shell routes isn't supported as we aren't creating navigation stacks // So right now we will just throw an exception so that once this is implemented // GotoAsync doesn't start acting inconsistently and all of a sudden starts creating routes int shellElementsMatched = pureGlobalRoutesMatch[0].SegmentsMatched.Count - pureGlobalRoutesMatch[0].GlobalRouteMatches.Count; if (!enableRelativeShellRoutes && shellElementsMatched > 0) { throw new Exception($"Relative routing to shell elements is currently not supported. Try prefixing your uri with ///: ///{originalRequest}"); } return(pureGlobalRoutesMatch); } currentLocation.Pop(); } string searchPath = String.Join(_pathSeparator, segments); if (routeKeys.Contains(searchPath)) { return(new List <RouteRequestBuilder> { new RouteRequestBuilder(searchPath, searchPath, null, segments) }); } RouteRequestBuilder builder = null; foreach (var segment in segments) { if (routeKeys.Contains(segment)) { if (builder == null) { builder = new RouteRequestBuilder(segment, segment, null, segments); } else { builder.AddGlobalRoute(segment, segment); } } } if (builder != null && builder.IsFullMatch) { return new List <RouteRequestBuilder> { builder } } ; return(new List <RouteRequestBuilder>()); }