2020/02/12

2020/02/12

  • XV6いろいろ
  • 学サポ
  • os.crの設定

# os.crの設定

akatsuki側で静的にユーザーに割り振っている

  • uid 666のuser
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
 #<IpAddress:0x000055601aabe008
  id: 2514,
  user_id: 666,
  affiliation: "cr",
  domain: "os",
  assigned_address: "10.0.0.146",
  mac_address: "a0:36:9f:67:6f:60",
  created_at: Sat, 26 May 2018 08:10:06 UTC +00:00,
  updated_at: Sat, 26 May 2018 08:14:45 UTC +00:00,
  vlan: 62>,

uid==666はりょっかさんっぽい

1
2
3
4
5
6
7
[14] pry(main)> User.find_by(id:666)
=> #<User:0x000055601833f770
 id: 666,
 created_at: Sat, 26 May 2018 08:02:05 UTC +00:00,
 updated_at: Sat, 26 May 2018 08:02:05 UTC +00:00,
 uid: "k188580",
 vm_limit: 0>

# 作業

# dalmoreのオブジェクトを取得

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
 #<IpAddress:0x000055601865e190
  id: 2514,
  user_id: 666,
  affiliation: "cr",
  domain: "os",
  assigned_address: "10.0.0.146",
  mac_address: "a0:36:9f:67:6f:60",
  created_at: Sat, 26 May 2018 08:10:06 UTC +00:00,
  updated_at: Sat, 26 May 2018 08:14:45 UTC +00:00,
  vlan: 62>,
 #<IpAddress:0x000055601865da38
  id: 1953,
  user_id: 35,
  affiliation: "cr",
  domain: "cinnamon",
  assigned_address: "10.0.0.55",
  mac_address: "08:00:37:30:7a:47",
  created_at: Tue, 23 May 2017 07:29:41 UTC +00:00,

# 先生のUserオブジェクトを取得

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
[21] pry(main)> User.find_by(uid:"kono")
=> #<User:0x000055601a244cb0
 id: 35,
 created_at: Sat, 05 Sep 2015 23:45:51 UTC +00:00,
 updated_at: Sat, 05 Sep 2015 23:45:51 UTC +00:00,
 uid: "kono",
 vm_limit: 0>
[22] pry(main)> IpAddress.find(2514)
=> #<IpAddress:0x0000556019f77898
 id: 2514,
 user_id: 666,
 affiliation: "cr",
 domain: "os",
 assigned_address: "10.0.0.146",
 mac_address: "a0:36:9f:67:6f:60",
 created_at: Sat, 26 May 2018 08:10:06 UTC +00:00,
 updated_at: Sat, 26 May 2018 08:14:45 UTC +00:00,
 vlan: 62>

# dalmoreのuidを書き換える

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[23] pry(main)> dalmore = IpAddress.find(2514)
=> #<IpAddress:0x0000556018532dc0
id: 2514,
user_id: 666,
affiliation: "cr",
domain: "os",
assigned_address: "10.0.0.146",
mac_address: "a0:36:9f:67:6f:60",
created_at: Sat, 26 May 2018 08:10:06 UTC +00:00,
updated_at: Sat, 26 May 2018 08:14:45 UTC +00:00,
vlan: 62>
[24] pry(main)> dalmore.user_id
=> 666
[25] pry(main)> dalmore.user_id = 35
=> 35
[26] pry(main)> dalmore
=> #<IpAddress:0x0000556018532dc0
id: 2514,
user_id: 35,
affiliation: "cr",
domain: "os",
assigned_address: "10.0.0.146",
mac_address: "a0:36:9f:67:6f:60",
created_at: Sat, 26 May 2018 08:10:06 UTC +00:00,
updated_at: Sat, 26 May 2018 08:14:45 UTC +00:00,
vlan: 62>
[27] pry(main)> dalmore.save!
=> true
[28] pry(main)>
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy