File tree Expand file tree Collapse file tree
plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource
scripts/storage/secondary Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -173,7 +173,12 @@ public string FullFileName
173173 {
174174 fileName += @"\" + this . path ;
175175 }
176- fileName = Utils . NormalizePath ( fileName + @"\" + this . name ) ;
176+
177+ fileName = Utils . NormalizePath ( fileName ) ;
178+ if ( Directory . Exists ( fileName ) )
179+ {
180+ fileName = Utils . NormalizePath ( fileName + @"\" + this . name ) ;
181+ }
177182 }
178183 else
179184 {
@@ -182,7 +187,7 @@ public string FullFileName
182187 throw new InvalidDataException ( errMsg ) ;
183188 }
184189
185- if ( this . format != null )
190+ if ( ! Path . HasExtension ( fileName ) && this . format != null )
186191 {
187192 fileName = fileName + "." + this . format . ToLowerInvariant ( ) ;
188193 }
Original file line number Diff line number Diff line change @@ -111,6 +111,14 @@ uncompress() {
111111 return 0
112112}
113113
114+ isCifs () {
115+ # TO:DO incase of multiple zone where cifs and nfs exists,
116+ # then check if the template file is from cifs using df -P filename
117+ # Currently only cifs is supported in hyperv zone.
118+ mount | grep " type cifs" > /dev/null
119+ echo $?
120+ }
121+
114122create_from_file () {
115123 local tmpltfs=$1
116124 local tmpltimg=$2
@@ -196,12 +204,15 @@ rollback_if_needed $tmpltfs $? "tar archives not supported\n"
196204
197205if [ ${tmpltname% .vhd} != ${tmpltname} ]
198206then
199- if which vhd-util & > /dev/null
200- then
201- vhd-util check -n ${tmpltimg2} > /dev/null
202- rollback_if_needed $tmpltfs $? " vhd check of $tmpltimg2 failed\n"
203- vhd-util set -n ${tmpltimg2} -f " hidden" -v " 0" > /dev/null
204- rollback_if_needed $tmpltfs $? " vhd remove $tmpltimg2 hidden failed\n"
207+ if [ isCifs -ne 0 ] ;
208+ then
209+ if which vhd-util & > /dev/null
210+ then
211+ vhd-util check -n ${tmpltimg2} > /dev/null
212+ rollback_if_needed $tmpltfs $? " vhd check of $tmpltimg2 failed\n"
213+ vhd-util set -n ${tmpltimg2} -f " hidden" -v " 0" > /dev/null
214+ rollback_if_needed $tmpltfs $? " vhd remove $tmpltimg2 hidden failed\n"
215+ fi
205216 fi
206217fi
207218
Original file line number Diff line number Diff line change @@ -958,8 +958,19 @@ public static HypervisorType getVolumeHyperType(long volumeId) {
958958 return _volumeDao .getHypervisorType (volumeId );
959959 }
960960
961- public static HypervisorType getHypervisorTypeFromFormat (ImageFormat format ){
962- return _storageMgr .getHypervisorTypeFromFormat (format );
961+ public static HypervisorType getHypervisorTypeFromFormat (long dcId , ImageFormat format ){
962+ HypervisorType type = _storageMgr .getHypervisorTypeFromFormat (format );
963+ if (format == ImageFormat .VHD ) {
964+ // Xenserver and Hyperv both support vhd format. Additionally hyperv is only supported
965+ // in a dc/zone if there aren't any other hypervisor types present in the zone). If the
966+ // format type is VHD check is any xenserver clusters are present. If not, we assume it
967+ // is a hyperv zone and update the type.
968+ List <ClusterVO > xenClusters = _clusterDao .listByDcHyType (dcId , HypervisorType .XenServer .toString ());
969+ if (xenClusters .isEmpty ()) {
970+ type = HypervisorType .Hyperv ;
971+ }
972+ }
973+ return type ;
963974 }
964975
965976
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ public VolumeResponse newVolumeResponse(VolumeJoinVO volume) {
115115 volResponse .setCreated (volume .getCreatedOnStore ());
116116
117117 if (caller .getType () == Account .ACCOUNT_TYPE_ADMIN || caller .getType () == Account .ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN )
118- volResponse .setHypervisor (ApiDBUtils .getHypervisorTypeFromFormat (volume .getFormat ()).toString ());
118+ volResponse .setHypervisor (ApiDBUtils .getHypervisorTypeFromFormat (volume .getDataCenterId (), volume . getFormat ()).toString ());
119119 if (volume .getDownloadState () != Status .DOWNLOADED ) {
120120 String volumeStatus = "Processing" ;
121121 if (volume .getDownloadState () == VMTemplateHostVO .Status .DOWNLOAD_IN_PROGRESS ) {
@@ -180,7 +180,7 @@ public VolumeResponse newVolumeResponse(VolumeJoinVO volume) {
180180 if (volume .getHypervisorType () != null ) {
181181 volResponse .setHypervisor (volume .getHypervisorType ().toString ());
182182 } else {
183- volResponse .setHypervisor (ApiDBUtils .getHypervisorTypeFromFormat (volume .getFormat ()).toString ());
183+ volResponse .setHypervisor (ApiDBUtils .getHypervisorTypeFromFormat (volume .getDataCenterId (), volume . getFormat ()).toString ());
184184 }
185185 }
186186 Long poolId = volume .getPoolId ();
You can’t perform that action at this time.
0 commit comments