Clean up image and make it work with cfgfactory

Basic refactor to work with the new CTL methods

Change-Id: I55e15a12949f2a8b61afb7aed617ceeb39231c26
This commit is contained in:
Schiefelbein, Andrew 2020-10-23 15:20:56 -05:00
parent fde880397c
commit 3ef6ff223f
6 changed files with 54 additions and 15 deletions

View File

@ -0,0 +1,31 @@
/*
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
/* add border & center the table */
.imageBorder {
padding-left: 10px;
padding-right: 10px;
padding-top: 10px;
padding-bottom: 10px;
border-spacing: 10px;
border:1px gray solid;
border-radius: 5px;
align-self: center;
width: 97%;
}
.container {
padding-left: 10px;
padding-right: 10px;
}

View File

@ -1 +1,6 @@
<button mat-raised-button color="accent" (click)="generateIso()">Generate ISO</button>
<h1>Airship Image Operations</h1>
<div class="container">
<div class="imageBorder">
<button type="button" id="DocPullBtn" (click)="generateIso()">Generate ISO</button>&nbsp;&nbsp;Response: {{statusMsg}}
</div>
</div>

View File

@ -14,7 +14,6 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ImageComponent } from './image.component';
import { MatButtonModule } from '@angular/material/button';
import { ToastrModule } from 'ngx-toastr';
describe('ImageComponent', () => {
@ -24,7 +23,6 @@ describe('ImageComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MatButtonModule,
ToastrModule.forRoot()
],
declarations: [

View File

@ -13,14 +13,15 @@
*/
import { Component } from '@angular/core';
import { WebsocketService } from '../../../services/websocket/websocket.service';
import { WebsocketMessage, WSReceiver } from '../../../services/websocket/websocket.models';
import { Log } from '../../../services/log/log.service';
import { LogMessage } from '../../../services/log/log-message';
import { WebsocketService } from 'src/services/websocket/websocket.service';
import { WebsocketMessage, WSReceiver } from 'src/services/websocket/websocket.models';
import { Log } from 'src/services/log/log.service';
import { LogMessage } from 'src/services/log/log-message';
@Component({
selector: 'app-bare-metal',
templateUrl: './image.component.html',
styleUrls: ['./image.component.css']
})
export class ImageComponent implements WSReceiver {
@ -28,6 +29,7 @@ export class ImageComponent implements WSReceiver {
// TODO (aschiefe): extract these strings to constants
type = 'ctl';
component = 'image';
statusMsg: string;
constructor(private websocketService: WebsocketService) {
this.websocketService.registerFunctions(this);

View File

@ -14,12 +14,8 @@
import { NgModule } from '@angular/core';
import { ImageComponent } from './image.component';
import { MatButtonModule } from '@angular/material/button';
@NgModule({
imports: [
MatButtonModule
],
declarations: [
ImageComponent
],

View File

@ -15,9 +15,10 @@
package ctl
import (
"errors"
"fmt"
"opendev.org/airship/airshipctl/pkg/config"
"opendev.org/airship/airshipctl/pkg/phase"
"opendev.org/airship/airshipui/pkg/configs"
)
@ -42,7 +43,7 @@ func HandleImageRequest(user *string, request configs.WsMessage) configs.WsMessa
subComponent := request.SubComponent
switch subComponent {
case configs.Build:
case configs.Generate:
// since this is long running cache it up
// TODO: Test before running the geniso
runningRequests[subComponent] = true
@ -63,7 +64,13 @@ func HandleImageRequest(user *string, request configs.WsMessage) configs.WsMessa
return response
}
// generate iso now just runs a phase and not an individual command
func (c *Client) generateIso() (*string, error) {
err := errors.New("Isogen is no longer available")
return nil, err
cfgFactory := config.CreateFactory(AirshipConfigPath, KubeConfigPath)
p := &phase.RunCommand{
Factory: cfgFactory,
}
p.Options.PhaseID.Name = config.BootstrapPhase
s := "Success"
return &s, p.RunE()
}