Default Values & Code Style
This commit is contained in:
		
							parent
							
								
									8dbe45a789
								
							
						
					
					
						commit
						7f998ebec2
					
				|  | @ -64,6 +64,9 @@ parameters: | ||||||
| ... | ... | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
|  | Note that it is currently not supported by Synology devices to restore a snapshot onto a different volume. You can | ||||||
|  | create volumes from snapshots, but you should use the same `StorageClass` as the original volume of the snapshot did.  | ||||||
|  | 
 | ||||||
| ### Enabling CHAP Authentication | ### Enabling CHAP Authentication | ||||||
| You can enable CHAP Authentication for `StorageClass`es by supplying an appropriate `StorageClass` secret (see the | You can enable CHAP Authentication for `StorageClass`es by supplying an appropriate `StorageClass` secret (see the | ||||||
| [documentation](https://kubernetes-csi.github.io/docs/secrets-and-credentials-storage-class.html) for more details). You | [documentation](https://kubernetes-csi.github.io/docs/secrets-and-credentials-storage-class.html) for more details). You | ||||||
|  |  | ||||||
|  | @ -39,7 +39,12 @@ class SynologyError extends GrpcError { | ||||||
| 
 | 
 | ||||||
| class SynologyHttpClient { | class SynologyHttpClient { | ||||||
|   constructor(options = {}) { |   constructor(options = {}) { | ||||||
|     this.options = JSON.parse(JSON.stringify(options)); |     this.options = Object.assign({ | ||||||
|  |       protocol: "https", | ||||||
|  |       port: 5001, | ||||||
|  |       allowInsecure: false, | ||||||
|  |       session: "democratic-csi" | ||||||
|  |     }, JSON.parse(JSON.stringify(options))); | ||||||
|     this.logger = console; |     this.logger = console; | ||||||
|     this.doLoginMutex = new Mutex(); |     this.doLoginMutex = new Mutex(); | ||||||
|     this.apiSerializeMutex = new Mutex(); |     this.apiSerializeMutex = new Mutex(); | ||||||
|  | @ -618,7 +623,7 @@ class SynologyHttpClient { | ||||||
|     return await this.do_request("GET", "entry.cgi", create_cloned_volume); |     return await this.do_request("GET", "entry.cgi", create_cloned_volume); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async CreateVolumeFromSnapshot(src_lun_uuid, snapshot_uuid, cloned_lun_name) { |   async CreateVolumeFromSnapshot(src_lun_uuid, snapshot_uuid, cloned_lun_name, description) { | ||||||
|     const create_volume_from_snapshot = { |     const create_volume_from_snapshot = { | ||||||
|       api: "SYNO.Core.ISCSI.LUN", |       api: "SYNO.Core.ISCSI.LUN", | ||||||
|       version: 1, |       version: 1, | ||||||
|  | @ -628,6 +633,9 @@ class SynologyHttpClient { | ||||||
|       cloned_lun_name: cloned_lun_name, // cloned lun name
 |       cloned_lun_name: cloned_lun_name, // cloned lun name
 | ||||||
|       clone_type: "democratic-csi", // check
 |       clone_type: "democratic-csi", // check
 | ||||||
|     }; |     }; | ||||||
|  |     if (description) { | ||||||
|  |       create_volume_from_snapshot.description = description; | ||||||
|  |     } | ||||||
|     return await this.do_request( |     return await this.do_request( | ||||||
|       "GET", |       "GET", | ||||||
|       "entry.cgi", |       "entry.cgi", | ||||||
|  |  | ||||||
|  | @ -441,7 +441,8 @@ class ControllerSynologyDriver extends CsiBaseDriver { | ||||||
|                 await httpClient.CreateVolumeFromSnapshot( |                 await httpClient.CreateVolumeFromSnapshot( | ||||||
|                   src_lun_uuid, |                   src_lun_uuid, | ||||||
|                   snapshot_uuid, |                   snapshot_uuid, | ||||||
|                   iscsiName |                   iscsiName, | ||||||
|  |                   normalizedParameters.description | ||||||
|                 ); |                 ); | ||||||
|               } |               } | ||||||
|               break; |               break; | ||||||
|  | @ -465,7 +466,12 @@ class ControllerSynologyDriver extends CsiBaseDriver { | ||||||
|                     `invalid volume_id: ${volume_content_source.volume.volume_id}` |                     `invalid volume_id: ${volume_content_source.volume.volume_id}` | ||||||
|                   ); |                   ); | ||||||
|                 } |                 } | ||||||
|                 await httpClient.CreateClonedVolume(src_lun_uuid, iscsiName, driver.getLocation(normalizedParameters)); |                 await httpClient.CreateClonedVolume( | ||||||
|  |                   src_lun_uuid, | ||||||
|  |                   iscsiName, | ||||||
|  |                   driver.getLocation(normalizedParameters), | ||||||
|  |                   normalizedParameters.description | ||||||
|  |                 ); | ||||||
|               } |               } | ||||||
|               break; |               break; | ||||||
|             default: |             default: | ||||||
|  | @ -549,13 +555,13 @@ class ControllerSynologyDriver extends CsiBaseDriver { | ||||||
|           iqn, |           iqn, | ||||||
|         }); |         }); | ||||||
|         if ('headerChecksum' in normalizedParameters) { |         if ('headerChecksum' in normalizedParameters) { | ||||||
|           data.has_data_checksum = normalizedParameters['headerChecksum']; |           data.has_data_checksum = normalizedParameters.headerChecksum; | ||||||
|         } |         } | ||||||
|         if ('dataChecksum' in normalizedParameters) { |         if ('dataChecksum' in normalizedParameters) { | ||||||
|           data.has_data_checksum = normalizedParameters['dataChecksum']; |           data.has_data_checksum = normalizedParameters.dataChecksum; | ||||||
|         } |         } | ||||||
|         if ('maxSessions' in normalizedParameters) { |         if ('maxSessions' in normalizedParameters) { | ||||||
|           data.max_sessions = Number(normalizedParameters['maxSessions']); |           data.max_sessions = Number(normalizedParameters.maxSessions); | ||||||
|           if (isNaN(data.max_sessions)) { |           if (isNaN(data.max_sessions)) { | ||||||
|             throw new GrpcError( |             throw new GrpcError( | ||||||
|               grpc.status.INVALID_ARGUMENT, |               grpc.status.INVALID_ARGUMENT, | ||||||
|  | @ -567,7 +573,7 @@ class ControllerSynologyDriver extends CsiBaseDriver { | ||||||
|           data.multi_sessions = data.max_sessions == 1; |           data.multi_sessions = data.max_sessions == 1; | ||||||
|         } |         } | ||||||
|         if ('maxReceiveSegmentBytes' in normalizedParameters) { |         if ('maxReceiveSegmentBytes' in normalizedParameters) { | ||||||
|           data.max_recv_seg_bytes = Number(normalizedParameters['maxReceiveSegmentBytes']); |           data.max_recv_seg_bytes = Number(normalizedParameters.maxReceiveSegmentBytes); | ||||||
|           if (isNaN(data.max_recv_seg_bytes)) { |           if (isNaN(data.max_recv_seg_bytes)) { | ||||||
|             throw new GrpcError( |             throw new GrpcError( | ||||||
|               grpc.status.INVALID_ARGUMENT, |               grpc.status.INVALID_ARGUMENT, | ||||||
|  | @ -576,7 +582,7 @@ class ControllerSynologyDriver extends CsiBaseDriver { | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|         if ('maxSendSegmentBytes' in normalizedParameters) { |         if ('maxSendSegmentBytes' in normalizedParameters) { | ||||||
|           data.max_send_seg_bytes = Number(normalizedParameters['maxSendSegmentBytes']); |           data.max_send_seg_bytes = Number(normalizedParameters.maxSendSegmentBytes); | ||||||
|           if (isNaN(data.max_send_seg_bytes)) { |           if (isNaN(data.max_send_seg_bytes)) { | ||||||
|             throw new GrpcError( |             throw new GrpcError( | ||||||
|               grpc.status.INVALID_ARGUMENT, |               grpc.status.INVALID_ARGUMENT, | ||||||
|  | @ -588,7 +594,7 @@ class ControllerSynologyDriver extends CsiBaseDriver { | ||||||
|         if ('user' in call.request.secrets && 'password' in call.request.secrets) { |         if ('user' in call.request.secrets && 'password' in call.request.secrets) { | ||||||
|           data.user = call.request.secrets.user; |           data.user = call.request.secrets.user; | ||||||
|           data.password = call.request.secrets.password; |           data.password = call.request.secrets.password; | ||||||
|           data['chap'] = true; |           data.chap = true; | ||||||
|           if ('mutualUser' in call.request.secrets && 'mutualPassword' in call.request.secrets) { |           if ('mutualUser' in call.request.secrets && 'mutualPassword' in call.request.secrets) { | ||||||
|             data.mutual_user = call.request.secrets.mutualUser; |             data.mutual_user = call.request.secrets.mutualUser; | ||||||
|             data.mutual_password = call.request.secrets.mutualPassword; |             data.mutual_password = call.request.secrets.mutualPassword; | ||||||
|  | @ -1001,12 +1007,12 @@ class ControllerSynologyDriver extends CsiBaseDriver { | ||||||
|         description: name, //check
 |         description: name, //check
 | ||||||
|       }); |       }); | ||||||
|       if ('isLocked' in normalizedParameters) { |       if ('isLocked' in normalizedParameters) { | ||||||
|         data['is_locked'] = driver.parseBoolean(normalizedParameters.isLocked); |         data.is_locked = driver.parseBoolean(normalizedParameters.isLocked); | ||||||
|       } |       } | ||||||
|       if (normalizedParameters.consistency === "AppConsistent") { |       if (normalizedParameters.consistency === "AppConsistent") { | ||||||
|         data['is_app_consistent'] = true; |         data.is_app_consistent = true; | ||||||
|       } else if (normalizedParameters.consistency === 'CrashConsistent') { |       } else if (normalizedParameters.consistency === 'CrashConsistent') { | ||||||
|         data['is_app_consistent'] = false; |         data.is_app_consistent = false; | ||||||
|       } else if ('consistency' in normalizedParameters.consistency) { |       } else if ('consistency' in normalizedParameters.consistency) { | ||||||
|         throw new GrpcError( |         throw new GrpcError( | ||||||
|           grpc.status.INVALID_ARGUMENT, |           grpc.status.INVALID_ARGUMENT, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue