jclouds-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ignasi <ignasi.barr...@gmail.com>
Subject Re: Query Chef Server Node using IpAddress
Date Mon, 20 May 2013 09:11:39 GMT
Hi Rahul,

As George pointed out, the best way to search nodes based on their
attributes is to use the search API. To do that, you just need to
build the appropriate search query. Here are some examples:

ChefApi api = chefContext.getApi(ChefApi.class);

SearchOptions ipFilter = SearchOptions.Builder.query("addresses:10.60.12.24");
SearchOptions macFilter =
SearchOptions.Builder.query("macaddress:10:40:f3:7b:9a:68");
SearchOptions ipAndMacFilter =
SearchOptions.Builder.query("addresses:10.60.12.24 AND
macaddress:10:40:f3:7b:9a:68");
SearchOptions ipWildcard = SearchOptions.Builder.query("addresses:10.60.12.*");

SearchResult< ? extends Node> nodes = api.searchNodes(filter);
for (Node node : nodes)  {
    System.out.println("Found node: " + node.getName());
}

As you can see, filters can build to search by concrete attributes.
You can compose them and use wildcards too.

HTH!

Ignasi



P.S. George, given that you work at Opscode, let me abuse a bit :) We
are currently a little blocked implementing the HostedChef and
PrivateChef provider apis. There is no public documentation of their
apis and we are trying to support them in jclouds-chef based on [1]
and [2]. Is there any chance to have some documentation of the APIs or
some help from you side on this?

[1] https://github.com/seth/knife-acl
[2] https://github.com/stevendanna/knife-opc

On 19 May 2013 23:02, George Moberly <george@opscode.com> wrote:
>
> Yes, use the search API endpoint to search the node index for any defined
> attribute, for example FQDN, IP address, etc.
>
> That will return the name of the node, which can be used to construct a node
> object. Since there is but a single namespace for nodes, and node-name is
> the unique key, this method should work.
>
> George.
>
>
> George Moberly
> VP Solutions
> +1.978.424.5159
> george@opscode.com
>
> Opscode
> 1008 Western Ave., Suite 600
> Seattle, WA 98104 USA
> www.opscode.com
>
>
> From: Rahul Nema <rahulnema@in.ibm.com>
> Reply-To: "user@jclouds.incubator.apache.org"
> <user@jclouds.incubator.apache.org>
> Date: Sunday, May 19, 2013 11:33 AM
> To: "user@jclouds.incubator.apache.org" <user@jclouds.incubator.apache.org>
> Subject: Query Chef Server Node using IpAddress
>
> Hi,
>
> Currently I am using this code to get NodeDetails which uses the name for
> querying a  Node on the chef server. Is there a way I can use more unique
> identity to search a Node on the server like ipAddress ??
>
> The need is to identify the Node correctly on the chef server such that the
> run-list can be updated correctly. This is what I use today but need it to
> be IpAddres and MaC is possible.
>
> Node node = context.getApi(ChefApi.class).getNode(name);
>                                 System.out.println(node);
>
>                                 Gson gson = new Gson();
>                                 dbJsonString = gson.toJson(node);
>                                 System.out.println(dbJsonString);
>
>                                 // release resources
>                                 context.close();
>
>
> With warm  regards,
>  ------------------------------------------------------------
> Rahul Nema,
> Tivoli Group
> IBM-India Software Lab,Pune
> Mo: +91-9860254300
> ------------------------------------------------------------

Mime
View raw message