2017-12-15 21:39:18 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import { computed } from '@ember/object';
|
2021-02-17 21:01:44 +00:00
|
|
|
import Model from '@ember-data/model';
|
|
|
|
import { attr } from '@ember-data/model';
|
2020-06-10 13:49:16 +00:00
|
|
|
import classic from 'ember-classic-decorator';
|
2021-05-13 17:29:51 +00:00
|
|
|
import formatHost from 'nomad-ui/utils/format-host';
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@classic
|
|
|
|
export default class Agent extends Model {
|
|
|
|
@service system;
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@attr('string') name;
|
|
|
|
@attr('string') address;
|
|
|
|
@attr('string') serfPort;
|
|
|
|
@attr('string') rpcPort;
|
|
|
|
@attr({ defaultValue: () => ({}) }) tags;
|
|
|
|
@attr('string') status;
|
|
|
|
@attr('string') datacenter;
|
|
|
|
@attr('string') region;
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@computed('address', 'port')
|
|
|
|
get rpcAddr() {
|
2019-03-26 07:46:44 +00:00
|
|
|
const { address, rpcPort } = this;
|
2021-05-13 17:29:51 +00:00
|
|
|
return formatHost(address, rpcPort);
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2021-02-17 21:01:44 +00:00
|
|
|
@computed('rpcAddr', 'system.leader.rpcAddr')
|
2020-06-10 13:49:16 +00:00
|
|
|
get isLeader() {
|
2019-03-26 07:46:44 +00:00
|
|
|
return this.get('system.leader.rpcAddr') === this.rpcAddr;
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2021-10-22 14:33:06 +00:00
|
|
|
|
|
|
|
@computed('tags.build')
|
|
|
|
get version() {
|
|
|
|
return this.tags?.build || '';
|
|
|
|
}
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|