找回密码
 注册
查看: 4660|回复: 0

nova 注入adminpass 添加用户等设置

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2019-4-4 20:37:33 | 显示全部楼层 |阅读模式
compute node install8 S& \6 J7 \" Y) D* d$ {9 T
( a" U' g# Z/ Y5 u

9 ]  h6 ?5 }! t" Y2 v7 nyum install libguestfs python-libguestfs libguestfs-tools-c
; G4 l% k- i" z* o) I% D6 B' Xcompute node config
8 ^! I+ z4 g7 B# J- L
9 s3 [( J: w8 }" _! L" t
" h; F1 ^. r2 k0 U[libvirt]7 A" Y3 g# }& ~1 R" x

6 T+ B) `( O" z  o& L+ hinject_password=true! o7 M% N  J6 l1 Z; L
  ~9 m9 A: U- ^% e1 A4 r3 D
inject_key=true( B- N. l& J* R8 V; M- ]
7 g6 \/ D8 S% t7 M# i8 M
inject_partition=-1
9 C+ r; L- [4 R& ]+ S8 f7 q0 u2 T( @. u" P" {2 F% ^
restart nova compute service
( w5 v$ j& W4 z. N7 I% T) p/ C- J! l3 d
$ Q8 [: {7 j2 W% A% B; H& z
systemctl restart openstack-nova-compute.service
3 Z/ F8 H8 l+ X. {4 \8 [6 ?5 A设置root/adminstrator的密码
, S' v& ^2 Y+ X8 K( T9 S9 {, a
, a) u6 V9 x" ^4 G% c3 x6 a
nova boot --admin-pass
8 K1 ^  c/ d6 z" y. A添加新用户
3 H: I/ n8 A/ X' n" C7 v" f. s; F2 C" E

8 F: \2 G6 ^9 c+ S: `nova boot --user-data- L; e- Z0 A9 T0 `& B$ F" a2 N3 W2 G
user-data example, {8 m8 F% y8 o% f1 Z' b( G
+ Y0 u5 K9 {# S3 r6 ?2 @+ J: V9 n( K0 k
复制代码
# z# v0 f7 U$ o3 l+ ^! A#!/bin/sh
3 m& M, B2 e1 ypasswd ubuntu<<EOF
, a4 I. M" Q/ t) N& G- v6 bubuntu6 E7 q  t9 w! n: u+ o
ubuntu2 B1 |  }' }& P
EOF2 _4 i& ^: k  ]
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
1 o7 ^( [" J  l% x0 a: Zservice ssh restart" n( n  k$ h! G: @# p

* \% W. r; f4 c% ?0 @7 J+ N) i) G 备注:
( W, U( E$ n5 B
# I2 ?6 G% c8 i1 https://cloud-images.ubuntu.com/ 上的ubuntu vm用该方法设置password, N/ m! r2 G- f. p2 z( S4 j
( P: h# y; W1 m; f
2 如果需要nova set-password起作用,需要image中装有qga,另外制作image时,需要设置meta中的 hw_qemu_guest_agent为yes
+ p9 j% r+ i! ?- h- R) j8 f* r/ x9 f8 n9 `/ K. ], B6 a; }7 b
镜像中还需要指定用户名。可以参考m版的nova代码9 ?. X% ?% [2 |4 k3 U

# Y6 @6 M* f7 `4 R( I/ D/ F, l. @' @! x7 X  U
def set_admin_password(self, instance, new_pass):
0 G# w3 D+ `' j        self._can_set_admin_password(instance.image_meta)
: f4 ?7 \8 c; C; A6 M9 x% K
6 p% {% Q7 ~: I% i0 Y8 j5 \        guest = self._host.get_guest(instance)3 ~1 Y. ]; g8 t+ _
        user = instance.image_meta.properties.get("os_admin_user")/ K$ h& a9 K+ y1 x7 {( D' M
        if not user:( I# t  s) ~% Z! q7 ?+ \9 @
            if instance.os_type == "windows":
; ]: s) }1 ^# j2 [9 Y                user = "Administrator"
$ s: t2 U8 x. f2 t            else:
/ E1 u  b- L: e' r3 x7 g  s                user = "root"3 b2 B6 d: z- Y
        try:- d- }9 G8 \) e# x
            guest.set_user_password(user, new_pass)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 02:23 , Processed in 0.017295 second(s), 23 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表