コード例 #1
0
    def do_provider(self, args, arguments):
        """
        ::

           Usage:
             provider list [--output=OUTPUT]
             provider delete NAME
             provider add NAME

           Arguments:
             NAME           The name of the key.

           Options:
              --output=OUTPUT               the format of the output [default: table]


           Description:

                THIS IS NOT YET IMPLEMENTED

                Managing the providers
        """

        map_parameters(arguments, 'output')

        if arguments.list:

            banner("Loaded Compute Providers")

            providers = ComputeProviderPlugin.__subclasses__()

            for provider in providers:
                print(provider.kind)
                pprint(provider)

            banner("Available Compute Providers")

            providers = ProviderList()

            for name in ["openstack",
                         "azure"]:
                try:
                    provider = providers[name]
                    print(name)
                except Exception as e:
                    print(e)
        elif arguments.delete:
            raise NotImplementedError

        elif arguments.add:
            raise NotImplementedError

        return ""
コード例 #2
0
    def __init__(self,
                 name=None,
                 configuration="~/.cloudmesh/cloudmesh.yaml"):
        # noinspection PyPep8
        try:
            super().__init__(name, configuration)
            self.kind = Config(configuration)[f"cloudmesh.cloud.{name}.cm.kind"]
            self.credentials = Config(configuration)[
                f"cloudmesh.cloud.{name}.credentials"]
            self.name = name
        except:
            Console.error(f"provider {name} not found in {configuration}")
            raise ValueError(f"provider {name} not found in {configuration}")

        provider = None

        providers = ProviderList()

        if self.kind in ['openstack',
                         'azure',
                         'docker',
                         "aws",
                         "azureaz",
                         "virtualbox"]:

            provider = providers[self.kind]

        elif self.kind in ["awslibcloud", "google"]:

            from cloudmesh.compute.libcloud.Provider import \
                Provider as LibCloudProvider
            provider = LibCloudProvider

        elif self.kind in ['oracle']:
            from cloudmesh.oracle.compute.Provider import \
                Provider as OracleComputeProvider
            provider = OracleComputeProvider

        # elif self.kind in ["vagrant", "virtualbox"]:
        #    from cloudmesh.compute.virtualbox.Provider import \
        #        Provider as VirtualboxCloudProvider
        #    provider = VirtualboxCloudProvider
        # elif self.kind in ["azureaz"]:
        #    from cloudmesh.compute.azure.AzProvider import \
        #        Provider as AzAzureProvider
        #    provider = AzAzureProvider

        if provider is None:
            Console.error(f"provider {name} not supported")
            raise ValueError(f"provider {name} not supported")

        self.p = provider(name=name, configuration=configuration)