Compare commits

...

27 Commits

Author SHA1 Message Date
2d2362815b Ok Fini 2025-11-27 14:57:15 +01:00
bd4bc7cb24 Fin Projet avant bonus 2025-11-27 14:06:29 +01:00
0b7d66777e Question 25 2025-11-27 13:20:04 +01:00
558a4c30f7 Projet 2025-11-27 11:59:36 +01:00
39f8b87743 fin TP3 2025-11-20 22:01:23 +01:00
ff878558f9 Fin TP3 2025-11-19 21:18:33 +01:00
f3f157318a TP3-Question 13 2025-11-18 19:31:26 +01:00
1948a6c927 Question 5 TP3 2025-11-15 15:49:53 +01:00
6aadc1e8e1 Question 5 2025-11-15 05:42:37 +01:00
bd0942782a Téléverser les fichiers vers "TP-02" 2025-11-14 20:32:01 +00:00
adc251afe6 Fin du TP2 2025-11-14 21:30:34 +01:00
72a79ee83f Question 21 2025-11-13 16:16:31 +01:00
ee6b19082a Question 19 2025-11-13 12:02:47 +01:00
dcb967dc2f Question 19 2025-11-13 11:53:55 +01:00
2389e11ed5 Ajout Config ESW3 2025-11-13 09:45:43 +01:00
ef4dffe5ef Ajout TP-02 2025-11-13 09:34:59 +01:00
5c7fa4d11a Téléverser les fichiers vers "TP-01" 2025-11-08 10:27:31 +00:00
328d48f861 TP01 2025-11-08 11:21:54 +01:00
amar
1f77db8472 update readme 2023-05-30 06:37:24 +00:00
amar
b1df2b1ce7 update readme 2023-05-30 06:35:57 +00:00
amar
ac3429868a add frontend project 2023-05-30 08:32:18 +02:00
amar kantas
2a564bba38 add jinja files 2023-04-19 14:29:23 +02:00
amar kantas
44fb59af52 add data files 2023-04-19 14:29:12 +02:00
amar
ef94773d1b Merge branch 'main' of https://gitlab.com/l3958/devnet 2023-04-04 12:05:51 +02:00
amar
5d53981423 add TP-03 2023-04-04 12:05:21 +02:00
amar
bfd36732ba Supprimer CHANGELOG 2023-03-20 18:07:12 +00:00
amar
0186015d37 Ajout de CHANGELOG 2023-03-20 18:06:52 +00:00
155 changed files with 22036 additions and 78 deletions

View File

@@ -0,0 +1,13 @@
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

90
PROJECT/fastprod_frontend/.gitignore vendored Normal file
View File

@@ -0,0 +1,90 @@
# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
/logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# Nuxt generate
dist
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless
# IDE / Editor
.idea
# Service worker
sw.*
# macOS
.DS_Store
# Vim swap files
*.swp

View File

@@ -0,0 +1,75 @@
# fastprod_frontend
## Build Setup
```
cd devnet/PROJECT/fastprod_frontend
#create a .env file and add your localhost api server ip address in API_URL env variable :
API_URL=http://localhost:5000
# install dependencies
$ npm install
# serve with hot reload at localhost:3000
$ npm run dev
# build for production and launch server
$ npm run build
$ npm run start
# generate static project
$ npm run generate
```
For detailed explanation on how things work, check out the [documentation](https://nuxtjs.org).
## Special Directories
You can create the following extra directories, some of which have special behaviors. Only `pages` is required; you can delete them if you don't want to use their functionality.
### `assets`
The assets directory contains your uncompiled assets such as Stylus or Sass files, images, or fonts.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/assets).
### `components`
The components directory contains your Vue.js components. Components make up the different parts of your page and can be reused and imported into your pages, layouts and even other components.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/components).
### `layouts`
Layouts are a great help when you want to change the look and feel of your Nuxt app, whether you want to include a sidebar or have distinct layouts for mobile and desktop.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/layouts).
### `pages`
This directory contains your application views and routes. Nuxt will read all the `*.vue` files inside this directory and setup Vue Router automatically.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/get-started/routing).
### `plugins`
The plugins directory contains JavaScript plugins that you want to run before instantiating the root Vue.js Application. This is the place to add Vue plugins and to inject functions or constants. Every time you need to use `Vue.use()`, you should create a file in `plugins/` and add its path to plugins in `nuxt.config.js`.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/plugins).
### `static`
This directory contains your static files. Each file inside this directory is mapped to `/`.
Example: `/static/robots.txt` is mapped as `/robots.txt`.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/static).
### `store`
This directory contains your Vuex store files. Creating a file in this directory automatically activates Vuex.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/store).

View File

@@ -0,0 +1,4 @@
// Ref: https://github.com/nuxt-community/vuetify-module#customvariables
//
// The variables you want to modify
// $font-size-root: 20px;

View File

@@ -0,0 +1,57 @@
<template>
<UiDialog
ref="ref"
:width="width"
:header="{
icon: header.icon,
label: header.label,
}"
>
<template #content>
<v-container>
<slot name="header"></slot>
<component
:is="component"
v-if="!!component"
:data="componentProps"
@event="$emit('event', null)"
@onSubmit="onSubmit"
></component>
</v-container>
</template>
</UiDialog>
</template>
<script>
export default {
props: {
component: {
type: String,
default: null,
},
componentProps: {
type: Object,
default: null,
},
width: {
type: String,
default: "800",
},
header: {
type: Object,
default: () => ({ icon: null, label: null }),
},
},
methods: {
open() {
this.$refs.ref.open();
},
close() {
this.$refs.ref.close();
},
onSubmit(e) {
this.$emit("onSubmit", e);
},
},
};
</script>

View File

@@ -0,0 +1,51 @@
<template>
<v-row justify="center">
<v-col cols="12">
<v-card :flat="flat" class="rounded-lg">
<v-card-title :class="headerClass">
<v-icon :color="iconColor" class="mr-1">mdi-{{ icon }}</v-icon>
{{ title }}
</v-card-title>
<div>
<slot name="headerActions"></slot>
</div>
<v-card-text>
<slot name="content"></slot>
</v-card-text>
<v-card-actions>
<slot name="footerActions"></slot>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</template>
<script>
export default {
props: {
title: {
type: String,
default: null,
},
icon: {
type: String,
default: null,
},
flat: {
type: Boolean,
default: true,
},
headerClass: {
type: String,
default: 'primary white--text mb-2',
},
iconColor: {
type: String,
default: 'white',
},
},
data() {
return {}
},
}
</script>
<style scoped></style>

View File

@@ -0,0 +1,51 @@
<template>
<div>
<v-dialog v-model="dialog" :max-width="width">
<v-card>
<v-toolbar v-if="!!header" color="primary" dark>
<v-icon>mdi-{{ header.icon }}</v-icon>
<h4 class="ml-2">{{ header.label }}</h4>
<v-spacer></v-spacer>
<v-btn icon dark @click="dialog = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-toolbar>
<v-card-text>
<slot name="content"></slot>
</v-card-text>
<v-card-actions class="justify-end">
<slot name="action"></slot>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</template>
<script>
export default {
props: {
width: {
type: String,
default: '800',
},
header: {
type: Object,
default: null,
},
},
data() {
return {
dialog: false,
}
},
methods: {
open() {
this.dialog = true
},
close() {
this.dialog = false
},
},
}
</script>
<style scoped></style>

View File

@@ -0,0 +1,179 @@
<template>
<div>
<ValidationObserver
ref="observer"
v-slot="{ handleSubmit, validated, invalid }"
>
<v-form @submit.prevent="onSubmit">
<v-row>
<v-col lg="6" md="6" cols="12">
<ValidationProvider
v-slot="{ errors, valid }"
rules="required"
name="Hostname"
>
<v-text-field
v-model="host.data.device_name"
:error-messages="errors"
color="primary"
outlined
label="Hostname"
prepend-inner-icon="mdi-subtitles-outline"
></v-text-field>
</ValidationProvider>
</v-col>
<v-col lg="6" md="6" cols="12">
<ValidationProvider
v-slot="{ errors, valid }"
rules="required"
name="Ip address"
>
<v-text-field
v-model="host.hostname"
:error-messages="errors"
color="primary"
outlined
label="Ip address"
prepend-inner-icon="mdi-router-network"
></v-text-field>
</ValidationProvider>
</v-col>
<v-col lg="6" md="6" cols="12">
<ValidationProvider
v-slot="{ errors, valid }"
rules="required"
name="Model"
>
<v-text-field
v-model="host.data.device_model"
:error-messages="errors"
color="primary"
outlined
label="Model"
prepend-inner-icon="mdi-cog-sync-outline"
></v-text-field>
</ValidationProvider>
</v-col>
<v-col lg="6" md="6" cols="12">
<ValidationProvider
v-slot="{ errors, valid }"
rules="required"
name="Type"
>
<v-select
v-model="host.data.device_type"
:items="['router', 'routeur_switch']"
outlined
:error-messages="errors"
color="primary"
label="Type"
prepend-inner-icon="mdi-devices"
></v-select>
</ValidationProvider>
</v-col>
<v-col lg="6" md="6" cols="12">
<ValidationProvider
v-slot="{ errors, valid }"
rules="required"
name="Locality"
>
<v-text-field
v-model="host.data.locality"
:error-messages="errors"
color="primary"
outlined
label="Locality"
prepend-inner-icon="mdi-map-marker-radius-outline"
></v-text-field>
</ValidationProvider>
</v-col>
<v-col lg="6" md="6" cols="12">
<ValidationProvider
v-slot="{ errors, valid }"
rules="required"
name="Building"
>
<v-text-field
v-model="host.data.building"
:error-messages="errors"
color="primary"
outlined
label="Building"
prepend-inner-icon="mdi-office-building-marker-outline"
></v-text-field>
</ValidationProvider>
</v-col>
<v-col lg="8" md="8" cols="12">
<ValidationProvider
v-slot="{ errors, valid }"
rules="required"
name="Room"
>
<v-text-field
v-model="host.data.room"
:error-messages="errors"
color="primary"
outlined
label="Room"
prepend-inner-icon="mdi-domain"
></v-text-field>
</ValidationProvider>
</v-col>
</v-row>
<div class="text-center">
<v-btn
:disabled="invalid"
color="primary"
class="white--text"
x-large
:loading="loading"
@click="add"
outlined
>
Add <v-icon right dark> mdi-check </v-icon>
</v-btn>
</div>
</v-form>
</ValidationObserver>
</div>
</template>
<script>
export default {
data() {
return {
loading: false,
host: {
hostname: null,
data: {
device_type: null,
device_name: null,
device_model: null,
locality: "cisco",
building: null,
room: null,
},
},
};
},
mounted() {},
methods: {
add() {
this.loading = true;
this.$store
.dispatch("inventory/post", { data: this.host })
.then((response) => {
this.loading = false;
this.$emit("onSubmit");
})
.catch((error) => {
this.loading = false;
console.log("error", error);
});
},
},
};
</script>
<style scoped></style>

View File

@@ -0,0 +1,103 @@
<template>
<UiCard title="Device informations" icon="server" :flat="false">
<template #headerActions>
<div class="text-center">
<v-btn
v-show="!loading"
@click="$emit('refresh')"
color="primary"
outlined
>
Refresh
</v-btn>
</div>
<div class="text-center" v-show="!loading">
<v-icon size="100" color="primary">mdi-remote-desktop</v-icon>
<br />
<span class="text-h5 text-center" v-if="!!item">
{{ item.hostname }}
</span>
</div>
</template>
<template #content>
<div class="text-center">
<v-progress-circular
:size="70"
:width="7"
color="primary"
indeterminate
v-show="loading"
></v-progress-circular>
</div>
<v-divider class="mb-4" v-show="!loading"></v-divider>
<v-row
justify="center"
align="center"
class="text-center"
v-if="!!item"
v-show="!loading"
>
<v-col cols="12" class="text-capitalize">
<v-icon color="primary"> mdi-webpack </v-icon>
<span class="font-weight-bold">FQDN :</span>
{{ item.fqdn }}
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-office-building-cog-outline </v-icon>
<span class="font-weight-bold">vendor :</span>
{{ item.vendor }}
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-cog-sync-outline </v-icon>
<span class="font-weight-bold">Model :</span>
{{ item.model }}
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-barcode </v-icon>
<span class="font-weight-bold">Serial number :</span>
<span class="text-capitalize">
{{ item.serial_number }}
</span>
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-clock-outline </v-icon>
<span class="font-weight-bold">Up time :</span>
<span class="text-capitalize">
{{ item.uptime }}
</span>
</v-col>
<v-col cols="12">
<v-icon color="primary"> mdi-code-tags </v-icon>
<span class="font-weight-bold">OS version :</span>
<span class="text-capitalize">
{{ item.os_version }}
</span>
</v-col>
</v-row>
</template>
</UiCard>
</template>
<script>
export default {
props: {
item: {
type: Object,
default: null,
},
loading: {
type: Boolean,
default: false,
},
},
data() {
return {};
},
mounted() {},
methods: {},
};
</script>
<style scoped></style>

View File

@@ -0,0 +1,94 @@
<template>
<UiCard :title="deviceName" icon="server" :flat="false" v-if="!!item">
<template #headerActions>
<div class="text-center" v-show="!loading">
<v-icon
size="100"
v-if="item.data.device_type === 'router'"
color="primary"
>mdi-router</v-icon
>
<v-icon size="100" v-else color="primary">mdi-border-outside</v-icon>
<br />
<span class="text-h5 text-center">{{ item.hostname }}</span>
</div>
</template>
<template #content>
<div class="text-center">
<v-progress-circular
:size="70"
:width="7"
color="primary"
indeterminate
v-show="loading"
></v-progress-circular>
</div>
<div v-show="!loading">
<v-divider class="mb-4"></v-divider>
<v-row justify="center" align="center" class="text-center">
<v-col cols="3" class="text-capitalize">
<v-icon color="primary"> mdi-map-marker-radius-outline </v-icon>
<span class="font-weight-bold">Location :</span>
{{ item.data.locality }}
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary">
mdi-office-building-marker-outline
</v-icon>
<span class="font-weight-bold">Building :</span>
{{ item.data.building }}
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-domain </v-icon>
<span class="font-weight-bold">Room :</span>
{{ item.data.room }}
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-devices </v-icon>
<span class="font-weight-bold">Type :</span>
<span v-if="item.data.device_type == 'router'">Router</span>
<span v-if="item.data.device_type == 'switch_router'">Router</span>
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-cog-sync-outline </v-icon>
<span class="font-weight-bold">Model :</span>
{{ item.data.device_model }}
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-cog-sync-outline </v-icon>
<span class="font-weight-bold">OS :</span>
<span class="text-capitalize">
{{ item.groups[0] }}
</span>
</v-col>
</v-row>
</div>
</template>
</UiCard>
</template>
<script>
export default {
props: {
item: {
type: Object,
default: null,
},
deviceName: {
type: String,
default: null,
},
loading: {
type: Boolean,
default: false,
},
},
data() {
return {};
},
mounted() {},
methods: {},
};
</script>
<style scoped></style>

