Skip to content
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

add vic appliance ip information in summary view #601

Merged
merged 1 commit into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,17 @@ describe('CreateVchWizardService', () => {
expect(response).toBe('10.20.250.255');
});

connection.mockRespond(new Response(new ResponseOptions({
body: ['vic-ova-2: v1.2.0-12000-bbbbbb, 10.20.250.255', 'vic-ova-1: v1.1.0-11000-aaaaaa, 10.20.250.254']
})));
if (!connection.response) {
connection.mockRespond(new Response(new ResponseOptions({
body: ['vic-ova-2: v1.2.0-12000-bbbbbb, 10.20.250.255', 'vic-ova-1: v1.1.0-11000-aaaaaa, 10.20.250.254']
})));
}
});

it('should handle invalid response from VIC appliance lookup endpoint', async() => {
service.getVicApplianceIp().subscribe(response => {}, err => {
expect(err).toBeTruthy();
it('should get value from cache if invoke ip address api second time', async() => {
service.getVicApplianceIp().subscribe(response => {
expect(response).toBe('10.20.250.255');
});

connection.mockRespond(new Response(new ResponseOptions({
body: 'not an array of string values'
})));
});

it('should retrieve a list of distributed port groups', async() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
limitations under the License.
*/

import 'rxjs/add/observable/timer';
import 'rxjs/add/observable/zip';
import 'rxjs/add/operator/mergeAll';
import 'rxjs/add/operator/mergeMap';

import {
CHECK_RP_UNIQUENESS_URL,
Expand All @@ -31,6 +27,10 @@ import { Http, URLSearchParams } from '@angular/http';
import { GlobalsService } from '../shared';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/timer';
import 'rxjs/add/observable/zip';
import 'rxjs/add/operator/mergeAll';
import 'rxjs/add/operator/mergeMap';
import { byteToLegibleUnit } from '../shared/utils/filesize';
import { flattenArray } from '../shared/utils/array-utils';
import {
Expand All @@ -52,6 +52,7 @@ export class CreateVchWizardService {
private _userId: string = null;
private _serverGuid: string[] = [];
private _userSession: any = null;
private _appliance: Observable <string []>;

constructor(
private http: Http,
Expand All @@ -60,6 +61,20 @@ export class CreateVchWizardService {
private vicVmViewService: VicVmViewService
) {
this.getUserSession();
this._appliance = this.setAppliance();
}

setAppliance(): Observable <string []> {
return this.http.get(VIC_APPLIANCES_LOOKUP_URL)
.publishReplay(1, 2000)
.refCount()
.take(1)
.catch(err => Observable.throw(err))
.map(response => response.json());
}

getAppliance() {
return this._appliance;
}

getClusterConfiguration(objRef: string): Observable<any[]> {
Expand Down Expand Up @@ -539,22 +554,11 @@ export class CreateVchWizardService {
});
}

/**
* Look up and return from the vSphere inventory name, version and IP address
* for all VIC appliance VMs
* @returns {Observable<string[]>} array of VIC appliances info sorted by build #
*/
private getVicAppliancesList(): Observable<string[]> {
return this.http.get(VIC_APPLIANCES_LOOKUP_URL)
.catch(err => Observable.throw(err))
.map(response => response.json());
}

/**
* Get the IP address of the newest VIC appliance
*/
public getVicApplianceIp(): Observable<string> {
return this.getVicAppliancesList()
return this.getAppliance()
.catch(err => Observable.throw(err))
.switchMap((list: string[]) => {
if (!list || !list.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,58 @@
</div>
</div>
</div>
<div class="col-xs-12">
<div class="col-xs-12 summary-wrapper">
<img class="vic-summary-view-logo" src="{{ vicLogoPath }}">
<ul class="summary-items-list">
<li id="vendor">
<span class="summary-label">
{{ vicI18n.translate(WS_SUMMARY_CONSTANTS, 'VENDOR') }}
</span>
<span class="summary-value">
VMware
</span>
</li>
<li id="version">
<span class="summary-label">
{{ vicI18n.translate(WS_SUMMARY_CONSTANTS, 'VERSION') }}
</span>
<span class="summary-value">
{{ pluginVersion }}
</span>
</li>
<li id="vch_len">
<span class="summary-label">
{{ vicI18n.translate(WS_SUMMARY_CONSTANTS, 'VCH') }}
</span>
<span class="summary-value">
{{ vchVmsLen }}
</span>
</li>
</ul>
<section class="summary-content">
<div class="summary-title">VIC PLUGIN INFORMATION</div>
<ul class="summary-items-list">
<li id="vendor">
<span class="summary-label">
{{ vicI18n.translate(WS_SUMMARY_CONSTANTS, 'VENDOR') }}
</span>
<span class="summary-value">
VMware
</span>
</li>
<li id="version">
<span class="summary-label">
{{ vicI18n.translate(WS_SUMMARY_CONSTANTS, 'VERSION') }}
</span>
<span class="summary-value">
{{ pluginVersion }}
</span>
</li>
<li id="vch_len">
<span class="summary-label">
{{ vicI18n.translate(WS_SUMMARY_CONSTANTS, 'VCH') }}
</span>
<span class="summary-value">
{{ vchVmsLen }}
</span>
</li>
</ul>
</section>
<section class="summary-content">
<div class="summary-title">VIC APPLIANCE INFORMATION</div>
<ul class="summary-items-list">
<li>
<span class="summary-label">
{{ vicI18n.translate(WS_SUMMARY_CONSTANTS, 'VERSION') }}
</span>
<span class="summary-value">
{{applianceVersion}}
</span>
</li>
<li>
<span class="summary-label">
IP Address
</span>
<span class="summary-value">
{{applianceIp}}
</span>
</li>
</ul>
</section>
</div>
<div class="col-xs">
<p class="summary-intro mt-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ describe('VIC object view: Summary tab', () => {
{ provide: CreateVchWizardService, useValue: {
verifyVicMachineApiEndpoint() {
return Observable.of('10.10.10.10');
},
getAppliance() {
return Observable.of(['vic-ova-2: v1.2.0-12000-bbbbbb, 10.20.250.255']);
}
}}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import { CreateVchWizardService } from '../create-vch-wizard/create-vch-wizard.service';
import { DataPropertyService } from '../services/data-property.service';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Rx';
import { Subscription, Subject} from 'rxjs/Rx';
import { Vic18nService } from '../shared/vic-i18n.service';

@Component({
Expand All @@ -37,10 +37,13 @@ export class VicSummaryViewComponent implements OnInit, OnDestroy {
public vicLogoPath: string;
public pluginVersion: string;
public vchVmsLen: number;
public appliance = new Subject<string []>();
public readonly WS_SUMMARY_CONSTANTS = WS_SUMMARY;
private rootInfoSubscription: Subscription;
private refreshSubscription: Subscription;
public error: any;
public applianceIp: string;
public applianceVersion: string;

constructor(
private zone: NgZone,
Expand Down Expand Up @@ -87,11 +90,24 @@ export class VicSummaryViewComponent implements OnInit, OnDestroy {

ngOnInit() {
this.fetchRootInfo();

// verify the appliance endpoint
this.getApplianceInfo();
this.checkVicMachineServer();
}

getApplianceInfo() {
this.createWzService.getAppliance()
.subscribe(
(response) => {
if (response.length > 0) {
const splitByColon = response[0].split(':');
this.applianceVersion = splitByColon[0];
this.applianceIp = splitByColon[1].split(',')[1].trim();
}
}
)
}

checkVicMachineServer() {
this.createWzService.verifyVicMachineApiEndpoint()
.subscribe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ div.summary-container {
padding-top: 10px;
font-size: 13px;
img.vic-summary-view-logo {
height:100px;
padding-right: 2em;
vertical-align: top;
}
Expand All @@ -29,7 +30,7 @@ ul.summary-items-list {
display: table-row-group;
span.summary-label {
display: table-cell;
width: auto;
min-width: 145px;
}
span.summary-value {
display: table-cell;
Expand All @@ -48,3 +49,17 @@ p.summary-intro {
.mb-2 {
margin-bottom: 2rem !important;
}

.summary-wrapper {
display: flex;

.summary-content {
margin-right: 80px;
min-width:340px;
}

.summary-title {
font-weight: bold;
margin-bottom: 10px;
}
}