I've used __dict__ with the provider a few times. Thats the best way I've
found too. Also be careful - using inspection on NodeDriver.__init__ can be
tricky as most providers use kwargs rather than arguments such as the
BaseProvider.

Rob
On Apr 16, 2012 8:50 PM, "Tomaž Muraus" <[email protected]> wrote:

> Hi,
>
> If you want to get a human readable list of all the supported providers,
> you can do something like this:
>
> from libcloud.compute.types import Provider
> names = [n for n in Provider.__dict__ if type(Provider.__dict__[n]) == int]
>
> ['IBM',
>  'SOFTLAYER',
>  'EC2_EU_WEST',
>  'ELASTICHOSTS',
>  'BRIGHTBOX',
>  'BLUEBOX',
>  'EC2_AP_SOUTHEAST',
>  'EC2_US_EAST',
>  'ELASTICHOSTS_UK2',
>  'ELASTICHOSTS_UK1',
>  'VPSNET',
>  'VOXEL',
>  'RACKSPACE',
>  'ELASTICHOSTS_US1',
>  'RIMUHOSTING',
>  'LINODE',
>  'OPENNEBULA',
>  'NIMBUS',
>  'GOGRID',
>  'DREAMHOST',
>  'ECP',
>  'GANDI',
>  'DUMMY',
>  'EC2_US_WEST_OREGON',
>  'EC2_US_WEST',
>  'TERREMARK',
>  'SERVERLOVE',
>  'NINEFOLD',
>  'CLOUDSIGMA_US',
>  'RACKSPACE_UK',
>  'EC2_AP_NORTHEAST',
>  'CLOUDSTACK',
>  'EC2',
>  'VCLOUD',
>  'EC2_SA_EAST',
>  'OPSOURCE',
>  'EUCALYPTUS',
>  'EC2_EU',
>  'SKALICLOUD',
>  'SLICEHOST',
>  'CLOUDSIGMA',
>  'OPENSTACK']
>
> On Mon, Apr 16, 2012 at 6:17 PM, Alex Brandt <[email protected]>
> wrote:
>
> > **
> >
> > Hello Everyone,
> >
> >
> >
> > I was looking for a way to list the providers in a human convertable
> > format and found that everything in libcloud.compute.types looks like an
> > enum. I'm not seeing the reason why these types would emulate enums and
> was
> > hoping someone could shine some light on it. Otherwise, if anyone can
> > suggest a better way to list the providers dynamically I'd love to hear
> > about it.
> >
> >
> >
> > Thanks in advance,
> >
> >
> >
> > --
> >
> > Alex Brandt
> >
> > Sales Engineer for Rackspace, RHCE
> >
> > http://www.alunduil.com
> >
> >
> >
>

Reply via email to