-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new method for returning all security groups from openstack. Re…
…-factored some code. Returning a common instance state instead of the state provided by openstack.
- Loading branch information
Jamie Hall
committed
Sep 8, 2021
1 parent
f2d496d
commit da2d37a
Showing
14 changed files
with
1,295 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {NextFunction, Request, Response} from "express"; | ||
import {singleton} from "tsyringe"; | ||
import {OpenstackService} from "../services"; | ||
|
||
@singleton() | ||
export class SecurityGroupController { | ||
|
||
private readonly _openstack: OpenstackService; | ||
|
||
/** | ||
* Create a new security group controller | ||
* @param openstack the openstack API http client | ||
*/ | ||
constructor(readonly openstack: OpenstackService) { | ||
this._openstack = openstack; | ||
} | ||
|
||
/** | ||
* Get a list of security groups | ||
* @param request the http request | ||
* @param response the http response | ||
* @param next the next middleware handler | ||
*/ | ||
public async all(request: Request, response: Response, next: NextFunction) { | ||
try { | ||
const groups = await this._openstack.securityGroups(); | ||
response.json(groups); | ||
} catch (error) { | ||
next(error); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {IocContainer} from '@tsoa/runtime'; | ||
import {container} from 'tsyringe'; | ||
import {OpenstackAuthenticator, OpenstackService} from "../services"; | ||
import {APPLICATION_CONFIG} from "../application-config"; | ||
|
||
container.register<OpenstackService>(OpenstackService, { | ||
useValue: new OpenstackService( | ||
{ | ||
computeEndpoint: APPLICATION_CONFIG().openstack.computeEndpoint, | ||
imageEndpoint: APPLICATION_CONFIG().openstack.imageEndpoint, | ||
networkEndpoint: APPLICATION_CONFIG().openstack.networkEndpoint | ||
}, | ||
{ | ||
addressProvider: APPLICATION_CONFIG().openstack.addressProvider, | ||
addressProviderUUID: APPLICATION_CONFIG().openstack.addressProviderUUID | ||
}, | ||
new OpenstackAuthenticator( | ||
APPLICATION_CONFIG().openstack.identityEndpoint, | ||
APPLICATION_CONFIG().openstack.applicationId, | ||
APPLICATION_CONFIG().openstack.applicationSecret, | ||
APPLICATION_CONFIG().openstack.timeout | ||
), | ||
APPLICATION_CONFIG().openstack.timeout | ||
) | ||
}); | ||
export const iocContainer: IocContainer = { | ||
get: <T>(controller: { prototype: T }): T => | ||
container.resolve<T>(controller as never), | ||
}; | ||
export {container}; | ||
export default iocContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export enum CloudInstanceState { | ||
UNKNOWN = 'UNKNOWN', | ||
BUILDING = 'BUILDING', | ||
STARTING = 'STARTING', | ||
ACTIVE = 'ACTIVE', | ||
STOPPING = 'STOPPING', | ||
STOPPED = 'STOPPED', | ||
REBOOTING = 'REBOOTING', | ||
UNAVAILABLE = 'UNAVAILABLE', | ||
ERROR = 'ERROR', | ||
DELETED = 'DELETED' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.