New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLOUDSTACK-10197: Rename xentools iso for XenServer 7.0+ #2365
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2592,9 +2592,10 @@ public VDI getIsoVDIByURL(final Connection conn, final String vmName, final Stri | |
String mountpoint = null; | ||
if (isoURL.startsWith("xs-tools")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This ISO URL remained the same? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it did. I had an idea to change the iso name (url here refers to name) to something general - like |
||
try { | ||
final Set<VDI> vdis = VDI.getByNameLabel(conn, isoURL); | ||
final String actualIsoURL = actualIsoTemplate(conn); | ||
final Set<VDI> vdis = VDI.getByNameLabel(conn, actualIsoURL); | ||
if (vdis.isEmpty()) { | ||
throw new CloudRuntimeException("Could not find ISO with URL: " + isoURL); | ||
throw new CloudRuntimeException("Could not find ISO with URL: " + actualIsoURL); | ||
} | ||
return vdis.iterator().next(); | ||
|
||
|
@@ -2630,6 +2631,22 @@ public VDI getIsoVDIByURL(final Connection conn, final String vmName, final Stri | |
} | ||
} | ||
|
||
private String actualIsoTemplate(final Connection conn) throws BadServerResponse, XenAPIException, XmlRpcException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind creating a documentation for the method? Then, you do not need comments in line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add the documentation, but I really don't think unit testing on this specific method will be possible. Because it needs a live XenServer Host for the method to connect to (both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do not need a real host. We only want to test the logic. Therefore, you can mock the method calls. PowerMockito and Mockito are there for this kind of job. |
||
final Host host = Host.getByUuid(conn, _host.getUuid()); | ||
final Host.Record record = host.getRecord(conn); | ||
final String xenBrand = record.softwareVersion.get("product_brand"); | ||
final String xenVersion = record.softwareVersion.get("product_version"); | ||
final String[] items = xenVersion.split("\\."); | ||
|
||
// guest-tools.iso for XenServer version 7.0+ | ||
if (xenBrand.equals("XenServer") && Integer.parseInt(items[0]) >= 7) { | ||
return "guest-tools.iso"; | ||
} | ||
|
||
// xs-tools.iso for older XenServer versions | ||
return "xs-tools.iso"; | ||
} | ||
|
||
public String getLabel() { | ||
final Connection conn = getConnection(); | ||
final String result = callHostPlugin(conn, "ovstunnel", "getLabel"); | ||
|
@@ -3882,9 +3899,10 @@ protected VDI mount(final Connection conn, final String vmName, final DiskTO vol | |
final String templateName = iso.getName(); | ||
if (templateName.startsWith("xs-tools")) { | ||
try { | ||
final Set<VDI> vdis = VDI.getByNameLabel(conn, templateName); | ||
final String actualTemplateName = actualIsoTemplate(conn); | ||
final Set<VDI> vdis = VDI.getByNameLabel(conn, actualTemplateName); | ||
if (vdis.isEmpty()) { | ||
throw new CloudRuntimeException("Could not find ISO with URL: " + templateName); | ||
throw new CloudRuntimeException("Could not find ISO with URL: " + actualTemplateName); | ||
} | ||
return vdis.iterator().next(); | ||
} catch (final XenAPIException e) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will create an entry for deployments that do not have it yet using this new "standardized name". However, for environment that already had it from previous versions, the name (display_text) will not be updated, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct, I can explicitly add
tmplt.setDisplayText("XenServer Tools Installer ISO (xen-pv-drv-iso)");
at line 544 (couple lines down here)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the right thing to do, so we get consistency.
You have to save the
tmplt
as well right? So, you update the data in the database