Skip to content
This repository has been archived by the owner on Nov 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #195 from suomiy/release-candidate
Browse files Browse the repository at this point in the history
Fixed disks and nics  for v4 API + APK
  • Loading branch information
jelkosz authored Sep 20, 2016
2 parents 220cee8 + 8ccb375 commit 8b7eae4
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You can install it from [Google Play Store](https://play.google.com/store/apps/d
Or using the [direct link](https://github.com/matobet/moVirt/blob/master/moVirt/moVirt-release.apk?raw=true)

###Supported oVirt and Android per moVirt version
| oVirt \ moVirt | 1.1<sup>1</sup> | 1.2<sup>1</sup> | 1.3<sup>2</sup>, 1.4<sup>2</sup> | 1.5<sup>2</sup>, 1.6<sup>2</sup> |
| oVirt \ moVirt | [1.1](https://github.com/matobet/moVirt/raw/430cb4a1aae86e66a3ed3a3b7cae7d072354cb76/moVirt/moVirt-release.apk)<sup>1</sup> | [1.2](https://github.com/matobet/moVirt/raw/f8585585a02396de7dd555860a102e2ba4dff4f8/moVirt/moVirt-release.apk)<sup>1</sup> | [1.3](https://github.com/matobet/moVirt/raw/976cceaad5d298b9e734a9b79cf4966a088eacc3/moVirt/moVirt-release.apk)<sup>2</sup>, [1.4](https://github.com/matobet/moVirt/raw/4896f4d8cecd6b733d921324a347505bc6437f72/moVirt/moVirt-release.apk)<sup>2</sup> | [1.5](https://github.com/matobet/moVirt/raw/9ce19a6a16e76da79473887a0074066b9e3ea494/moVirt/moVirt-release.apk)<sup>2</sup>, [1.6](https://github.com/matobet/moVirt/raw/524af62b55f7490232c0476a74ea56582c1f1b5b/moVirt/moVirt-release.apk)<sup>2</sup> |
| --------------- | ---- | --- | ----| --- |
| **3.4** | yes | yes | no<sup>3</sup> | no<sup>3</sup> |
| **3.5** | no | yes | yes | no<sup>3</sup> |
Expand Down
Binary file modified moVirt/moVirt-release.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public Bundle getAuthToken(AccountAuthenticatorResponse accountAuthenticatorResp
final String password = getPassword();
if (username != null && password != null) {
try {
if(!AuthenticatorActivity.isInUserLogin()){ // do not attempt to login while user tries
if (!AuthenticatorActivity.isInUserLogin()) { // do not attempt to login while user tries
authToken = client.login(username, password);
}
} catch (Exception x) { // do not fail on bad login info
Expand Down Expand Up @@ -164,6 +164,10 @@ public String getApiMajorVersion() {
return read(API_MAJOR_VERSION, fallbackMajorVersion);
}

public String getFallbackMajorVersion() {
return fallbackMajorVersion;
}

public int getApiMajorVersionAsInt() {
return Integer.parseInt(getApiMajorVersion());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public Disk fire() {
if (isApiV3()) {
wrapper = restClient.getDiskV3(vmId, id);
} else {
wrapper = restClient.getDiskV4(vmId, id);
wrapper = restClient.getDiskV4(id);
}
entity = wrapper.toEntity();
}
Expand Down Expand Up @@ -421,10 +421,15 @@ public List<Disk> fire() {
entities = mapToEntities(wrappers);
setVmId(entities, vmId);
} else {
if (isApiV3()) {
// fallback to API 3 here until this feature is fixed
// https://bugzilla.redhat.com/show_bug.cgi?id=1377359
try {
if (!isApiV3()) {
setupVersionHeader(restClient, authenticator.getFallbackMajorVersion());
}
wrappers = restClient.getDisksV3(vmId);
} else {
wrappers = restClient.getDisksV4(vmId);
} finally {
setupVersionHeader(restClient, authenticator.getApiMajorVersion());
}
entities = mapToEntities(wrappers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

@Rest(converters = MappingJackson2HttpMessageConverter.class)
@Accept(MediaType.APPLICATION_JSON + "; detail=statistics+disks+nics")
// disks and nics work only in v3 API
@RequiresHeader({"Filter", "Accept-Encoding", "Session-TTL", "Prefer", "Version"})
@SetsCookie("JSESSIONID")
@RequiresCookie("JSESSIONID")
Expand Down Expand Up @@ -133,8 +134,8 @@ public interface OVirtRestClient extends RestClientRootUrl, RestClientHeaders, R
@Get("/vms/{vmId}/disks/{diskId}")
org.ovirt.mobile.movirt.rest.v3.Disk getDiskV3(@Path String vmId, @Path String diskId);

@Get("/vms/{vmId}/disks/{diskId}")
org.ovirt.mobile.movirt.rest.v4.Disk getDiskV4(@Path String vmId, @Path String diskId);
@Get("/disks/{diskId}")
org.ovirt.mobile.movirt.rest.v4.Disk getDiskV4(@Path String diskId);

@Get("/vms/{vmId}/snapshots/{snapshotId}/disks/{diskId}")
org.ovirt.mobile.movirt.rest.v3.Disk getDiskV3(@Path String vmId, @Path String snapshotId, @Path String diskId);
Expand All @@ -145,9 +146,6 @@ public interface OVirtRestClient extends RestClientRootUrl, RestClientHeaders, R
@Get("/vms/{vmId}/disks")
org.ovirt.mobile.movirt.rest.v3.Disks getDisksV3(@Path String vmId);

@Get("/vms/{vmId}/disks")
org.ovirt.mobile.movirt.rest.v4.Disks getDisksV4(@Path String vmId);

@Get("/vms/{vmId}/snapshots/{snapshotId}/disks")
org.ovirt.mobile.movirt.rest.v3.Disks getDisksV3(@Path String vmId, @Path String snapshotId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import android.widget.TextView;

import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.Receiver;
import org.ovirt.mobile.movirt.Broadcasts;
import org.ovirt.mobile.movirt.R;
import org.ovirt.mobile.movirt.auth.MovirtAuthenticator;
import org.ovirt.mobile.movirt.model.Disk;
import org.ovirt.mobile.movirt.ui.ProgressBarResponse;
import org.ovirt.mobile.movirt.ui.ResumeSyncableBaseEntityListFragment;
Expand All @@ -29,6 +31,9 @@
public class VmDisksFragment extends ResumeSyncableBaseEntityListFragment<Disk> {
private static final String TAG = VmDisksFragment.class.getSimpleName();

@Bean
MovirtAuthenticator authenticator;

public VmDisksFragment() {
super(Disk.class);
}
Expand Down Expand Up @@ -66,7 +71,7 @@ public boolean setViewValue(View view, Cursor cursor, int columnIndex) {

@Override
public boolean isResumeSyncable() {
return isSnapshotFragment();
return !authenticator.isApiV3() || isSnapshotFragment(); //we fetch disks with vm in v3 API
}

@Background
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import android.widget.TextView;

import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.Receiver;
import org.ovirt.mobile.movirt.Broadcasts;
import org.ovirt.mobile.movirt.R;
import org.ovirt.mobile.movirt.auth.MovirtAuthenticator;
import org.ovirt.mobile.movirt.model.Nic;
import org.ovirt.mobile.movirt.ui.ProgressBarResponse;
import org.ovirt.mobile.movirt.ui.ResumeSyncableBaseEntityListFragment;
Expand All @@ -31,6 +33,9 @@
public class VmNicsFragment extends ResumeSyncableBaseEntityListFragment<Nic> {
private static final String TAG = VmNicsFragment.class.getSimpleName();

@Bean
MovirtAuthenticator authenticator;

public VmNicsFragment() {
super(Nic.class);
}
Expand Down Expand Up @@ -79,7 +84,7 @@ public String[] getSortEntries() {

@Override
public boolean isResumeSyncable() {
return isSnapshotFragment();
return !authenticator.isApiV3() || isSnapshotFragment(); //we fetch nics with vm in v3 API
}

@Background
Expand Down

0 comments on commit 8b7eae4

Please sign in to comment.