Merge pull request #257 from vatesfr/julien-f-remove-unnecessary-await

Remove unnecessary `await`s.
This commit is contained in:
Julien Fontanet 2016-03-03 12:28:50 +01:00
commit 2d791571d5
22 changed files with 46 additions and 46 deletions

View File

@ -1,5 +1,5 @@
export async function get () {
return await this.getAllAcls()
return /* await */ this.getAllAcls()
}
get.permission = 'admin'
@ -9,7 +9,7 @@ get.description = 'get existing ACLs'
// -------------------------------------------------------------------
export async function getCurrentPermissions () {
return await this.getPermissionsForUser(this.session.get('user_id'))
return /* await */ this.getPermissionsForUser(this.session.get('user_id'))
}
getCurrentPermissions.permission = ''

View File

@ -27,7 +27,7 @@ delete_.params = {
// -------------------------------------------------------------------
export async function getAll () {
return await this.getAllGroups()
return /* await */ this.getAllGroups()
}
getAll.description = 'returns all the existing group'

View File

@ -1,14 +1,14 @@
// FIXME so far, no acls for jobs
export async function getAll () {
return await this.getAllJobs()
return /* await */ this.getAllJobs()
}
getAll.permission = 'admin'
getAll.description = 'Gets all available jobs'
export async function get (id) {
return await this.getJob(id)
return /* await */ this.getJob(id)
}
get.permission = 'admin'

View File

@ -1,5 +1,5 @@
export async function get () {
return await this.getPlugins()
return /* await */ this.getPlugins()
}
get.description = 'returns a list of all installed plugins'

View File

@ -1,12 +1,12 @@
export async function getAll () {
return await this.getAllRemotes()
return /* await */ this.getAllRemotes()
}
getAll.permission = 'admin'
getAll.description = 'Gets all existing fs remote points'
export async function get ({id}) {
return await this.getRemote(id)
return /* await */ this.getRemote(id)
}
get.permission = 'admin'
@ -16,7 +16,7 @@ get.params = {
}
export async function list ({id}) {
return await this.listRemoteBackups(id)
return /* await */ this.listRemoteBackups(id)
}
list.permission = 'admin'
@ -26,7 +26,7 @@ list.params = {
}
export async function create ({name, url}) {
return await this.createRemote({name, url})
return /* await */ this.createRemote({name, url})
}
create.permission = 'admin'

View File

@ -1,3 +1,3 @@
export async function getAll () {
return await this.getRoles()
return /* await */ this.getRoles()
}

View File

@ -1,14 +1,14 @@
// FIXME so far, no acls for schedules
export async function getAll () {
return await this.getAllSchedules()
return /* await */ this.getAllSchedules()
}
getAll.permission = 'admin'
getAll.description = 'Gets all existing schedules'
export async function get (id) {
return await this.getSchedule(id)
return /* await */ this.getSchedule(id)
}
get.permission = 'admin'
@ -18,7 +18,7 @@ get.params = {
}
export async function create ({jobId, cron, enabled, name}) {
return await this.createSchedule(this.session.get('user_id'), {job: jobId, cron, enabled, name})
return /* await */ this.createSchedule(this.session.get('user_id'), {job: jobId, cron, enabled, name})
}
create.permission = 'admin'

View File

@ -84,7 +84,7 @@ export default class Collection extends EventEmitter {
: {}
}
return await this._get(properties)
return /* await */ this._get(properties)
}
async remove (ids) {

View File

@ -29,7 +29,7 @@ export class Groups extends Collection {
// Serializes.
group.users = JSON.stringify(group.users)
return await this.update(group)
return /* await */ this.update(group)
}
async get (properties) {

View File

@ -19,13 +19,13 @@ export class Jobs extends Collection {
job.userId = userId
// Serializes.
job.paramsVector = JSON.stringify(job.paramsVector)
return await this.add(new Job(job))
return /* await */ this.add(new Job(job))
}
async save (job) {
// Serializes.
job.paramsVector = JSON.stringify(job.paramsVector)
return await this.update(job)
return /* await */ this.update(job)
}
async get (properties) {

View File

@ -18,7 +18,7 @@ export class PluginsMetadata extends Collection {
}
async save ({ id, autoload, configuration }) {
return await this.update({
return /* await */ this.update({
id,
autoload: autoload ? 'true' : 'false',
configuration: configuration && JSON.stringify(configuration)
@ -31,7 +31,7 @@ export class PluginsMetadata extends Collection {
throw new Error('no such plugin metadata')
}
return await this.save({
return /* await */ this.save({
...pluginMetadata.properties,
...data
})

View File

@ -27,7 +27,7 @@ export class Remotes extends Collection {
}
async save (remote) {
return await this.update(remote)
return /* await */ this.update(remote)
}
async get (properties) {

View File

@ -26,7 +26,7 @@ export class Schedules extends Collection {
}
async save (schedule) {
return await this.update(schedule)
return /* await */ this.update(schedule)
}
async get (properties) {

View File

@ -17,6 +17,6 @@ export class Servers extends Collection {
throw new Error('server already exists')
}
return await this.add({host, username, password, readOnly})
return /* await */ this.add({host, username, password, readOnly})
}
}

View File

@ -30,14 +30,14 @@ export class Users extends Collection {
const user = new User(properties)
// Adds the user to the collection.
return await this.add(user)
return /* await */ this.add(user)
}
async save (user) {
// Serializes.
user.groups = JSON.stringify(user.groups)
return await this.update(user)
return /* await */ this.update(user)
}
async get (properties) {

View File

@ -677,7 +677,7 @@ export default class Xapi extends XapiBase {
}
async installPoolPatchOnHost (patchUuid, hostId) {
return await this._installPoolPatchOnHost(
return /* await */ this._installPoolPatchOnHost(
patchUuid,
this.getObject(hostId)
)
@ -835,7 +835,7 @@ export default class Xapi extends XapiBase {
}`)
try {
return await this.call(
return /* await */ this.call(
'VM.copy',
snapshotRef || vm.$ref,
nameLabel,
@ -889,13 +889,13 @@ export default class Xapi extends XapiBase {
: this._copyVm(vm, nameLabel)
)
return await this._getOrWaitObject(cloneRef)
return /* await */ this._getOrWaitObject(cloneRef)
}
async copyVm (vmId, srId, {
nameLabel = undefined
} = {}) {
return await this._getOrWaitObject(
return /* await */ this._getOrWaitObject(
await this._copyVm(
this.getObject(vmId),
nameLabel,
@ -1230,7 +1230,7 @@ export default class Xapi extends XapiBase {
}
async deleteVm (vmId, deleteDisks = false) {
return await this._deleteVm(
return /* await */ this._deleteVm(
this.getObject(vmId),
deleteDisks
)
@ -1632,7 +1632,7 @@ export default class Xapi extends XapiBase {
onlyMetadata = false,
srId
} = {}) {
return await this._getOrWaitObject(await this._importVm(
return /* await */ this._getOrWaitObject(await this._importVm(
stream,
srId && this.getObject(srId),
onlyMetadata
@ -1680,7 +1680,7 @@ export default class Xapi extends XapiBase {
}
async snapshotVm (vmId, nameLabel = undefined) {
return await this._getOrWaitObject(
return /* await */ this._getOrWaitObject(
await this._snapshotVm(
this.getObject(vmId),
nameLabel
@ -1896,7 +1896,7 @@ export default class Xapi extends XapiBase {
data.xenstore_data = xenstore_data
}
return await this.call('VDI.create', data)
return /* await */ this.call('VDI.create', data)
}
async moveVdi (vdiId, srId) {
@ -2030,7 +2030,7 @@ export default class Xapi extends XapiBase {
}
async createVdi (size, opts) {
return await this._getOrWaitObject(
return /* await */ this._getOrWaitObject(
await this._createVdi(size, opts)
)
}
@ -2206,7 +2206,7 @@ export default class Xapi extends XapiBase {
}
async createVif (vmId, networkId, opts = undefined) {
return await this._getOrWaitObject(
return /* await */ this._getOrWaitObject(
await this._createVif(
this.getObject(vmId),
this.getObject(networkId),
@ -2225,7 +2225,7 @@ export default class Xapi extends XapiBase {
const vm = this.getObject(vmId)
const host = vm.$resident_on || this.pool.$master
return await this.call('host.call_plugin', host.$ref, 'xscontainer', action, {
return /* await */ this.call('host.call_plugin', host.$ref, 'xscontainer', action, {
vmuuid: vm.uuid,
container: containerId
})

View File

@ -180,7 +180,7 @@ export default class {
const getPath = (file, dir) => dir ? `${dir}/${file}` : file
await Promise.all(
mapToArray(backups.slice(0, n), async backup => await handler.unlink(getPath(backup, dir)))
mapToArray(backups.slice(0, n), async backup => /* await */ handler.unlink(getPath(backup, dir)))
)
}
@ -214,7 +214,7 @@ export default class {
// Import vm metadata.
const vm = await (async () => {
const stream = await handler.createReadStream(`${filePath}.xva`)
return await xapi.importVm(stream, { onlyMetadata: true })
return /* await */ xapi.importVm(stream, { onlyMetadata: true })
})()
const vmName = vm.name_label
@ -431,7 +431,7 @@ export default class {
async _listDeltaVmBackups (handler, dir) {
const files = await handler.list(dir)
return await sortBy(filter(files, isDeltaBackup))
return /* await */ sortBy(filter(files, isDeltaBackup))
}
async _failedRollingDeltaVmBackup (xapi, handler, dir, fulFilledVdiBackups) {

View File

@ -26,7 +26,7 @@ export default class {
}
async getAllJobs () {
return await this._jobs.get()
return /* await */ this._jobs.get()
}
async getJob (id) {
@ -45,11 +45,11 @@ export default class {
}
async updateJob (job) {
return await this._jobs.save(job)
return /* await */ this._jobs.save(job)
}
async removeJob (id) {
return await this._jobs.remove(id)
return /* await */ this._jobs.remove(id)
}
async runJobSequence (idSequence) {

View File

@ -122,7 +122,7 @@ export default class {
}
async getPlugins () {
return await Promise.all(
return /* await */ Promise.all(
mapToArray(this._plugins, ({ id }) => this._getPlugin(id))
)
}

View File

@ -71,7 +71,7 @@ export default class {
async createRemote ({name, url}) {
let remote = await this._remotes.create(name, url)
return await this.updateRemote(remote.get('id'), {enabled: true})
return /* await */ this.updateRemote(remote.get('id'), {enabled: true})
}
async updateRemote (id, {name, url, enabled, error}) {

View File

@ -134,7 +134,7 @@ export default class {
}
async getAllSchedules () {
return await this._redisSchedules.get()
return /* await */ this._redisSchedules.get()
}
async createSchedule (userId, {job, cron, enabled, name}) {

View File

@ -184,7 +184,7 @@ export default class {
throw new Error(`registering ${name} user is forbidden`)
}
return await this.createUser(name, {
return /* await */ this.createUser(name, {
_provider: provider
})
}