View File

@@ -0,0 +1,135 @@
<template>
<UiCard title="Devices interfaces" icon="connection" :flat="false">
<template #headerActions>
<div class="text-center">
<v-btn
@click="$emit('refresh')"
color="primary"
outlined
v-show="!loading"
>
Refresh
</v-btn>
</div>
<div class="text-center" v-show="!loading">
<v-icon size="100" color="primary">mdi-connection</v-icon>
<br />
<span class="text-h5 text-center" v-if="!!items">
{{ deviceName }}
</span>
</div>
</template>
<template #content>
<div class="text-center">
<v-progress-circular
:size="70"
:width="7"
color="primary"
indeterminate
v-show="loading"
></v-progress-circular>
</div>
<v-divider class="mb-4" v-show="!loading"></v-divider>
<div v-if="!!items" v-show="!loading">
<v-row justify="end">
<v-col cols="4">
<v-text-field
v-if="items.length > 1"
v-model="search"
color="secondary"
append-icon="mdi-magnify"
label="search an interface..."
single-line
hide-details
></v-text-field>
</v-col>
</v-row>
<v-data-table
hide-default-footer
class="row-pointer"
:search="search"
:headers="headers"
:items="items"
:items-per-page="100"
>
<template #[`item.is_up`]="{ item }">
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
v-bind="attrs"
icon
color="error"
v-on="on"
@click="onDelete(item)"
>
<v-icon size="65" :color="item.is_up ? 'success' : 'error'">
mdi-circle-small
</v-icon>
</v-btn>
</template>
<span>
<span v-if="item.is_up">IS UP</span>
<span v-else>IS DOWN</span>
</span>
</v-tooltip>
</template>
</v-data-table>
</div>
</template>
</UiCard>
</template>
<script>
export default {
props: {
items: {
type: Array,
default: null,
},
loading: {
type: Boolean,
default: false,
},
deviceName: {
type: String,
default: false,
},
},
data() {
return {
search: "",
headers: [
{
text: "Name",
value: "name",
align: "center",
},
{
text: "Description",
value: "description",
align: "center",
},
{
text: "Admin status",
value: "is_enabled",
align: "center",
},
{
text: "Status",
value: "is_up",
align: "center",
},
{
text: "Mac address",
value: "mac_addresss",
align: "center",
},
],
};
},
mounted() {},
methods: {},
};
</script>
<style scoped></style>

View File

@@ -0,0 +1,104 @@
<template>
<UiCard title="Configured interfaces" icon="connection" :flat="false">
<template #headerActions>
<div class="text-center">
<v-btn
@click="$emit('refresh')"
color="primary"
outlined
v-show="!loading"
>
Refresh
</v-btn>
</div>
<div class="text-center" v-show="!loading">
<v-icon size="100" color="primary">mdi-connection</v-icon>
<br />
<span class="text-h5 text-center" v-if="!!items">
{{ deviceName }}
</span>
</div>
</template>
<template #content>
<div class="text-center">
<v-progress-circular
:size="70"
:width="7"
color="primary"
indeterminate
v-show="loading"
></v-progress-circular>
</div>
<v-divider class="mb-4" v-show="!loading"></v-divider>
<div v-if="!!items" v-show="!loading">
<v-row justify="end">
<v-col cols="4">
<v-text-field
v-if="items.length > 1"
v-model="search"
color="secondary"
append-icon="mdi-magnify"
label="search an interface..."
single-line
hide-details
></v-text-field>
</v-col>
</v-row>
<v-data-table
hide-default-footer
class="row-pointer"
:search="search"
:headers="headers"
:items="items"
:items-per-page="100"
>
</v-data-table>
</div>
</template>
</UiCard>
</template>
<script>
export default {
props: {
items: {
type: Array,
default: null,
},
loading: {
type: Boolean,
default: false,
},
deviceName: {
type: String,
default: false,
},
},
data() {
return {
search:"",
headers: [
{
text: "Name",
value: "name",
align: "center",
},
{
text: "Ip address",
value: "ip",
align: "center",
},
{
text: "Prefix length",
value: "prefix_length",
align: "center",
},
],
};
},
mounted() {},
methods: {},
};
</script>
<style scoped></style>

View File

@@ -0,0 +1,132 @@
<template>
<UiCard
title="Devices snapshots"
icon="content-save-cog-outline"
:flat="false"
>
<template #headerActions>
<div class="text-center">
<v-btn
@click="$emit('createSnapshot')"
color="primary"
outlined
v-show="!loading"
>
Make a snapshot
</v-btn>
<v-btn
@click="$emit('refresh')"
color="primary"
outlined
v-show="!loading"
>
Refresh
</v-btn>
</div>
<div class="text-center" v-show="!loading">
<v-icon size="100" color="primary">mdi-content-save-cog-outline</v-icon>
<br />
<span class="text-h5 text-center" v-if="!!items">
{{ deviceName }}
</span>
</div>
</template>
<template #content>
<div class="text-center">
<v-progress-circular
:size="70"
:width="7"
color="primary"
indeterminate
v-show="loading"
></v-progress-circular>
</div>
<v-divider class="mb-4" v-show="!loading"></v-divider>
<div v-if="!!items" v-show="!loading">
<v-row justify="end">
<v-col cols="4">
<v-text-field
v-if="items.length > 1"
v-model="search"
color="secondary"
append-icon="mdi-magnify"
label="search a snapshot..."
single-line
hide-details
></v-text-field>
</v-col>
</v-row>
<v-data-table
hide-default-footer
class="row-pointer"
:search="search"
:headers="headers"
:items="items"
:items-per-page="100"
>
<template #[`item.actions`]="{ item }">
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn v-bind="attrs" icon v-on="on" link :href="'http://192.168.1.36:5000/snapshots/'+item.file">
<v-icon> mdi-cloud-download-outline </v-icon>
</v-btn>
</template>
<span> Download </span>
</v-tooltip>
</template>
</v-data-table>
</div>
</template>
</UiCard>
</template>
<script>
export default {
props: {
items: {
type: Array,
default: null,
},
loading: {
type: Boolean,
default: false,
},
deviceName: {
type: String,
default: false,
},
},
data() {
return {
search: "",
headers: [
{
text: "Name",
value: "file",
align: "center",
},
{
text: "Path",
value: "path",
align: "center",
},
{
text: "At",
value: "at",
align: "center",
},
{
text: "Actions",
value: "actions",
align: "center",
},
],
};
},
mounted() {},
methods: {},
};
</script>
<style scoped></style>

View File

@@ -0,0 +1,152 @@
<template>
<div>
<v-row justify="center">
<v-col lg="6" md="12" cols="12">
<UiCard title="Show commands SHELL" icon="console" :flat="false">
<template #content>
<v-textarea
outlined
name="input-7-4"
label="Show commands"
v-model="showCommands"
></v-textarea>
<div class="text-center">
<v-btn
outlined
color="primary"
@click="sendShowCommands"
:loading="loadingShowCommands"
>
Send <v-icon>mdi-arrange-send-to-back</v-icon>
</v-btn>
</div>
</template>
</UiCard>
</v-col>
<v-col lg="6" md="12" cols="12">
<UiCard title="Config commands SHELL" icon="console" :flat="false">
<template #content>
<v-textarea
outlined
name="input-7-4"
label="Config commands"
v-model="configCommands"
></v-textarea>
<div class="text-center">
<v-btn
outlined
color="primary"
@click="sendConfigCommands"
:loading="loadingConfigCommands"
>
Send <v-icon>mdi-arrange-send-to-back</v-icon>
</v-btn>
<v-alert
dense
text
type="success"
class="my-5"
v-if="!!configResult && !configError"
>
Configuration deployed!
</v-alert>
<v-alert dense outlined type="error" class="my-5" v-if="configError">
Error config could not be deployed...
</v-alert>
</div>
</template>
</UiCard>
</v-col>
<v-col cols="12">
<div v-if="!!result" class="text-center">
<v-textarea
:value="result"
height="280"
outlined
color="primary"
label="Output"
></v-textarea>
</div>
</v-col>
</v-row>
</div>
</template>
<script>
export default {
data() {
return {
loadingShowCommands: false,
selectedDeviceName: null,
showCommands: null,
configCommands: null,
loadingConfigCommands: null,
result: null,
configResult: null,
configError:false,
};
},
mounted() {
//this.getDevices();
this.selectedDeviceName = this.$route.params.name;
},
methods: {
getDeviceByName() {
this.loading = true;
this.$store
.dispatch("inventory/getByName", { name: this.$route.params.name })
.then((response) => {
this.loading = false;
this.device = response.data.device;
})
.catch((error) => {
this.loading = false;
console.log("error", error);
});
},
sendShowCommands() {
const data = { mode: "enable", commands: this.showCommands.split("\n") };
this.loadingShowCommands = true;
this.$store
.dispatch("inventory/config", {
name: this.$route.params.name,
data: data,
})
.then((response) => {
this.loadingShowCommands = false;
this.result = response.data.result
.map((item) => {
return item.result;
})
.join("\n\n\n");
})
.catch((error) => {
this.loadingShowCommands = false;
console.log("error", error);
});
},
sendConfigCommands() {
const data = {
mode: "config",
commands: this.configCommands.split("\n"),
};
this.loadingConfigCommands = true;
this.configError = false
this.$store
.dispatch("inventory/config", {
name: this.$route.params.name,
data: data,
})
.then((response) => {
this.loadingConfigCommands = false;
this.configResult = response.data.result;
})
.catch((error) => {
this.configError = true
this.loadingConfigCommands = false;
console.log("error", error);
});
},
},
};
</script>

View File

@@ -0,0 +1,131 @@
<template>
<div>
<v-row justify="end">
<v-col cols="3">
<v-text-field
v-if="items.length > 1"
v-model="search"
color="secondary"
append-icon="mdi-magnify"
label="search a device..."
single-line
hide-details
></v-text-field>
</v-col>
</v-row>
<v-data-table
hide-default-footer
class="row-pointer"
:search="search"
:headers="headers"
:items="items"
:items-per-page="100"
>
<template #[`item.data`]="{ item }">
<span class="text-capitalize">
{{ item.data.locality }} - {{ item.data.building }}
</span>
</template>
<template #[`item.data.device_type`]="{ item }">
<span v-if="item.data.device_type == 'router_switch'">
Ethernet switch router - {{ item.data.device_model }}
</span>
<span v-if="item.data.device_type == 'router'">
Router - {{ item.data.device_model }}
</span>
</template>
<template #[`item.actions`]="{ item }">
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
v-bind="attrs"
icon
color="secondary"
v-on="on"
@click="onView(item)"
>
<v-icon> mdi-magnify </v-icon>
</v-btn>
</template>
<span> Detail </span>
</v-tooltip>
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
v-bind="attrs"
icon
color="error"
v-on="on"
@click="onDelete(item)"
>
<v-icon> mdi-delete-circle-outline </v-icon>
</v-btn>
</template>
<span> Delete this device </span>
</v-tooltip>
</template>
<template #no-data> No data .... </template>
<template #no-results> No data ....</template>
</v-data-table>
</div>
</template>
<script>
export default {
props: {
items: {
type: Array,
default: null,
},
},
data() {
return {
search: "",
headers: [
{
text: "Hostname",
value: "name",
align: "center",
},
{
text: "Ip address",
value: "hostname",
align: "center",
},
{
text: "Type",
value: "data.device_type",
align: "center",
},
{
text: "Location",
value: "data",
align: "center",
},
{
text: "Actions",
value: "actions",
align: "center",
},
],
};
},
mounted() {},
methods: {
onView(item) {
this.$emit("onAction", { item, action: "show" });
},
onDelete(item) {
this.$emit("onAction", { item, action: "delete" });
},
},
};
</script>
<style scoped>
.row-pointer >>> tbody tr :hover {
cursor: pointer;
}
</style>

View File

@@ -0,0 +1,11 @@
<template>
<svg class="nuxt-logo" viewBox="0 0 45 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M24.7203 29.704H41.1008C41.6211 29.7041 42.1322 29.5669 42.5828 29.3061C43.0334 29.0454 43.4075 28.6704 43.6675 28.2188C43.9275 27.7672 44.0643 27.2549 44.0641 26.7335C44.0639 26.2121 43.9266 25.6999 43.6662 25.2485L32.6655 6.15312C32.4055 5.70162 32.0315 5.32667 31.581 5.06598C31.1305 4.8053 30.6195 4.66805 30.0994 4.66805C29.5792 4.66805 29.0682 4.8053 28.6177 5.06598C28.1672 5.32667 27.7932 5.70162 27.5332 6.15312L24.7203 11.039L19.2208 1.48485C18.9606 1.03338 18.5864 0.658493 18.1358 0.397853C17.6852 0.137213 17.1741 0 16.6538 0C16.1336 0 15.6225 0.137213 15.1719 0.397853C14.7213 0.658493 14.3471 1.03338 14.0868 1.48485L0.397874 25.2485C0.137452 25.6999 0.000226653 26.2121 2.8053e-07 26.7335C-0.000226092 27.2549 0.136554 27.7672 0.396584 28.2188C0.656614 28.6704 1.03072 29.0454 1.48129 29.3061C1.93185 29.5669 2.44298 29.7041 2.96326 29.704H13.2456C17.3195 29.704 20.3239 27.9106 22.3912 24.4118L27.4102 15.7008L30.0986 11.039L38.1667 25.0422H27.4102L24.7203 29.704ZM13.0779 25.0374L5.9022 25.0358L16.6586 6.36589L22.0257 15.7008L18.4322 21.9401C17.0593 24.2103 15.4996 25.0374 13.0779 25.0374Z" fill="#00DC82" />
</svg>
</template>
<style>
.nuxt-logo {
height: 180px;
}
</style>

View File

