Multi-Cloud-Explorer

Warning

Ne pas utiliser ce projet en production pour l’instant !!!

Multi-Cloud-Explorer a pour objectif de centraliser l’inventaire et le suivi des changements, pour les ressources de toutes vos souscriptions Cloud.

La récupération des resources se fait par plusieurs méthodes:

  • Inventaire périodique lancé à partir d’un worker MCE

  • Réception des évènements par l’api REST, à partir d’une fonction serverless

  • Appel manuel de l’api REST déclenché par vos soins

L’inventaire pourra être exploité par différents moyens:

  • Navigation et recherche dans l’application Web

  • Bus d’évènements qui recevra tous les changements détectés

  • Utilisation de l’api REST

Architecture

La solution est modulaire et hautement évolutive. Vous pouvez utiliser une partie des composants (ex: mce-lib-azure) ou la totalité (ex: mce-django-server).

Composants

mce-lib-azure

Librairie pour parcourir toutes les ressources d’une souscription Azure.

mce-lib-aws

Librairie pour parcourir toutes les ressources d’une souscription AWS.

mce-lib-vsphere

Librairie pour parcourir toutes les ressources d’un Vcenter

mce-django-app

Application Django que vous pouvez ajouter à un projet Django existant ou utiliser à travers le projet mce-django-server.

mce-tasks-rq

Implémentation Python RQ du worker de gestion des tâches (alternative à Celery).

mce-django-server

Solution complète, intégrant les composants précédents dans un projet Django et prêt à l’emploi dans un docker-compose.

mce-event-push

Service d’envoi de message pour chaque changement dans l’inventaire.

Composants obsolètes

mce-tasks-djq

Implémentation Django-Q du worker de gestion des tâches (alternative à Celery).

Ne convenait pas aux besoins.

Démarrage Rapide

Installation avec docker-compose

git clone https://github.com/multi-cloud-explorer/mce-django-server.git
cd mce-django-server

docker-compose up -d

# Vérifiez l'état des services
docker-compose ps

# Créez le compte administrateur
docker-compose exec app ./manage.py createsuperuser \
   --username admin --email admin@localhost.net

# Récupérez le login/password de l'administrateur
docker-compose logs app --tail 10

Intégration à votre projet Django existant

TODO..

Evaluez la solution en toute sécurité

Intégration

Azure

TODO…

  • Créez un compte de service Principal

  • Test en ligne de commande

Status

Documentation status

mce-django-server

Travis mce-django-server Coveralls mce-django-server Codecov mce-django-server Requirements Status

mce-django-server

mce-django-app

Travis mce-django-app Coveralls mce-django-app Codecov mce-django-app Requirements Status

mce-django-app

mce-tasks-rq

Travis mce-tasks-rq Coveralls mce-tasks-rq Codecov mce-tasks-rq Requirements Status

mce-tasks-rq

mce-lib-azure

Travis mce-lib-azure Coveralls mce-lib-azure Codecov mce-lib-azure Requirements Status

mce-lib-azure

mce-lib-aws

Travis mce-lib-aws Coveralls mce-lib-aws Codecov mce-lib-aws Requirements Status

mce-lib-aws

mce-lib-vsphere

Travis mce-lib-vsphere Sonar mce-lib-vsphere Coveralls mce-lib-vsphere Codecov mce-lib-vsphere Requirements mce-lib-vsphere PyPI - Python Version Latest version on PyPI

mce-lib-vsphere

mce-event-push

Travis mce-event-push Coveralls mce-event-push Codecov mce-event-push Requirements Status

mce-event-push

Python 3 Updates

Microsoft Azure

Amazon AWS

mce_lib_vsphere package

mce_lib_vsphere.core module

PyVmomi package

pyVim.connect module

Connect to a VMOMI ServiceInstance.

Detailed description (for [e]pydoc goes here).

pyVim.connect.Connect(host='localhost', port=443, user='root', pwd='', service='hostd', adapter='SOAP', namespace=None, path='/sdk', connectionPoolTimeout=900, version=None, keyFile=None, certFile=None, thumbprint=None, sslContext=None, b64token=None, mechanism='userpass')[source]

