Beispiel #1
0
class Machine(OODict):
    """A saved machine in the machines list of some backend.

    For the time being, only bare metal machines are saved, for API backends
    we get the machine list from the provider.

    """

    ## hasMonitoring = BoolField()
    uuid = StrField()
    ## monitor_server = make_field(MonitorServer)()
    dns_name = HtmlSafeStrField()
    public_ips = ListField()
    ## collectd_password = StrField()
    name = HtmlSafeStrField()
    ssh_port = IntField(22)
Beispiel #2
0
class Backend(OODict):
    """A cloud vm provider backend"""

    enabled = BoolField()
    machine_count = IntField()
    apiurl = StrField()
    apikey = HtmlSafeStrField()
    apisecret = StrField()
    title = HtmlSafeStrField()
    tenant_name = HtmlSafeStrField()
    auth_version = HtmlSafeStrField()
    region = HtmlSafeStrField()
    poll_interval = IntField(10000)
    provider = HtmlSafeStrField()
    ## datacenter = StrField()
    compute_endpoint = StrField()
    docker_port = IntField(4243)
    machines = make_field(Machines)()
    starred = ListField()
    unstarred = ListField()

    def __repr__(self):
        print_fields = ['title', 'provider', 'region']
        return super(Backend, self).__repr__(print_fields)

    def get_id(self):
        from mist.io.helpers import b58_encode
        if self.provider == 'docker':
            concat = '%s%s%s' % (self.provider, self.title, self.apiurl)
        elif self.provider == 'bare_metal':
            name = self.machines.values()[0].name
            concat = '%s%s%s' % (self.provider, '', name)
        else:
            concat = '%s%s%s' % (self.provider, self.region, self.apikey)
        return b58_encode(int(sha1(concat).hexdigest(), 16))
Beispiel #3
0
class Cloud(OODict):
    """A cloud vm provider cloud"""

    enabled = BoolField()
    machine_count = IntField()
    apiurl = StrField()
    apikey = HtmlSafeStrField()
    apisecret = StrField()
    title = HtmlSafeStrField()
    tenant_name = HtmlSafeStrField()
    auth_version = HtmlSafeStrField()
    region = HtmlSafeStrField()
    poll_interval = IntField(10000)
    provider = HtmlSafeStrField()
    ## datacenter = StrField()
    compute_endpoint = StrField()
    key_file = StrField()
    cert_file = StrField()
    ca_cert_file = StrField()
    ssh_port = IntField(22)
    docker_port = IntField(4243)
    machines = make_field(Machines)()
    starred = ListField()
    unstarred = ListField()
    images_location = StrField()

    def __repr__(self):
        print_fields = ['title', 'provider', 'region']
        return super(Cloud, self).__repr__(print_fields)

    def get_id(self):
        from mist.io.helpers import b58_encode
        if self.provider == 'docker':
            concat = '%s%s%s' % (self.provider, self.title, self.apiurl)
        elif self.provider in ['bare_metal', 'coreos']:
            name = self.machines.values()[0].name
            concat = '%s%s%s' % (self.provider, '', name)
        elif self.provider == 'openstack' or 'hpcloud' in self.provider:
            concat = "%s%s%s%s%s" % (self.provider, self.region, self.apikey,
                                     self.apiurl, self.tenant_name)
        elif self.provider == 'libvirt':
            concat = "%s%s" % (self.provider, self.apiurl)
        elif self.provider in ['vcloud', 'indonesian_vcloud', 'vsphere']:
            concat = "%s%s%s%s" % (self.provider, self.apikey, self.apisecret,
                                   self.apiurl)
        else:
            concat = '%s%s%s' % (self.provider, self.region, self.apikey)
        return b58_encode(int(sha1(concat).hexdigest(), 16))