@@ -0,0 +1,52 @@
<!-- Please remove this file from your project -->
<template>
<div class="relative flex items-top justify-center min-h-screen bg-gray-100 sm:items-center sm:pt-0">
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.1.2/dist/tailwind.min.css" rel="stylesheet">
<div class="max-w-4xl mx-auto sm:px-6 lg:px-8">
<a class="flex justify-center pt-8 sm:pt-0" href="https://nuxtjs.org" target="_blank">
<svg width="218" height="45" viewBox="0 0 159 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M55.5017 6.81866H60.1727L70.0719 22.9912V6.81866H74.3837V29.7345H69.7446L59.8135 13.5955V29.7345H55.5017V6.81866Z" fill="#003543" /> <path d="M93.657 29.7344H89.6389V27.1747C88.7241 28.9761 86.8628 29.9904 84.5113 29.9904C80.7869 29.9904 78.3684 27.3059 78.3684 23.4423V13.2339H82.3865V22.5976C82.3865 24.8566 83.7594 26.4276 85.8171 26.4276C88.0712 26.4276 89.6389 24.6598 89.6389 22.2377V13.2339H93.657V29.7344Z" fill="#003543" /> <path d="M107.64 29.7344L103.784 24.2342L99.9291 29.7344H95.6492L101.596 21.1242L96.1074 13.2339H100.485L103.784 17.9821L107.051 13.2339H111.461L105.94 21.1242L111.886 29.7344H107.64Z" fill="#003543" /> <path d="M120.053 8.25848V13.2339H124.627V16.6063H120.053V24.7974C120.053 25.0725 120.162 25.3363 120.356 25.531C120.55 25.7257 120.813 25.8353 121.087 25.8357H124.627V29.728H121.98C118.386 29.728 116.035 27.6323 116.035 23.9687V16.6095H112.801V13.2339H114.83C115.776 13.2339 116.327 12.6692 116.327 11.7349V8.25848H120.053Z" fill="#003543" /> <path d="M134.756 24.5446V6.81866H139.066V23.1864C139.066 27.6067 136.943 29.7345 133.349 29.7345H128.332V25.8421H133.461C133.804 25.8421 134.134 25.7054 134.377 25.4621C134.619 25.2188 134.756 24.8888 134.756 24.5446Z" fill="#003543" /> <path d="M141.649 22.0409H145.799C146.029 24.6006 147.728 26.2308 150.472 26.2308C152.923 26.2308 154.623 25.2501 154.623 23.2199C154.623 18.3085 142.331 21.7129 142.331 12.9395C142.334 9.17515 145.568 6.55945 150.215 6.55945C155.05 6.55945 158.317 9.34153 158.516 13.6306H154.388C154.193 11.6341 152.632 10.2918 150.207 10.2918C147.953 10.2918 146.548 11.3397 146.548 12.9427C146.548 18.0173 159 14.2226 159 23.1576C159 27.4131 155.504 30 150.474 30C145.279 30 141.882 26.8563 141.654 22.0441" fill="#003543" /> <path d="M24.7203 29.704H41.1008C41.6211 29.7041 42.1322 29.5669 42.5828 29.3061C43.0334 29.0454 43.4075 28.6704 43.6675 28.2188C43.9275 27.7672 44.0643 27.2549 44.0641 26.7335C44.0639 26.2121 43.9266 25.6999 43.6662 25.2485L32.6655 6.15312C32.4055 5.70162 32.0315 5.32667 31.581 5.06598C31.1305 4.8053 30.6195 4.66805 30.0994 4.66805C29.5792 4.66805 29.0682 4.8053 28.6177 5.06598C28.1672 5.32667 27.7932 5.70162 27.5332 6.15312L24.7203 11.039L19.2208 1.48485C18.9606 1.03338 18.5864 0.658493 18.1358 0.397853C17.6852 0.137213 17.1741 0 16.6538 0C16.1336 0 15.6225 0.137213 15.1719 0.397853C14.7213 0.658493 14.3471 1.03338 14.0868 1.48485L0.397874 25.2485C0.137452 25.6999 0.000226653 26.2121 2.8053e-07 26.7335C-0.000226092 27.2549 0.136554 27.7672 0.396584 28.2188C0.656614 28.6704 1.03072 29.0454 1.48129 29.3061C1.93185 29.5669 2.44298 29.7041 2.96326 29.704H13.2456C17.3195 29.704 20.3239 27.9106 22.3912 24.4118L27.4102 15.7008L30.0986 11.039L38.1667 25.0422H27.4102L24.7203 29.704ZM13.0779 25.0374L5.9022 25.0358L16.6586 6.36589L22.0257 15.7008L18.4322 21.9401C17.0593 24.2103 15.4996 25.0374 13.0779 25.0374Z" fill="#00DC82" /></svg>
</a>
<div class="mt-8 bg-white overflow-hidden shadow sm:rounded-lg p-6">
<h2 class="text-2xl leading-7 font-semibold">
Welcome to your Nuxt Application
</h2>
<p class="mt-3 text-gray-600">
We recommend you take a look at the <a href="https://nuxtjs.org" target="_blank" class="button--doc text-green-500 hover:underline">Nuxt documentation</a>, whether you are new or have previous experience with the framework.<br>
</p>
<p class="mt-4 pt-4 text-gray-800 border-t border-dashed">
To get started, remove <code class="bg-gray-100 text-sm p-1 rounded border">components/Tutorial.vue</code> and start coding in <code class="bg-gray-100 text-sm p-1 rounded border">pages/index.vue</code>. Have fun!
</p>
</div>
<div class="flex justify-center pt-4 space-x-2">
<a href="https://github.com/nuxt/nuxt.js" target="_blank"><svg
class="w-6 h-6 text-gray-600 hover:text-gray-800 button--github"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
aria-hidden="true"
role="img"
width="32"
height="32"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 24 24"
><path d="M12 2.247a10 10 0 0 0-3.162 19.487c.5.088.687-.212.687-.475c0-.237-.012-1.025-.012-1.862c-2.513.462-3.163-.613-3.363-1.175a3.636 3.636 0 0 0-1.025-1.413c-.35-.187-.85-.65-.013-.662a2.001 2.001 0 0 1 1.538 1.025a2.137 2.137 0 0 0 2.912.825a2.104 2.104 0 0 1 .638-1.338c-2.225-.25-4.55-1.112-4.55-4.937a3.892 3.892 0 0 1 1.025-2.688a3.594 3.594 0 0 1 .1-2.65s.837-.262 2.75 1.025a9.427 9.427 0 0 1 5 0c1.912-1.3 2.75-1.025 2.75-1.025a3.593 3.593 0 0 1 .1 2.65a3.869 3.869 0 0 1 1.025 2.688c0 3.837-2.338 4.687-4.563 4.937a2.368 2.368 0 0 1 .675 1.85c0 1.338-.012 2.413-.012 2.75c0 .263.187.575.687.475A10.005 10.005 0 0 0 12 2.247z" fill="currentColor" /></svg></a>
<a href="https://twitter.com/nuxt_js" target="_blank"><svg
class="w-6 h-6 text-gray-600 hover:text-gray-800"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
aria-hidden="true"
role="img"
width="32"
height="32"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 24 24"
><path d="M22.46 6c-.77.35-1.6.58-2.46.69c.88-.53 1.56-1.37 1.88-2.38c-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29c0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15c0 1.49.75 2.81 1.91 3.56c-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07a4.28 4.28 0 0 0 4 2.98a8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21C16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56c.84-.6 1.56-1.36 2.14-2.23z" fill="currentColor" /></svg></a>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'NuxtTutorial'
}
</script>

View File

@@ -0,0 +1,22 @@
<template>
<img
class="vuetify-logo"
alt="Vuetify Logo"
src="/vuetify-logo.svg"
>
</template>
<style>
.vuetify-logo {
height: 180px;
width: 180px;
transform: rotateY(560deg);
animation: turn 3.5s ease-out forwards 1s;
}
@keyframes turn {
100% {
transform: rotateY(0deg);
}
}
</style>

View File

@@ -0,0 +1,67 @@
<template>
<v-app dark>
<v-navigation-drawer :clipped="true" fixed app >
<v-list>
<v-list-item
v-for="(item, i) in items"
:key="i"
:to="item.to"
router
color="primary"
exact
>
<v-list-item-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title v-text="item.title" />
</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>
<v-app-bar :clipped-left="true" fixed app color="primary" class="white--text" flat>
<v-toolbar-title v-text="title" />
<v-icon class="white--text">mdi-code-tags</v-icon>
<v-spacer />
version 1.0.0
</v-app-bar>
<v-main>
<v-container>
<Nuxt />
</v-container>
</v-main>
<v-footer :absolute="!fixed" app>
<span>By &copy; Amar KANTAS - {{ new Date().getFullYear() }}</span>
</v-footer>
</v-app>
</template>
<script>
export default {
name: "DefaultLayout",
data() {
return {
clipped: false,
drawer: false,
fixed: false,
items: [
{
icon: "mdi-view-dashboard",
title: "Dashboard",
to: "/",
},
{
icon: "mdi-server",
title: "Inventory",
to: "/inventory",
},
],
miniVariant: false,
right: true,
rightDrawer: false,
title: "FastProduction",
};
},
};
</script>

View File

@@ -0,0 +1,45 @@
<template>
<v-app dark>
<h1 v-if="error.statusCode === 404">
{{ pageNotFound }}
</h1>
<h1 v-else>
{{ otherError }}
</h1>
<NuxtLink to="/">
Home page
</NuxtLink>
</v-app>
</template>
<script>
export default {
name: 'EmptyLayout',
layout: 'empty',
props: {
error: {
type: Object,
default: null
}
},
data () {
return {
pageNotFound: '404 Not Found',
otherError: 'An error occurred'
}
},
head () {
const title =
this.error.statusCode === 404 ? this.pageNotFound : this.otherError
return {
title
}
}
}
</script>
<style scoped>
h1 {
font-size: 20px;
}
</style>

View File

@@ -0,0 +1,80 @@
import colors from "vuetify/es5/util/colors";
export default {
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
ssr: false,
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
titleTemplate: "%s - fastprod_frontend",
title: "fastprod_frontend",
htmlAttrs: {
lang: "en",
},
meta: [
{ charset: "utf-8" },
{ name: "viewport", content: "width=device-width, initial-scale=1" },
{ hid: "description", name: "description", content: "" },
{ name: "format-detection", content: "telephone=no" },
],
link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }],
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
// { src: '~/plugins/vuetify.js' },
{ src: "~/plugins/veeValidate.js" },
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: [
"~/components",
{ path: "~/components/Common", prefix: "" },
{ path: "~/components/Common/Ui", prefix: "ui" },
],
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
// https://go.nuxtjs.dev/vuetify
"@nuxtjs/vuetify",
"@nuxtjs/dotenv",
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: ["@nuxtjs/axios"],
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {
baseURL: process.env.API_URL,
https: false,
progress: false,
// proxy: true,
debug: false,
prefix: "/",
},
// Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify
vuetify: {
customVariables: ["~/assets/variables.scss"],
theme: {
dark: false,
themes: {
dark: {
primary: colors.blue.darken2,
accent: colors.grey.darken3,
secondary: "#E4EFFA",
info: colors.teal.lighten1,
warning: colors.amber.base,
error: colors.deepOrange.accent4,
success: colors.green.accent3,
},
},
},
},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {},
};

10457
PROJECT/fastprod_frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,26 @@
{
"name": "fastprod_frontend",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
},
"dependencies": {
"@nuxtjs/axios": "^5.13.6",
"@nuxtjs/dotenv": "^1.4.1",
"core-js": "^3.19.3",
"nuxt": "^2.15.8",
"vee-validate": "^3.4.5",
"vue": "^2.6.14",
"vue-server-renderer": "^2.6.14",
"vue-template-compiler": "^2.6.14",
"vuetify": "^2.6.1",
"webpack": "^4.46.0"
},
"devDependencies": {
"@nuxtjs/vuetify": "^1.12.3"
}
}

View File

@@ -0,0 +1,83 @@
<template>
<v-row justify="center" align="center">
<v-col cols="12" sm="8" md="6">
<v-card class="logo py-4 d-flex justify-center">
<NuxtLogo />
<VuetifyLogo />
</v-card>
<v-card>
<v-card-title class="headline">
Welcome to the Vuetify + Nuxt.js template
</v-card-title>
<v-card-text>
<p>Vuetify is a progressive Material Design component framework for Vue.js. It was designed to empower developers to create amazing applications.</p>
<p>
For more information on Vuetify, check out the <a
href="https://vuetifyjs.com"
target="_blank"
rel="noopener noreferrer"
>
documentation
</a>.
</p>
<p>
If you have questions, please join the official <a
href="https://chat.vuetifyjs.com/"
target="_blank"
rel="noopener noreferrer"
title="chat"
>
discord
</a>.
</p>
<p>
Find a bug? Report it on the github <a
href="https://github.com/vuetifyjs/vuetify/issues"
target="_blank"
rel="noopener noreferrer"
title="contribute"
>
issue board
</a>.
</p>
<p>Thank you for developing with Vuetify and I look forward to bringing more exciting features in the future.</p>
<div class="text-xs-right">
<em><small>&mdash; John Leider</small></em>
</div>
<hr class="my-3">
<a
href="https://nuxtjs.org/"
target="_blank"
rel="noopener noreferrer"
>
Nuxt Documentation
</a>
<br>
<a
href="https://github.com/nuxt/nuxt.js"
target="_blank"
rel="noopener noreferrer"
>
Nuxt GitHub
</a>
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn
color="primary"
nuxt
to="/inspire"
>
Continue
</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</template>
<script>
export default {
name: 'IndexPage'
}
</script>

View File

@@ -0,0 +1,25 @@
<template>
<v-row>
<v-col class="text-center">
<img
src="/v.png"
alt="Vuetify.js"
class="mb-5"
>
<blockquote class="blockquote">
&#8220;First, solve the problem. Then, write the code.&#8221;
<footer>
<small>
<em>&mdash;John Johnson</em>
</small>
</footer>
</blockquote>
</v-col>
</v-row>
</template>
<script>
export default {
name: 'InspirePage'
}
</script>

View File

@@ -0,0 +1,242 @@
<template>
<div>
<DialogBindComponent
ref="deviceShell"
:header="dialogHeader"
component="InventoryDeviceShelllCards"
@onSubmit="submitHandler"
:width="'1800'"
/>
<v-row justify="center">
<v-col cols="12">
<v-toolbar dense flat>
<v-toolbar-title>
<h3>{{ selectedDeviceName }}</h3>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
v-bind="attrs"
color="primary"
class="mr-2"
outlined
v-on="on"
@click="showShellDialog"
>
<v-icon>mdi-console</v-icon>
</v-btn>
</template>
<span> Console </span>
</v-tooltip>
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
v-bind="attrs"
color="primary"
outlined
v-on="on"
@click="refreshAll"
>
<v-icon>mdi-refresh</v-icon>
</v-btn>
</template>
<span> Refresh </span>
</v-tooltip>
</v-toolbar>
</v-col>
<v-col lg="6" md="10" cols="12">
<InventoryDeviceInfoCard
:loading="loading"
:item="device"
:device-name="selectedDeviceName"
/>
<InventoryDeviceFactsCard
:item="deviceFacts"
:loading="loadingFacts"
@refresh="getDeviceFacts"
/>
</v-col>
<v-col lg="6" md="10" cols="12">
<InventoryDeviceSanpshotsCard
:items="deviceSnapshots"
:loading="loadingSnapshots"
@refresh="getDeviceSnapshots"
@createSnapshot="buildSnapshot"
:device-name="selectedDeviceName"
/>
</v-col>
<v-col lg="6" md="10" cols="12">
<InventoryDeviceIpInterfacesCard
:items="deviceIpInterfaces"
:device-name="selectedDeviceName"
:loading="loadingIpInterfaces"
@refresh="getdeviceIpInterfaces"
/>
</v-col>
<v-col lg="6" md="10" cols="12">
<InventoryDeviceInterfacesCard
:items="deviceInterfaces"
:device-name="selectedDeviceName"
:loading="loadingInterfaces"
@refresh="getdeviceInterfaces"
/>
</v-col>
</v-row>
<v-snackbar v-model="snackbar" color="success" class="font-weight-bold">
{{ notification.title }}
<template v-slot:action="{ attrs }">
<v-btn color="white" text v-bind="attrs" @click="snackbar = false">
Close
</v-btn>
</template>
</v-snackbar>
</div>
</template>
<script>
export default {
data() {
return {
loading: false,
loadingFacts: false,
loadingIpInterfaces: false,
loadingInterfaces: false,
loadingSnapshots: false,
notification: {},
selectedDeviceName: null,
device: null,
deviceFacts: null,
deviceInterfaces: null,
deviceIpInterfaces: null,
deviceSnapshots: null,
snackbar: false,
dialog: false,
items: [],
dialogHeader: {
icon: "console",
label: "FastProd SHELL",
},
};
},
mounted() {
//this.getDevices();
this.selectedDeviceName = this.$route.params.name;
this.getDeviceByName();
this.getDeviceFacts();
this.getdeviceIpInterfaces();
this.getdeviceInterfaces();
this.getDeviceSnapshots();
},
methods: {
refreshAll() {
this.getDeviceByName();
this.getDeviceFacts();
this.getdeviceIpInterfaces();
this.getdeviceInterfaces();
this.getDeviceSnapshots();
},
getDeviceByName() {
this.loading = true;
this.$store
.dispatch("inventory/getByName", { name: this.$route.params.name })
.then((response) => {
this.loading = false;
this.device = response.data.device;
})
.catch((error) => {
this.loading = false;
console.log("error", error);
});
},
getDeviceFacts() {
this.loadingFacts = true;
this.$store
.dispatch("inventory/getFacts", { name: this.$route.params.name })
.then((response) => {
this.loadingFacts = false;
this.deviceFacts = response.data.facts;
})
.catch((error) => {
this.loadingFacts = false;
console.log("error", error);
});
},
getdeviceIpInterfaces() {
this.loadingIpInterfaces = true;
this.$store
.dispatch("inventory/getInterfacesIp", {
name: this.$route.params.name,
})
.then((response) => {
this.loadingIpInterfaces = false;
this.deviceIpInterfaces = response.data.interfaces_ip;
})
.catch((error) => {
this.loadingIpInterfaces = false;
console.log("error", error);
});
},
getdeviceInterfaces() {
this.loadingInterfaces = true;
this.$store
.dispatch("inventory/getInterfaces", {
name: this.$route.params.name,
})
.then((response) => {
this.loadingInterfaces = false;
this.deviceInterfaces = response.data.interfaces;
})
.catch((error) => {
this.loadingInterfaces = false;
console.log("error", error);
});
},
getDeviceSnapshots() {
this.loadingSnapshots = true;
this.$store
.dispatch("inventory/getSnapshots", {
name: this.$route.params.name,
})
.then((response) => {
this.loadingSnapshots = false;
this.deviceSnapshots = response.data.snapshots;
})
.catch((error) => {
this.loadingSnapshots = false;
console.log("error", error);
});
},
openDialog() {
this.$refs.addDeviceDialog.open();
},
submitHandler(e) {
this.$refs.addDeviceDialog.close();
this.notification.title = "Device added!";
this.snackbar = true;
this.getDevices();
},
buildSnapshot() {
this.$store
.dispatch("inventory/buildSnapshots", {
name: this.$route.params.name,
})
.then((response) => {
this.notification.title = "Snapshot created!";
this.snackbar = true;
this.getDeviceSnapshots();
})
.catch((error) => {
console.log("error", error);
});
},
showShellDialog() {
this.$refs.deviceShell.open();
},
},
};
</script>

View File

@@ -0,0 +1,187 @@
<template>
<div>
<DialogBindComponent
ref="addDeviceDialog"
:header="dialogHeader"
component="InventoryAddDeviceForm"
@onSubmit="submitHandler"
/>
<v-dialog v-model="dialog" persistent max-width="290">
<v-card>
<v-card-title class="text-center">
Do you want to delete this device ?
</v-card-title>
<v-card-text v-if="!!selectedItem">
Hostname : {{ selectedItem.data.device_name }}
<br />
Ip address :
{{ selectedItem.hostname }}
<br />
Device type :
{{ selectedItem.data.device_type }}
<br />
Device model :
{{ selectedItem.data.device_model }}
<br />
<br />
<span class="text-center error--text">
Device will be permanently removed from the inventory
</span>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="green darken-1" text @click="dialog = false">
Cancel
</v-btn>
<v-btn color="error darken-1" text @click="deleteDevice">
Delete
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-row justify="center" align="center">
<v-col cols="12">
<v-toolbar dense flat>
<v-toolbar-title>
<h3>Inventory</h3>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
color="primary"
outlined
v-bind="attrs"
v-on="on"
class="mr-2"
@click="openDialog"
>
<v-icon>mdi-plus</v-icon>
</v-btn>
</template>
<span> Add a new device </span>
</v-tooltip>
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
v-bind="attrs"
color="primary"
outlined
v-on="on"
@click="getDevices"
>
<v-icon>mdi-refresh</v-icon>
</v-btn>
</template>
<span> Refresh </span>
</v-tooltip>
</v-toolbar>
</v-col>
<v-col lg="10" md="10" cols="12">
<UiCard title="Device list" icon="server" :flat="false">
<template #headerActions>
<v-progress-linear
v-show="loading"
color="primary"
indeterminate
rounded
height="6"
></v-progress-linear>
</template>
<template #content>
<InventoryTable :items="items" @onAction="handleAction" />
</template>
</UiCard>
</v-col>
</v-row>
<v-snackbar v-model="snackbar" color="success">
{{ notification.title }}
<template v-slot:action="{ attrs }">
<v-btn color="white" text v-bind="attrs" @click="snackbar = false">
Close
</v-btn>
</template>
</v-snackbar>
</div>
</template>
<script>
export default {
data() {
return {
notification: {},
selectedItem: null,
snackbar: false,
loading: false,
dialog: false,
items: [],
dialogHeader: {
icon: "server",
label: "Add a new device",
},
};
},
mounted() {
this.getDevices();
},
methods: {
getDevices() {
this.loading = true;
this.$store
.dispatch("inventory/get")
.then((response) => {
this.loading = false;
this.items = response.data.devices;
})
.catch((error) => {
this.loading = false;
console.log("error", error);
});
},
openDialog() {
this.$refs.addDeviceDialog.open();
},
submitHandler(e) {
this.$refs.addDeviceDialog.close();
this.notification.title = "Device added!";
this.snackbar = true;
this.getDevices();
},
handleAction(e) {
console.log(e);
if (e.action == "delete") {
this.selectedItem = e.item;
this.dialog = true;
}
if (e.action == "show") {
this.$router.push({
name: "inventory-name",
params: { name: e.item.data.device_name },
});
}
},
deleteDevice() {
this.dialog = false;
this.loading = true;
this.$store
.dispatch("inventory/delete", {
name: this.selectedItem.data.device_name,
})
.then((response) => {
this.loading = false;
this.notification.title = "Device removed!";
this.snackbar = true;
this.getDevices();
})
.catch((error) => {
this.loading = false;
console.log("error", error);
});
},
},
};
</script>

View File