Connect to the specified server, login and return the service instance object.

Throws any exception back to caller. The service instance object is also saved in the library for easy access.

Clients should modify the service parameter only when connecting to a VMOMI server other than hostd/vpxd. For both of the latter, the default value is fine.

@param host: Which host to connect to. @type host: string @param port: Port @type port: int @param user: User @type user: string @param pwd: Password @type pwd: string @param service: Service @type service: string @param adapter: Adapter @type adapter: string @param namespace: Namespace * Deprecated: Use version instead * @type namespace: string @param path: Path @type path: string @param connectionPoolTimeout: Timeout in secs for idle connections to close, specify negative numbers for never

closing the connections

@type connectionPoolTimeout: int @param version: Version @type version: string @param keyFile: ssl key file path @type keyFile: string @param certFile: ssl cert file path @type certFile: string @param thumbprint: host cert thumbprint @type thumbprint: string @param sslContext: SSL Context describing the various SSL options. It is only

supported in Python 2.7.9 or higher.

@type sslContext: SSL.Context @param b64token: base64 encoded token @type b64token: string @param mechanism: authentication mechanism: userpass or sspi @type mechanism: string

pyVim.connect.ConnectNoSSL(host='localhost', port=443, user='root', pwd='', service='hostd', adapter='SOAP', namespace=None, path='/sdk', version=None, keyFile=None, certFile=None, thumbprint=None, b64token=None, mechanism='userpass')[source]

Provides a standard method for connecting to a specified server without SSL verification. Useful when connecting to servers with self-signed certificates or when you wish to ignore SSL altogether. Will attempt to create an unverified SSL context and then connect via the Connect method.

class pyVim.connect.Connection(*args, **kwargs)[source]

Bases: object

pyVim.connect.Disconnect(si)[source]

Disconnect (logout) service instance @param si: Service instance (returned from Connect)

pyVim.connect.GetLocalTicket(si, user)[source]
pyVim.connect.GetSi()[source]

Get the saved service instance.

pyVim.connect.GetStub()[source]

Get the global saved stub.

pyVim.connect.OpenPathWithStub(path, stub, verify=True)[source]

Open the specified path using HTTP, using the host/port/protocol associated with the specified stub. If the stub has a session cookie, it is included with the HTTP request. Returns the response as a file-like object.

pyVim.connect.OpenUrlWithBasicAuth(url, user='root', pwd='', verify=True)[source]

Open the specified URL, using HTTP basic authentication to provide the specified credentials to the server as part of the request. Returns the response as a file-like object.

pyVim.connect.SetSi(si)[source]

Set the saved service instance.

pyVim.connect.SmartConnect(protocol='https', host='localhost', port=443, user='root', pwd='', service='hostd', path='/sdk', connectionPoolTimeout=900, preferredApiVersions=None, keyFile=None, certFile=None, thumbprint=None, sslContext=None, b64token=None, mechanism='userpass')[source]

Determine the most preferred API version supported by the specified server, then connect to the specified server using that API version, login and return the service instance object.

Throws any exception back to caller. The service instance object is also saved in the library for easy access.

Clients should modify the service parameter only when connecting to a VMOMI server other than hostd/vpxd. For both of the latter, the default value is fine.

@param protocol: What protocol to use for the connection (e.g. https or http). @type protocol: string @param host: Which host to connect to. @type host: string @param port: Port @type port: int @param user: User @type user: string @param pwd: Password @type pwd: string @param service: Service @type service: string @param path: Path @type path: string @param connectionPoolTimeout: Timeout in secs for idle connections to close, specify negative numbers for never

closing the connections

@type connectionPoolTimeout: int @param preferredApiVersions: Acceptable API version(s) (e.g. vim.version.version3)

If a list of versions is specified the versions should be ordered from most to least preferred. If None is specified, the list of versions support by pyVmomi will be used.

@type preferredApiVersions: string or string list @param keyFile: ssl key file path @type keyFile: string @param certFile: ssl cert file path @type certFile: string @param thumbprint: host cert thumbprint @type thumbprint: string @param sslContext: SSL Context describing the various SSL options. It is only

supported in Python 2.7.9 or higher.

@type sslContext: SSL.Context

