From 3220ba29d20b4dcee30959327e9154c59d3bb073 Mon Sep 17 00:00:00 2001 From: Sergio Betanzos Date: Fri, 22 Jan 2021 13:17:20 +0100 Subject: [PATCH 01/11] F #3951: Fix links in descriptions (#695) --- .../containers/Providers/Form/Create/Steps/Template/index.js | 2 +- .../containers/Provisions/Form/Create/Steps/Template/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fireedge/src/client/containers/Providers/Form/Create/Steps/Template/index.js b/src/fireedge/src/client/containers/Providers/Form/Create/Steps/Template/index.js index 82ec920b4a..5b660d36d7 100644 --- a/src/fireedge/src/client/containers/Providers/Form/Create/Steps/Template/index.js +++ b/src/fireedge/src/client/containers/Providers/Form/Create/Steps/Template/index.js @@ -69,7 +69,7 @@ const Template = () => ({ const RenderDescription = ({ description = '' }) => (

{(sanitize`${description}`)?.split(' ').map((string, idx) => isExternalURL(string) - ? {string} + ? {string} : ` ${string}` )}

) diff --git a/src/fireedge/src/client/containers/Provisions/Form/Create/Steps/Template/index.js b/src/fireedge/src/client/containers/Provisions/Form/Create/Steps/Template/index.js index a413357f20..ce6cc05e49 100644 --- a/src/fireedge/src/client/containers/Provisions/Form/Create/Steps/Template/index.js +++ b/src/fireedge/src/client/containers/Provisions/Form/Create/Steps/Template/index.js @@ -76,7 +76,7 @@ const Template = () => ({ const RenderDescription = ({ description = '' }) => (

{(sanitize`${description}`)?.split(' ').map((string, idx) => isExternalURL(string) - ? {string} + ? {string} : ` ${string}` )}

) From eca0414f7468d125c6bb548ca1b80307bd6c14f9 Mon Sep 17 00:00:00 2001 From: Jorge Miguel Lobo Escalona <47326048+jloboescalona2@users.noreply.github.com> Date: Thu, 21 Jan 2021 19:30:40 +0100 Subject: [PATCH 02/11] F #3951: Initial testing (#690) Co-authored-by: Jorge Lobo --- src/fireedge/cypress.json | 16 ++ src/fireedge/cypress/command/index.js | 110 +++++++++ src/fireedge/cypress/fixtures/defaults.json | 27 +++ .../provision/dashboard/index.spec.js | 16 ++ .../integration/provision/login/index.spec.js | 31 +++ .../provision/provider/index.spec.js | 218 +++++++++++++++++ .../provision/provision/index.spec.js | 221 ++++++++++++++++++ src/fireedge/cypress/support/commands.js | 89 +++++++ src/fireedge/cypress/support/utils.js | 41 ++++ src/fireedge/package.json | 5 + 10 files changed, 774 insertions(+) create mode 100644 src/fireedge/cypress.json create mode 100644 src/fireedge/cypress/command/index.js create mode 100644 src/fireedge/cypress/fixtures/defaults.json create mode 100644 src/fireedge/cypress/integration/provision/dashboard/index.spec.js create mode 100644 src/fireedge/cypress/integration/provision/login/index.spec.js create mode 100644 src/fireedge/cypress/integration/provision/provider/index.spec.js create mode 100644 src/fireedge/cypress/integration/provision/provision/index.spec.js create mode 100644 src/fireedge/cypress/support/commands.js create mode 100644 src/fireedge/cypress/support/utils.js diff --git a/src/fireedge/cypress.json b/src/fireedge/cypress.json new file mode 100644 index 0000000000..363c88dcff --- /dev/null +++ b/src/fireedge/cypress.json @@ -0,0 +1,16 @@ +{ + "port": 2617, + "numTestsKeptInMemory": 20, + "env":{}, + "video": false, + "viewportHeight": 720, + "viewportWidth": 1280, + "baseUrl": "http://localhost:2616", + "reporter": "mochawesome", + "reporterOptions": { + "reportDir": "cypress/results", + "overwrite": false, + "html": false, + "json": true + } +} diff --git a/src/fireedge/cypress/command/index.js b/src/fireedge/cypress/command/index.js new file mode 100644 index 0000000000..8e0afe28b4 --- /dev/null +++ b/src/fireedge/cypress/command/index.js @@ -0,0 +1,110 @@ +const cypress = require('cypress') +const marge = require('mochawesome-report-generator') +const { merge } = require('mochawesome-merge') +const { existsSync, mkdirsSync, readFileSync, writeFileSync, removeSync } = require('fs-extra') +const { dirname } = require('path') + +const config = { + browser: 'chrome', + headless: true, + spec: 'cypress/integration/**/*.spec.js' +} + +const generateReport = (options = { + reportDir: 'cypress/results', + reportFilename: 'merge-results', + saveJson: true, + saveHtml: false, + files: [ + './cypress/results/*.json' + ] +}) => { + return merge(options).then(report => marge.create(report, options)) +} + +const parseReport = (dataReport = '') => { + if (dataReport && Array.isArray(dataReport) && dataReport.slice(-1).pop()) { + const pathMergeJson = dataReport.slice(-1).pop() + const bsname = dirname(pathMergeJson) + const fileData = readFileSync(pathMergeJson, 'utf8') + if (fileData) { + const dataJSON = JSON.parse(fileData) + const parsedJSON = {} + + // version + parsedJSON.version = dataJSON.meta.mochawesome.version + + // examples + const examples = [] + // results -19 + if (dataJSON.results) { + dataJSON.results.forEach(results => { + const pathTest = results.fullFile + // results.suites -28 + if (results && results.suites && Array.isArray(results.suites)) { + results.suites.forEach(suites => { + // result.suites.tests -36 + if (suites && suites.tests && Array.isArray(suites.tests)) { + suites.tests.forEach(test => { + const parsedTest = {} + parsedTest.id = pathTest + parsedTest.description = test.title || null + parsedTest.full_description = test.fullTitle || null + parsedTest.status = test.pass ? 'passed' : 'failed' + parsedTest.file_path = pathTest + parsedTest.line_number = null + parsedTest.run_time = test.duration || null + parsedTest.pending_message = null + + if (test.fail && test.code && test.code.length) { + parsedTest.exception = { + class: test.err.message, + backtrace: test.err.estack && [test.err.estack], + message: test.code + } + } + examples.push(parsedTest) + }) + } + }) + } + }) + } + parsedJSON.examples = examples + + // summary + parsedJSON.summary = { + duration: dataJSON.stats.duration, + example_count: dataJSON.stats.tests, + failure_count: dataJSON.stats.failures, + pending_count: dataJSON.stats.pending, + errors_outside_of_examples_count: dataJSON.stats.other + } + + // summary_line + parsedJSON.summary_line = `${dataJSON.stats.testsRegistered} examples, ${dataJSON.stats.failures} failures` + + // clear results folder + removeSync(bsname) + + // create path + if (!existsSync(bsname)) { + mkdirsSync(bsname) + } + + // create JSON file + writeFileSync(`${bsname}/results.json`, JSON.stringify(parsedJSON)) + } + } +} + +cypress.run(config).then( + () => { + generateReport().then(parseReport) + }, + error => { + generateReport().then(parseReport) + console.error(error) + process.exit(1) + } +) diff --git a/src/fireedge/cypress/fixtures/defaults.json b/src/fireedge/cypress/fixtures/defaults.json new file mode 100644 index 0000000000..3f233670ac --- /dev/null +++ b/src/fireedge/cypress/fixtures/defaults.json @@ -0,0 +1,27 @@ +{ + "auth": { + "jwtName": "FireedgeToken", + "username": "oneadmin", + "password": "opennebula" + }, + "endpoints": { + "login": "/api/auth/", + "userInfo": "/api/user/info" + }, + "provision": { + "provision": "hybrid+", + "provider": "aws", + "nameProvider": "aws-frankfurt", + "descriptionProvider": "Elastic cluster on AWS in Frakfurt", + "descriptionProviderEdited": "Elastic cluster on AWS in Frakfurt Edited!", + "descriptionProvision": "Provision description", + "key": "access key", + "keyEdited": "access key Edited!", + "secretKey": "secret access key", + "secretKeyEdited": "secret access key Edited!", + "nameProvision": "aws-cluster", + "numberInstances": "1", + "amiImage": "ami-0b793c1e0d1dc4d28", + "instanceType": "i3-metal" + } +} \ No newline at end of file diff --git a/src/fireedge/cypress/integration/provision/dashboard/index.spec.js b/src/fireedge/cypress/integration/provision/dashboard/index.spec.js new file mode 100644 index 0000000000..c65f450389 --- /dev/null +++ b/src/fireedge/cypress/integration/provision/dashboard/index.spec.js @@ -0,0 +1,16 @@ +// / + +context('Dashboard', () => { + before(() => { + cy.visit('/') + cy.login() + }) + + after(() => { + cy.logout() + }) + + it('validate items', () => { + + }) +}) diff --git a/src/fireedge/cypress/integration/provision/login/index.spec.js b/src/fireedge/cypress/integration/provision/login/index.spec.js new file mode 100644 index 0000000000..b1c8c8f5e2 --- /dev/null +++ b/src/fireedge/cypress/integration/provision/login/index.spec.js @@ -0,0 +1,31 @@ +// const { internalLog } = require('../../../support/utils') +// / +context('Login', () => { + before(() => { + cy.goToIndex(__dirname, () => { + cy.login() + }) + }) + + after(() => { + cy.logout() + }) + + it('has successfull login', () => { + cy.getJWT((JWT) => { + if (JWT && cy.wrap(JWT).should('exist')) { + cy.get('[data-cy=header]').should('be.visible') + } + }) + }) + + it('has username on header', () => { + cy.get('[data-cy=header-user-button]').click() + cy.fixture('defaults').then(defaults => { + cy.get('[data-cy=header-username]').should( + 'have.text', + defaults.auth.username + ) + }) + }) +}) diff --git a/src/fireedge/cypress/integration/provision/provider/index.spec.js b/src/fireedge/cypress/integration/provision/provider/index.spec.js new file mode 100644 index 0000000000..bb81de2708 --- /dev/null +++ b/src/fireedge/cypress/integration/provision/provider/index.spec.js @@ -0,0 +1,218 @@ +const { createIntercept, waitIntercept } = require('../../../support/utils') +const testType = 'Provider' + +const reloadProviderComponent = () => { + // for reload the provider react-component this update the provider list + cy.navigateMenu('dashboard') +} + +const interceptList = { + method: 'GET', + url: '/provider/list' +} +const interceptCreate = { + method: 'POST', + url: '/provider/create' +} +const interceptConfigure = { + method: 'PUT', + url: '/provider/update' +} +const interceptDelete = { + method: 'DELETE', + url: '/provider/delete' +} + +let defaultSettings = {} + +context(testType, () => { + before(() => { + // fill settings + cy.fixture('defaults').then(defaults => { + defaultSettings = defaults.provision + }) + + // go to index app + cy.visit('/') + cy.login() + }) + + after(() => { + cy.logout() + }) + + it('Create a Provider', () => { + cy.navigateMenu(`${testType}s`, () => { + cy.get('[data-cy=create-provider]').click({ force: true }).then(() => { + waitIntercept(createIntercept(interceptList), () => { + cy.get('[data-cy=select-provision-type]').select(defaultSettings.provision || '') + cy.get('[data-cy=select-provider-type]').select(defaultSettings.provider || '') + let brk = true + + // expect test + const validateTest = request => { + expect(request).to.be.a('object') + expect(request).to.nested.include({ 'response.body.id': 200 }) + } + + // fill form "Configure Connection" tab + const fillFormConfigureConnection = () => { + cy.get('[data-cy=stepper-next-button]').then($button => { + cy.get('[data-cy=form-provider-access_key]').clear().type(defaultSettings.key || '') + cy.get('[data-cy=form-provider-secret_key]').clear().type(defaultSettings.secretKey || '') + const intercept = createIntercept(interceptCreate) + cy.wrap($button).click({ force: true }) + waitIntercept(intercept, validateTest) + }) + } + + // fill form "Provider Overview" tab + const fillFormProviderOverview = () => { + cy.get('[data-cy=stepper-next-button]').then($button => { + cy.get('[data-cy=form-provider-name]').clear().type(defaultSettings.nameProvider || '') + cy.get('[data-cy=form-provider-description]').clear().type(defaultSettings.descriptionProvider || '') + cy.wrap($button).click({ force: true }) + fillFormConfigureConnection() + }) + } + + // select template in "Provider template" tab + const selectTemplate = $el => { + brk = false + cy.wrap($el).find('>button').click({ force: true }).then(() => { + cy.get('[data-cy=stepper-next-button]').then($button => { + cy.wrap($button).click({ force: true }) + fillFormProviderOverview() + }) + }) + } + + // find provider template in "Provider template" tab + cy.get('[data-cy=providers-templates]').find('[data-cy=provider-template-card]').each($el => { + if (defaultSettings && defaultSettings.nameProvider && $el.find('[data-cy=provider-template-card-title]').text() === defaultSettings.nameProvider) { + selectTemplate($el) + } + return brk + }) + }) + }) + }) + }) + + it('Check information a Provider', () => { + reloadProviderComponent() + cy.navigateMenu(`${testType}s`, () => { + waitIntercept(createIntercept(interceptList), () => { + let brk = true + + // select provider + const selectProvider = $el => { + brk = false + cy.wrap($el).find('>button').click({ force: true }).then(() => { + waitIntercept(createIntercept(interceptList), info => { + cy.get('[data-cy=provider-name]').should('have.text', defaultSettings.nameProvider) + cy.get('[data-cy=provider-description]').should('have.text', defaultSettings.descriptionProvider) + cy.get('[data-cy=provider-type]').should('have.text', defaultSettings.provider) + cy.get('[data-cy=provider-access_key]').should('have.text', defaultSettings.key) + cy.get('[data-cy=provider-secret_key]').should('have.text', defaultSettings.secretKey) + cy.get('[data-cy=dg-cancel-button]').click({ force: true }) + }) + }) + } + + // find provider + cy.get('[data-cy=providers]').find('[data-cy=provider-card]').each($el => { + if (defaultSettings && defaultSettings.nameProvider && $el.find('[data-cy=provider-card-title]').text() === defaultSettings.nameProvider) { + selectProvider($el) + } + return brk + }) + }) + }) + }) + + it('Configure', () => { + reloadProviderComponent() + cy.navigateMenu(`${testType}s`, () => { + waitIntercept(createIntercept(interceptList), () => { + let brk = true + + // expect test + const validateTest = request => { + expect(request).to.be.a('object') + expect(request).to.nested.include({ 'response.body.id': 200 }) + } + + // fill "Configure connection" tab + const fillConfigureConnection = $button => { + const intercept = createIntercept(interceptConfigure) + cy.get('[data-cy=form-provider-access_key]').clear().type(defaultSettings.keyEdited || '') + cy.get('[data-cy=form-provider-secret_key]').clear().type(defaultSettings.secretKeyEdited || '') + cy.wrap($button).click({ force: true }) + waitIntercept(intercept, validateTest) + } + + // fill "Provider overview" tab + const fillProviderOverview = $button => { + cy.get('[data-cy=form-provider-description]').clear().type(defaultSettings.descriptionProviderEdited || '') + cy.wrap($button).click({ force: true }) + cy.get('[data-cy=stepper-next-button]').then(fillConfigureConnection) + } + + // select provider + const selectProvider = $el => { + brk = false + cy.wrap($el).find('[data-cy=provider-edit]').click({ force: true }).then(() => { + waitIntercept(createIntercept(interceptList), () => { + cy.get('[data-cy=stepper-next-button]').then(fillProviderOverview) + }) + }) + } + + // find provider + cy.get('[data-cy=providers]').find('[data-cy=provider-card]').each($el => { + if (defaultSettings && defaultSettings.nameProvider && $el.find('[data-cy=provider-card-title]').text() === defaultSettings.nameProvider) { + selectProvider($el) + } + return brk + }) + }) + }) + }) + + it('Delete', () => { + reloadProviderComponent() + cy.navigateMenu(`${testType}s`, () => { + waitIntercept(createIntercept(interceptList), () => { + let brk = true + + // expect test + const validateTest = request => { + expect(request).to.be.a('object') + expect(request).to.nested.include({ 'response.body.id': 202 }) + } + + // select provider + const selectProvider = $el => { + brk = false + cy.wrap($el).find('[data-cy=provider-delete]').click({ force: true }).then(() => { + waitIntercept(createIntercept(interceptList), () => { + const intercept = createIntercept(interceptDelete) + cy.get('[data-cy=dg-accept-button]').click({ force: true }).then(() => { + waitIntercept(intercept, validateTest) + }) + }) + }) + } + + // find provider + cy.get('[data-cy=providers]').find('[data-cy=provider-card]').each($el => { + if (defaultSettings && defaultSettings.nameProvider && $el.find('[data-cy=provider-card-title]').text() === defaultSettings.nameProvider) { + selectProvider($el) + } + return brk + }) + }) + }) + }) +}) diff --git a/src/fireedge/cypress/integration/provision/provision/index.spec.js b/src/fireedge/cypress/integration/provision/provision/index.spec.js new file mode 100644 index 0000000000..c322c1b941 --- /dev/null +++ b/src/fireedge/cypress/integration/provision/provision/index.spec.js @@ -0,0 +1,221 @@ +const { createIntercept, waitIntercept } = require('../../../support/utils') +const testType = 'Provision' + +const reloadProvisionComponent = () => { + // for reload the provision react-component this update the provider list + cy.navigateMenu('dashboard') +} + +const interceptProviderList = { + method: 'GET', + url: '/provider/list' +} +const interceptList = { + method: 'GET', + url: '/provision/list' +} +const interceptCreate = { + method: 'POST', + url: '/provision/create' +} +const interceptConfigure = { + method: 'PUT', + url: '/provision/configure' +} +const interceptDelete = { + method: 'DELETE', + url: '/provision/delete' +} +let defaultSettings = {} + +context(testType, () => { + before(() => { + // fill settings + cy.fixture('defaults').then(defaults => { + defaultSettings = defaults.provision + }) + + //go to index app + cy.visit('/') + cy.login() + }) + + after(() => { + cy.logout() + }) + + it('Create', () => { + cy.navigateMenu(`${testType}s`, () => { + cy.get('[data-cy=create-provision]').click({ force: true }).then(() => { + waitIntercept(createIntercept(interceptProviderList), () => { + cy.get('[data-cy=select-provision-type]').select(defaultSettings.provision || '') + cy.get('[data-cy=select-provider-type]').select(defaultSettings.provider || '') + let brkProvisionTemplate = true + let brkProvider = true + + // expect test + const validateTest = request => { + expect(request).to.be.a('object') + expect(request).to.nested.include({ 'response.body.id': 202 }) + } + + // fill form "Configure inputs" tab + const fillFormConfigureInputs = () => { + cy.get('[data-cy=stepper-next-button]').then($button => { + cy.get('[data-cy=form-provision-number_hosts]').clear().type(defaultSettings.numberInstances || '') + const intercept = createIntercept(interceptCreate) + cy.wrap($button).click({ force: true }) + waitIntercept(intercept, validateTest) + }) + } + + // fill form "Provider overview" tab + const fillFormProvision = () => { + cy.get('[data-cy=stepper-next-button]').then($button => { + cy.get('[data-cy=form-provision-name]').clear().type(defaultSettings.nameProvision || '') + cy.get('[data-cy=form-provision-description]').clear().type(defaultSettings.descriptionProvision || '') + cy.wrap($button).click({ force: true }) + fillFormConfigureInputs() + }) + } + + // find provider in "Provider" tab + const selectProvider = $el => { + brkProvider = false + cy.wrap($el).find('>button').click({ force: true }).then(() => { + cy.get('[data-cy=stepper-next-button]').then($button => { + cy.wrap($button).click({ force: true }) + fillFormProvision() + }) + }) + } + + // find provider in "Provider" tab + const findProvider = () => { + cy.get('[data-cy=stepper-next-button]').then($button => { + cy.wrap($button).click({ force: true }) + cy.get('[data-cy=providers]').find('[data-cy=provider-card]').each($el => { + if (defaultSettings && defaultSettings.nameProvision && $el.find('[data-cy=provider-card-title]').text().includes(defaultSettings.nameProvider)) { + selectProvider($el) + } + return brkProvider + }) + }) + } + + // select provision template in "Provision template" tab + const selectProvisionTemplate = $el => { + brkProvisionTemplate = false + cy.wrap($el).find('>button').click({ force: true }).then(findProvider) + } + + // find provision template in "Provision template" tab + cy.get('[data-cy=provisions-templates]').find('[data-cy=provision-template-card]').each($el => { + if (defaultSettings && defaultSettings.nameProvision && $el.find('[data-cy=provision-template-card-title]').text() === defaultSettings.nameProvision) { + selectProvisionTemplate($el) + } + return brkProvisionTemplate + }) + }) + }) + }) + }) + + it('Check information', () => { + reloadProvisionComponent() + cy.navigateMenu(`${testType}s`, () => { + waitIntercept(createIntercept(interceptList), () => { + let brk = true + + //select provider + const selectProvider = $el => { + brk = false + cy.wrap($el).find('>button').click({ force: true }).then(() => { + waitIntercept(createIntercept(interceptList), info => { + cy.get('[data-cy=provision-name]').should('have.text', defaultSettings.nameProvision) + cy.get('[data-cy=provision-description]').should('have.text', defaultSettings.descriptionProvision) + cy.get('[data-cy=provider-provider-name]').should('have.text', defaultSettings.nameProvider) + cy.get('[data-cy=provider-cluster]').should('contain', defaultSettings.nameProvision) + }) + }) + } + + //find provider + cy.get('[data-cy=provisions]').find('[data-cy=provision-card]').each($el => { + if (defaultSettings && defaultSettings.nameProvider && $el.find('[data-cy=provision-card-title]').text() === defaultSettings.nameProvision) { + selectProvider($el) + } + return brk + }) + }) + }) + }) + + it('Configure', () => { + reloadProvisionComponent() + cy.navigateMenu(`${testType}s`, () => { + waitIntercept(createIntercept(interceptList), () => { + let brk = true + + // expect test + const validateTest = request => { + expect(request).to.be.a('object') + expect(request).to.nested.include({ 'response.body.id': 202}) + } + + // select provider + const selectProvider = $el => { + brk = false + cy.wrap($el).find('[data-cy=provision-configure]').click({ force: true }).then(() => { + waitIntercept(createIntercept(interceptConfigure), validateTest) + }) + } + + // find provider + cy.get('[data-cy=provisions]').find('[data-cy=provision-card]').each($el => { + if (defaultSettings && defaultSettings.nameProvision && $el.find('[data-cy=provision-card-title]').text() === defaultSettings.nameProvision) { + selectProvider($el) + } + return brk + }) + }) + }) + }) + + it('Delete', () => { + reloadProvisionComponent() + cy.navigateMenu(`${testType}s`, () => { + waitIntercept(createIntercept(interceptList), () => { + let brk = true + + // expect test + const validateTest = request => { + expect(request).to.be.a('object') + expect(request).to.nested.include({ 'response.body.id': 202}) + } + + // select provider + const selectProvider = $el => { + brk = false + cy.wrap($el).find('[data-cy=provision-delete]').click({ force: true }).then(() => { + waitIntercept(createIntercept(interceptList), ()=>{ + const intercept = createIntercept(interceptDelete) + cy.get('[data-cy=dg-accept-button]').click({force:true}).then(()=>{ + waitIntercept(intercept, validateTest) + }) + }) + }) + } + + // find provider + cy.get('[data-cy=provisions]').find('[data-cy=provision-card]').each($el => { + if (defaultSettings && defaultSettings.nameProvision && $el.find('[data-cy=provision-card-title]').text() === defaultSettings.nameProvision) { + selectProvider($el) + } + return brk + }) + }) + }) + }) + +}) diff --git a/src/fireedge/cypress/support/commands.js b/src/fireedge/cypress/support/commands.js new file mode 100644 index 0000000000..c909c6450f --- /dev/null +++ b/src/fireedge/cypress/support/commands.js @@ -0,0 +1,89 @@ +const { internalLog } = require('./utils') +const { sep } = require('path') + +Cypress.Commands.add('login', () => { + cy.fixture('defaults').then(defaults => { + cy.get('[data-cy=login-user]').clear().type(defaults.auth.username) + cy.get('[data-cy=login-token]').clear().type(defaults.auth.password) + }) + cy.get('[data-cy=login-button]').then(($btn) => { + cy.wrap($btn).click() + }) +}) + +Cypress.Commands.add('openUserModal', (callback = () => undefined) => { + cy.get('[data-cy=header-user-button]').then(($btn) => { + if ($btn) { + cy.wrap($btn).click({ force: true }) + } + callback() + }) +}) + +Cypress.Commands.add('logout', () => { + cy.openUserModal( + () => { + cy.get('[data-cy=header-logout-button]').then(($btn) => { + if ($btn) { + cy.wrap($btn).click({ force: true }) + cy.fixture('defaults').then(defaults => { + cy.window().its('sessionStorage').invoke('removeItem', defaults.auth.jwtName) + }) + } + }) + } + ) +}) + +Cypress.Commands.add('getJWT', (callback = () => undefined) => { + cy.fixture('defaults').then(defaults => { + cy.window().then(win => { + callback(win.sessionStorage.getItem(defaults.auth.jwtName)) + }) + }) +}) + +Cypress.Commands.add('navigateMenu', (contentText = '', callback = () => undefined) => { + if (contentText) { + let rtn = true + cy.get('[data-cy=main-menu]').find('li').each($li => { + if ($li && $li.text && typeof $li.text === 'function' && $li.text().toLowerCase() === contentText.toLowerCase()) { + rtn = false + cy.wrap($li).click({ force: true }).then(() => { + callback() + }) + } + return rtn + }) + } +}) + +Cypress.Commands.add('goToIndex', (path = '', callback = () => undefined) => { + if (expect(path).to.not.be.empty) { + const folders = path.split(sep) + cy.fixture('defaults').then(defaults => { + if (expect(defaults.apps).to.be.a('object')) { + const apps = Object.keys(defaults.apps) + let selectApp = '' + apps.forEach(app => { + if (folders.includes(app)) { + selectApp = app + } + }) + if (expect(apps).to.be.a('array') && expect(apps).to.include(selectApp)) { + cy.visit(`/${selectApp}`, { timeout: 30000 }) + cy.getJWT((JWT) => { + if (!JWT) { + cy.get('[data-cy=opennebula-logo]').then($window => { + if ($window) { + cy.wait(1500) + } + }) + } + callback() + }) + } + } + }) + } +}) diff --git a/src/fireedge/cypress/support/utils.js b/src/fireedge/cypress/support/utils.js new file mode 100644 index 0000000000..203cfa0d9d --- /dev/null +++ b/src/fireedge/cypress/support/utils.js @@ -0,0 +1,41 @@ + +const { v4 } = require('uuid') + +const createIntercept = (data = {}) => { + const uuidv4 = v4() + cy.intercept({ + method: data.method || 'GET', + url: data.url || '' + }).as(uuidv4) + return uuidv4 +} + +const waitIntercept = (intercept = '', callback = () => undefined) => { + if (intercept) { + cy.wait(`@${intercept}`).then(interception => { + if (interception && interception.state && interception.state === 'Complete' && typeof callback === 'function') { + callback(interception) + } + }) + } +} + +const internalLog = (command = '', message = '') => { + Cypress.log({ + name: command, + displayName: command, + consoleProps: () => { + return { + error: message + } + } + }) +} + +const utils = { + internalLog, + createIntercept, + waitIntercept +} + +module.exports = utils diff --git a/src/fireedge/package.json b/src/fireedge/package.json index ba15173391..9ab4c52b94 100644 --- a/src/fireedge/package.json +++ b/src/fireedge/package.json @@ -9,6 +9,8 @@ "build-server": "rimraf dist/index.js && rimraf dist/fireedge-server.conf && webpack --config ./webpack.config.prod.server.js", "build": "npm run build-front && npm run build-server", "start": "cross-env NODE_ENV=production babel-node ./dist/index.js", + "cypress:open": "cypress open", + "cypress:run": "rimraf cypress/results/* && node cypress/command/index.js", "pot": "node potfile.js", "po2json": "node po2json.js", "lint": "eslint ./src/client/", @@ -39,6 +41,9 @@ "eslint-plugin-standard": "^4.0.1", "fireedge-genpotfile": "^1.0.0", "fireedge-pojson": "^1.0.2", + "mochawesome": "^6.2.1", + "mochawesome-merge": "^4.2.0", + "mochawesome-report-generator": "^5.1.0", "react-hot-loader": "^4.13.0", "webpack-dev-middleware": "^3.7.2", "webpack-hot-middleware": "^2.25.0" From 80c4f0b92f1f1e561341fc8eb603080846872c70 Mon Sep 17 00:00:00 2001 From: Jorge Miguel Lobo Escalona <47326048+jloboescalona2@users.noreply.github.com> Date: Fri, 22 Jan 2021 11:51:56 +0100 Subject: [PATCH 03/11] F #3951: remove fireedge-server.conf in prod (#693) Signed-off-by: Jorge Lobo --- src/fireedge/package.json | 2 +- src/fireedge/webpack.config.prod.server.js | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/fireedge/package.json b/src/fireedge/package.json index 9ab4c52b94..7be19ee137 100644 --- a/src/fireedge/package.json +++ b/src/fireedge/package.json @@ -6,7 +6,7 @@ "scripts": { "dev": "rimraf dist/ && cross-env NODE_ENV=development babel-node ./src/server/index.js", "build-front": "rimraf dist/client && webpack --config ./webpack.config.prod.client.js", - "build-server": "rimraf dist/index.js && rimraf dist/fireedge-server.conf && webpack --config ./webpack.config.prod.server.js", + "build-server": "rimraf dist/index.js && webpack --config ./webpack.config.prod.server.js", "build": "npm run build-front && npm run build-server", "start": "cross-env NODE_ENV=production babel-node ./dist/index.js", "cypress:open": "cypress open", diff --git a/src/fireedge/webpack.config.prod.server.js b/src/fireedge/webpack.config.prod.server.js index 1b7eadd783..afa241d341 100644 --- a/src/fireedge/webpack.config.prod.server.js +++ b/src/fireedge/webpack.config.prod.server.js @@ -4,7 +4,6 @@ const nodeExternals = require('webpack-node-externals') const CopyPlugin = require('copy-webpack-plugin') const { defaultProductionWebpackMode } = require('./src/server/utils/constants/defaults') - const js = { test: /\.js$/, loader: 'babel-loader', @@ -31,14 +30,6 @@ module.exports = { 'process.env': { NODE_ENV: JSON.stringify(defaultProductionWebpackMode) } - }), - new CopyPlugin({ - patterns: [ - { - from: path.resolve(__dirname, 'fireedge-server.conf'), - to: path.resolve(__dirname, 'dist', 'fireedge-server.conf') - } - ] }) ], module: { From 2ab48453e7e963b56f9d5e13dc451900934b4b42 Mon Sep 17 00:00:00 2001 From: Jan Orel Date: Fri, 22 Jan 2021 16:49:00 +0100 Subject: [PATCH 04/11] M #: Fix oneprovison rc comparsion (#694) --- src/cli/oneprovision | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/oneprovision b/src/cli/oneprovision index 83bdce9fc6..e9047a74fa 100755 --- a/src/cli/oneprovision +++ b/src/cli/oneprovision @@ -123,7 +123,7 @@ CommandParser::CmdParser.new(ARGV) do if OpenNebula.is_error?(rc) STDERR.puts rc.message exit(-1) - elsif rc < 0 + elsif rc.to_i < 0 puts "ID: #{rc}" rc else From b1ed347bec14957884fa6fd66df7915ed5aff73b Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Herrero Date: Mon, 25 Jan 2021 09:51:40 +0100 Subject: [PATCH 05/11] M #-: add missing snapshot dir to dummy (#699) --- install.sh | 5 ++++- share/oneprovision/provisions/provisions | 1 + .../dummy-probes.d/vm/snapshot/recovery.rb | 20 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 120000 share/oneprovision/provisions/provisions create mode 100755 src/im_mad/remotes/dummy-probes.d/vm/snapshot/recovery.rb diff --git a/install.sh b/install.sh index 36383285ad..fd72ae27fc 100755 --- a/install.sh +++ b/install.sh @@ -346,6 +346,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \ $VAR_LOCATION/remotes/im/dummy-probes.d/host/system \ $VAR_LOCATION/remotes/im/dummy-probes.d/vm/monitor \ $VAR_LOCATION/remotes/im/dummy-probes.d/vm/status \ + $VAR_LOCATION/remotes/im/dummy-probes.d/vm/snapshot \ $VAR_LOCATION/remotes/im/lxd.d \ $VAR_LOCATION/remotes/im/lxd-probes.d/host/beacon \ $VAR_LOCATION/remotes/im/lxd-probes.d/host/monitor \ @@ -581,6 +582,7 @@ INSTALL_FILES=( IM_PROBES_DUMMY_HOST_SYSTEM_FILES:$VAR_LOCATION/remotes/im/dummy-probes.d/host/system IM_PROBES_DUMMY_VM_MONITOR_FILES:$VAR_LOCATION/remotes/im/dummy-probes.d/vm/monitor IM_PROBES_DUMMY_VM_STATUS_FILES:$VAR_LOCATION/remotes/im/dummy-probes.d/vm/status + IM_PROBES_DUMMY_VM_STATUS_FILES:$VAR_LOCATION/remotes/im/dummy-probes.d/vm/snapshot IM_PROBES_LXD_HOST_BEACON_FILES:$VAR_LOCATION/remotes/im/lxd-probes.d/host/beacon IM_PROBES_LXD_HOST_MONITOR_FILES:$VAR_LOCATION/remotes/im/lxd-probes.d/host/monitor IM_PROBES_LXD_HOST_SYSTEM_FILES:$VAR_LOCATION/remotes/im/lxd-probes.d/host/system @@ -1344,7 +1346,8 @@ IM_PROBES_DUMMY_HOST_SYSTEM_FILES="\ IM_PROBES_DUMMY_VM_MONITOR_FILES="\ src/im_mad/remotes/dummy-probes.d/vm/monitor/monitor.rb" -IM_PROBES_DUMMY_VM_STATUS_FILES="" +IM_PROBES_DUMMY_VM_STATUS_FILES="\ +src/im_mad/remotes/dummy-probes.d/vm/snapshot/recovery.rb" # LXD PROBES IM_PROBES_LXD_FILES="\ diff --git a/share/oneprovision/provisions/provisions b/share/oneprovision/provisions/provisions new file mode 120000 index 0000000000..bb859955b4 --- /dev/null +++ b/share/oneprovision/provisions/provisions @@ -0,0 +1 @@ +/home/alex/Workspace/one-ee/share/oneprovision/provisions/ \ No newline at end of file diff --git a/src/im_mad/remotes/dummy-probes.d/vm/snapshot/recovery.rb b/src/im_mad/remotes/dummy-probes.d/vm/snapshot/recovery.rb new file mode 100755 index 0000000000..ef94a6bc80 --- /dev/null +++ b/src/im_mad/remotes/dummy-probes.d/vm/snapshot/recovery.rb @@ -0,0 +1,20 @@ +#!/usr/bin/env ruby + +# -------------------------------------------------------------------------- # +# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems # +# # +# 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. # +#--------------------------------------------------------------------------- # + +STDIN=`cat -` +exit 0 From 6abf26dd1b0021445833000239c65acffed5c24c Mon Sep 17 00:00:00 2001 From: Jan Orel Date: Mon, 25 Jan 2021 11:03:13 +0100 Subject: [PATCH 06/11] F #4985: Remove recoery snaps from monitor_ds (#701) --- install.sh | 8 ++++--- share/oneprovision/provisions/provisions | 1 - .../dummy-probes.d/vm/snapshot/recovery.rb | 20 ---------------- src/tm_mad/ssh/monitor_ds | 24 ------------------- 4 files changed, 5 insertions(+), 48 deletions(-) delete mode 120000 share/oneprovision/provisions/provisions delete mode 100755 src/im_mad/remotes/dummy-probes.d/vm/snapshot/recovery.rb diff --git a/install.sh b/install.sh index fd72ae27fc..d07af7f2f2 100755 --- a/install.sh +++ b/install.sh @@ -368,24 +368,28 @@ VAR_DIRS="$VAR_LOCATION/remotes \ $VAR_LOCATION/remotes/im/ec2-probes.d/host/system \ $VAR_LOCATION/remotes/im/ec2-probes.d/vm/monitor \ $VAR_LOCATION/remotes/im/ec2-probes.d/vm/status \ + $VAR_LOCATION/remotes/im/ec2-probes.d/vm/snapshot \ $VAR_LOCATION/remotes/im/az.d \ $VAR_LOCATION/remotes/im/az-probes.d/host/beacon \ $VAR_LOCATION/remotes/im/az-probes.d/host/monitor \ $VAR_LOCATION/remotes/im/az-probes.d/host/system \ $VAR_LOCATION/remotes/im/az-probes.d/vm/monitor \ $VAR_LOCATION/remotes/im/az-probes.d/vm/status \ + $VAR_LOCATION/remotes/im/az-probes.d/vm/snapshot \ $VAR_LOCATION/remotes/im/one.d \ $VAR_LOCATION/remotes/im/one-probes.d/host/beacon \ $VAR_LOCATION/remotes/im/one-probes.d/host/monitor \ $VAR_LOCATION/remotes/im/one-probes.d/host/system \ $VAR_LOCATION/remotes/im/one-probes.d/vm/monitor \ $VAR_LOCATION/remotes/im/one-probes.d/vm/status \ + $VAR_LOCATION/remotes/im/one-probes.d/vm/snapshot \ $VAR_LOCATION/remotes/im/packet.d \ $VAR_LOCATION/remotes/im/packet-probes.d/host/beacon \ $VAR_LOCATION/remotes/im/packet-probes.d/host/monitor \ $VAR_LOCATION/remotes/im/packet-probes.d/host/system \ $VAR_LOCATION/remotes/im/packet-probes.d/vm/monitor \ $VAR_LOCATION/remotes/im/packet-probes.d/vm/status \ + $VAR_LOCATION/remotes/im/packet-probes.d/vm/snapshot \ $VAR_LOCATION/remotes/vmm \ $VAR_LOCATION/remotes/vmm/lib \ $VAR_LOCATION/remotes/vmm/kvm \ @@ -582,7 +586,6 @@ INSTALL_FILES=( IM_PROBES_DUMMY_HOST_SYSTEM_FILES:$VAR_LOCATION/remotes/im/dummy-probes.d/host/system IM_PROBES_DUMMY_VM_MONITOR_FILES:$VAR_LOCATION/remotes/im/dummy-probes.d/vm/monitor IM_PROBES_DUMMY_VM_STATUS_FILES:$VAR_LOCATION/remotes/im/dummy-probes.d/vm/status - IM_PROBES_DUMMY_VM_STATUS_FILES:$VAR_LOCATION/remotes/im/dummy-probes.d/vm/snapshot IM_PROBES_LXD_HOST_BEACON_FILES:$VAR_LOCATION/remotes/im/lxd-probes.d/host/beacon IM_PROBES_LXD_HOST_MONITOR_FILES:$VAR_LOCATION/remotes/im/lxd-probes.d/host/monitor IM_PROBES_LXD_HOST_SYSTEM_FILES:$VAR_LOCATION/remotes/im/lxd-probes.d/host/system @@ -1346,8 +1349,7 @@ IM_PROBES_DUMMY_HOST_SYSTEM_FILES="\ IM_PROBES_DUMMY_VM_MONITOR_FILES="\ src/im_mad/remotes/dummy-probes.d/vm/monitor/monitor.rb" -IM_PROBES_DUMMY_VM_STATUS_FILES="\ -src/im_mad/remotes/dummy-probes.d/vm/snapshot/recovery.rb" +IM_PROBES_DUMMY_VM_STATUS_FILES="" # LXD PROBES IM_PROBES_LXD_FILES="\ diff --git a/share/oneprovision/provisions/provisions b/share/oneprovision/provisions/provisions deleted file mode 120000 index bb859955b4..0000000000 --- a/share/oneprovision/provisions/provisions +++ /dev/null @@ -1 +0,0 @@ -/home/alex/Workspace/one-ee/share/oneprovision/provisions/ \ No newline at end of file diff --git a/src/im_mad/remotes/dummy-probes.d/vm/snapshot/recovery.rb b/src/im_mad/remotes/dummy-probes.d/vm/snapshot/recovery.rb deleted file mode 100755 index ef94a6bc80..0000000000 --- a/src/im_mad/remotes/dummy-probes.d/vm/snapshot/recovery.rb +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env ruby - -# -------------------------------------------------------------------------- # -# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems # -# # -# 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. # -#--------------------------------------------------------------------------- # - -STDIN=`cat -` -exit 0 diff --git a/src/tm_mad/ssh/monitor_ds b/src/tm_mad/ssh/monitor_ds index 603771ca61..4feb45e48e 100755 --- a/src/tm_mad/ssh/monitor_ds +++ b/src/tm_mad/ssh/monitor_ds @@ -19,8 +19,6 @@ dir="$1" vms=$(ls "$dir" | grep '^[0-9]\+$') -one_dir=$(dirname $0 | sed -e 's/tm\/ssh//') -xpath="$one_dir/datastore/xpath.rb --stdin" for vm in $vms; do vmdir="${dir}/${vm}" @@ -52,28 +50,6 @@ for vm in $vms; do "[ ID=${snap}, DISK_ID=${disk_id}, SIZE=${snap_size}]" done fi - - # create disk recovery snapshot if required - if [ -f "${dir}/${vm}/vm.xml" ] && [ -f "${dir}/${vm}/ds.xml" ] ; then - freq=$(awk 'gsub(/[\0]/, x)' <(cat "${dir}/${vm}/vm.xml"| $xpath \ - /VM/TEMPLATE/DISK[DISK_ID=$disk_id]/RECOVERY_SNAPSHOT_FREQ)) - - replica_host=$(awk 'gsub(/[\0]/, x)' <(cat "${dir}/${vm}/ds.xml"| $xpath \ - /DATASTORE/TEMPLATE/REPLICA_HOST)) - - if [ -n "$freq" ] && [ -n "$replica_host" ]; then - - snap_ts=$($one_dir/tm/ssh/recovery_snap_create_live \ - $vm $vmdir/$disk $freq $replica_host) - rc=$? - - if [ -n "$snap_ts" ] && [ "$rc" = "0" ]; then - vm_monitor="${vm_monitor}\nDISK_RECOVERY_SNAPSHOT = [ ID=${disk_id}, TIMESTAMP=${snap_ts}]" - else - vm_monitor="${vm_monitor}\nDISK_RECOVERY_SNAPSHOT = [ ID=${disk_id}, MSG=\"ERROR $rc ${snap_ts}\"]" - fi - fi - fi done echo -e "$vm_monitor" | base64 -w 0 - From aea18de8b6d774bc743d7f7f9ef8e17f0ff8d5e9 Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Herrero Date: Mon, 25 Jan 2021 11:43:49 +0100 Subject: [PATCH 07/11] M #-: print provision CMD and options (#702) --- src/cli/one_helper/oneprovision_helper.rb | 9 ++++++--- src/cli/oneprovision | 20 +++++++++++++++----- src/oneprovision/lib/provision/provision.rb | 12 ++++++++---- src/oneprovision/lib/provision/utils.rb | 21 +++++++++++++++++++++ 4 files changed, 50 insertions(+), 12 deletions(-) diff --git a/src/cli/one_helper/oneprovision_helper.rb b/src/cli/one_helper/oneprovision_helper.rb index 9c528c1722..162bc510c6 100644 --- a/src/cli/one_helper/oneprovision_helper.rb +++ b/src/cli/one_helper/oneprovision_helper.rb @@ -489,6 +489,9 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper def resources_operation(args, operation, options, type) parse_options(options) + OneProvision::Utils.print_cmd("#{type} #{operation[:operation]}", + options) + objects = names_to_ids(args[0], type) return [-1, objects.message] if OpenNebula.is_error?(objects) @@ -498,7 +501,7 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper operation[:message]) do |obj| rc = obj.info - return rc if OpenNebula.is_error?(rc) + return [-1, rc.message] if OpenNebula.is_error?(rc) case type when 'HOSTS' @@ -515,14 +518,14 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper end unless p_id - return OpenNebula::Error.new('No provision ID found') + return [-1, 'No provision ID found'] end provision = OneProvision::Provision.new_with_id(p_id, @client) rc = provision.info - return rc if OpenNebula.is_error?(rc) + return [-1, rc.message] if OpenNebula.is_error?(rc) provision.update_objects(type.downcase, :remove, obj['ID']) end diff --git a/src/cli/oneprovision b/src/cli/oneprovision index e9047a74fa..38df95cbef 100755 --- a/src/cli/oneprovision +++ b/src/cli/oneprovision @@ -99,6 +99,8 @@ CommandParser::CmdParser.new(ARGV) do :options => OneProvisionHelper::CREATE_OPTIONS do helper.parse_options(options) + OneProvision::Utils.print_cmd('create', options) + if options[:cleanup_timeout].nil? timeout = 20 else @@ -191,6 +193,8 @@ CommandParser::CmdParser.new(ARGV) do [OpenNebulaHelper::FORMAT] do helper.parse_options(options) + OneProvision::Utils.print_cmd('configure', options) + rc = helper.configure(args[0], options.key?(:force)) if OpenNebula.is_error?(rc) @@ -217,6 +221,8 @@ CommandParser::CmdParser.new(ARGV) do [OpenNebulaHelper::FORMAT] do helper.parse_options(options) + OneProvision::Utils.print_cmd('delete', options) + if options[:cleanup_timeout].nil? timeout = 20 else @@ -354,14 +360,18 @@ CommandParser::CmdParser.new(ARGV) do :options => [OneProvisionHelper::MODES, OneProvisionHelper::FORCE] do rc = helper.resources_operation(args, - {}, + { :operation => 'delete' }, options, resource.upcase) - return 0 if rc[0] == 0 - - STDERR.puts rc[1] - exit(-1) + if rc.is_a?(Array) && rc[0] == 0 + 0 + elsif rc.is_a?(Array) + STDERR.puts rc[1] + exit(-1) + else + 0 + end end end end diff --git a/src/oneprovision/lib/provision/provision.rb b/src/oneprovision/lib/provision/provision.rb index 1e9b4eefa5..1a1de7a0f8 100644 --- a/src/oneprovision/lib/provision/provision.rb +++ b/src/oneprovision/lib/provision/provision.rb @@ -424,7 +424,7 @@ module OneProvision def update_objects(object, operation, id, name = nil) rc = info - return rc if OpenNebula.is_error?(rc) + return [-1, rc.message] if OpenNebula.is_error?(rc) if FULL_CLUSTER.include?(object) path = 'infrastructure' @@ -438,11 +438,11 @@ module OneProvision o = Resource.object(object, provider) rc = o.info(id) - return rc if OpenNebula.is_error?(rc) + return [-1, rc.message] if OpenNebula.is_error?(rc) rc = o.delete(FULL_CLUSTER.include?(object) ? tf : nil) - return rc if OpenNebula.is_error?(rc) + return [-1, rc.message] if OpenNebula.is_error?(rc) # If it is an array, a host has been deleted if rc.is_a? Array @@ -455,7 +455,11 @@ module OneProvision end end - update + rc = update + + [-1, rc.message] if OpenNebula.is_error?(rc) + + 0 end # Reads provider name from template diff --git a/src/oneprovision/lib/provision/utils.rb b/src/oneprovision/lib/provision/utils.rb index 2098aac971..0d55c58bf6 100644 --- a/src/oneprovision/lib/provision/utils.rb +++ b/src/oneprovision/lib/provision/utils.rb @@ -49,6 +49,27 @@ module OneProvision ERROR_OPEN = 'ERROR MESSAGE --8<------' ERROR_CLOSE = 'ERROR MESSAGE ------>8--' + # Prints command and options in the debug output + # + # @param cmd [String] Command executed + # @param options [Hash] Command optioms + def print_cmd(cmd, options) + cmd_options = [] + + options.each do |key, value| + if value + cmd_options << "[#{key}, #{value}]" + else + cmd_options << key + end + end + + cmd_options = cmd_options.join(' ') + + OneProvisionLogger.debug("Executing command: `#{cmd}`") + OneProvisionLogger.debug("Command options: #{cmd_options}") + end + # Checks if the file can be read # # @param name [String] Path to file to read From 45bda534347007844103f8af7e59206ccbee717d Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sun, 24 Jan 2021 22:27:06 +0000 Subject: [PATCH 08/11] M #-: Add qemu based hybrid+ provisions --- share/etc/oned.conf | 74 ++++------------- .../provisions/hybrid+_qemu/description.txt | 7 ++ .../providers/aws/aws-eu-west-2.yml | 26 ++++++ .../provisions/aws.d/datastores.yml | 39 +++++++++ .../provisions/aws.d/defaults.yml | 26 ++++++ .../hybrid+_qemu/provisions/aws.d/inputs.yml | 38 +++++++++ .../provisions/aws.d/networks.yml | 40 ++++++++++ .../hybrid+_qemu/provisions/aws.yml | 80 +++++++++++++++++++ .../provisions/common.d/defaults.yml | 32 ++++++++ .../provisions/common.d/qemu_hosts.yml | 35 ++++++++ .../provisions/common.d/resources.yml | 38 +++++++++ 11 files changed, 375 insertions(+), 60 deletions(-) create mode 100644 share/oneprovision/provisions/hybrid+_qemu/description.txt create mode 100644 share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-eu-west-2.yml create mode 100644 share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/datastores.yml create mode 100644 share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/defaults.yml create mode 100644 share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/inputs.yml create mode 100644 share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/networks.yml create mode 100644 share/oneprovision/provisions/hybrid+_qemu/provisions/aws.yml create mode 100644 share/oneprovision/provisions/hybrid+_qemu/provisions/common.d/defaults.yml create mode 100644 share/oneprovision/provisions/hybrid+_qemu/provisions/common.d/qemu_hosts.yml create mode 100644 share/oneprovision/provisions/hybrid+_qemu/provisions/common.d/resources.yml diff --git a/share/etc/oned.conf b/share/etc/oned.conf index b0249559b2..cd8c1d5909 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -451,6 +451,20 @@ VM_MAD = [ disk-detach, nic-attach, nic-detach, snapshot-create, snapshot-delete" ] +# This variant should be used for nested virtualization +VM_MAD = [ + NAME = "qemu", + SUNSTONE_NAME = "QEMU", + EXECUTABLE = "one_vmm_exec", + ARGUMENTS = "-t 15 -r 0 kvm", + DEFAULT = "vmm_exec/vmm_exec_kvm.conf", + TYPE = "qemu", + KEEP_SNAPSHOTS = "yes", + LIVE_RESIZE = "yes", + IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend, + resume, delete, reboot, reboot-hard, resched, unresched, disk-attach, + disk-detach, nic-attach, nic-detach, snapshot-create, snapshot-delete" +] #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- @@ -531,66 +545,6 @@ VM_MAD = [ ] #------------------------------------------------------------------------------- -#------------------------------------------------------------------------------- -# EC2 Virtualization Driver Manager Configuration -# -r number of retries when monitoring a host -# -t number of threads, i.e. number of actions performed at the same time -# -w Timeout in seconds to execute external commands (default unlimited) -# -p more than one action per host in parallel, needs support from hypervisor -#------------------------------------------------------------------------------- -#VM_MAD = [ -# NAME = "ec2", -# SUNSTONE_NAME = "Amazon EC2", -# EXECUTABLE = "one_vmm_sh", -# ARGUMENTS = "-t 15 -r 0 -w 600 -p ec2", -# TYPE = "xml", -# KEEP_SNAPSHOTS = "no", -# IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend, -# resume, delete, reboot, reboot-hard, resched, unresched, poweroff, -# poweroff-hard, disk-attach, disk-detach, nic-attach, nic-detach, -# snap-create, snap-delete" -#] -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Azure Virtualization Driver Manager Configuration -# -r number of retries when monitoring a host -# -t number of threads, i.e. number of actions performed at the same time -# -w Timeout in seconds to execute external commands (default unlimited) -#------------------------------------------------------------------------------- -#VM_MAD = [ -# NAME = "az", -# SUNSTONE_NAME = "Microsoft Azure", -# EXECUTABLE = "one_vmm_sh", -# ARGUMENTS = "-t 15 -r 0 az", -# TYPE = "xml", -# KEEP_SNAPSHOTS = "no", -# IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend, -# resume, delete, reboot, reboot-hard, resched, unresched, poweroff, -# poweroff-hard, disk-attach, disk-detach, nic-attach, nic-detach, -# snap-create, snap-delete" -#] -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Hybrid OpenNebula Virtualization Driver Manager Configuration -# -r number of retries when monitoring a host -# -t number of threads, i.e. number of actions performed at the same time -#------------------------------------------------------------------------------- -# VM_MAD = [ -# NAME = "one", -# SUNSTONE_NAME = "OpenNebula", -# EXECUTABLE = "one_vmm_sh", -# ARGUMENTS = "-t 15 -r 0 one", -# TYPE = "xml", -# KEEP_SNAPSHOTS = "no", -# IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend, -# resume, delete, reboot, reboot-hard, resched, unresched, poweroff, -# poweroff-hard" -# ] -#------------------------------------------------------------------------------- - - #------------------------------------------------------------------------------- # Dummy Virtualization Driver Configuration #------------------------------------------------------------------------------- diff --git a/share/oneprovision/provisions/hybrid+_qemu/description.txt b/share/oneprovision/provisions/hybrid+_qemu/description.txt new file mode 100644 index 0000000000..779606e0d9 --- /dev/null +++ b/share/oneprovision/provisions/hybrid+_qemu/description.txt @@ -0,0 +1,7 @@ +The QEMU provision uses nested virtualization (KVM) to start emulated VMs in virtualized hosts. It is useful for developing and testing purposes. It features the following characteristics: + +* Hosts are provisioned as VMs in the selected provider +* The provision includes a public network (Internet reachable IPs) +* It also includes a virtual network template to create private VLANs. You need to instantiate this network template. + +More information about using this provision can be found in the [OpenNebula documentation](https://opennebula.io) diff --git a/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-eu-west-2.yml b/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-eu-west-2.yml new file mode 100644 index 0000000000..7bac74d4c8 --- /dev/null +++ b/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-eu-west-2.yml @@ -0,0 +1,26 @@ +name: 'aws-london' + +description: 'Elastic cluster on AWS in London' +provider: 'aws' + +plain: + provision_type: 'hybrid+_qemu' + image: 'AWS.webp' + +location_key: 'region' +connection: + access_key: 'Encrypted AWS access key' + secret_key: 'Encrypted AWS secret key' + region: 'eu-west-2' + +inputs: + - name: 'aws_ami_image' + type: 'list' + options: + - 'ami-0bab5c8be0975423b' + - name: 'aws_instance_type' + type: 'list' + options: + - 't2.micro' + - 't2.small' + - 't2.medium' diff --git a/share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/datastores.yml b/share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/datastores.yml new file mode 100644 index 0000000000..04ec0b320c --- /dev/null +++ b/share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/datastores.yml @@ -0,0 +1,39 @@ +--- +# ---------------------------------------------------------------------------- # +# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems # +# # +# 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. # +# ---------------------------------------------------------------------------- # + +#------------------------------------------------------------------------------- +# datastores: Defines the storage area for the cluster using the SSH replication +# drivers. It creates the following datastores, using Replica driver: +# 1. Image datastore, ${cluster_name}-image +# 2. System datastore, ${cluster_name}-system +# +# Configuration/Input attributes: +# - replica_host: The host that will hold the cluster replicas and snapshots. +#------------------------------------------------------------------------------- +datastores: + + - name: "${provision}-image" + type: 'image_ds' + ds_mad: 'fs' + tm_mad: 'ssh' + safe_dirs: "/var/tmp /tmp" + + - name: "${provision}-system" + type: 'system_ds' + tm_mad: 'ssh' + safe_dirs: "/var/tmp /tmp" + replica_host: "use-first-host" diff --git a/share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/defaults.yml b/share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/defaults.yml new file mode 100644 index 0000000000..343ee0a312 --- /dev/null +++ b/share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/defaults.yml @@ -0,0 +1,26 @@ +--- +# ---------------------------------------------------------------------------- # +# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems # +# # +# 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. # +# ---------------------------------------------------------------------------- # + +#------------------------------------------------------------------------------- +# defaults: Common configuration attributes for provision objects +#-------------------------------------------------------------------------------- +# configuration: Ansible role parameters. +#-------------------------------------------------------------------------------- +# Check defaults/main.yml in each role for the available variables +#------------------------------------------------------------------------------- + +... diff --git a/share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/inputs.yml b/share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/inputs.yml new file mode 100644 index 0000000000..a095876f31 --- /dev/null +++ b/share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/inputs.yml @@ -0,0 +1,38 @@ +--- +# ---------------------------------------------------------------------------- # +# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems # +# # +# 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. # +# ---------------------------------------------------------------------------- # + +inputs: + - name: 'number_hosts' + type: text + description: 'Number of AWS instances to create' + default: '1' + + - name: 'number_public_ips' + type: text + description: 'Number of public IPs to get' + default: '1' + + - name: 'aws_ami_image' + type: text + description: "AWS ami image used for host deployments" + default: '' + + - name: 'aws_instance_type' + type: text + description: "AWS instance type, use bare-metal instances, otherwise use QEMU" + default: '' +... diff --git a/share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/networks.yml b/share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/networks.yml new file mode 100644 index 0000000000..159031b6b0 --- /dev/null +++ b/share/oneprovision/provisions/hybrid+_qemu/provisions/aws.d/networks.yml @@ -0,0 +1,40 @@ +--- +# ---------------------------------------------------------------------------- # +# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems # +# # +# 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. # +# ---------------------------------------------------------------------------- # + +networks: + - name: "${provision}-public" + vn_mad: 'elastic' + bridge: 'br0' + netrole: 'public' + provision: + count: "${input.number_public_ips}" + ar: + - provison_id: "${provision_id}" + size: '1' + ipam_mad: 'aws' + cidr: "${cluster.0.cidr}" + +vntemplates: + - name: "${provision}-private" + vn_mad: 'vxlan' + phydev: 'eth0' + automatic_vlan_id: 'yes' + netrole: 'private' + vxlan_mode: 'evpn' + vxlan_tep: 'dev' + ip_link_conf: 'nolearning=' + cluster_ids: "${cluster.0.id}" diff --git a/share/oneprovision/provisions/hybrid+_qemu/provisions/aws.yml b/share/oneprovision/provisions/hybrid+_qemu/provisions/aws.yml new file mode 100644 index 0000000000..7ac74dc451 --- /dev/null +++ b/share/oneprovision/provisions/hybrid+_qemu/provisions/aws.yml @@ -0,0 +1,80 @@ +--- +# ---------------------------------------------------------------------------- # +# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems # +# # +# 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. # +# ---------------------------------------------------------------------------- # + +#------------------------------------------------------------------------------- +# This is the canonical description file for a cluster build with 'AWS' +# resources using the KVM hypervisor. +# ------------------------------------------------------------------------------ + +name: 'aws-cluster' +provision_type: 'hybrid+_qemu' +provider: 'aws' + +image: 'OPENNEBULA-AWS.png' + +extends: + - common.d/defaults.yml + - common.d/resources.yml + - common.d/qemu_hosts.yml + - aws.d/datastores.yml + - aws.d/defaults.yml + - aws.d/inputs.yml + - aws.d/networks.yml + +#------------------------------------------------------------------------------- +# playbook: Ansible playbook used for hosts configuration.The aws playbook +# include the following roles: +# - ddc +# - opennebula-repository +# - opennebula-node-kvm +# - opennebula-ssh +# - tuntap +# - bridged-networking +# - iptables +#------------------------------------------------------------------------------- +playbook: + - aws + +#------------------------------------------------------------------------------- +# defaults: Common configuration attributes for provision objects +#-------------------------------------------------------------------------------- +defaults: + provision: + provider_name: 'aws' + ami: "${input.aws_ami_image}" + instancetype: "${input.aws_instance_type}" + cloud_init: true + connection: + remote_user: 'centos' + +#------------------------------------------------------------------------------- +# cluster: Parameters for the OpenNebula cluster. Applies to all the Hosts +#-------------------------------------------------------------------------------- +# name: of the cluster +# description: Additional information +# reserved_cpu: In percentage. It will be subtracted from the TOTAL CPU +# reserved_memory: In percentage. It will be subtracted from the TOTAL MEM +#-------------------------------------------------------------------------------- +cluster: + name: "${provision}" + description: 'AWS cluster' + reserved_cpu: '0' + reserved_mem: '0' + datastores: + - 1 + provision: + cidr: '10.0.0.0/16' diff --git a/share/oneprovision/provisions/hybrid+_qemu/provisions/common.d/defaults.yml b/share/oneprovision/provisions/hybrid+_qemu/provisions/common.d/defaults.yml new file mode 100644 index 0000000000..43499ddf65 --- /dev/null +++ b/share/oneprovision/provisions/hybrid+_qemu/provisions/common.d/defaults.yml @@ -0,0 +1,32 @@ +--- +# ---------------------------------------------------------------------------- # +# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems # +# # +# 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. # +# ---------------------------------------------------------------------------- # + +#------------------------------------------------------------------------------- +# defaults: Common configuration attributes for provision objects +#-------------------------------------------------------------------------------- + +defaults: + configuration: + opennebula_node_kvm_use_ev: true + + # required for copying recovery VM snaphosts to the replica host + opennebula_ssh_deploy_private_key: true + + # Options to enable nested virtualization + opennebula_node_kvm_param_nested: True + + opennebula_node_kvm_manage_kvm: False diff --git a/share/oneprovision/provisions/hybrid+_qemu/provisions/common.d/qemu_hosts.yml b/share/oneprovision/provisions/hybrid+_qemu/provisions/common.d/qemu_hosts.yml new file mode 100644 index 0000000000..042fa7100a --- /dev/null +++ b/share/oneprovision/provisions/hybrid+_qemu/provisions/common.d/qemu_hosts.yml @@ -0,0 +1,35 @@ +--- +# ---------------------------------------------------------------------------- # +# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems # +# # +# 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. # +# ---------------------------------------------------------------------------- # + +#------------------------------------------------------------------------------- +# hosts: Packet or AWS metal servers +# provision: +# - count: Number of servers to create +# - hostname: kvm-host1, kvm-host2 .... of the server +# +# You can define specific OpenNebula configuration attributes for all the hosts: +# - reserved_cpu: In percentage. It will be subtracted from the TOTAL CPU +# - reserved_memory: In percentage. It will be subtracted from the TOTAL MEM +#------------------------------------------------------------------------------- +hosts: + + - im_mad: 'kvm' + vm_mad: 'qemu' + provision: + count: "${input.number_hosts}" + hostname: "qemu-host${index}" +... diff --git a/share/oneprovision/provisions/hybrid+_qemu/provisions/common.d/resources.yml b/share/oneprovision/provisions/hybrid+_qemu/provisions/common.d/resources.yml new file mode 100644 index 0000000000..8cd361b23c --- /dev/null +++ b/share/oneprovision/provisions/hybrid+_qemu/provisions/common.d/resources.yml @@ -0,0 +1,38 @@ +--- +# ---------------------------------------------------------------------------- # +# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems # +# # +# 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. # +# ---------------------------------------------------------------------------- # + +#------------------------------------------------------------------------------- +# Use this file to define custom resources associated to the cluster, example: +# - images +# - marketplaceapps +# - templates +# - vntemplates +# - flowtemplates +# +# Cross-references to other objects can be made: +# - by name, eg. ${datastore.images.id} to get the OpenNebula ID of the +# datastore with name "images" +# - by index, eg. ${datastore.0.id} to get the OpenNebula ID of the **first** +# datastore defined in the provision +#------------------------------------------------------------------------------- +marketplaceapps: + - appname: "Alpine Linux 3.10" + name: "alpine" + dsid: "${datastore.0.id}" + meta: + wait: true + wait_timeout: 60 From b626e5e126f94a38937ec69b739956f13449708c Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Herrero Date: Mon, 25 Jan 2021 13:36:55 +0100 Subject: [PATCH 09/11] M #-: use provider inputs (#704) --- src/oneprovision/lib/provision/provision.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/oneprovision/lib/provision/provision.rb b/src/oneprovision/lib/provision/provision.rb index 1a1de7a0f8..001dd8b522 100644 --- a/src/oneprovision/lib/provision/provision.rb +++ b/src/oneprovision/lib/provision/provision.rb @@ -257,7 +257,16 @@ module OneProvision if cfg['inputs'].nil? cfg['inputs'] = provider.inputs else - cfg['inputs'] << provider.inputs unless provider.inputs.nil? + unless provider.inputs.nil? + provider.inputs.each do |input| + i = cfg['inputs'].find do |v| + v['name'] == input['name'] + end + + cfg['inputs'].delete(i) if i + cfg['inputs'] << input + end + end end cfg.validate(false) From 9bd36d803cdae4c6237d551462273fa099c6d843 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Mon, 25 Jan 2021 17:52:00 +0100 Subject: [PATCH 10/11] M #-: Add EXTERNAL NIC attribute to short_body --- src/vm/VirtualMachineNic.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/vm/VirtualMachineNic.cc b/src/vm/VirtualMachineNic.cc index ea6b502f0a..d6352e9ba8 100644 --- a/src/vm/VirtualMachineNic.cc +++ b/src/vm/VirtualMachineNic.cc @@ -167,9 +167,10 @@ void VirtualMachineNic::to_xml_short(std::ostringstream& oss) const std::string ip = vector_value("IP"); std::string ip6 = vector_value("IP6"); std::string ip6_ula = vector_value("IP6_ULA"); - std::string ip6_link = vector_value("IP6_LINK"); - std::string ip6_global = vector_value("IP6_GLOBAL"); + std::string ip6_link = vector_value("IP6_LINK"); + std::string ip6_global = vector_value("IP6_GLOBAL"); + std::string ip_external = vector_value("EXTERNAL"); /* PROVISION AWS_IPAM */ std::string reqs = vector_value("SCHED_REQUIREMENTS"); std::string rank = vector_value("SCHED_RANK"); @@ -182,6 +183,11 @@ void VirtualMachineNic::to_xml_short(std::ostringstream& oss) const oss << "" << one_util::escape_xml(ip) << ""; } + if (!ip_external.empty()) + { + oss << "" << one_util::escape_xml(ip_external) << ""; + } + if (!ip6.empty()) { oss << "" << one_util::escape_xml(ip6) << ""; From 44dc72dde99ce0e348ba620ee6538d9e17bb2afd Mon Sep 17 00:00:00 2001 From: Jan Orel Date: Mon, 25 Jan 2021 17:55:34 +0100 Subject: [PATCH 11/11] M #-: Review and add AWS/Equinix providers (#706) --- .../providers/aws/aws-eu-central-1.yml | 9 +++---- .../hybrid+/providers/aws/aws-eu-west-2.yml | 24 +++++++++++++++++ .../hybrid+/providers/aws/aws-us-east-1.yml | 10 +++---- .../hybrid+/providers/aws/aws-us-west-1.yml | 24 +++++++++++++++++ .../{packet-amsterdam.yml => packet-ams1.yml} | 7 +++-- .../hybrid+/providers/packet/packet-ewr1.yml | 26 +++++++++++++++++++ .../hybrid+/providers/packet/packet-nrt1.yml | 26 +++++++++++++++++++ .../hybrid+/providers/packet/packet-sjc1.yml | 26 +++++++++++++++++++ .../provisions/hybrid+/provisions/aws.yml | 2 ++ .../providers/aws/aws-eu-central-1.yml | 26 +++++++++++++++++++ .../providers/aws/aws-eu-west-2.yml | 4 +-- .../providers/aws/aws-us-east-1.yml | 26 +++++++++++++++++++ .../providers/aws/aws-us-west-1.yml | 26 +++++++++++++++++++ 13 files changed, 219 insertions(+), 17 deletions(-) create mode 100644 share/oneprovision/provisions/hybrid+/providers/aws/aws-eu-west-2.yml create mode 100644 share/oneprovision/provisions/hybrid+/providers/aws/aws-us-west-1.yml rename share/oneprovision/provisions/hybrid+/providers/packet/{packet-amsterdam.yml => packet-ams1.yml} (75%) create mode 100644 share/oneprovision/provisions/hybrid+/providers/packet/packet-ewr1.yml create mode 100644 share/oneprovision/provisions/hybrid+/providers/packet/packet-nrt1.yml create mode 100644 share/oneprovision/provisions/hybrid+/providers/packet/packet-sjc1.yml create mode 100644 share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-eu-central-1.yml create mode 100644 share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-us-east-1.yml create mode 100644 share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-us-west-1.yml diff --git a/share/oneprovision/provisions/hybrid+/providers/aws/aws-eu-central-1.yml b/share/oneprovision/provisions/hybrid+/providers/aws/aws-eu-central-1.yml index 54812494e3..5c3850d61b 100644 --- a/share/oneprovision/provisions/hybrid+/providers/aws/aws-eu-central-1.yml +++ b/share/oneprovision/provisions/hybrid+/providers/aws/aws-eu-central-1.yml @@ -9,17 +9,16 @@ plain: location_key: 'region' connection: - access_key: 'Encrypted AWS access key' - secret_key: 'Encrypted AWS secret key' + access_key: 'AWS access key' + secret_key: 'AWS secret key' region: 'eu-central-1' inputs: - name: 'aws_ami_image' type: 'list' options: - - 'ami-0e342d72b12109f91' - - 'ami-0b793c1e0d1dc4d28' + - 'ami-04c21037b3f953d37' - name: 'aws_instance_type' type: 'list' options: - - 'i3-metal' + - 'i3.metal' diff --git a/share/oneprovision/provisions/hybrid+/providers/aws/aws-eu-west-2.yml b/share/oneprovision/provisions/hybrid+/providers/aws/aws-eu-west-2.yml new file mode 100644 index 0000000000..77cb4ab708 --- /dev/null +++ b/share/oneprovision/provisions/hybrid+/providers/aws/aws-eu-west-2.yml @@ -0,0 +1,24 @@ +name: 'aws-london' + +description: 'Elastic cluster on AWS in London' +provider: 'aws' + +plain: + provision_type: 'hybrid+_qemu' + image: 'AWS.webp' + +location_key: 'region' +connection: + access_key: 'AWS access key' + secret_key: 'AWS secret key' + region: 'eu-west-2' + +inputs: + - name: 'aws_ami_image' + type: 'list' + options: + - 'ami-0bab5c8be0975423b' + - name: 'aws_instance_type' + type: 'list' + options: + - 'i3.metal' diff --git a/share/oneprovision/provisions/hybrid+/providers/aws/aws-us-east-1.yml b/share/oneprovision/provisions/hybrid+/providers/aws/aws-us-east-1.yml index afc3d9fe99..6407edd5ea 100644 --- a/share/oneprovision/provisions/hybrid+/providers/aws/aws-us-east-1.yml +++ b/share/oneprovision/provisions/hybrid+/providers/aws/aws-us-east-1.yml @@ -9,18 +9,16 @@ plain: location_key: 'region' connection: - access_key: 'Encrypted AWS access key' - secret_key: 'Encrypted AWS secret key' + access_key: 'AWS access key' + secret_key: 'AWS secret key' region: 'us-east-1' inputs: - name: 'aws_ami_image' type: 'list' options: - - 'ami-096fda3c22c1c990a' - - 'ami-00ddb0e5626798373' + - 'ami-0d6e9a57f6259ba3a' - name: 'aws_instance_type' type: 'list' options: - - 'i3-metal' - - 'i3.large' + - 'i3.metal' diff --git a/share/oneprovision/provisions/hybrid+/providers/aws/aws-us-west-1.yml b/share/oneprovision/provisions/hybrid+/providers/aws/aws-us-west-1.yml new file mode 100644 index 0000000000..c2283da77d --- /dev/null +++ b/share/oneprovision/provisions/hybrid+/providers/aws/aws-us-west-1.yml @@ -0,0 +1,24 @@ +name: 'aws-north-california' + +description: 'Elastic cluster on AWS in North California' +provider: 'aws' + +plain: + provision_type: 'hybrid+' + image: 'AWS.webp' + +location_key: 'region' +connection: + access_key: 'AWS access key' + secret_key: 'AWS secret key' + region: 'us-west-1' + +inputs: + - name: 'aws_ami_image' + type: 'list' + options: + - 'ami-08b547f0dcb46c4d3' + - name: 'aws_instance_type' + type: 'list' + options: + - 'i3.metal' diff --git a/share/oneprovision/provisions/hybrid+/providers/packet/packet-amsterdam.yml b/share/oneprovision/provisions/hybrid+/providers/packet/packet-ams1.yml similarity index 75% rename from share/oneprovision/provisions/hybrid+/providers/packet/packet-amsterdam.yml rename to share/oneprovision/provisions/hybrid+/providers/packet/packet-ams1.yml index b2c69a2c56..5aa2932599 100644 --- a/share/oneprovision/provisions/hybrid+/providers/packet/packet-amsterdam.yml +++ b/share/oneprovision/provisions/hybrid+/providers/packet/packet-ams1.yml @@ -9,16 +9,15 @@ plain: location_key: 'facility' connection: - token: 'Encrypted Packet token' - project: 'Encrypted Packet project' + token: 'Packet token' + project: 'Packet project' facility: 'ams1' inputs: - name: 'packet_os' type: 'list' options: - - 'centos_7' - - 'ubuntu_18_04' + - 'centos_8' - name: 'packet_plan' type: 'list' options: diff --git a/share/oneprovision/provisions/hybrid+/providers/packet/packet-ewr1.yml b/share/oneprovision/provisions/hybrid+/providers/packet/packet-ewr1.yml new file mode 100644 index 0000000000..fa1135da6b --- /dev/null +++ b/share/oneprovision/provisions/hybrid+/providers/packet/packet-ewr1.yml @@ -0,0 +1,26 @@ +name: 'packet-ewr1' + +description: 'Elastic cluster on Packet in Parsippany, USA, NJ' +provider: 'packet' + +plain: + provision_type: 'hybrid+' + image: 'EQUINIX.webp' + +location_key: 'facility' +connection: + token: 'Packet token' + project: 'Packet project' + facility: 'ewr1' + +inputs: + - name: 'packet_os' + type: 'list' + options: + - 'centos_8' + - name: 'packet_plan' + type: 'list' + options: + - 't1.small' + - 'c1.small' + - 'm1.xlarge' diff --git a/share/oneprovision/provisions/hybrid+/providers/packet/packet-nrt1.yml b/share/oneprovision/provisions/hybrid+/providers/packet/packet-nrt1.yml new file mode 100644 index 0000000000..c4c5388988 --- /dev/null +++ b/share/oneprovision/provisions/hybrid+/providers/packet/packet-nrt1.yml @@ -0,0 +1,26 @@ +name: 'packet-nrt1' + +description: 'Elastic cluster on Packet in Tokyo, Japan' +provider: 'packet' + +plain: + provision_type: 'hybrid+' + image: 'EQUINIX.webp' + +location_key: 'facility' +connection: + token: 'Packet token' + project: 'Packet project' + facility: 'nrt1' + +inputs: + - name: 'packet_os' + type: 'list' + options: + - 'centos_8' + - name: 'packet_plan' + type: 'list' + options: + - 't1.small' + - 'c1.small' + - 'm1.xlarge' diff --git a/share/oneprovision/provisions/hybrid+/providers/packet/packet-sjc1.yml b/share/oneprovision/provisions/hybrid+/providers/packet/packet-sjc1.yml new file mode 100644 index 0000000000..09937442f1 --- /dev/null +++ b/share/oneprovision/provisions/hybrid+/providers/packet/packet-sjc1.yml @@ -0,0 +1,26 @@ +name: 'packet-sjc1' + +description: 'Elastic cluster on Packet in Sunnyvale, USA, CA' +provider: 'packet' + +plain: + provision_type: 'hybrid+' + image: 'EQUINIX.webp' + +location_key: 'facility' +connection: + token: 'Packet token' + project: 'Packet project' + facility: 'sjc1' + +inputs: + - name: 'packet_os' + type: 'list' + options: + - 'centos_8' + - name: 'packet_plan' + type: 'list' + options: + - 't1.small' + - 'c1.small' + - 'm1.xlarge' diff --git a/share/oneprovision/provisions/hybrid+/provisions/aws.yml b/share/oneprovision/provisions/hybrid+/provisions/aws.yml index e4e48c5e13..0daaf331a9 100644 --- a/share/oneprovision/provisions/hybrid+/provisions/aws.yml +++ b/share/oneprovision/provisions/hybrid+/provisions/aws.yml @@ -58,6 +58,8 @@ defaults: ami: "${input.aws_ami_image}" instancetype: "${input.aws_instance_type}" cloud_init: true + connection: + remote_user: 'centos' #------------------------------------------------------------------------------- # cluster: Parameters for the OpenNebula cluster. Applies to all the Hosts diff --git a/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-eu-central-1.yml b/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-eu-central-1.yml new file mode 100644 index 0000000000..46e3946585 --- /dev/null +++ b/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-eu-central-1.yml @@ -0,0 +1,26 @@ +name: 'aws-frankfurt' + +description: 'Elastic cluster on AWS in Frankfurt' +provider: 'aws' + +plain: + provision_type: 'hybrid+_qemu' + image: 'AWS.webp' + +location_key: 'region' +connection: + access_key: 'AWS access key' + secret_key: 'AWS secret key' + region: 'eu-central-1' + +inputs: + - name: 'aws_ami_image' + type: 'list' + options: + - 'ami-04c21037b3f953d37' + - name: 'aws_instance_type' + type: 'list' + options: + - 't2.micro' + - 't2.small' + - 't2.medium' diff --git a/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-eu-west-2.yml b/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-eu-west-2.yml index 7bac74d4c8..28b030eca6 100644 --- a/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-eu-west-2.yml +++ b/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-eu-west-2.yml @@ -9,8 +9,8 @@ plain: location_key: 'region' connection: - access_key: 'Encrypted AWS access key' - secret_key: 'Encrypted AWS secret key' + access_key: 'AWS access key' + secret_key: 'AWS secret key' region: 'eu-west-2' inputs: diff --git a/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-us-east-1.yml b/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-us-east-1.yml new file mode 100644 index 0000000000..1f54061062 --- /dev/null +++ b/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-us-east-1.yml @@ -0,0 +1,26 @@ +name: 'aws-north-virginia' + +description: 'Elastic cluster on AWS in North Virginia' +provider: 'aws' + +plain: + provision_type: 'hybrid+_qemu' + image: 'AWS.webp' + +location_key: 'region' +connection: + access_key: 'AWS access key' + secret_key: 'AWS secret key' + region: 'us-east-1' + +inputs: + - name: 'aws_ami_image' + type: 'list' + options: + - 'ami-0d6e9a57f6259ba3a' + - name: 'aws_instance_type' + type: 'list' + options: + - 't2.micro' + - 't2.small' + - 't2.medium' diff --git a/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-us-west-1.yml b/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-us-west-1.yml new file mode 100644 index 0000000000..0b041f3a0e --- /dev/null +++ b/share/oneprovision/provisions/hybrid+_qemu/providers/aws/aws-us-west-1.yml @@ -0,0 +1,26 @@ +name: 'aws-north-california' + +description: 'Elastic cluster on AWS in North California' +provider: 'aws' + +plain: + provision_type: 'hybrid+_qemu' + image: 'AWS.webp' + +location_key: 'region' +connection: + access_key: 'AWS access key' + secret_key: 'AWS secret key' + region: 'us-west-1' + +inputs: + - name: 'aws_ami_image' + type: 'list' + options: + - 'ami-08b547f0dcb46c4d3' + - name: 'aws_instance_type' + type: 'list' + options: + - 't2.micro' + - 't2.small' + - 't2.medium'