[Openstack] [Swift] How to get a list of devices from the ring in Java / Bash?

Alexandr Porunov alexandr.porunov at gmail.com
Tue Jan 31 07:55:23 UTC 2017


Hello Matt,

Wow! It's a perfect solution! You've changed my day :)
Thank you very much again!

Best regards,
Alexandr

On Tue, Jan 31, 2017 at 12:32 AM, Matthew Oliver <matt at oliver.net.au> wrote:

> Hey Alexandr,
>
> If you wanted to do it using python, and you didn't have swift installed
> you can use pickle and unpickle the builder. something like:
>
>   import pickle
>   builder = pickle.load(open('<path to builder>')
>
> Then you'd have a python dict structure, where I think you can
> 'builder['devs']'
>
> or with swift installed you can use the RingBuilder class:
>
>   from swift.common.ring.builder import RingBuilder
>   builder = RingBuilder.load('<path to object.builder>')
>   builder.devs
>
> Where builder.devs will be a list of dictionary objects. You could then
> json-ify and output for java to read or put it into an easier to pass list.
>
> There could be a much simpler way, but I'm a Python dev, so this is what
> I'd do ;)
>
> Regards,
> Matt
>
> On Sat, Jan 28, 2017 at 6:21 AM, Alexandr Porunov <
> alexandr.porunov at gmail.com> wrote:
>
>> Hello,
>>
>> I need to get a list / array of devices in Java or Bash. Is it possible
>> to get? Are there any API or something like that?
>>
>> I know we can obtain a list with the next command:
>> swift-ring-builder object.builder
>>
>> But it return a string with the list of devices which are quite hard to
>> parse. In the documentation there is an example how to get a list of
>> devices with python:
>> devices = list(self._iter_devs())
>>
>> But it doesn't show which library to use to get a list of devices and how
>> to use that library.
>>
>> Sincerely,
>> Alexandr
>>
>> _______________________________________________
>> Mailing list: http://lists.openstack.org/cgi
>> -bin/mailman/listinfo/openstack
>> Post to     : openstack at lists.openstack.org
>> Unsubscribe : http://lists.openstack.org/cgi
>> -bin/mailman/listinfo/openstack
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20170131/eeb9e7d2/attachment.html>


More information about the Openstack mailing list