易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 4658|回复: 0
收起左侧

nova 注入adminpass 添加用户等设置

[复制链接]
发表于 2019-4-4 20:37:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?开始注册

x
compute node install
% C2 [( C+ C; [& c- ~
3 |  e% u6 M' G/ R
' O( s+ k0 N) q! Q6 i' G% Ryum install libguestfs python-libguestfs libguestfs-tools-c/ A# ?4 |. C7 @- Z+ @6 a
compute node config
0 A; q- ?; S! ~9 e$ ]' V
1 g( F  u$ ~4 ^5 |9 r- Q
7 q0 q* _) O3 \# x" e0 H) c2 w6 A# q[libvirt]5 u% z( b" c) ~  g
* E0 ]3 S! ?3 b
inject_password=true/ @+ ]0 h- Z' O* w3 F
) Z7 t- }: ^+ J- R6 l) D
inject_key=true
# e; V# x3 g8 l2 w! t1 ?8 [* r% Z' f5 l' L2 B2 n
inject_partition=-1
$ Q% c3 S2 o: M! d( Z2 u% `& H- G+ W" i+ T8 t
restart nova compute service8 S" B8 m0 U# S/ c% |) a+ G$ j1 G
( g* m# P, H  }& g+ d* N
3 X/ ~$ \! w# n: h
systemctl restart openstack-nova-compute.service5 A4 p1 g6 n9 Q3 C! C
设置root/adminstrator的密码2 k$ b( k4 [2 z' S/ `
) D" w* `& m$ g# r
0 L+ v( E; a2 h
nova boot --admin-pass
! o8 J/ z  }4 m6 L添加新用户
. |! Y* j" @; l% {  K" s) g+ }$ H  `, \: W/ M: D6 @
, ?7 Q3 s2 x2 k6 Y" p' B5 b
nova boot --user-data
5 W# m7 W; q( ~( Y8 l7 [+ {0 X  L user-data example+ ]0 p* e5 _  J( o4 V% P- o1 L" h
$ ]) [) z3 t" u0 I
复制代码
4 c3 @0 R5 M1 C$ G#!/bin/sh
+ W7 M  j# G) e) G- S/ C$ epasswd ubuntu<<EOF
- n$ P$ C- `) I9 _+ mubuntu
5 x- L  H! [5 v. cubuntu
8 L& b6 e7 S0 e. \EOF
. a& ^, z) @/ D# y( @sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
- l$ ?% c& m: Y% \service ssh restart: a: h0 s% g' E. B( g! F
  l+ |: C- {; t" I1 b6 E; Y
备注:
+ ]; t: [9 h/ c0 Q: }$ V/ q0 X/ f3 G/ S' W+ @
1 https://cloud-images.ubuntu.com/ 上的ubuntu vm用该方法设置password* S1 b  S2 w  O5 q! t  x7 X3 Z& s1 g

3 D) }  }# `% l2 如果需要nova set-password起作用,需要image中装有qga,另外制作image时,需要设置meta中的 hw_qemu_guest_agent为yes
' U/ t, U8 s' Y  C6 Z
7 D  h0 c2 `  K2 R  ]镜像中还需要指定用户名。可以参考m版的nova代码
( j3 F& A' n8 s8 |6 R6 d% j4 v
/ D" Q! e$ b( C) |# l9 Y% g2 o4 V" u4 k+ ]4 O
def set_admin_password(self, instance, new_pass):0 P- V6 ~6 y  v  S' g- @
        self._can_set_admin_password(instance.image_meta)1 J/ q! S" }5 C

  b* ?) S' D5 Z" Q( E/ e% K  M& W        guest = self._host.get_guest(instance), X* C$ \0 |. p7 f
        user = instance.image_meta.properties.get("os_admin_user")3 q, j* b  z: l. \
        if not user:
+ ~; e/ x9 b" S# F: U            if instance.os_type == "windows":3 {. F; ?: R6 f; F; {
                user = "Administrator"
  \" r" M5 i% J- x1 _            else:
1 K& p  ~; c. a6 G5 y                user = "root"; V9 {3 T' v& J1 B7 A0 q
        try:
0 Y9 M, w. T' d0 ~: d            guest.set_user_password(user, new_pass)
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )点击这里给我发消息

GMT+8, 2026-4-8 21:20 , Processed in 0.048358 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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