@@ -0,0 +1,57 @@
// import * as VeeValidate from 'vee-validate'
import {
required,
confirmed,
email,
alpha,
digits,
numeric,
regex,
} from "vee-validate/dist/rules";
import {
ValidationProvider,
ValidationObserver,
extend,
localize,
} from "vee-validate";
// import attributesFr from 'vee-validate/dist/locale/fr'
import fr from "vee-validate/dist/locale/fr.json";
import Vue from "vue";
Vue.component("ValidationProvider", ValidationProvider);
Vue.component("ValidationObserver", ValidationObserver);
localize("fr", fr);
extend("required", required);
extend("confirmed", confirmed);
extend("alpha", alpha);
extend("digits", digits);
extend("regex", regex);
extend("numeric", numeric);
extend("decimal", {
validate: (value, { decimals = "*", separator = "." } = {}) => {
if (value === null || value === undefined || value === "") {
return {
valid: false,
};
}
if (Number(decimals) === 0) {
return {
valid: /^-?\d*$/.test(value),
};
}
const regexPart = decimals === "*" ? "+" : `{1,${decimals}}`;
// eslint-disable-next-line no-unused-vars
const regex = new RegExp(
`^[-+]?\\d*(\\${separator}\\d${regexPart})?([eE]{1}[-]?\\d+)?$`
);
value = Number(value);
return {
valid: regex.test(value),
};
},
message:
"Le champ {_field_} doit contenir seulement un chiffre décimal par exemple: 500 ou 500.50",
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 87.5 100"><defs><style>.cls-1{fill:#1697f6;}.cls-2{fill:#7bc6ff;}.cls-3{fill:#1867c0;}.cls-4{fill:#aeddff;}</style></defs><title>Artboard 46</title><polyline class="cls-1" points="43.75 0 23.31 0 43.75 48.32"/><polygon class="cls-2" points="43.75 62.5 43.75 100 0 14.58 22.92 14.58 43.75 62.5"/><polyline class="cls-3" points="43.75 0 64.19 0 43.75 48.32"/><polygon class="cls-4" points="64.58 14.58 87.5 14.58 43.75 100 43.75 62.5 64.58 14.58"/></svg>

After

Width:  |  Height:  |  Size: 539 B

View File

@@ -0,0 +1,10 @@
# STORE
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains your Vuex Store files.
Vuex Store option is implemented in the Nuxt.js framework.
Creating a file in this directory automatically activates the option in the framework.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/vuex-store).

View File

@@ -0,0 +1,57 @@
export const state = () => ({
devices: [],
device: {},
});
export const mutations = {
update(state, params) {
state.device = { ...params };
},
updateDevices(state, params) {
state.devices = [...params];
},
};
export const actions = {
get({ commit, state }, params) {
console.log("===>", this.$axios);
return this.$axios.get(`/devices`);
},
getByName({ commit, rootGetters }, params) {
return this.$axios.get(`/devices/${params.name}`);
},
getFacts({ commit, rootGetters }, params) {
return this.$axios.get(`/devices/${params.name}/facts`);
},
getInterfacesIp({ commit, rootGetters }, params) {
return this.$axios.get(`/devices/${params.name}/interfaces/ip`);
},
getInterfaces({ commit, rootGetters }, params) {
return this.$axios.get(`/devices/${params.name}/interfaces`);
},
getSnapshots({ commit, rootGetters }, params) {
return this.$axios.get(`/devices/${params.name}/snapshots`);
},
buildSnapshots({ commit, rootGetters }, params) {
return this.$axios.post(`/devices/${params.name}/snapshots`);
},
config({ commit, rootGetters }, params) {
return this.$axios.post(`/devices/${params.name}/config`, params.data);
},
post({ commit }, params) {
return this.$axios.post(`/devices`, params.data);
},
delete({ commit }, params) {
return this.$axios.delete(`/devices/${params.name}`);
},
};
export const getters = {
get: (state) => {
return state.device;
},
getDevices: (state) => {
return state.devices;
},
};

109
Pipfile.lock.old Normal file
View File

@@ -0,0 +1,109 @@
{
"_meta": {
"hash": {
"sha256": "918d1549cca9dcec46bd830771c96b3ef413742ea1b7c178caca4e709bf894ae"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.12"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"nornir": {
"hashes": [
"sha256:7e273d7b2aa519fa84b4fbbeb74ac5df3595d80105009049f0157c72a345b0b2",
"sha256:f0d212999a37bc5962534738c47099b3e11a45d8f7dc8bc855530f7fb73d2f64"
],
"index": "pypi",
"markers": "python_version >= '3.9' and python_version < '4.0'",
"version": "==3.5.0"
},
"ruamel.yaml": {
"hashes": [
"sha256:048f26d64245bae57a4f9ef6feb5b552a386830ef7a826f235ffb804c59efbba",
"sha256:a6e587512f3c998b2225d68aa1f35111c29fad14aed561a26e73fab729ec5e5a"
],
"markers": "python_version >= '3.8'",
"version": "==0.18.16"
},
"ruamel.yaml.clib": {
"hashes": [
"sha256:090782b5fb9d98df96509eecdbcaffd037d47389a89492320280d52f91330d78",
"sha256:0a54e5e40a7a691a426c2703b09b0d61a14294d25cfacc00631aa6f9c964df0d",
"sha256:10d9595b6a19778f3269399eff6bab642608e5966183abc2adbe558a42d4efc9",
"sha256:13997d7d354a9890ea1ec5937a219817464e5cc344805b37671562a401ca3008",
"sha256:16a60d69f4057ad9a92f3444e2367c08490daed6428291aa16cefb445c29b0e9",
"sha256:18c041b28f3456ddef1f1951d4492dbebe0f8114157c1b3c981a4611c2020792",
"sha256:1c1acc3a0209ea9042cc3cfc0790edd2eddd431a2ec3f8283d081e4d5018571e",
"sha256:1f118b707eece8cf84ecbc3e3ec94d9db879d85ed608f95870d39b2d2efa5dca",
"sha256:2070bf0ad1540d5c77a664de07ebcc45eebd1ddcab71a7a06f26936920692beb",
"sha256:26a8de280ab0d22b6e3ec745b4a5a07151a0f74aad92dd76ab9c8d8d7087720d",
"sha256:275f938692013a3883edbd848edde6d9f26825d65c9a2eb1db8baa1adc96a05d",
"sha256:27c070cf3888e90d992be75dd47292ff9aa17dafd36492812a6a304a1aedc182",
"sha256:29757bdb7c142f9595cc1b62ec49a3d1c83fab9cef92db52b0ccebaad4eafb98",
"sha256:4ccba93c1e5a40af45b2f08e4591969fa4697eae951c708f3f83dcbf9f6c6bb1",
"sha256:4f4a150a737fccae13fb51234d41304ff2222e3b7d4c8e9428ed1a6ab48389b8",
"sha256:557df28dbccf79b152fe2d1b935f6063d9cc431199ea2b0e84892f35c03bb0ee",
"sha256:5ac5ff9425d8acb8f59ac5b96bcb7fd3d272dc92d96a7c730025928ffcc88a7a",
"sha256:5bae1a073ca4244620425cd3d3aa9746bde590992b98ee8c7c8be8c597ca0d4e",
"sha256:5e56ac47260c0eed992789fa0b8efe43404a9adb608608631a948cee4fc2b052",
"sha256:6aeadc170090ff1889f0d2c3057557f9cd71f975f17535c26a5d37af98f19c27",
"sha256:6d5472f63a31b042aadf5ed28dd3ef0523da49ac17f0463e10fda9c4a2773352",
"sha256:70eda7703b8126f5e52fcf276e6c0f40b0d314674f896fc58c47b0aef2b9ae83",
"sha256:7df6f6e9d0e33c7b1d435defb185095386c469109de723d514142632a7b9d07f",
"sha256:7e4f9da7e7549946e02a6122dcad00b7c1168513acb1f8a726b1aaf504a99d32",
"sha256:803f5044b13602d58ea378576dd75aa759f52116a0232608e8fdada4da33752e",
"sha256:808c7190a0fe7ae7014c42f73897cf8e9ef14ff3aa533450e51b1e72ec5239ad",
"sha256:81f6d3b19bc703679a5705c6a16dabdc79823c71d791d73c65949be7f3012c02",
"sha256:83bbd8354f6abb3fdfb922d1ed47ad8d1db3ea72b0523dac8d07cdacfe1c0fcf",
"sha256:8dd3c2cc49caa7a8d64b67146462aed6723a0495e44bf0aa0a2e94beaa8432f6",
"sha256:915748cfc25b8cfd81b14d00f4bfdb2ab227a30d6d43459034533f4d1c207a2a",
"sha256:94f3efb718f8f49b031f2071ec7a27dd20cbfe511b4dfd54ecee54c956da2b31",
"sha256:9b4104bf43ca0cd4e6f738cb86326a3b2f6eef00f417bd1e7efb7bdffe74c539",
"sha256:9bd8fe07f49c170e09d76773fb86ad9135e0beee44f36e1576a201b0676d3d1d",
"sha256:9bf6b699223afe6c7fe9f2ef76e0bfa6dd892c21e94ce8c957478987ade76cd8",
"sha256:a05ba88adf3d7189a974b2de7a9d56731548d35dc0a822ec3dc669caa7019b29",
"sha256:a0ac90efbc7a77b0d796c03c8cc4e62fd710b3f1e4c32947713ef2ef52e09543",
"sha256:a0cb71ccc6ef9ce36eecb6272c81afdc2f565950cdcec33ae8e6cd8f7fc86f27",
"sha256:a37f40a859b503304dd740686359fcf541d6fb3ff7fc10f539af7f7150917c68",
"sha256:a911aa73588d9a8b08d662b9484bc0567949529824a55d3885b77e8dd62a127a",
"sha256:aef953f3b8bd0b50bd52a2e52fb54a6a2171a1889d8dea4a5959d46c6624c451",
"sha256:b28caeaf3e670c08cb7e8de221266df8494c169bd6ed8875493fab45be9607a4",
"sha256:b30110b29484adc597df6bd92a37b90e63a8c152ca8136aad100a02f8ba6d1b6",
"sha256:b5b0f7e294700b615a3bcf6d28b26e6da94e8eba63b079f4ec92e9ba6c0d6b54",
"sha256:c099cafc1834d3c5dac305865d04235f7c21c167c8dd31ebc3d6bbc357e2f023",
"sha256:d73a0187718f6eec5b2f729b0f98e4603f7bd9c48aa65d01227d1a5dcdfbe9e8",
"sha256:d8354515ab62f95a07deaf7f845886cc50e2f345ceab240a3d2d09a9f7d77853",
"sha256:dba72975485f2b87b786075e18a6e5d07dc2b4d8973beb2732b9b2816f1bad70",
"sha256:dd7546c851e59c06197a7c651335755e74aa383a835878ca86d2c650c07a2f85",
"sha256:df3ec9959241d07bc261f4983d25a1205ff37703faf42b474f15d54d88b4f8c9",
"sha256:e1d1735d97fd8a48473af048739379975651fab186f8a25a9f683534e6904179",
"sha256:e501c096aa3889133d674605ebd018471bc404a59cbc17da3c5924421c54d97c",
"sha256:e7cb9ad1d525d40f7d87b6df7c0ff916a66bc52cb61b66ac1b2a16d0c1b07640",
"sha256:f4e97a1cf0b7a30af9e1d9dad10a5671157b9acee790d9e26996391f49b965a2",
"sha256:f8b2acb0ffdd2ce8208accbec2dca4a06937d556fdcaefd6473ba1b5daa7e3c4",
"sha256:fb04c5650de6668b853623eceadcdb1a9f2fee381f5d7b6bc842ee7c239eeec4",
"sha256:fbc08c02e9b147a11dfcaa1ac8a83168b699863493e183f7c0c8b12850b7d259",
"sha256:ff86876889ea478b1381089e55cf9e345707b312beda4986f823e1d95e8c0f59"
],
"markers": "platform_python_implementation == 'CPython' and python_version < '3.14'",
"version": "==0.2.14"
},
"setuptools": {
"hashes": [
"sha256:062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922",
"sha256:f36b47402ecde768dbfafc46e8e4207b4360c654f1f3bb84475f0a28628fb19c"
],
"markers": "python_version >= '3.9'",
"version": "==80.9.0"
}
},
"develop": {}
}

12
Pipfile.old Normal file
View File

@@ -0,0 +1,12 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
nornir = "*"
[dev-packages]
[requires]
python_version = "3.12"

BIN
TP-01/DEVNET-TP-01.pdf Normal file

Binary file not shown.

13
TP-01/Pipfile Normal file
View File

@@ -0,0 +1,13 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
jinja2 = "*"
pyyaml = "*"
[dev-packages]
[requires]
python_version = "3.12"

205
TP-01/Pipfile.lock generated Normal file
View File

@@ -0,0 +1,205 @@
{
"_meta": {
"hash": {
"sha256": "a3c8224561587db26f9d12d82bbaa6632243dac7cba493723678689f72ca8403"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.12"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"jinja2": {
"hashes": [
"sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d",
"sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67"
],
"index": "pypi",
"markers": "python_version >= '3.7'",
"version": "==3.1.6"
},
"markupsafe": {
"hashes": [
"sha256:0303439a41979d9e74d18ff5e2dd8c43ed6c6001fd40e5bf2e43f7bd9bbc523f",
"sha256:068f375c472b3e7acbe2d5318dea141359e6900156b5b2ba06a30b169086b91a",
"sha256:0bf2a864d67e76e5c9a34dc26ec616a66b9888e25e7b9460e1c76d3293bd9dbf",
"sha256:0db14f5dafddbb6d9208827849fad01f1a2609380add406671a26386cdf15a19",
"sha256:0eb9ff8191e8498cca014656ae6b8d61f39da5f95b488805da4bb029cccbfbaf",
"sha256:0f4b68347f8c5eab4a13419215bdfd7f8c9b19f2b25520968adfad23eb0ce60c",
"sha256:1085e7fbddd3be5f89cc898938f42c0b3c711fdcb37d75221de2666af647c175",
"sha256:116bb52f642a37c115f517494ea5feb03889e04df47eeff5b130b1808ce7c219",
"sha256:12c63dfb4a98206f045aa9563db46507995f7ef6d83b2f68eda65c307c6829eb",
"sha256:133a43e73a802c5562be9bbcd03d090aa5a1fe899db609c29e8c8d815c5f6de6",
"sha256:1353ef0c1b138e1907ae78e2f6c63ff67501122006b0f9abad68fda5f4ffc6ab",
"sha256:15d939a21d546304880945ca1ecb8a039db6b4dc49b2c5a400387cdae6a62e26",
"sha256:177b5253b2834fe3678cb4a5f0059808258584c559193998be2601324fdeafb1",
"sha256:1872df69a4de6aead3491198eaf13810b565bdbeec3ae2dc8780f14458ec73ce",
"sha256:1b4b79e8ebf6b55351f0d91fe80f893b4743f104bff22e90697db1590e47a218",
"sha256:1b52b4fb9df4eb9ae465f8d0c228a00624de2334f216f178a995ccdcf82c4634",
"sha256:1ba88449deb3de88bd40044603fafffb7bc2b055d626a330323a9ed736661695",
"sha256:1cc7ea17a6824959616c525620e387f6dd30fec8cb44f649e31712db02123dad",
"sha256:218551f6df4868a8d527e3062d0fb968682fe92054e89978594c28e642c43a73",
"sha256:26a5784ded40c9e318cfc2bdb30fe164bdb8665ded9cd64d500a34fb42067b1c",
"sha256:2713baf880df847f2bece4230d4d094280f4e67b1e813eec43b4c0e144a34ffe",
"sha256:2a15a08b17dd94c53a1da0438822d70ebcd13f8c3a95abe3a9ef9f11a94830aa",
"sha256:2f981d352f04553a7171b8e44369f2af4055f888dfb147d55e42d29e29e74559",
"sha256:32001d6a8fc98c8cb5c947787c5d08b0a50663d139f1305bac5885d98d9b40fa",
"sha256:3524b778fe5cfb3452a09d31e7b5adefeea8c5be1d43c4f810ba09f2ceb29d37",
"sha256:3537e01efc9d4dccdf77221fb1cb3b8e1a38d5428920e0657ce299b20324d758",
"sha256:35add3b638a5d900e807944a078b51922212fb3dedb01633a8defc4b01a3c85f",
"sha256:38664109c14ffc9e7437e86b4dceb442b0096dfe3541d7864d9cbe1da4cf36c8",
"sha256:3a7e8ae81ae39e62a41ec302f972ba6ae23a5c5396c8e60113e9066ef893da0d",
"sha256:3b562dd9e9ea93f13d53989d23a7e775fdfd1066c33494ff43f5418bc8c58a5c",
"sha256:457a69a9577064c05a97c41f4e65148652db078a3a509039e64d3467b9e7ef97",
"sha256:4bd4cd07944443f5a265608cc6aab442e4f74dff8088b0dfc8238647b8f6ae9a",
"sha256:4e885a3d1efa2eadc93c894a21770e4bc67899e3543680313b09f139e149ab19",
"sha256:4faffd047e07c38848ce017e8725090413cd80cbc23d86e55c587bf979e579c9",
"sha256:509fa21c6deb7a7a273d629cf5ec029bc209d1a51178615ddf718f5918992ab9",
"sha256:5678211cb9333a6468fb8d8be0305520aa073f50d17f089b5b4b477ea6e67fdc",
"sha256:591ae9f2a647529ca990bc681daebdd52c8791ff06c2bfa05b65163e28102ef2",
"sha256:5a7d5dc5140555cf21a6fefbdbf8723f06fcd2f63ef108f2854de715e4422cb4",
"sha256:69c0b73548bc525c8cb9a251cddf1931d1db4d2258e9599c28c07ef3580ef354",
"sha256:6b5420a1d9450023228968e7e6a9ce57f65d148ab56d2313fcd589eee96a7a50",
"sha256:722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698",
"sha256:729586769a26dbceff69f7a7dbbf59ab6572b99d94576a5592625d5b411576b9",
"sha256:77f0643abe7495da77fb436f50f8dab76dbc6e5fd25d39589a0f1fe6548bfa2b",
"sha256:795e7751525cae078558e679d646ae45574b47ed6e7771863fcc079a6171a0fc",
"sha256:7be7b61bb172e1ed687f1754f8e7484f1c8019780f6f6b0786e76bb01c2ae115",
"sha256:7c3fb7d25180895632e5d3148dbdc29ea38ccb7fd210aa27acbd1201a1902c6e",
"sha256:7e68f88e5b8799aa49c85cd116c932a1ac15caaa3f5db09087854d218359e485",
"sha256:83891d0e9fb81a825d9a6d61e3f07550ca70a076484292a70fde82c4b807286f",
"sha256:8485f406a96febb5140bfeca44a73e3ce5116b2501ac54fe953e488fb1d03b12",
"sha256:8709b08f4a89aa7586de0aadc8da56180242ee0ada3999749b183aa23df95025",
"sha256:8f71bc33915be5186016f675cd83a1e08523649b0e33efdb898db577ef5bb009",
"sha256:915c04ba3851909ce68ccc2b8e2cd691618c4dc4c4232fb7982bca3f41fd8c3d",
"sha256:949b8d66bc381ee8b007cd945914c721d9aba8e27f71959d750a46f7c282b20b",
"sha256:94c6f0bb423f739146aec64595853541634bde58b2135f27f61c1ffd1cd4d16a",
"sha256:9a1abfdc021a164803f4d485104931fb8f8c1efd55bc6b748d2f5774e78b62c5",
"sha256:9b79b7a16f7fedff2495d684f2b59b0457c3b493778c9eed31111be64d58279f",
"sha256:a320721ab5a1aba0a233739394eb907f8c8da5c98c9181d1161e77a0c8e36f2d",
"sha256:a4afe79fb3de0b7097d81da19090f4df4f8d3a2b3adaa8764138aac2e44f3af1",
"sha256:ad2cf8aa28b8c020ab2fc8287b0f823d0a7d8630784c31e9ee5edea20f406287",
"sha256:b8512a91625c9b3da6f127803b166b629725e68af71f8184ae7e7d54686a56d6",
"sha256:bc51efed119bc9cfdf792cdeaa4d67e8f6fcccab66ed4bfdd6bde3e59bfcbb2f",
"sha256:bdc919ead48f234740ad807933cdf545180bfbe9342c2bb451556db2ed958581",
"sha256:bdd37121970bfd8be76c5fb069c7751683bdf373db1ed6c010162b2a130248ed",
"sha256:be8813b57049a7dc738189df53d69395eba14fb99345e0a5994914a3864c8a4b",
"sha256:c0c0b3ade1c0b13b936d7970b1d37a57acde9199dc2aecc4c336773e1d86049c",
"sha256:c47a551199eb8eb2121d4f0f15ae0f923d31350ab9280078d1e5f12b249e0026",
"sha256:c4ffb7ebf07cfe8931028e3e4c85f0357459a3f9f9490886198848f4fa002ec8",
"sha256:ccfcd093f13f0f0b7fdd0f198b90053bf7b2f02a3927a30e63f3ccc9df56b676",
"sha256:d2ee202e79d8ed691ceebae8e0486bd9a2cd4794cec4824e1c99b6f5009502f6",
"sha256:d53197da72cc091b024dd97249dfc7794d6a56530370992a5e1a08983ad9230e",
"sha256:d6dd0be5b5b189d31db7cda48b91d7e0a9795f31430b7f271219ab30f1d3ac9d",
"sha256:d88b440e37a16e651bda4c7c2b930eb586fd15ca7406cb39e211fcff3bf3017d",
"sha256:de8a88e63464af587c950061a5e6a67d3632e36df62b986892331d4620a35c01",
"sha256:df2449253ef108a379b8b5d6b43f4b1a8e81a061d6537becd5582fba5f9196d7",
"sha256:e1c1493fb6e50ab01d20a22826e57520f1284df32f2d8601fdd90b6304601419",
"sha256:e1cf1972137e83c5d4c136c43ced9ac51d0e124706ee1c8aa8532c1287fa8795",
"sha256:e2103a929dfa2fcaf9bb4e7c091983a49c9ac3b19c9061b6d5427dd7d14d81a1",
"sha256:e56b7d45a839a697b5eb268c82a71bd8c7f6c94d6fd50c3d577fa39a9f1409f5",
"sha256:e8afc3f2ccfa24215f8cb28dcf43f0113ac3c37c2f0f0806d8c70e4228c5cf4d",
"sha256:e8fc20152abba6b83724d7ff268c249fa196d8259ff481f3b1476383f8f24e42",
"sha256:eaa9599de571d72e2daf60164784109f19978b327a3910d3e9de8c97b5b70cfe",
"sha256:ec15a59cf5af7be74194f7ab02d0f59a62bdcf1a537677ce67a2537c9b87fcda",
"sha256:f190daf01f13c72eac4efd5c430a8de82489d9cff23c364c3ea822545032993e",
"sha256:f34c41761022dd093b4b6896d4810782ffbabe30f2d443ff5f083e0cbbb8c737",
"sha256:f3e98bb3798ead92273dc0e5fd0f31ade220f59a266ffd8a4f6065e0a3ce0523",
"sha256:f42d0984e947b8adf7dd6dde396e720934d12c506ce84eea8476409563607591",
"sha256:f71a396b3bf33ecaa1626c255855702aca4d3d9fea5e051b41ac59a9c1c41edc",
"sha256:f9e130248f4462aaa8e2552d547f36ddadbeaa573879158d721bbd33dfe4743a",
"sha256:fed51ac40f757d41b7c48425901843666a6677e3e8eb0abcff09e4ba6e664f50"
],
"markers": "python_version >= '3.9'",
"version": "==3.0.3"
},
"pyyaml": {
"hashes": [
"sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c",
"sha256:0150219816b6a1fa26fb4699fb7daa9caf09eb1999f3b70fb6e786805e80375a",
"sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3",
"sha256:02ea2dfa234451bbb8772601d7b8e426c2bfa197136796224e50e35a78777956",
"sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6",
"sha256:10892704fc220243f5305762e276552a0395f7beb4dbf9b14ec8fd43b57f126c",
"sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65",
"sha256:1d37d57ad971609cf3c53ba6a7e365e40660e3be0e5175fa9f2365a379d6095a",
"sha256:1ebe39cb5fc479422b83de611d14e2c0d3bb2a18bbcb01f229ab3cfbd8fee7a0",
"sha256:214ed4befebe12df36bcc8bc2b64b396ca31be9304b8f59e25c11cf94a4c033b",
"sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1",
"sha256:22ba7cfcad58ef3ecddc7ed1db3409af68d023b7f940da23c6c2a1890976eda6",
"sha256:27c0abcb4a5dac13684a37f76e701e054692a9b2d3064b70f5e4eb54810553d7",
"sha256:28c8d926f98f432f88adc23edf2e6d4921ac26fb084b028c733d01868d19007e",
"sha256:2e71d11abed7344e42a8849600193d15b6def118602c4c176f748e4583246007",
"sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310",
"sha256:37503bfbfc9d2c40b344d06b2199cf0e96e97957ab1c1b546fd4f87e53e5d3e4",
"sha256:3c5677e12444c15717b902a5798264fa7909e41153cdf9ef7ad571b704a63dd9",
"sha256:3ff07ec89bae51176c0549bc4c63aa6202991da2d9a6129d7aef7f1407d3f295",
"sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea",
"sha256:418cf3f2111bc80e0933b2cd8cd04f286338bb88bdc7bc8e6dd775ebde60b5e0",
"sha256:44edc647873928551a01e7a563d7452ccdebee747728c1080d881d68af7b997e",
"sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac",
"sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9",
"sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7",
"sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35",
"sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb",
"sha256:5cf4e27da7e3fbed4d6c3d8e797387aaad68102272f8f9752883bc32d61cb87b",
"sha256:5e0b74767e5f8c593e8c9b5912019159ed0533c70051e9cce3e8b6aa699fcd69",
"sha256:5ed875a24292240029e4483f9d4a4b8a1ae08843b9c54f43fcc11e404532a8a5",
"sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b",
"sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c",
"sha256:6344df0d5755a2c9a276d4473ae6b90647e216ab4757f8426893b5dd2ac3f369",
"sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd",
"sha256:652cb6edd41e718550aad172851962662ff2681490a8a711af6a4d288dd96824",
"sha256:66291b10affd76d76f54fad28e22e51719ef9ba22b29e1d7d03d6777a9174198",
"sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065",
"sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c",
"sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c",
"sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764",
"sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196",
"sha256:8098f252adfa6c80ab48096053f512f2321f0b998f98150cea9bd23d83e1467b",
"sha256:850774a7879607d3a6f50d36d04f00ee69e7fc816450e5f7e58d7f17f1ae5c00",
"sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac",
"sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8",
"sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e",
"sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28",
"sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3",
"sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5",
"sha256:9c57bb8c96f6d1808c030b1687b9b5fb476abaa47f0db9c0101f5e9f394e97f4",
"sha256:9c7708761fccb9397fe64bbc0395abcae8c4bf7b0eac081e12b809bf47700d0b",
"sha256:9f3bfb4965eb874431221a3ff3fdcddc7e74e3b07799e0e84ca4a0f867d449bf",
"sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5",
"sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702",
"sha256:b30236e45cf30d2b8e7b3e85881719e98507abed1011bf463a8fa23e9c3e98a8",
"sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788",
"sha256:b865addae83924361678b652338317d1bd7e79b1f4596f96b96c77a5a34b34da",
"sha256:b8bb0864c5a28024fac8a632c443c87c5aa6f215c0b126c449ae1a150412f31d",
"sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc",
"sha256:bdb2c67c6c1390b63c6ff89f210c8fd09d9a1217a465701eac7316313c915e4c",
"sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba",
"sha256:c2514fceb77bc5e7a2f7adfaa1feb2fb311607c9cb518dbc378688ec73d8292f",
"sha256:c3355370a2c156cffb25e876646f149d5d68f5e0a3ce86a5084dd0b64a994917",
"sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5",
"sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26",
"sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f",
"sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b",
"sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be",
"sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c",
"sha256:efd7b85f94a6f21e4932043973a7ba2613b059c4a000551892ac9f1d11f5baf3",
"sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6",
"sha256:fa160448684b4e94d80416c0fa4aac48967a969efe22931448d853ada8baf926",
"sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0"
],
"index": "pypi",
"markers": "python_version >= '3.8'",
"version": "==6.0.3"
}
},
"develop": {}
}

30
TP-01/config/ESW2.conf Normal file
View File

@@ -0,0 +1,30 @@
hostname ESW2
! Configuration des interfaces
interface f1/1
description Connexion vers le VLAN 10
switchport mode access
switchport access vlan 10
no shutdown
interface f1/2
description Connexion vers le VLAN 20
switchport mode access
switchport access vlan 20
no shutdown
interface f1/0
description Connexion vers le routeur R2
switchport mode trunk
switchport trunk allowed vlan add 10,20
no shutdown
end

View File

@@ -0,0 +1,30 @@
hostname ESW2
! Configuration des interfaces
interface f1/1
description Connexion vers VPC3
switchport mode access
switchport access vlan 10
no shutdown
interface f1/2
description Connexion vers VPC4
switchport mode access
switchport access vlan 20
no shutdown
interface f1/0
description Connexion vers le routeur R2
switchport mode trunk
switchport trunk allowed vlan add 10,20,99
no shutdown
end

15
TP-01/config/R2.conf Normal file
View File

@@ -0,0 +1,15 @@
hostname R2
interface g0/0.10
description Gateway pour le reseau 172.16.30.0/24
ip address 172.16.30.254 255.255.255.0
encapsulation dot1Q 10
no shutdown
interface g0/0.20
description Gateway pour le reseau 172.16.40.0/24
ip address 172.16.40.254 255.255.255.0
encapsulation dot1Q 20
no shutdown
end

View File

@@ -0,0 +1,45 @@
hostname R2
interface g0/0
description Interface physique parent
ip address None None
encapsulation dot1Q
no shutdown
interface g0/0.10
description Sous interface g0/0.10
ip address 172.16.30.254 255.255.255.0
encapsulation dot1Q 10
no shutdown
interface g0/0.20
description Sous interface g0/0.20
ip address 172.16.40.254 255.255.255.0
encapsulation dot1Q 20
no shutdown
interface g2/0
description Lien principal vers le switch ESW4
ip address None None
encapsulation dot1Q
no shutdown
interface g2/0.10
description Gateway pour le reseau 172.16.50.0
ip address 172.16.50.254 255.255.255.0
encapsulation dot1Q 10
no shutdown
interface g2/0.20
description Gateway pour le reseau 172.16.60.0
ip address 172.16.60.254 255.255.255.0
encapsulation dot1Q 20
no shutdown
interface g2/0.99
description Interface de gestion VLAN 99
ip address 172.16.100.254 255.255.255.192
encapsulation dot1Q 99
no shutdown
end

23
TP-01/data/ESW2.json Normal file
View File

@@ -0,0 +1,23 @@
{
"hostname": "ESW2",
"interfaces": [
{
"name": "f1/1",
"mode": "access",
"vlan_id": "10",
"description": "Connexion vers le VLAN 10"
},
{
"name": "f1/2",
"mode": "access",
"vlan_id": "20",
"description": "Connexion vers le VLAN 20"
},
{
"name": "f1/0",
"mode": "trunk",
"vlan_id": "10,20",
"description": "Connexion vers le routeur R2"
}
]
}

14
TP-01/data/ESW2.yaml Normal file
View File

@@ -0,0 +1,14 @@
hostname: ESW2
interfaces:
- name: f1/1
mode: access
vlan_id: 10
description: Connexion vers VPC3
- name: f1/2
mode: access
vlan_id: 20
description: Connexion vers VPC4
- name: f1/0
mode: trunk
vlan_id: "10,20,99"
description: Connexion vers le routeur R2

19
TP-01/data/ESW4.yaml Normal file
View File

@@ -0,0 +1,19 @@
hostname: ESW4
management:
ip_address: 172.16.100.253
subnet: 255.255.255.192
vlan: 99
interfaces:
- name: f1/1
mode: access
vlan_id: 10
description: Connexion vers VPC5
- name: f1/2
mode: access
vlan_id: 20
description: Connexion vers VPC6
- name: f1/0
mode: trunk
vlan_id: "10,20,99"
description: Connexion vers le routeur R2

19
TP-01/data/R2.json Normal file
View File

@@ -0,0 +1,19 @@
{
"hostname": "R2",
"interfaces": [
{
"name": "g0/0.10",
"description": "Gateway pour le reseau 172.16.30.0/24",
"ip": "172.16.30.254",
"mask": "255.255.255.0",
"vlan_id": "10"
},
{
"name": "g0/0.20",
"description": "Gateway pour le reseau 172.16.40.0/24",
"ip": "172.16.40.254",
"mask": "255.255.255.0",
"vlan_id": "20"
}
]
}

41
TP-01/data/R2.yaml Normal file
View File

@@ -0,0 +1,41 @@
hostname: R2
interfaces:
- name: g0/0
description: Interface physique parent
ip: null
mask: null
- name: g0/0.10
description: Sous interface g0/0.10
ip: 172.16.30.254
mask: 255.255.255.0
vlan_id: 10
- name: g0/0.20
description: Sous interface g0/0.20
ip: 172.16.40.254
mask: 255.255.255.0
vlan_id: 20
- name: g2/0
description: Lien principal vers le switch ESW4
ip: null
mask: null
- name: g2/0.10
description: Gateway pour le reseau 172.16.50.0
ip: 172.16.50.254
mask: 255.255.255.0
vlan_id: 10
- name: g2/0.20
description: Gateway pour le reseau 172.16.60.0
ip: 172.16.60.254
mask: 255.255.255.0
vlan_id: 20
- name: g2/0.99
description: Interface de gestion VLAN 99
ip: 172.16.100.254
mask: 255.255.255.192
vlan_id: 99

View File

@@ -1,44 +1,51 @@
import json
import yaml
from jinja2 import Template, Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader("templates"))
def load_json_data_from_file(file_path):
"""
A compléter ....
"""
pass
with open(file_path) as json_file:
data = json.load(json_file)
return data
def load_yaml_data_from_file(file_path):
"""
A compléter ....
"""
pass
with open(file_path) as yaml_file:
data = yaml.safe_load(yaml_file)
return data
def render_network_config(template_name, data):
"""
A compléter ....
"""
pass
template = env.get_template(template_name)
return template.render(data)
def save_built_config(file_name, data):
"""
A compléter ....
"""
pass
with open(file_name, "w") as f:
f.write(data)
return file_name
if __name__ == "__main__":
#process R2
# r2_data = load_json_data_from_file(file_path='data/R2.json')
# r2_config = render_network_config(template_name='R2.j2', data=r2_data)
# save_built_config('config/R2.conf', r2_config)
r2_data = load_json_data_from_file(file_path='data/R2.json')
esw2_data = load_json_data_from_file(file_path='data/ESW2.json')
#fichier_inconnu_data = load_json_data_from_file(file_path='data/file-unknown.json')
#print(r2_data)
r2_config = render_network_config(template_name='R2.j2', data=r2_data)
save_built_config('config/R2.conf', r2_config)
#process ESW2
# esw2_data = load_json_data_from_file(file_path='data/ESW2.json')
# esw2_config = render_network_config(template_name='ESW2.j2', data=esw2_data)
# save_built_config('config/ESW2.conf', esw2_config)
esw2_data = load_json_data_from_file(file_path='data/ESW2.json')
esw2_config = render_network_config(template_name='ESW2.j2', data=esw2_data)
save_built_config('config/ESW2.conf', esw2_config)
r2_data_yaml = load_yaml_data_from_file(file_path='data/R2.yaml')
r2_config_yaml = render_network_config(template_name='R2.j2', data=r2_data_yaml)
save_built_config('config/R2_from_yaml.conf', r2_config_yaml)
esw2_data_yaml = load_yaml_data_from_file(file_path='data/ESW2.yaml')
esw2_config_yaml = render_network_config(template_name='ESW2.j2', data=esw2_data_yaml)
save_built_config('config/ESW2_from_yaml.conf', esw2_config_yaml)
pass