pyVim.connect.SmartConnectNoSSL(protocol='https', host='localhost', port=443, user='root', pwd='', service='hostd', path='/sdk', connectionPoolTimeout=900, preferredApiVersions=None, keyFile=None, certFile=None, thumbprint=None, b64token=None, mechanism='userpass')[source]

Provides a standard method for connecting to a specified server without SSL verification. Useful when connecting to servers with self-signed certificates or when you wish to ignore SSL altogether. Will attempt to create an unverified SSL context and then connect via the SmartConnect method.

class pyVim.connect.SmartConnection(*args, **kwargs)[source]

Bases: object

pyVim.connect.SmartStubAdapter(host='localhost', port=443, path='/sdk', url=None, sock=None, poolSize=5, certFile=None, certKeyFile=None, httpProxyHost=None, httpProxyPort=80, sslProxyPath=None, thumbprint=None, cacertsFile=None, preferredApiVersions=None, acceptCompressedResponses=True, connectionPoolTimeout=900, samlToken=None, sslContext=None)[source]

Determine the most preferred API version supported by the specified server, then create a soap stub adapter using that version

The parameters are the same as for pyVmomi.SoapStubAdapter except for version which is renamed to prefferedApiVersions

@param preferredApiVersions: Acceptable API version(s) (e.g. vim.version.version3)

If a list of versions is specified the versions should be ordered from most to least preferred. If None is specified, the list of versions support by pyVmomi will be used.

@type preferredApiVersions: string or string list

class pyVim.connect.VimSessionOrientedStub(soapStub, loginMethod, retryDelay=0.1, retryCount=4)[source]

Bases: pyVmomi.SoapAdapter.SessionOrientedStub

A vim-specific SessionOrientedStub. See the SessionOrientedStub class in pyVmomi/SoapAdapter.py for more information.

SESSION_EXCEPTIONS = (<class 'pyVmomi.VmomiSupport.vim.fault.NotAuthenticated'>,)
static makeCertHokTokenLoginMethod(stsUrl, stsCert=None)[source]

Return a function that will call the vim.SessionManager.LoginByToken() after obtaining a HoK SAML token from the STS. The result of this function can be passed as the “loginMethod” to a SessionOrientedStub constructor.

@param stsUrl: URL of the SAML Token issuing service. (i.e. SSO server). @param stsCert: public key of the STS service.

static makeCredBearerTokenLoginMethod(username, password, stsUrl, stsCert=None)[source]

Return a function that will call the vim.SessionManager.LoginByToken() after obtaining a Bearer token from the STS. The result of this function can be passed as the “loginMethod” to a SessionOrientedStub constructor.

@param username: username of the user/service registered with STS. @param password: password of the user/service registered with STS. @param stsUrl: URL of the SAML Token issueing service. (i.e. SSO server). @param stsCert: public key of the STS service.

static makeExtensionLoginMethod(extensionKey)[source]

Return a function that will call the vim.SessionManager.Login() method with the given parameters. The result of this function can be passed as the “loginMethod” to a SessionOrientedStub constructor.

static makeUserLoginMethod(username, password, locale=None)[source]

Return a function that will call the vim.SessionManager.Login() method with the given parameters. The result of this function can be passed as the “loginMethod” to a SessionOrientedStub constructor.

class pyVim.connect.closing(obj)[source]

Bases: object

Helper class for using closable objects in a ‘with’ statement, similar to the one provided by contextlib.

pyVim.connect.localSslFixup(host, sslContext)[source]

Connections to ‘localhost’ do not need SSL verification as a certificate will never match. The OS provides security by only allowing root to bind to low-numbered ports.

pyVmomi.VmomiSupport module

pyVmomi.VmomiSupport.AddBreakingChangesInfo(branchName, vmodlNamespace, count)[source]
pyVmomi.VmomiSupport.AddVersionParent(version, parent)[source]
class pyVmomi.VmomiSupport.Array[source]

Bases: list

