Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
612561ad
Commit
612561ad
authored
Oct 08, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1250 from dagwieers/hpilo_boot-fixes
Various small fixes to boolean usage and defaults
parents
62a56a21
5503cfaa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
35 deletions
+47
-35
library/debug
+9
-5
library/hpilo_boot
+27
-20
library/hpilo_facts
+7
-6
library/vsphere_facts
+4
-4
No files found.
library/debug
View file @
612561ad
...
...
@@ -68,13 +68,17 @@ def main():
)
)
if
module
.
params
[
'fail'
]
in
BOOLEANS_TRUE
and
module
.
params
[
'rc'
]
==
0
:
module
.
params
[
'rc'
]
=
1
fail
=
module
.
boolean
(
module
.
params
.
get
(
'fail'
))
msg
=
module
.
params
.
get
(
'msg'
)
rc
=
module
.
params
.
get
(
'rc'
)
if
module
.
params
[
'fail'
]
in
BOOLEANS_TRUE
:
module
.
fail_json
(
rc
=
module
.
params
[
'rc'
],
msg
=
module
.
params
[
'msg'
])
if
fail
and
rc
==
0
:
rc
=
1
if
fail
:
module
.
fail_json
(
rc
=
rc
,
msg
=
msg
)
else
:
module
.
exit_json
(
msg
=
m
odule
.
params
[
'msg'
]
)
module
.
exit_json
(
msg
=
m
sg
)
# this is magic, see lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
...
...
library/hpilo_boot
View file @
612561ad
...
...
@@ -61,7 +61,7 @@ options:
C(protocol://username:password@hostname:port/filename)
- protocol is either C(http) or C(https)
- username:password is optional
•
- port is optional
- port is optional
required: false
state:
description:
...
...
@@ -111,52 +111,59 @@ def main():
login
=
dict
(
default
=
'Administrator'
),
password
=
dict
(
default
=
'admin'
),
match
=
dict
(
default
=
None
),
media
=
dict
(
choices
=
[
'cdrom'
,
'floppy'
,
'hdd'
,
'network'
,
'normal'
,
'usb'
]),
media
=
dict
(
default
=
None
,
choices
=
[
'cdrom'
,
'floppy'
,
'hdd'
,
'network'
,
'normal'
,
'usb'
]),
image
=
dict
(
default
=
None
),
state
=
dict
(
required
=
True
,
default
=
'boot_once'
,
choices
=
[
'boot_always'
,
'boot_once'
,
'connect'
,
'disconnect'
,
'no_boot'
]),
force
=
dict
(
default
=
True
,
choices
=
BOOLEANS
),
state
=
dict
(
default
=
'boot_once'
,
choices
=
[
'boot_always'
,
'boot_once'
,
'connect'
,
'disconnect'
,
'no_boot'
]),
force
=
dict
(
default
=
'no'
,
choices
=
BOOLEANS
),
)
)
host
=
module
.
params
[
'host'
]
login
=
module
.
params
[
'login'
]
password
=
module
.
params
[
'password'
]
force
=
module
.
params
[
'force'
]
host
=
module
.
params
.
get
(
'host'
)
login
=
module
.
params
.
get
(
'login'
)
password
=
module
.
params
.
get
(
'password'
)
match
=
module
.
params
.
get
(
'match'
)
media
=
module
.
params
.
get
(
'media'
)
image
=
module
.
params
.
get
(
'image'
)
state
=
module
.
params
.
get
(
'state'
)
force
=
module
.
boolean
(
module
.
params
.
get
(
'force'
))
ilo
=
hpilo
.
Ilo
(
host
,
login
=
login
,
password
=
password
)
# If match=string is provided, only reboot server if iLO name matches 'string'
if
m
odule
.
params
[
'match'
]
!=
None
:
if
m
atch
!=
None
:
try
:
server_name
=
ilo
.
get_server_name
()
except
Exception
,
e
:
module
.
fail_json
(
rc
=
1
,
msg
=
'Failed to connect to
%
s:
%
s'
%
(
host
,
e
.
message
))
if
not
server_name
.
lower
()
.
startswith
(
m
odule
.
params
[
'match'
]
.
lower
()):
module
.
fail_json
(
rc
=
1
,
msg
=
'The iLO server name
\'
%
s
\'
does not match
\'
%
s
\'
'
%
(
server_name
,
m
odule
.
params
[
'match'
]
))
if
not
server_name
.
lower
()
.
startswith
(
m
atch
.
lower
()):
module
.
fail_json
(
rc
=
1
,
msg
=
'The iLO server name
\'
%
s
\'
does not match
\'
%
s
\'
'
%
(
server_name
,
m
atch
))
if
m
odule
.
params
[
'media'
]
:
if
m
edia
:
### FIXME: In the below case iLO fails for a short period of time due to the server rebooting
# File "/usr/lib/python2.6/site-packages/hpilo.py", line 381, in _parse_message
# raise IloError("Error communicating with iLO: %s" % child.get('MESSAGE'))
#hpilo.IloError: Error communicating with iLO: Problem manipulating EV
ilo
.
set_one_time_boot
(
m
odule
.
params
[
'media'
]
)
ilo
.
set_one_time_boot
(
m
edia
)
# TODO: Verify if image URL exists/works
if
module
.
params
[
'image'
]
:
ilo
.
insert_virtual_media
(
m
odule
.
params
[
'media'
],
module
.
params
[
'image'
]
)
if
image
:
ilo
.
insert_virtual_media
(
m
edia
,
image
)
if
m
odule
.
params
[
'media'
]
==
'cdrom'
:
ilo
.
set_vm_status
(
'cdrom'
,
module
.
params
[
'state'
]
,
True
)
if
m
edia
==
'cdrom'
:
ilo
.
set_vm_status
(
'cdrom'
,
state
,
True
)
status
=
ilo
.
get_vm_status
()
elif
module
.
params
[
'media'
]
==
'floppy'
:
ilo
.
set_vf_status
(
module
.
params
[
'state'
],
True
)
elif
media
==
'floppy'
:
ilo
.
set_vf_status
(
state
,
True
)
status
=
ilo
.
get_vf_status
()
elif
media
==
'usb'
:
ilo
.
set_vf_status
(
state
,
True
)
status
=
ilo
.
get_vf_status
()
# Only perform a boot when state is boot_once or boot_always, or in case we want to force a reboot
if
module
.
params
[
'state'
]
in
(
'boot_once'
,
'boot_always'
)
or
force
:
if
state
in
(
'boot_once'
,
'boot_always'
)
or
force
:
power_status
=
ilo
.
get_host_power_status
()
...
...
library/hpilo_facts
View file @
612561ad
...
...
@@ -106,21 +106,22 @@ def main():
)
)
host
=
module
.
params
[
'host'
]
login
=
module
.
params
[
'login'
]
password
=
module
.
params
[
'password'
]
host
=
module
.
params
(
'host'
)
login
=
module
.
params
(
'login'
)
password
=
module
.
params
(
'password'
)
match
=
module
.
params
.
get
(
'match'
)
ilo
=
hpilo
.
Ilo
(
host
,
login
=
login
,
password
=
password
)
# If match=string is provided, only reboot server if iLO name matches 'string'
if
m
odule
.
params
[
'match'
]
!=
None
:
if
m
atch
!=
None
:
try
:
server_name
=
ilo
.
get_server_name
()
except
Exception
,
e
:
module
.
fail_json
(
rc
=
1
,
msg
=
'Failed to connect to
%
s:
%
s'
%
(
host
,
e
.
message
))
if
not
server_name
.
lower
()
.
startswith
(
m
odule
.
params
[
'match'
]
.
lower
()):
module
.
fail_json
(
rc
=
1
,
msg
=
'The iLO server name
\'
%
s
\'
does not match
\'
%
s
\'
'
%
(
server_name
,
m
odule
.
params
[
'match'
]
))
if
not
server_name
.
lower
()
.
startswith
(
m
atch
.
lower
()):
module
.
fail_json
(
rc
=
1
,
msg
=
'The iLO server name
\'
%
s
\'
does not match
\'
%
s
\'
'
%
(
server_name
,
m
atch
))
# TODO: Count number of CPUs, DIMMs and total memory
data
=
ilo
.
get_host_data
()
...
...
library/vsphere_facts
View file @
612561ad
...
...
@@ -88,10 +88,10 @@ def main():
)
)
host
=
module
.
params
[
'host'
]
login
=
module
.
params
[
'login'
]
password
=
module
.
params
[
'password'
]
guest
=
module
.
params
[
'guest'
]
host
=
module
.
params
.
get
(
'host'
)
login
=
module
.
params
.
get
(
'login'
)
password
=
module
.
params
.
get
(
'password'
)
guest
=
module
.
params
.
get
(
'guest'
)
server
=
pysphere
.
VIServer
()
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment