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
7b0b9016
Commit
7b0b9016
authored
Jun 21, 2013
by
Vincent Viallet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve error messages on missing required variables.
parent
c124411c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
36 deletions
+23
-36
library/cloud/linode
+23
-36
No files found.
library/cloud/linode
View file @
7b0b9016
...
@@ -237,18 +237,11 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino
...
@@ -237,18 +237,11 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino
# Any create step triggers a job that need to be waited for.
# Any create step triggers a job that need to be waited for.
if
not
servers
:
if
not
servers
:
new_server
=
True
for
arg
in
(
'name'
,
'plan'
,
'distribution'
,
'datacenter'
):
# TODO - improve
if
not
eval
(
arg
):
if
not
name
:
module
.
fail_json
(
msg
=
'
%
s is required for active state'
%
arg
)
module
.
fail_json
(
msg
=
'
%
s is required for active state'
%
'name'
)
if
not
plan
:
module
.
fail_json
(
msg
=
'
%
s is required for active state'
%
'plan'
)
if
not
distribution
:
module
.
fail_json
(
msg
=
'
%
s is required for active state'
%
'distribution'
)
if
not
datacenter
:
module
.
fail_json
(
msg
=
'
%
s is required for active state'
%
'datacenter'
)
# Create linode entity
# Create linode entity
new_server
=
True
try
:
try
:
res
=
api
.
linode_create
(
DatacenterID
=
datacenter
,
PlanID
=
plan
,
res
=
api
.
linode_create
(
DatacenterID
=
datacenter
,
PlanID
=
plan
,
PaymentTerm
=
payment_term
)
PaymentTerm
=
payment_term
)
...
@@ -261,16 +254,11 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino
...
@@ -261,16 +254,11 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino
module
.
fail_json
(
msg
=
'
%
s'
%
e
.
value
[
0
][
'ERRORMESSAGE'
])
module
.
fail_json
(
msg
=
'
%
s'
%
e
.
value
[
0
][
'ERRORMESSAGE'
])
if
not
disks
:
if
not
disks
:
new_server
=
True
for
arg
in
(
'name'
,
'linode_id'
,
'distribution'
):
# TODO - improve
if
not
eval
(
arg
):
if
not
name
:
module
.
fail_json
(
msg
=
'
%
s is required for active state'
%
arg
)
module
.
fail_json
(
msg
=
'
%
s is required for active state'
%
'name'
)
if
not
linode_id
:
module
.
fail_json
(
msg
=
'
%
s is required for active state'
%
'linode_id'
)
if
not
distribution
:
module
.
fail_json
(
msg
=
'
%
s is required for active state'
%
'distribution'
)
# Create disks (1 from distrib, 1 for SWAP)
# Create disks (1 from distrib, 1 for SWAP)
new_server
=
True
try
:
try
:
if
not
password
:
if
not
password
:
# Password is required on creation, if not provided generate one
# Password is required on creation, if not provided generate one
...
@@ -299,14 +287,9 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino
...
@@ -299,14 +287,9 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino
module
.
fail_json
(
msg
=
'
%
s'
%
e
.
value
[
0
][
'ERRORMESSAGE'
])
module
.
fail_json
(
msg
=
'
%
s'
%
e
.
value
[
0
][
'ERRORMESSAGE'
])
if
not
configs
:
if
not
configs
:
new_server
=
True
for
arg
in
(
'name'
,
'linode_id'
,
'distribution'
):
# TODO - improve
if
not
eval
(
arg
):
if
not
name
:
module
.
fail_json
(
msg
=
'
%
s is required for active state'
%
arg
)
module
.
fail_json
(
msg
=
'
%
s is required for active state'
%
'name'
)
if
not
linode_id
:
module
.
fail_json
(
msg
=
'
%
s is required for active state'
%
'linode_id'
)
if
not
distribution
:
module
.
fail_json
(
msg
=
'
%
s is required for active state'
%
'distribution'
)
# Check architecture
# Check architecture
for
distrib
in
api
.
avail_distributions
():
for
distrib
in
api
.
avail_distributions
():
...
@@ -337,6 +320,7 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino
...
@@ -337,6 +320,7 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino
disks_list
=
','
.
join
(
disks_id
)
disks_list
=
','
.
join
(
disks_id
)
# Create config
# Create config
new_server
=
True
try
:
try
:
api
.
linode_config_create
(
LinodeId
=
linode_id
,
KernelId
=
kernel_id
,
api
.
linode_config_create
(
LinodeId
=
linode_id
,
KernelId
=
kernel_id
,
Disklist
=
disks_list
,
Label
=
'
%
s config'
%
name
)
Disklist
=
disks_list
,
Label
=
'
%
s config'
%
name
)
...
@@ -388,14 +372,15 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino
...
@@ -388,14 +372,15 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino
if
new_server
and
not
ssh_pub_key
:
if
new_server
and
not
ssh_pub_key
:
instance
[
'password'
]
=
password
instance
[
'password'
]
=
password
instances
.
append
(
instance
)
instances
.
append
(
instance
)
elif
state
in
(
'stopped'
):
elif
state
in
(
'stopped'
):
if
not
name
:
for
arg
in
(
'name'
,
'linode_id'
):
module
.
fail_json
(
msg
=
'
%
s is required for stopped state'
%
'name'
)
if
not
eval
(
arg
):
if
not
linode_id
:
module
.
fail_json
(
msg
=
'
%
s is required for active state'
%
arg
)
module
.
fail_json
(
msg
=
'
%
s is required for stopped state'
%
'linode_id'
)
if
not
servers
:
if
not
servers
:
module
.
fail_json
(
msg
=
'Server
%
s (lid:
%
s) not found'
%
(
name
,
linode_id
))
module
.
fail_json
(
msg
=
'Server
%
s (lid:
%
s) not found'
%
(
name
,
linode_id
))
for
server
in
servers
:
for
server
in
servers
:
instance
=
getInstanceDetails
(
api
,
server
)
instance
=
getInstanceDetails
(
api
,
server
)
if
server
[
'STATUS'
]
!=
2
:
if
server
[
'STATUS'
]
!=
2
:
...
@@ -408,14 +393,15 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino
...
@@ -408,14 +393,15 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino
else
:
else
:
instance
[
'status'
]
=
'Stopped'
instance
[
'status'
]
=
'Stopped'
instances
.
append
(
instance
)
instances
.
append
(
instance
)
elif
state
in
(
'restarted'
):
elif
state
in
(
'restarted'
):
if
not
name
:
for
arg
in
(
'name'
,
'linode_id'
):
module
.
fail_json
(
msg
=
'
%
s is required for restarted state'
%
'name'
)
if
not
eval
(
arg
):
if
not
linode_id
:
module
.
fail_json
(
msg
=
'
%
s is required for active state'
%
arg
)
module
.
fail_json
(
msg
=
'
%
s is required for restarted state'
%
'linode_id'
)
if
not
servers
:
if
not
servers
:
module
.
fail_json
(
msg
=
'Server
%
s (lid:
%
s) not found'
%
(
name
,
linode_id
))
module
.
fail_json
(
msg
=
'Server
%
s (lid:
%
s) not found'
%
(
name
,
linode_id
))
for
server
in
servers
:
for
server
in
servers
:
instance
=
getInstanceDetails
(
api
,
server
)
instance
=
getInstanceDetails
(
api
,
server
)
try
:
try
:
...
@@ -425,6 +411,7 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino
...
@@ -425,6 +411,7 @@ def linodeServers(module, api, state, name, plan, distribution, datacenter, lino
instance
[
'status'
]
=
'Restarting'
instance
[
'status'
]
=
'Restarting'
changed
=
True
changed
=
True
instances
.
append
(
instance
)
instances
.
append
(
instance
)
elif
state
in
(
'absent'
,
'deleted'
):
elif
state
in
(
'absent'
,
'deleted'
):
for
server
in
servers
:
for
server
in
servers
:
instance
=
getInstanceDetails
(
api
,
server
)
instance
=
getInstanceDetails
(
api
,
server
)
...
...
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