Binary file not shown.

22
TP-01/templates/ESW2.j2 Normal file
View File

@@ -0,0 +1,22 @@
hostname {{ hostname }}
! Configuration des interfaces
{% for interface in interfaces %}
interface {{ interface.name }}
description {{ interface.description }}
{% if interface.mode == "access" %}
switchport mode access
switchport access vlan {{ interface.vlan_id }}
{% elif interface.mode == "trunk" %}
switchport mode trunk
switchport trunk allowed vlan add {{ interface.vlan_id }}
{% endif %}
no shutdown
{% endfor %}
{% if management is defined %}
! Configuration de l'IP de management
interface vlan {{ management.vlan }}
ip address {{ management.ip_address }} {{ management.subnet }}
no shutdown
{% endif %}
end

9
TP-01/templates/R2.j2 Normal file
View File

@@ -0,0 +1,9 @@
hostname {{ hostname }}
{% for interface in interfaces %}
interface {{ interface.name }}
description {{ interface.description }}
ip address {{ interface.ip }} {{ interface.mask }}
encapsulation dot1Q {{ interface.vlan_id }}
no shutdown
{% endfor %}
end

1
TP-01/test.py Normal file
View File

@@ -0,0 +1 @@
print("Hello world")

BIN
TP-02/DEVNET-TP-02.pdf Normal file

