Skip to content

Commit

Permalink
feat: add firewall support (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
janus-reith authored Apr 5, 2021
1 parent 7d89685 commit 4ce4c87
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
16 changes: 15 additions & 1 deletion component/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default Ember.Component.extend(NodeDriver, {
imageId: "168855", // ubuntu-18.04
userData: '',
networks: [],
firewalls: [],
usePrivateNetwork: false,
serverLabel: [''],
});
Expand All @@ -68,6 +69,10 @@ export default Ember.Component.extend(NodeDriver, {
this.set('model.%%DRIVERNAME%%Config.networks', [])
}

if (!this.get('model.%%DRIVERNAME%%Config.firewalls')) {
this.set('model.%%DRIVERNAME%%Config.firewalls', [])
}

if (!this.get('model.%%DRIVERNAME%%Config.serverLabel')) {
this.set('model.%%DRIVERNAME%%Config.serverLabel', [])
}
Expand Down Expand Up @@ -95,7 +100,7 @@ export default Ember.Component.extend(NodeDriver, {
getData() {
this.set('gettingData', true);
let that = this;
Promise.all([this.apiRequest('/v1/locations'), this.apiRequest('/v1/images'), this.apiRequest('/v1/server_types'), this.apiRequest('/v1/networks'), this.apiRequest('/v1/ssh_keys')]).then(function (responses) {
Promise.all([this.apiRequest('/v1/locations'), this.apiRequest('/v1/images'), this.apiRequest('/v1/server_types'), this.apiRequest('/v1/networks'), this.apiRequest('/v1/ssh_keys'), this.apiRequest('/v1/firewalls')]).then(function (responses) {
that.setProperties({
errors: [],
needAPIToken: false,
Expand All @@ -116,6 +121,11 @@ export default Ember.Component.extend(NodeDriver, {
.map(key => ({
...key,
id: key.id.toString()
})),
firewallChoices: responses[5].firewalls
.map(firewall => ({
...firewall,
id: firewall.id.toString()
}))
});
}).catch(function (err) {
Expand All @@ -131,6 +141,10 @@ export default Ember.Component.extend(NodeDriver, {
let options = [...select.target.options].filter(o => o.selected).map(o => o.value)
this.set('model.%%DRIVERNAME%%Config.networks', options);
},
modifyFirewalls: function (select) {
let options = [...select.target.options].filter(o => o.selected).map(o => o.value)
this.set('model.%%DRIVERNAME%%Config.firewalls', options);
},
setLabels: function(labels){
let labels_list = labels.map(l => l.key + "=" + l.value);
this.set('model.%%DRIVERNAME%%Config.serverLabel', labels_list);
Expand Down
10 changes: 10 additions & 0 deletions component/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@
Use private network (first private network which is attached will be used for communication)
</label>
</div>
</div>
<div class="col-md-2">
<label class="form-control-static">Firewalls (Beta, optional. You have to create these Firewalls in the <a href="https://console.hetzner.cloud" target="_blank" rel="noopener noreferrer">Hetzner Cloud Console</a>)</label>
</div>
<div class="col-md-4">
<select class="form-control" onchange={{action 'modifyFirewalls' }} multiple="true">
{{#each firewallChoices as |firewall|}}
<option value={{firewall.id}} selected={{array-includes model.hetznerConfig.firewalls firewall.id}}>{{firewall.name}}</option>
{{/each}}
</select>
</div>
<div class="col-md-2">
<label class="form-control-static">Additional SSH Keys</label>
Expand Down

0 comments on commit 4ce4c87

Please sign in to comment.