pyVmomi.VmomiSupport.Capitalize(str)[source]
pyVmomi.VmomiSupport.CheckField(info, val)[source]
pyVmomi.VmomiSupport.CreateAndLoadDataType(vmodlName, wsdlName, parent, version, props)[source]
pyVmomi.VmomiSupport.CreateAndLoadEnumType(vmodlName, wsdlName, version, values)[source]
pyVmomi.VmomiSupport.CreateAndLoadManagedType(vmodlName, wsdlName, parent, version, props, methods)[source]
pyVmomi.VmomiSupport.CreateAndLoadMethodFaultType()[source]
pyVmomi.VmomiSupport.CreateArrayType(itemType)[source]
pyVmomi.VmomiSupport.CreateDataType(vmodlName, wsdlName, parent, version, props)[source]
pyVmomi.VmomiSupport.CreateEnumType(vmodlName, wsdlName, version, values)[source]
pyVmomi.VmomiSupport.CreateManagedType(vmodlName, wsdlName, parent, version, props, methods)[source]
class pyVmomi.VmomiSupport.Curry(f, *args)[source]

Bases: object

class pyVmomi.VmomiSupport.DataObject(**kwargs)[source]

Bases: object

Array

alias of DataObject[]

class pyVmomi.VmomiSupport.Enum[source]

Bases: str

pyVmomi.VmomiSupport.FinalizeType(type)[source]
pyVmomi.VmomiSupport.FormatObject(val, info=<pyVmomi.VmomiSupport.Object object>, indent=0)[source]
pyVmomi.VmomiSupport.GetBreakingChanges()[source]
pyVmomi.VmomiSupport.GetCompatibleType(type, version)[source]
pyVmomi.VmomiSupport.GetHttpContext()[source]

Get the Http context for the current thread

pyVmomi.VmomiSupport.GetPropertyInfo(type, name)[source]
pyVmomi.VmomiSupport.GetPythonMethodName(wsdlTypeName, ns, wsdlMethodName)[source]
pyVmomi.VmomiSupport.GetPythonTypeName(wsdlTypeName, ns)[source]
pyVmomi.VmomiSupport.GetQualifiedWsdlName(type)[source]
pyVmomi.VmomiSupport.GetRequestContext()[source]

Get the RequestContext for the current thread

pyVmomi.VmomiSupport.GetServiceVersions(namespace)[source]

Get all the versions for the service with specified namespace (partially) ordered by compatibility (i.e. any version in the list that is compatible with some version v in the list will preceed v)

pyVmomi.VmomiSupport.GetVersionFromVersionUri(version)[source]
pyVmomi.VmomiSupport.GetVersionNamespace(version)[source]

Get version namespace from version

pyVmomi.VmomiSupport.GetVersionParents(version)[source]
pyVmomi.VmomiSupport.GetVersionProps(version)[source]

Get version properties

This function is a fixed version of GetVersion().

pyVmomi.VmomiSupport.GetVmodlName(typ)[source]

Get vmodl type name from type

pyVmomi.VmomiSupport.GetVmodlNs(version)[source]
pyVmomi.VmomiSupport.GetVmodlType(name)[source]

Get type from vmodl name

pyVmomi.VmomiSupport.GetWsdlMethod(ns, wsdlName)[source]

Get wsdl method from ns, wsdlName

pyVmomi.VmomiSupport.GetWsdlMethodName(pythonTypeName, pythonMethodName)[source]
pyVmomi.VmomiSupport.GetWsdlName(type)[source]
pyVmomi.VmomiSupport.GetWsdlNamespace(version)[source]

Get wsdl namespace from version

pyVmomi.VmomiSupport.GetWsdlType(ns, name)[source]
pyVmomi.VmomiSupport.GetWsdlTypeName(pythonTypeName)[source]
pyVmomi.VmomiSupport.GetWsdlTypes()[source]
pyVmomi.VmomiSupport.GuessWsdlMethod(name)[source]
pyVmomi.VmomiSupport.GuessWsdlType(name)[source]
pyVmomi.VmomiSupport.InverseMap(map)[source]
class pyVmomi.VmomiSupport.LazyModule(name)[source]

Bases: object

class pyVmomi.VmomiSupport.LazyObject(**kwargs)[source]

Bases: pyVmomi.VmomiSupport.Object

class pyVmomi.VmomiSupport.LazyType[source]

