def retrieve(): instances = [] for paas in ApiPaas.list({'state': 'running', 'sort_by': 'name'}): paas['vhosts'] = vhosts = ApiVhost.list({'paas_id': paas['id']}) instances.append(paas) return instances
def from_vhost(cls, vhost): """Retrieve paas instance id associated to a vhost.""" result = Vhost().list() paas_hosts = {} for host in result: paas_hosts[host['name']] = host['paas_id'] return paas_hosts.get(vhost)
def init_conf(cls, id, vhost=None, created=True, vhosts=None, background=False): """ Initialize local configuration with PaaS information. """ paas = Paas.info(cls.usable_id(id)) cls.debug('save PaaS instance information to local configuration') if vhost and not vhosts: vhosts = [vhost] if not vhosts: if 'php' not in paas['type']: vhost = 'default' elif paas['vhosts']: vhosts = [vht['name'] for vht in paas['vhosts']] else: return for vhost in vhosts: Vhost.create(paas, vhost, True, background)
def create(cls, name, size, type, quantity, duration, datacenter, vhosts, password, snapshot_profile, background, sshkey): """Create a new PaaS instance.""" if not background and not cls.intty(): background = True datacenter_id_ = int(Datacenter.usable_id(datacenter)) paas_params = { 'name': name, 'size': size, 'type': type, 'duration': duration, 'datacenter_id': datacenter_id_, } if password: paas_params['password'] = password if quantity: paas_params['quantity'] = quantity paas_params.update(cls.convert_sshkey(sshkey)) if snapshot_profile: paas_params['snapshot_profile'] = snapshot_profile result = cls.call('paas.create', paas_params) if not background: # interactive mode, run a progress bar cls.echo('Creating your PaaS instance.') cls.display_progress(result) cls.echo('Your PaaS instance %s has been created.' % name) if vhosts: paas_info = cls.info(name) Vhost.create(paas_info, vhosts, True, background) return result