|
34 | 34 | elsif @current_resource.version == nil |
35 | 35 | install_version = candidate_version |
36 | 36 | end |
| 37 | + |
| 38 | + # Set the timeout (units in seconds) |
| 39 | + timeout = 900 |
| 40 | + if @new_resource.timeout |
| 41 | + timeout = @new_resource.timeout |
| 42 | + end |
37 | 43 |
|
38 | 44 | if install_version |
39 | 45 | Chef::Log.info("Installing #{@new_resource} version #{install_version}") |
40 | | - status = install_package(@new_resource.package_name, install_version) |
| 46 | + status = install_package(@new_resource.package_name, install_version, timeout) |
41 | 47 | if status |
42 | 48 | @new_resource.updated_by_last_action(true) |
43 | 49 | end |
44 | 50 | end |
45 | 51 | end |
46 | 52 |
|
47 | 53 | action :upgrade do |
| 54 | + # Set the timeout (units in seconds) |
| 55 | + timeout = 900 |
| 56 | + if @new_resource.timeout |
| 57 | + timeout = @new_resource.timeout |
| 58 | + end |
| 59 | + |
48 | 60 | if @current_resource.version != candidate_version |
49 | 61 | orig_version = @current_resource.version || "uninstalled" |
50 | 62 | Chef::Log.info("Upgrading #{@new_resource} version from #{orig_version} to #{candidate_version}") |
51 | | - status = upgrade_package(@new_resource.package_name, candidate_version) |
| 63 | + status = upgrade_package(@new_resource.package_name, candidate_version, timeout) |
52 | 64 | if status |
53 | 65 | @new_resource.updated_by_last_action(true) |
54 | 66 | end |
55 | 67 | end |
56 | 68 | end |
57 | 69 |
|
58 | 70 | action :remove do |
| 71 | + # Set the timeout (units in seconds) |
| 72 | + timeout = 900 |
| 73 | + if @new_resource.timeout |
| 74 | + timeout = @new_resource.timeout |
| 75 | + end |
| 76 | + |
59 | 77 | if removing_package? |
60 | 78 | Chef::Log.info("Removing #{@new_resource}") |
61 | | - remove_package(@current_resource.package_name, @new_resource.version) |
| 79 | + remove_package(@current_resource.package_name, @new_resource.version, timeout) |
62 | 80 | @new_resource.updated_by_last_action(true) |
63 | 81 | else |
64 | 82 | end |
@@ -121,18 +139,18 @@ def candidate_version |
121 | 139 | end |
122 | 140 | end |
123 | 141 |
|
124 | | -def install_package(name,version) |
| 142 | +def install_package(name, version, timeout) |
125 | 143 | v = "==#{version}" unless version.eql?('latest') |
126 | | - shell_out!("pip install#{expand_options(@new_resource.options)}#{expand_virtualenv(can_haz_virtualenv(@new_resource))} #{name}#{v}") |
| 144 | + shell_out!("pip install#{expand_options(@new_resource.options)}#{expand_virtualenv(can_haz_virtualenv(@new_resource))} #{name}#{v}", :timeout => timeout) |
127 | 145 | end |
128 | 146 |
|
129 | | -def upgrade_package(name, version) |
| 147 | +def upgrade_package(name, version, timeout) |
130 | 148 | v = "==#{version}" unless version.eql?('latest') |
131 | | - shell_out!("pip install --upgrade#{expand_options(@new_resource.options)}#{expand_virtualenv(can_haz_virtualenv(@new_resource))} #{@new_resource.name}#{v}") |
| 149 | + shell_out!("pip install --upgrade#{expand_options(@new_resource.options)}#{expand_virtualenv(can_haz_virtualenv(@new_resource))} #{@new_resource.name}#{v}", :timeout => timeout) |
132 | 150 | end |
133 | 151 |
|
134 | | -def remove_package(name, version) |
135 | | - shell_out!("pip uninstall -y#{expand_options(@new_resource.options)}#{expand_virtualenv(can_haz_virtualenv(@new_resource))} #{@new_resource.name}") |
| 152 | +def remove_package(name, version, timeout) |
| 153 | + shell_out!("pip uninstall -y#{expand_options(@new_resource.options)}#{expand_virtualenv(can_haz_virtualenv(@new_resource))} #{@new_resource.name}", :timeout => timeout) |
136 | 154 | end |
137 | 155 |
|
138 | 156 | def expand_virtualenv(virtualenv) |
|
0 commit comments