Binary file not shown.

14
TP-02/Pipfile Normal file
View File

@@ -0,0 +1,14 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
jinja2 = "*"
netmiko = "*"
napalm = "*"
[dev-packages]
[requires]
python_version = "3.12"

1023
TP-02/Pipfile.lock generated Normal file

File diff suppressed because it is too large Load Diff

1
TP-02/backup/ESW2.bak Normal file

File diff suppressed because one or more lines are too long

1
TP-02/backup/ESW3.bak Normal file

File diff suppressed because one or more lines are too long

1
TP-02/backup/R01.bak Normal file

File diff suppressed because one or more lines are too long

1
TP-02/backup/R02.bak Normal file

File diff suppressed because one or more lines are too long

1
TP-02/backup/R03.bak Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
interface loopback 1
ip address 192.168.1.1 255.255.255.255
description "interface loopback 1"
no shut
interface loopback 2
ip address 192.168.2.1 255.255.255.255
description "interface loopback 2"
no shut

View File

@@ -0,0 +1,16 @@
interface loopback 1
ip address 192.168.1.1 255.255.255.255
description "interface loopback 1"
no shut
interface loopback 2
ip address 192.168.2.1 255.255.255.255
description "interface loopback 2"
no shut
interface loopback 3
ip address 192.168.3.1 255.255.255.255
description "interface loopback 3"
no shut
interface loopback 4
ip address 192.168.4.1 255.255.255.255
description "interface loopback 4"
no shut

14
TP-02/config/ospf_R1.conf Normal file
View File

@@ -0,0 +1,14 @@
router ospf 1
router-id 1.1.1.1
network 172.16.10.0 0.0.0.255 area 0
network 172.16.20.0 0.0.0.255 area 0
network 172.16.100.0 0.0.0.63 area 0
network 10.1.3.0 0.0.0.3 area 0
network 10.1.1.0 0.0.0.3 area 0
end

14
TP-02/config/ospf_R2.conf Normal file
View File

@@ -0,0 +1,14 @@
router ospf 1
router-id 2.2.2.2
network 172.16.30.0 0.0.0.255 area 0
network 172.16.40.0 0.0.0.255 area 0
network 172.16.100.64 0.0.0.63 area 0
network 10.1.2.0 0.0.0.3 area 0
network 10.1.1.0 0.0.0.3 area 0
end

14
TP-02/config/ospf_R3.conf Normal file
View File

@@ -0,0 +1,14 @@
router ospf 1
router-id 3.3.3.3
network 172.16.50.0 0.0.0.255 area 0
network 172.16.60.0 0.0.0.255 area 0
network 172.16.100.192 0.0.0.63 area 0
network 10.1.3.0 0.0.0.3 area 0
network 10.1.2.0 0.0.0.3 area 0
end

View File

@@ -0,0 +1,30 @@
hostname ESW2
! Configuration des interfaces
interface f1/1
description Connexion vers le VLAN 10
switchport mode access
switchport access vlan 10
no shutdown
interface f1/2
description Connexion vers le VLAN 20
switchport mode access
switchport access vlan 20
no shutdown
interface f1/0
description Connexion vers le routeur R2
switchport mode trunk
switchport trunk allowed vlan add 10,20
no shutdown
end

View File

@@ -0,0 +1,30 @@
hostname ESW3
! Configuration des interfaces
interface f1/1
description Connexion vers le VLAN 10
switchport mode access
switchport access vlan 10
no shutdown
interface f1/2
description Connexion vers le VLAN 20
switchport mode access
switchport access vlan 20
no shutdown
interface f1/0
description Connexion vers le routeur R2
switchport mode trunk
switchport trunk allowed vlan add 10,20
no shutdown
end

View File

@@ -0,0 +1,15 @@
hostname R2
interface g0/0.10
description Gateway pour le reseau 172.16.30.0/24
ip address 172.16.30.254 255.255.255.0
encapsulation dot1Q 10
no shutdown
interface g0/0.20
description Gateway pour le reseau 172.16.40.0/24
ip address 172.16.40.254 255.255.255.0
encapsulation dot1Q 20
no shutdown
end

View File

@@ -0,0 +1,15 @@
hostname R3
interface g0/0.10
description Gateway pour le reseau 172.16.50.0/24
ip address 172.16.50.254 255.255.255.0
encapsulation dot1Q 10
no shutdown
interface g0/0.20
description Gateway pour le reseau 172.16.60.0/24
ip address 172.16.60.254 255.255.255.0
encapsulation dot1Q 20
no shutdown
end

11
TP-02/data/ospf_R01.json Normal file
View File

@@ -0,0 +1,11 @@
{
"hostname": "R1",
"id_router": "1.1.1.1",
"networks": [
"172.16.10.0 0.0.0.255",
"172.16.20.0 0.0.0.255",
"172.16.100.0 0.0.0.63",
"10.1.3.0 0.0.0.3",
"10.1.1.0 0.0.0.3"
]
}

11
TP-02/data/ospf_R02.json Normal file
View File

@@ -0,0 +1,11 @@
{
"hostname": "R2",
"id_router": "2.2.2.2",
"networks": [
"172.16.30.0 0.0.0.255",
"172.16.40.0 0.0.0.255",
"172.16.100.64 0.0.0.63",
"10.1.2.0 0.0.0.3",
"10.1.1.0 0.0.0.3"
]
}

11
TP-02/data/ospf_R03.json Normal file
View File

@@ -0,0 +1,11 @@
{
"hostname": "R3",
"id_router": "3.3.3.3",
"networks": [
"172.16.50.0 0.0.0.255",
"172.16.60.0 0.0.0.255",
"172.16.100.192 0.0.0.63",
"10.1.3.0 0.0.0.3",
"10.1.2.0 0.0.0.3"
]
}

23
TP-02/data/vlan_ESW2.json Normal file
View File

@@ -0,0 +1,23 @@
{
"hostname": "ESW2",
"interfaces": [
{
"name": "f1/1",
"mode": "access",
"vlan_id": "10",
"description": "Connexion vers le VLAN 10"
},
{
"name": "f1/2",
"mode": "access",
"vlan_id": "20",
"description": "Connexion vers le VLAN 20"
},
{
"name": "f1/0",
"mode": "trunk",
"vlan_id": "10,20",
"description": "Connexion vers le routeur R2"
}
]
}

23
TP-02/data/vlan_ESW3.json Normal file
View File

@@ -0,0 +1,23 @@
{
"hostname": "ESW3",
"interfaces": [
{
"name": "f1/1",
"mode": "access",
"vlan_id": "10",
"description": "Connexion vers le VLAN 10"
},
{
"name": "f1/2",
"mode": "access",
"vlan_id": "20",
"description": "Connexion vers le VLAN 20"
},
{
"name": "f1/0",
"mode": "trunk",
"vlan_id": "10,20",
"description": "Connexion vers le routeur R2"
}
]
}

19
TP-02/data/vlan_R02.json Normal file
View File

@@ -0,0 +1,19 @@
{
"hostname": "R2",
"interfaces": [
{
"name": "g0/0.10",
"description": "Gateway pour le reseau 172.16.30.0/24",
"ip": "172.16.30.254",
"mask": "255.255.255.0",
"vlan_id": "10"
},
{
"name": "g0/0.20",
"description": "Gateway pour le reseau 172.16.40.0/24",
"ip": "172.16.40.254",
"mask": "255.255.255.0",
"vlan_id": "20"
}
]
}

19
TP-02/data/vlan_R03.json Normal file
View File

@@ -0,0 +1,19 @@
{
"hostname": "R3",
"interfaces": [
{
"name": "g0/0.10",
"description": "Gateway pour le reseau 172.16.50.0/24",
"ip": "172.16.50.254",
"mask": "255.255.255.0",
"vlan_id": "10"
},
{
"name": "g0/0.20",
"description": "Gateway pour le reseau 172.16.60.0/24",
"ip": "172.16.60.254",
"mask": "255.255.255.0",
"vlan_id": "20"
}
]
}

View File

@@ -0,0 +1,44 @@
[
{
"hostname":"R01",
"ip":"172.16.100.126",
"device_type": "cisco_ios",
"username": "cisco",
"password": "cisco"
},
{
"hostname":"R02",
"ip":"172.16.100.190",
"device_type": "cisco_ios",
"username": "cisco",
"password": "cisco"
},
{
"hostname":"R03",
"ip":"172.16.100.254",
"device_type": "cisco_ios",
"username": "cisco",
"password": "cisco"
},
{
"hostname":"ESW1",
"ip":"172.16.100.125",
"device_type": "cisco_ios",
"username": "cisco",
"password": "cisco"
},
{
"hostname":"ESW2",
"ip":"172.16.100.189",
"device_type": "cisco_ios",
"username": "cisco",
"password": "cisco"
},
{
"hostname":"ESW3",
"ip":"172.16.100.253",
"device_type": "cisco_ios",
"username": "cisco",
"password": "cisco"
}
]

Binary file not shown.

View File

@@ -4,38 +4,85 @@ from jinja2 import Template, Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader("templates"))
def load_json_data_from_file(file_path):
pass
with open(file_path) as json_file:
data = json.load(json_file)
return data
def load_yaml_data_from_file(file_path):
with open(file_path) as yaml_file:
data = yaml.safe_load(yaml_file)
return data
def render_network_config(template_name, data):
pass
template = env.get_template(template_name)
return template.render(data)
def save_built_config(file_name, data):
pass
with open(file_name, "w") as f:
f.write(data)
return file_name
def create_vlan_config_cpe_marseille():
"""
Must return two values : router config and the switch config
"""
pass
esw2_data = load_json_data_from_file(file_path='data/vlan_ESW2.json')
esw2_config = render_network_config(template_name='vlan_switch.j2', data=esw2_data)
R2_data = load_json_data_from_file(file_path='data/vlan_R02.json')
R2_config = render_network_config(template_name='vlan_router.j2', data=R2_data)
return R2_config,esw2_config
def create_vlan_config_cpe_paris():
"""
Must return two values : router config and the switch config
"""
pass
esw3_data = load_json_data_from_file(file_path='data/vlan_ESW3.json')
esw3_config = render_network_config(template_name='vlan_switch.j2', data=esw3_data)
R3_data = load_json_data_from_file(file_path='data/vlan_R03.json')
R3_config = render_network_config(template_name='vlan_router.j2', data=R3_data)
return R3_config,esw3_config
def create_ospf_config_cpe_marseille():
R1_data = load_json_data_from_file(file_path='data/ospf_R01.json')
R1_config = render_network_config(template_name='config_ospf.j2', data=R1_data)
return R1_config
def create_ospf_config_cpe_paris():
R2_data = load_json_data_from_file(file_path='data/ospf_R02.json')
R2_config = render_network_config(template_name='config_ospf.j2', data=R2_data)
return R2_config
def create_ospf_config_cpe_lyon():
R3_data = load_json_data_from_file(file_path='data/ospf_R03.json')
R3_config = render_network_config(template_name='config_ospf.j2', data=R3_data)
return R3_config
if __name__ == "__main__":
"""
process question 1 to 5:
"""
# r02_config, esw2_config = create_vlan_config_cpe_marseille()
# save_built_config('config/vlan_R02.conf', r02_config)
# save_built_config('config/vlan_ESW2.conf', esw2_config)
r02_config, esw2_config = create_vlan_config_cpe_marseille()
save_built_config('config/vlan_R02.conf', r02_config)
save_built_config('config/vlan_ESW2.conf', esw2_config)
r03_config, esw3_config = create_vlan_config_cpe_paris()
save_built_config('config/vlan_R03.conf', r03_config)
save_built_config('config/vlan_ESW3.conf', esw3_config)
R1_ospf_config = create_ospf_config_cpe_marseille()
save_built_config('config/ospf_R1.conf', R1_ospf_config)
R2_ospf_config = create_ospf_config_cpe_paris()
save_built_config('config/ospf_R2.conf', R2_ospf_config)
R3_ospf_config = create_ospf_config_cpe_lyon()
save_built_config('config/ospf_R3.conf', R3_ospf_config)
# r03_config, esw3_config = create_vlan_config_cpe_paris()
# save_built_config('config/vlan_R03.conf', r03_config)
# save_built_config('config/vlan_ESW3.conf', esw3_config)

