@@ -5,7 +5,7 @@ import FormModalButton from '../common/modal/FormModalButton';
55import FormModal from '../common/modal/FormModal' ;
66import Utils from '../../utils' ;
77import { connect } from 'react-redux' ;
8- import { DecommissionRack , RemoveRack , ReactivateRack , FetchRacks } from '../../actions/api/racks' ;
8+ import { DecommissionRack , RemoveRack , ReactivateRack , FreezeRack , FetchRacks } from '../../actions/api/racks.es6 ' ;
99import rootComponent from '../../rootComponent' ;
1010import { Link } from 'react-router' ;
1111import Column from '../common/table/Column' ;
@@ -25,23 +25,23 @@ const Racks = (props) => {
2525 label : 'Message (optional)'
2626 }
2727
28- const showUser = ( rack ) => Utils . isIn ( rack . currentState . state , [ 'ACTIVE' , 'DECOMMISSIONING' , 'DECOMMISSIONED' , 'STARTING_DECOMMISSION' ] ) ;
28+ const showUser = ( rack ) => Utils . isIn ( rack . currentState . state , [ 'ACTIVE' , 'FROZEN' , ' DECOMMISSIONING', 'DECOMMISSIONED' , 'STARTING_DECOMMISSION' ] ) ;
2929
30- const getMaybeReactivateButton = ( rack ) => ( Utils . isIn ( rack . currentState . state , [ 'DECOMMISSIONING' , 'DECOMMISSIONED' , 'STARTING_DECOMMISSION' ] ) &&
30+ const getMaybeReactivateButton = ( rack ) => ( Utils . isIn ( rack . currentState . state , [ 'FROZEN' , ' DECOMMISSIONING', 'DECOMMISSIONED' , 'STARTING_DECOMMISSION' ] ) &&
3131 < FormModalButton
3232 name = "Reactivate Rack"
3333 buttonChildren = { < Glyphicon glyph = "new-window" /> }
3434 action = "Reactivate Rack"
3535 onConfirm = { ( data ) => props . reactivateRack ( rack , data . message ) }
3636 tooltipText = { `Reactivate ${ rack . id } ` }
3737 formElements = { [ messageElement ] } >
38- < p > Are you sure you want to cancel decommission and reactivate this rack??</ p >
38+ < p > Are you sure you want to cancel decommission/freeze and reactivate this rack??</ p >
3939 < pre > { rack . id } </ pre >
40- < p > Reactivating a rack will cancel the decommission without erasing the rack's history and move it back to the active state.</ p >
40+ < p > Reactivating a rack will cancel the decommission/freeze without erasing the rack's history and move it back to the active state.</ p >
4141 </ FormModalButton >
4242 ) ;
4343
44- const getMaybeDecommissionButton = ( rack ) => ( rack . currentState . state === 'ACTIVE' && (
44+ const getMaybeDecommissionButton = ( rack ) => ( Utils . isIn ( rack . currentState . state , [ 'ACTIVE' , 'FROZEN' ] ) && (
4545 < FormModalButton
4646 name = "Decommission Rack"
4747 buttonChildren = { < Glyphicon glyph = "trash" /> }
@@ -59,6 +59,24 @@ const Racks = (props) => {
5959 </ FormModalButton >
6060 ) ) ;
6161
62+ const getMaybeFreezeButton = ( rack ) => ( rack . currentState . state === 'ACTIVE' && (
63+ < FormModalButton
64+ name = "Freeze Rack"
65+ buttonChildren = { < Glyphicon glyph = "pause" /> }
66+ action = "Freeze Rack"
67+ onConfirm = { ( data ) => props . freezeRack ( rack , data . message ) }
68+ tooltipText = { `Freeze ${ rack . id } ` }
69+ formElements = { [ messageElement ] } >
70+ < p > Are you sure you want to freeze this rack?</ p >
71+ < pre > { rack . id } </ pre >
72+ < p >
73+ Freezing a rack prevents new tasks from being scheduled on the rack, but tasks currently running on it will not be rescheduled.
74+ New tasks will no longer consider the rack with id < code > { rack . id } </ code > a valid target for execution.
75+ This process should be near-instant, as no tasks need to be replaced/killed.
76+ </ p >
77+ </ FormModalButton >
78+ ) ) ;
79+
6280 const getMaybeRemoveButton = ( rack ) => ( rack . currentState . state !== 'ACTIVE' && (
6381 < FormModalButton
6482 name = "Remove Rack"
@@ -131,6 +149,7 @@ const Racks = (props) => {
131149 < span >
132150 { getMaybeReactivateButton ( rack ) }
133151 { getMaybeDecommissionButton ( rack ) }
152+ { getMaybeFreezeButton ( rack ) }
134153 { getMaybeRemoveButton ( rack ) }
135154 < JSONButton object = { rack } showOverlay = { true } >
136155 { '{ }' }
@@ -145,7 +164,7 @@ const Racks = (props) => {
145164 const activeRacks = props . racks . filter ( ( { currentState} ) => Utils . isIn ( currentState . state , [ 'ACTIVE' ] ) ) ;
146165
147166 const decommissioningRacks = props . racks . filter ( ( { currentState} ) => Utils . isIn ( currentState . state , [ 'DECOMMISSIONING' , 'DECOMMISSIONED' , 'STARTING_DECOMMISSION' ] ) ) ;
148-
167+ const frozenRacks = props . racks . filter ( ( { currentState } ) => Utils . isIn ( currentState . state , [ 'FROZEN' ] ) ) ;
149168 const inactiveRacks = props . racks . filter ( ( { currentState} ) => Utils . isIn ( currentState . state , [ 'DEAD' , 'MISSING_ON_STARTUP' ] ) ) ;
150169
151170 const states = [
@@ -161,6 +180,12 @@ const Racks = (props) => {
161180 columns : getColumns ( 'decommissioning' ) ,
162181 hostsInState : decommissioningRacks
163182 } ,
183+ {
184+ stateName : 'Frozen' ,
185+ emptyMessage : 'No Frozen Racks' ,
186+ columns : getColumns ( 'frozen' ) ,
187+ hostsInState : frozenRacks
188+ } ,
164189 {
165190 stateName : 'Inactive' ,
166191 emptyMessage : 'No Inactive Racks' ,
@@ -183,14 +208,15 @@ Racks.propTypes = {
183208 state : PropTypes . string
184209 } ) ) ,
185210 removeRack : PropTypes . func . isRequired ,
211+ freezeRack : PropTypes . func . isRequired ,
186212 decommissionRack : PropTypes . func . isRequired ,
187213 reactivateRack : PropTypes . func . isRequired ,
188214 clear : PropTypes . func . isRequired ,
189215 error : PropTypes . string
190216} ;
191217
192218function getErrorFromState ( state ) {
193- const { decommissionRack, removeRack, reactivateRack } = state . api ;
219+ const { decommissionRack, removeRack, reactivateRack, freezeRack } = state . api ;
194220 if ( decommissionRack . error ) {
195221 return `Error decommissioning rack: ${ state . api . decommissionRack . error . message } ` ;
196222 }
@@ -200,6 +226,9 @@ function getErrorFromState(state) {
200226 if ( reactivateRack . error ) {
201227 return `Error reactivating rack: ${ state . api . reactivateRack . error . message } ` ;
202228 }
229+ if ( freezeRack . error ) {
230+ return `Error freezing rack: ${ state . api . freezeRack . error . message } ` ;
231+ }
203232 return null ;
204233}
205234
@@ -214,12 +243,14 @@ function mapDispatchToProps(dispatch) {
214243 function clear ( ) {
215244 return Promise . all ( [
216245 dispatch ( DecommissionRack . clear ( ) ) ,
246+ dispatch ( FreezeRack . clear ( ) ) ,
217247 dispatch ( RemoveRack . clear ( ) ) ,
218248 dispatch ( ReactivateRack . clear ( ) )
219249 ] ) ;
220250 }
221251 return {
222252 decommissionRack : ( rack , message ) => { clear ( ) . then ( ( ) => dispatch ( DecommissionRack . trigger ( rack . id , message ) ) ) . then ( ( ) => dispatch ( FetchRacks . trigger ( ) ) ) ; } ,
253+ freezeRack : ( rack , message ) => { clear ( ) . then ( ( ) => dispatch ( FreezeRack . trigger ( rack . id , message ) ) ) . then ( ( ) => dispatch ( FetchRacks . trigger ( ) ) ) ; } ,
223254 removeRack : ( rack , message ) => { clear ( ) . then ( ( ) => dispatch ( RemoveRack . trigger ( rack . id , message ) ) ) . then ( ( ) => dispatch ( FetchRacks . trigger ( ) ) ) ; } ,
224255 reactivateRack : ( rack , message ) => { clear ( ) . then ( ( ) => dispatch ( ReactivateRack . trigger ( rack . id , message ) ) ) . then ( ( ) => dispatch ( FetchRacks . trigger ( ) ) ) ; } ,
225256 fetchRacks : ( ) => dispatch ( FetchRacks . trigger ( ) ) ,
0 commit comments