Bases: type

Bases: str

class pyVmomi.VmomiSupport.LinkResolver(scope)[source]

Bases: object

pyVmomi.VmomiSupport.LoadDataType(vmodlName, wsdlName, parent, version, props)[source]
pyVmomi.VmomiSupport.LoadEnumType(vmodlName, wsdlName, version, values)[source]
pyVmomi.VmomiSupport.LoadManagedType(vmodlName, wsdlName, parent, version, props, methods)[source]
class pyVmomi.VmomiSupport.ManagedMethod(info)[source]

Bases: pyVmomi.VmomiSupport.Curry

class pyVmomi.VmomiSupport.ManagedObject(moId, stub=None, serverGuid=None)[source]

Bases: object

Array

alias of ManagedObject[]

class pyVmomi.VmomiSupport.Object(**kwargs)[source]

Bases: object

class pyVmomi.VmomiSupport.PropertyPath

Bases: str

pyVmomi.VmomiSupport.SetAttr()

Implement setattr(self, name, value).

class pyVmomi.VmomiSupport.StringDict(*args, **kwargs)[source]

Bases: dict

String only dictionary: same as dict, except it only accept string as value

dict in python is kind of strange. U cannot just override __setitem__, as __init__, update, and setdefault all bypass __setitem__. When override, we have to override all three together

setdefault(key, val=None)[source]

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) → None. Update D from dict/iterable E and F.[source]

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

pyVmomi.VmomiSupport.Type(obj)[source]
pyVmomi.VmomiSupport.TypeDefExists(name)[source]
class pyVmomi.VmomiSupport.URI

Bases: str

class pyVmomi.VmomiSupport.UncallableManagedMethod(name)[source]

Bases: pyVmomi.VmomiSupport.ManagedMethod

pyVmomi.VmomiSupport.Uncapitalize(str)[source]
pyVmomi.VmomiSupport.UncapitalizeVmodlName(str)[source]
exception pyVmomi.VmomiSupport.UnknownWsdlTypeError[source]

Bases: KeyError

class pyVmomi.VmomiSupport.VmomiJSONEncoder(*args, **kwargs)[source]

Bases: json.encoder.JSONEncoder

Custom JSON encoder to encode vSphere objects.

When a ManagedObject is encoded, it gains three properties:

_vimid is the _moId (ex: ‘vm-42’) _vimref is the moRef (ex: ‘vim.VirtualMachine:vm-42’) _vimtype is the class name (ex: ‘vim.VirtualMachine’)

When a DataObject is encoded, it gains one property:

_vimtype is the class name (ex: ‘vim.VirtualMachineQuestionInfo’)

If the dynamicProperty and dynamicType are empty, they are optionally

omitted from the results of DataObjects and ManagedObjects

@example “Explode only the object passed in”

data = json.dumps(vm, cls=VmomiJSONEncoder)

@example “Explode specific objects”
data = json.dumps(vm, cls=VmomiJSONEncoder,

explode=[vm, vm.network[0]])

@example “Explode all virtual machines in a list and their snapshots”
data = json.dumps([vm1, vm2], cls=VmomiJSONEncoder,
explode=[templateOf(‘VirtualMachine’),

templateOf(‘VirtualMachineSnapshot’)])

default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
explode(obj)[source]

Determine if the object should be exploded.

pyVmomi.VmomiSupport.arrayType

alias of pyVmomi.VmomiSupport.PropertyPath[]

class pyVmomi.VmomiSupport.binary

Bases: bytes

class pyVmomi.VmomiSupport.byte

Bases: int

class pyVmomi.VmomiSupport.double

Bases: float

class pyVmomi.VmomiSupport.long

Bases: int

class pyVmomi.VmomiSupport.short

Bases: int

pyVmomi.VmomiSupport.templateOf(typestr)[source]

Returns a class template.

vim.VirtualMachine class

Fonctionnalités

  • [x] Inventaire automatique des resources

  • [x] Historisation des changements au format Json Patch

  • [ ] Push des évènements vers une queue de donnée ou un WebHook

Providers

  • [x] Azure

  • [ ] AWS

  • [ ] GCP

  • [ ] VMware

Indices and tables