Skip to content

Commit a45bd6f

Browse files
committed
wip
1 parent 07cc4c8 commit a45bd6f

File tree

7 files changed

+44
-5
lines changed

7 files changed

+44
-5
lines changed

packages/xen-api/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export class Xapi extends EventEmitter {
115115
}
116116

117117
this._allowUnauthorized = opts.allowUnauthorized
118+
this._httpProxy = opts.httpProxy
118119
this._setUrl(url)
119120

120121
this._connected = new Promise(resolve => {
@@ -851,6 +852,7 @@ export class Xapi extends EventEmitter {
851852
rejectUnauthorized: !this._allowUnauthorized,
852853
},
853854
url,
855+
httpProxy: this._httpProxy,
854856
})
855857
this._url = url
856858
}

packages/xen-api/src/transports/json-rpc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import httpRequestPlus from 'http-request-plus'
2+
import ProxyAgent from 'proxy-agent'
23
import { format, parse } from 'json-rpc-protocol'
34

45
import XapiError from '../_XapiError'
56

67
import UnsupportedTransport from './_UnsupportedTransport'
78

89
// https://github.com/xenserver/xenadmin/blob/0df39a9d83cd82713f32d24704852a0fd57b8a64/XenModel/XenAPI/Session.cs#L403-L433
9-
export default ({ secureOptions, url }) => {
10+
export default ({ secureOptions, url, httpProxy }) => {
11+
// httpProxyUrl = 'http://172.16.210.156:3128'
12+
if (httpProxy) {
13+
secureOptions.agent = new ProxyAgent(httpProxy)
14+
}
1015
return (method, args) =>
1116
httpRequestPlus
1217
.post(url, {

packages/xo-server/src/api/server.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ add.params = {
3636
optional: true,
3737
type: 'boolean',
3838
},
39+
httpProxy: {
40+
optional: true,
41+
type: 'string',
42+
},
3943
}
4044

4145
// -------------------------------------------------------------------
@@ -104,6 +108,10 @@ set.params = {
104108
optional: true,
105109
type: 'boolean',
106110
},
111+
httpProxy: {
112+
optional: true,
113+
type: 'string',
114+
},
107115
}
108116

109117
// -------------------------------------------------------------------

packages/xo-server/src/xo-mixins/xen-servers.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ export default class {
288288
readOnly: server.readOnly,
289289

290290
...config.get('xapiOptions'),
291+
httpProxy: server.httpProxy,
291292
guessVhdSizeOnImport: config.get('guessVhdSizeOnImport'),
292293

293294
auth: {

packages/xo-web/src/common/intl/messages.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,6 +1821,8 @@ const messages = {
18211821
serverEnabled: 'Enabled',
18221822
serverDisabled: 'Disabled',
18231823
serverDisable: 'Disable server',
1824+
serverHttpProxy: ' Http proxy Url',
1825+
serverHttpProxyPlaceHolder: ' Http proxy Url',
18241826

18251827
// ----- Copy VM -----
18261828
copyVm: 'Copy VM',

packages/xo-web/src/common/xo/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,13 +558,14 @@ export const exportConfig = () =>
558558

559559
// Server ------------------------------------------------------------
560560

561-
export const addServer = (host, username, password, label, allowUnauthorized) =>
561+
export const addServer = (host, username, password, label, allowUnauthorized, httpProxy) =>
562562
_call('server.add', {
563563
allowUnauthorized,
564564
host,
565565
label,
566566
password,
567567
username,
568+
httpProxy,
568569
})::tap(subscribeServers.forceRefresh, () => error(_('serverError'), _('serverAddFailed')))
569570

570571
export const editServer = (server, props) =>

packages/xo-web/src/xo-app/settings/servers/index.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,17 @@ const COLUMNS = [
132132
itemRenderer: ({ poolId }) => poolId !== undefined && <Pool id={poolId} link />,
133133
name: _('pool'),
134134
},
135+
{
136+
itemRenderer: (server, formatMessage) => (
137+
<Text
138+
value={server.httpProxy || ''}
139+
onChange={httpProxy => editServer(server, { httpProxy })}
140+
placeholder={formatMessage(messages.serverHttpProxyPlaceHolder)}
141+
/>
142+
),
143+
name: _('serverHttpProxy'),
144+
sortCriteria: _ => _.httpProxy,
145+
},
135146
]
136147
const INDIVIDUAL_ACTIONS = [
137148
{
@@ -152,16 +163,16 @@ export default class Servers extends Component {
152163
}
153164

154165
_addServer = async () => {
155-
const { label, host, password, username, allowUnauthorized } = this.state
156-
157-
await addServer(host, username, password, label, allowUnauthorized)
166+
const { label, host, password, username, allowUnauthorized, httpProxy } = this.state
167+
await addServer(host, username, password, label, allowUnauthorized, httpProxy)
158168

159169
this.setState({
160170
allowUnauthorized: false,
161171
host: '',
162172
label: '',
163173
password: '',
164174
username: '',
175+
httpProxy: '',
165176
})
166177
}
167178

@@ -227,6 +238,15 @@ export default class Servers extends Component {
227238
<Toggle onChange={this.linkState('allowUnauthorized')} value={state.allowUnauthorized} />
228239
</Tooltip>
229240
</div>{' '}
241+
<div className='form-group'>
242+
<input
243+
className='form-control'
244+
onChange={this.linkState('httpProxy')}
245+
placeholder={formatMessage(messages.serverHttpProxy)}
246+
type='url'
247+
value={state.httpProxy || ''}
248+
/>
249+
</div>{' '}
230250
<ActionButton btnStyle='primary' form='form-add-server' handler={this._addServer} icon='save'>
231251
{_('serverConnect')}
232252
</ActionButton>

0 commit comments

Comments
 (0)