Revision d328a525

b/Changelog
41 41
* Compute quotas for CPU and memory of running vms.
42 42
* Obsolete PUBLIC_USE_POOL setting, since Cyclades manages IP pool for all
43 43
  type of networks.
44
* Extend servers info API respones with 'SNF:fqdn' attribute, and introduce
45
  CYCLADES_SERVERS_FQDN to set the template for servers FDQN.
44 46

  
45 47
Pithos
46 48
------
b/snf-cyclades-app/conf/20-snf-cyclades-app-api.conf
107 107

  
108 108
# Tune the size of the http connection pool to astakos.
109 109
#CYCLADES_ASTAKOSCLIENT_POOLSIZE = 50
110
#
111
## Template to use to build the FQDN of VMs. The setting will be formated with
112
## the id of the VM. If set to 'None' the first public IPv4 or IPv6 address
113
## of the VM will be used.
114
#CYCLADES_SERVERS_FQDN = 'snf-%(id)s.vm.example.synnefo.org'
b/snf-cyclades-app/synnefo/api/servers.py
170 170
        d["config_drive"] = ""
171 171
        d["accessIPv4"] = ""
172 172
        d["accessIPv6"] = ""
173
        d["SNF:fqdn"] = get_server_fqdn(vm)
173 174

  
174 175
    return d
175 176

  
176 177

  
178
def get_server_fqdn(vm):
179
    fqdn_setting = settings.CYCLADES_SERVERS_FQDN
180
    if fqdn_setting is None:
181
        public_nics = vm.nics.filter(network__public=True, state="ACTIVE")
182
        # Return the first public IPv4 address if exists
183
        ipv4_nics = public_nics.exclude(ipv4=None)
184
        if ipv4_nics:
185
            return ipv4_nics[0].ipv4
186
        # Else return the first public IPv6 address if exists
187
        ipv6_nics = public_nics.exclude(ipv6=None)
188
        if ipv6_nics:
189
            return ipv6_nics[0].ipv6
190
        return ""
191
    elif isinstance(fqdn_setting, basestring):
192
        return fqdn_setting % {"id": vm.id}
193
    else:
194
        msg = ("Invalid setting: CYCLADES_SERVERS_FQDN."
195
               " Value must be a string.")
196
        raise faults.InternalServerError(msg)
197

  
198

  
177 199
def diagnostics_to_dict(diagnostics):
178 200
    """
179 201
    Extract api data from diagnostics QuerySet.
b/snf-cyclades-app/synnefo/app_settings/default/api.py
107 107
# endpoints. Set this to False if you deploy cyclades-app/astakos-app on the
108 108
# same machine.
109 109
CYCLADES_PROXY_USER_SERVICES = True
110

  
111
# Template to use to build the FQDN of VMs. The setting will be formated with
112
# the id of the VM. If set to 'None' the first public IPv4 or IPv6 address
113
# of the VM will be used.
114
CYCLADES_SERVERS_FQDN = 'snf-%(id)s.vm.example.synnefo.org'

Also available in: Unified diff