View File

@@ -1,56 +1,123 @@
import json
from napalm import get_network_driver
def save_built_config(file_name, data):
with open(file_name, "w") as f:
f.write(data)
return file_name
def get_inventory():
pass
"""
Lit le fichier inventory/hosts.json et retourne son contenu.
"""
inventory_file = "inventory/hosts.json"
try:
with open(inventory_file, "r") as f:
data = json.load(f)
return data
except FileNotFoundError:
print(f"Erreur : le fichier {inventory_file} n'existe pas.")
return []
def get_json_data_from_file(file):
pass
def question_26(device):
pass
command = ['show ip interface brief']
output = device.cli(command)
def question_27(device):
pass
def question_28(device):
pass
command = ['show ip interface brief']
output = device.cli(command)
print(type(output))
def question_29(device):
pass
#output = device.get_config()
output = device.get_arp_table()
print(output)
def question_30(device):
pass
output = device.get_arp_table()
print(type(output))
def question_31():
pass
device.load_merge_candidate(filename='config/loopback_R01.conf')
print(device.compare_config())
device.commit_config()
def question_32():
pass
def question_33():
r01 = {
'hostname': '172.16.100.62',
'username': 'cisco',
'password': 'cisco'
}
r02 = {
'hostname': '172.16.100.190',
'username': 'cisco',
'password': 'cisco'
}
r03 = {
'hostname': '172.16.100.254',
'username': 'cisco',
'password': 'cisco'
}
routers = {'1': r01, '2': r02, '3': r03}
def question_34():
pass
for i in range(1, 4):
driver = get_network_driver('ios')
device = driver(**routers[str(i)])
device.open()
device.load_merge_candidate(filename=f'config/ospf_R{i}.conf')
print(device.compare_config())
device.commit_config()
device.close()
def question_35():
liste_hosts = get_inventory()
for host in liste_hosts:
nom_host = host['hostname']
connexion_info = {
'hostname': host['ip'],
'username': host['username'],
'password': host['password']
}
try:
driver_ios = get_network_driver('ios')
device = driver_ios(**connexion_info)
device.open()
config_sauvegarde = device.get_config()
with open(f'backup/{nom_host}.bak', 'w') as fichier_sauvegarde:
fichier_sauvegarde.write(str(config_sauvegarde))
device.close()
except Exception as erreur:
print(f"Erreur lors de la connexion à {nom_host} : {erreur}")
continue
if __name__ == "__main__":
r01 = {
'hostname':'xx.xx.xx.xx',
'username': "xx",
'password': "xx"
'hostname':'172.16.100.62',
'username': "cisco",
'password': "cisco"
}
# driver = get_network_driver('ios')
# device = driver(**r01)
# device.open()
driver = get_network_driver('ios')
device = driver(**r01)
device.open()
#question_26(device)
#question_27(device)
@@ -58,5 +125,5 @@ if __name__ == "__main__":
#question_29(device)
#question_30(device)
#question_31()
#question_32()
#question_34()
#question_33()
question_35()

View File

@@ -2,39 +2,111 @@ import json
from netmiko import ConnectHandler
def question_9(net_connect):
pass
print(net_connect.__dict__)
print("Adresse IP :", net_connect.host)
print("Device type :", net_connect.device_type)
def question_10(net_connect):
pass
output = net_connect.send_command("show ip interface brief")
print(output)
def question_11(net_connect):
pass
output = net_connect.send_command("show ip interface brief", use_textfsm=True)
print(type(output))
def question_12(net_connect):
pass
def question_13(net_connect):
pass
output = net_connect.send_command("show ip route", use_textfsm=True)
print(output)
print(type(output))
def question_14(net_connect):
pass
interfaces_status = net_connect.send_command("show ip interface brief", use_textfsm=True)
print("État des interfaces du routeur R1 :")
#print(interfaces_status)
for iface in interfaces_status:
intf_name = iface['interface']
print(f"\nConfiguration de l'interface {intf_name} :")
config = net_connect.send_command(f"show run interface {intf_name}")
print(config)
def question_15(net_connect):
pass
# Liste de commandes pour créer l'interface Loopback
loopback_cmds = [
"interface loopback1",
"ip address 192.168.1.1 255.255.255.255",
"description loopback interface from netmiko",
"no shutdown"
]
# Exécution des commandes en mode configuration
output = net_connect.send_config_set(loopback_cmds)
print("Résultat de la configuration :")
print(output)
# Sauvegarder la configuration
save_output = net_connect.save_config()
print("\nConfiguration sauvegardée :")
print(save_output)
def question_16(net_connect):
pass
# Exécution en mode configuration
output = net_connect.send_config_set("no interface loopback1")
print("Résultat de la suppression de loopback1 :")
print(output)
# Sauvegarder la configuration
save_output = net_connect.save_config()
print("\nConfiguration sauvegardée après suppression :")
print(save_output)
def question_17(net_connect):
pass
# Lire les commandes depuis le fichier
with open("config/loopback_R01.conf", "r") as f:
commands = [line.strip() for line in f if line.strip()] # ignore les lignes vides
# Exécuter les commandes en mode configuration
output = net_connect.send_config_set(commands)
print("Résultat de l'exécution des commandes :")
print(output)
# Sauvegarder la configuration
save_output = net_connect.save_config()
print("\nConfiguration sauvegardée :")
print(save_output)
def question_18(net_connect):
for i in range(1, 5):
loopback_name = f"loopback{i}"
commands = [f"no interface {loopback_name}"]
print(f"\nSuppression de l'interface {loopback_name} :")
output = net_connect.send_config_set(commands)
print(output)
# Sauvegarder la configuration
save_output = net_connect.save_config()
print("\nConfiguration sauvegardée :")
print(save_output)
def get_inventory():
pass
"""
Lit le fichier inventory/hosts.json et retourne son contenu.
"""
inventory_file = "inventory/hosts.json"
try:
with open(inventory_file, "r") as f:
data = json.load(f)
return data
except FileNotFoundError:
print(f"Erreur : le fichier {inventory_file} n'existe pas.")
return []
def question_20():
@@ -42,16 +114,70 @@ def question_20():
def question_21():
pass
inventory = get_inventory()
for device in inventory:
print(f"\n=== Connexion au routeur {device['hostname']} ({device['ip']}) ===")
try:
# Connexion au routeur
net_connect = ConnectHandler(
device_type=device["device_type"],
host=device["ip"],
username=device["username"],
password=device["password"]
)
# Commande à exécuter
command = "show run interface GigabitEthernet0/0.99"
output = net_connect.send_command(command)
print(f"\nConfiguration de GigabitEthernet0/0.99 sur {device['hostname']} :\n")
print(output)
net_connect.disconnect()
except Exception as e:
print(f"❌ Erreur sur {device['hostname']} : {e}")
def question_22():
inventory = get_inventory()
for device in inventory:
# On ne traite pas les routeurs dont le hostname != 'R1' de ESW1
if 'R1' == device["hostname"] or 'ESW1' == device["hostname"]:
continue
print(f"\n=== Connexion au routeur {device['hostname']} ({device['ip']}) ===")
try:
# Paramètres de connexion
device_params = {
'device_type': device['device_type'],
'host': device['ip'],
'username': device['username'],
'password': device['password']
}
net_connect = ConnectHandler(**device_params)
net_connect.enable()
# affiche le hostname
print(f"Connexion réussie sur {device['hostname']}")
config_file = f'config/vlan_{device["hostname"]}.conf'
output = net_connect.send_config_from_file(config_file)
print(f"\nRésultat de l'application de la configuration sur {device['hostname']} :\n{output}")
# Sauvegarde la configuration
save_output = net_connect.save_config()
print(f"\nSauvegarde de la configuration sur {device['hostname']} :\n{save_output}")
net_connect.disconnect()
except Exception as e:
print(f"❌ Erreur sur {device['hostname']} : {e}")
if __name__ == "__main__":
r01 = {
'device_type': 'cisco_ios',
'host': 'xx.xx.xx.xx',
'username': 'xx',
'password': 'xx'
}
#net_connect = ConnectHandler(**r01)
#question_9(net_connect)
#question_10(net_connect)
@@ -62,7 +188,9 @@ if __name__ == "__main__":
#question_15(net_connect)
#question_16(net_connect)
#question_17(net_connect)
# hosts = get_inventory()
# print(hosts)
#question_18(net_connect)
hosts = get_inventory()
#print(hosts)
#question_20()
#question_21()
question_22()

View File

@@ -0,0 +1,6 @@
router ospf 1
router-id {{ id_router }}
{% for network in networks %}
network {{ network }} area 0
{% endfor %}
end

View File

@@ -0,0 +1,9 @@
hostname {{ hostname }}
{% for interface in interfaces %}
interface {{ interface.name }}
description {{ interface.description }}
ip address {{ interface.ip }} {{ interface.mask }}
encapsulation dot1Q {{ interface.vlan_id }}
no shutdown
{% endfor %}
end

View File

@@ -0,0 +1,22 @@
hostname {{ hostname }}
! Configuration des interfaces
{% for interface in interfaces %}
interface {{ interface.name }}
description {{ interface.description }}
{% if interface.mode == "access" %}
switchport mode access
switchport access vlan {{ interface.vlan_id }}
{% elif interface.mode == "trunk" %}
switchport mode trunk
switchport trunk allowed vlan add {{ interface.vlan_id }}
{% endif %}
no shutdown
{% endfor %}
{% if management is defined %}
! Configuration de l'IP de management
interface vlan {{ management.vlan }}
ip address {{ management.ip_address }} {{ management.subnet }}
no shutdown
{% endif %}
end

16
TP_03/Pipfile Normal file
View File

@@ -0,0 +1,16 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
jinja2 = "*"
nornir = "*"
nornir-utils = "*"
nornir-napalm = "*"
nornir-netmiko = "*"
[dev-packages]
[requires]
python_version = "3.12"

1071
TP_03/Pipfile.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
vlan 10
name teacher
exit
vlan 20
name student
exit
interface fa1/14
switchport mode trunk
switchport trunk allowed vlan all
exit
interface fa1/15
switchport mode trunk
switchport trunk allowed vlan all
exit
interface fa1/1
switchport mode access
switchport access vlan 10
description "port vlan teacher"
exit
interface fa1/2
switchport mode access
switchport access vlan 20
description "port vlan student"
exit

View File

@@ -0,0 +1,30 @@
vlan 10
name teacher
exit
vlan 20
name student
exit
interface fa1/14
switchport mode trunk
switchport trunk allowed vlan all
exit
interface fa1/15
switchport mode trunk
switchport trunk allowed vlan all
exit
interface fa1/1
switchport mode access
switchport access vlan 10
description "port vlan teacher"
exit
interface fa1/2
switchport mode access
switchport access vlan 20
description "port vlan student"
exit

View File

@@ -0,0 +1,15 @@
interface g2/0
no shutdown
exit
interface g2/0.10
encapsulation dot1Q 10
description "Gateway for teacher vlan"
ip address 172.16.10.253 255.255.255.0
exit
interface g2/0.20
encapsulation dot1Q 20
description "Gateway for student vlan"
ip address 172.16.20.253 255.255.255.0
exit

View File

@@ -0,0 +1,10 @@
router ospf 1
router-id 1.1.1.1
network 172.16.10.0 0.0.0.255 area 0
network 172.16.20.0 0.0.0.255 area 0
network 172.16.100.0 0.0.0.63 area 0
end

View File

@@ -0,0 +1,10 @@
interface g2/0.10
vrrp 10 ip 172.16.10.252
vrrp 10 priority 100
interface g2/0.20
vrrp 20 ip 172.16.20.252
vrrp 20 priority 100

View File

@@ -0,0 +1,15 @@
interface g3/0
no shutdown
exit
interface g3/0.10
encapsulation dot1Q 10
description "Gateway for teacher vlan"
ip address 172.16.30.253 255.255.255.0
exit
interface g3/0.20
encapsulation dot1Q 20
description "Gateway for student vlan"
ip address 172.16.40.253 255.255.255.0
exit

View File

@@ -0,0 +1,10 @@
router ospf 1
router-id 4.4.4.4
network 172.16.30.0 0.0.0.255 area 0
network 172.16.40.0 0.0.0.255 area 0
network 172.16.100.64 0.0.0.63 area 0
end

View File

@@ -0,0 +1,10 @@
interface g3/0.10
vrrp 10 ip 172.16.30.252
vrrp 10 priority 100
interface g3/0.20
vrrp 20 ip 172.16.40.252
vrrp 20 priority 100

View File

@@ -0,0 +1,10 @@
interface g2/0.10
vrrp 10 ip 172.16.10.252
vrrp 10 priority 100
interface g2/0.20
vrrp 20 ip 172.16.20.252
vrrp 20 priority 100

View File

@@ -0,0 +1,10 @@
interface g3/0.10
vrrp 10 ip 172.16.30.252
vrrp 10 priority 100
interface g3/0.20
vrrp 20 ip 172.16.40.252
vrrp 20 priority 100

View File

@@ -0,0 +1,15 @@
interface g2/0
no shutdown
exit
interface g2/0.10
encapsulation dot1Q 10
description "Gateway for teacher vlan"
ip address 172.16.10.254 255.255.255.0
exit
interface g2/0.20
encapsulation dot1Q 20
description "Gateway for student vlan"
ip address 172.16.20.254 255.255.255.0
exit

View File

@@ -0,0 +1,10 @@
router ospf 1
router-id 2.2.2.2
network 172.16.10.0 0.0.0.255 area 0
network 172.16.20.0 0.0.0.255 area 0
network 172.16.100.0 0.0.0.63 area 0
end

View File

@@ -0,0 +1,14 @@
interface g2/0.10
vrrp 10 ip 172.16.10.252
vrrp 10 priority 110
vrrp 10 preempt
exit
interface g2/0.20
vrrp 20 ip 172.16.20.252
vrrp 20 priority 110
vrrp 20 preempt
exit

Some files were not shown because too many files have changed in this diff Show More