1- import NodeDriver from 'shared/mixins/node-driver' ;
1+ import NodeDriver , { DynamicDependentKeysProperty , registerDisplayLocation , registerDisplaySize } from 'shared/mixins/node-driver' ;
22import fetch from '@rancher/ember-api-store/utils/fetch' ;
33const LAYOUT ;
44
5+ registerDisplayLocation ( new DynamicDependentKeysProperty ( { driver : '%%DRIVERNAME%%' , keyOrKeysToWatch : 'config.facilityCode' } ) ) ;
6+ registerDisplaySize ( new DynamicDependentKeysProperty ( { driver : '%%DRIVERNAME%%' , keyOrKeysToWatch : 'config.plan' } ) ) ;
7+
58const OS_WHITELIST = [ 'centos_7' , 'coreos_stable' , 'ubuntu_14_04' , 'ubuntu_16_04' , 'ubuntu_18_04' , 'rancher' ] ;
69const PLAN_BLACKLIST = [ 'baremetal_2a' ] ; // quick wheres james spader?
710const DEFAULTS = {
@@ -21,12 +24,15 @@ const isEmpty = Ember.isEmpty;
2124
2225export default Ember . Component . extend ( NodeDriver , {
2326 driverName : 'packet' ,
27+ cloudCredentials : null ,
2428 facilityChoices : null ,
2529 planChoices : null ,
2630 osChoices : null ,
2731 step : 1 ,
2832
2933 config : alias ( 'model.packetConfig' ) ,
34+ app : service ( ) ,
35+ intl : service ( ) ,
3036
3137 init ( ) {
3238 const decodedLayout = window . atob ( LAYOUT ) ;
@@ -46,7 +52,19 @@ export default Ember.Component.extend(NodeDriver, {
4652 } ,
4753
4854 actions : {
55+ finishAndSelectCloudCredential ( cred ) {
56+ if ( cred ) {
57+ set ( this , 'model.cloudCredentialId' , get ( cred , 'id' ) ) ;
58+
59+ this . send ( 'authPacket' ) ;
60+ }
61+ } ,
4962 authPacket ( savedCB ) {
63+ const auth = {
64+ type : 'cloud' ,
65+ token : get ( this , 'model.cloudCredentialId' ) ,
66+ } ;
67+
5068 if ( ! this . validateAuthentication ( ) ) {
5169 savedCB ( false ) ;
5270 return ;
@@ -160,10 +178,10 @@ export default Ember.Component.extend(NodeDriver, {
160178
161179 bootstrap ( ) {
162180 let store = get ( this , 'globalStore' ) ;
181+ set ( this , 'cloudCredentials' , this . globalStore . all ( 'cloudCredential' ) ) ;
163182 let config = store . createRecord ( {
164183 type : 'packetConfig' ,
165184 projectId : '' ,
166- apiKey : '' ,
167185 hwReservationId : '' ,
168186 deviceType : 'on-demand' ,
169187 } ) ;
@@ -267,6 +285,10 @@ export default Ember.Component.extend(NodeDriver, {
267285 errors . push ( 'Plan is requried' ) ;
268286 }
269287
288+ if ( ! this . validateCloudCredentials ( ) ) {
289+ errors . push ( this . intl . t ( 'nodeDriver.cloudCredentialError' ) ) ;
290+ }
291+
270292 if ( errors . length ) {
271293 set ( this , 'errors' , errors . uniq ( ) ) ;
272294
0 commit comments