Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

Commit 5ccc910

Browse files
brandoldeggoynes
andauthored
Update file manager configuration page (#54)
* Changed API for list of subnet_Ids and changed front end to send list of subnet id. This is pushed to the branch * update file manager configuration page Co-authored-by: Eddie Goynes <[email protected]>
1 parent 7dbe443 commit 5ccc910

File tree

3 files changed

+77
-49
lines changed

3 files changed

+77
-49
lines changed

source/api/app.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ def proxy_operation_to_efs_lambda(filesystem_id, event):
4949
return response
5050

5151

52-
def create_filesystem_access_point(filesystem_id):
52+
def create_filesystem_access_point(filesystem_id, uid, gid, path):
5353
try:
5454
response = efs.create_access_point(
5555
FileSystemId=filesystem_id,
5656
PosixUser={
57-
'Uid': 1000,
58-
'Gid': 1000
57+
'Uid': uid,
58+
'Gid': gid
5959
},
6060
RootDirectory={
61-
'Path': '/efs',
61+
'Path': path,
6262
'CreationInfo': {
63-
'OwnerUid': 1000,
64-
'OwnerGid': 1000,
63+
'OwnerUid': uid,
64+
'OwnerGid': gid,
6565
'Permissions': '777'
6666
}
6767
}
@@ -309,21 +309,22 @@ def create_filesystem_lambda(filesystem_id):
309309
json_body = request.json_body
310310

311311
try:
312-
subnet_id = json_body['subnetId']
312+
subnet_ids = json_body['subnetIds']
313313
security_groups = json_body['securityGroups']
314+
uid = int(json_body['uid'])
315+
gid = int(json_body['gid'])
316+
path = json_body['path']
314317
except KeyError as error:
315318
app.log.error(error)
316319
raise BadRequestError("Check API logs")
317320
else:
318321
vpc_config = {
319-
'SubnetIds': [
320-
subnet_id,
321-
],
322+
'SubnetIds': subnet_ids,
322323
'SecurityGroupIds': security_groups
323324
}
324325

325326
try:
326-
access_point_arn = create_filesystem_access_point(filesystem_id)
327+
access_point_arn = create_filesystem_access_point(filesystem_id, uid, gid, path)
327328
except Exception as error:
328329
app.log.error(error)
329330
raise ChaliceViewError('Check API Logs')

source/web/src/components/filesystems.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
</div>
1111
</template>
1212
<template v-slot:cell(managed)="data">
13-
<div v-if=data.value>
13+
<div v-if="data.value === true">
1414
<p>{{data.value}}</p>
1515
</div>
1616
<div v-else-if="data.value === 'Creating'">
17-
<p>{{data.value}}</p>
17+
<b-link href="/" v-b-tooltip.hover title="Lambda creation can take several minutes. Click to refresh.">{{data.value}}</b-link>
1818
</div>
1919
<div v-else>
2020
<a :href="`/configure/${data.item.file_system_id}`">{{ data.value }}</a>

source/web/src/routes/Configure.vue

Lines changed: 63 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,34 @@
88
</div>
99
<div v-else>
1010
<b-row>
11-
<b-col>
12-
<br>
13-
<br>
14-
<br>
15-
<br>
16-
<h3> Mount Target Network Information</h3>
17-
<p>{{netinfo}}</p>
18-
</b-col>
1911
<b-col align-self="center">
2012
<b-form @submit="onSubmit">
2113
<h3> Create file manager lambda</h3>
22-
<p> Select a mount point to attach to:</p>
23-
<b-form-select v-model="selected" :options="options"></b-form-select>
24-
<br>
25-
<br>
26-
<b-button type="submit">
14+
<b-form-group
15+
label="User ID:"
16+
description="The numeric POSIX user ID that lambda will use to make file system requests as"
17+
>
18+
<b-form-input v-model="uid" :state="valid" placeholder="Enter a custom UID or leave default (1000)"></b-form-input>
19+
</b-form-group>
20+
21+
<b-form-group
22+
label="Group ID:"
23+
description="The numeric POSIX group ID that lambda will use to make file system requests as"
24+
>
25+
<b-form-input v-model="gid" :state="valid" placeholder="Enter a custom GID or leave default (1000)"></b-form-input>
26+
</b-form-group>
27+
28+
<b-form-group
29+
label="Path:"
30+
description="The file system directory that lambda will use as the root directory"
31+
>
32+
<b-form-input v-model="path" :state="valid" placeholder="Enter a custom path or leave default (/efs)"></b-form-input>
33+
</b-form-group>
34+
35+
<b-form-invalid-feedback :state="valid">
36+
UID, GID, and Path must not be empty. The path must begin with a forward slash: /
37+
</b-form-invalid-feedback>
38+
<b-button :disabled='!valid' type="submit">
2739
Submit
2840
<b-icon icon="Hammer" aria-hidden="true"></b-icon>
2941
</b-button>
@@ -45,44 +57,59 @@ export default {
4557
data () {
4658
return {
4759
processing: false,
48-
netinfo: null,
49-
form: {
50-
mountTarget: null
51-
},
52-
selected: null
60+
uid: '1000',
61+
gid: '1000',
62+
path: '/efs'
5363
}
5464
},
55-
created: function () {
56-
this.getFilesystemNetinfo()
57-
},
5865
computed: {
59-
options: function () {
60-
let mountTargetNames = Object.keys(this.netinfo)
61-
return mountTargetNames
66+
valid() {
67+
return this.uid != "" && this.gid != "" && this.path != "" && this.path.charAt(0) == '/'
6268
}
6369
},
6470
methods: {
65-
onSubmit(evt) {
66-
evt.preventDefault()
67-
let mountTarget = this.selected
68-
let mountTargetNetinfo = this.netinfo[mountTarget]
69-
this.createManagerLambda(mountTargetNetinfo)
71+
async onSubmit(evt) {
72+
evt.preventDefault();
73+
74+
if (this.valid) {
75+
let mountTargetNetinfo = await this.getFilesystemNetinfo()
76+
77+
mountTargetNetinfo['uid'] = this.uid
78+
mountTargetNetinfo['gid'] = this.gid
79+
mountTargetNetinfo['path'] = this.path
80+
81+
console.log(mountTargetNetinfo)
82+
83+
this.createManagerLambda(mountTargetNetinfo)
84+
}
85+
else {
86+
alert("Form Validation Error. Check the form input and try again.")
87+
}
7088
},
7189
formatNetinfo (netinfo) {
72-
let tmpNetinfo = {}
90+
let subnets = []
91+
let securityGroups = []
92+
7393
for (var i=0, n=netinfo.length; i < n; ++i ) {
74-
let netinfoKeys = Object.keys(netinfo[i])
75-
let mountTargetName = netinfoKeys[0]
76-
tmpNetinfo[mountTargetName] = netinfo[i][mountTargetName]
77-
94+
if (i === 5) { break; }
95+
let mountTarget = Object.keys(netinfo[i])[0]
96+
97+
let subnet = netinfo[i][mountTarget]['subnet_id']
98+
let securityGroup = netinfo[i][mountTarget]['security_groups']
99+
100+
subnets.push(subnet)
101+
securityGroups.push.apply(securityGroups, securityGroup)
78102
}
103+
104+
let tmpNetinfo = {'subnetIds': subnets, 'securityGroups': securityGroups}
105+
79106
return tmpNetinfo
80107
},
81108
async getFilesystemNetinfo () {
82109
try {
83110
let response = await API.get('fileManagerApi', '/api/filesystems/' + this.$route.params.id + '/netinfo')
84111
let formattedNetinfo = this.formatNetinfo(response)
85-
this.netinfo = formattedNetinfo
112+
return formattedNetinfo
86113
}
87114
catch (error) {
88115
alert('Unable to retrieve filesystem netinfo, check api logs')
@@ -91,7 +118,7 @@ export default {
91118
},
92119
async createManagerLambda (netinfo) {
93120
const params = {
94-
body: {"subnetId": netinfo.subnet_id, "securityGroups": netinfo.security_groups},
121+
body: {"subnetIds": netinfo.subnetIds, "securityGroups": netinfo.securityGroups, "uid": netinfo.uid, "gid": netinfo.gid, "path": netinfo.path},
95122
headers: {"Content-Type": "application/json"}
96123
}
97124
try {

0 commit comments

Comments
 (0)