Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
brdunn
IPAM
Commits
edb53ffc
Commit
edb53ffc
authored
May 02, 2019
by
Brandon Dunn
Browse files
working on add host
parent
a92d10e7
Changes
9
Hide whitespace changes
Inline
Side-by-side
IPAM/src/app/app.component.ts
View file @
edb53ffc
...
...
@@ -153,8 +153,7 @@ export interface Hosts{
adapter_name
:
any
,
mac
:
any
,
ipv4
:
any
,
ipv6
:
any
,
subnet
:
any
ipv6
:
any
}
export
interface
Records
{
...
...
IPAM/src/app/sample.service.ts
View file @
edb53ffc
...
...
@@ -35,7 +35,6 @@ export class SampleService {
mac
:
'
00:40:96:12:ab:23
'
,
ipv4
:
'
192.168.0.1
'
,
ipv6
:
null
,
subnet
:
'
ECE
'
}
...
...
@@ -50,7 +49,7 @@ export class SampleService {
AddHost
(
addInformation
:
AddHostInformation
):
void
{
this
.
endpoint
=
'
api/AddHost
'
this
.
http
.
p
u
t
(
this
.
HostLocation
+
this
.
endpoint
,
addInformation
,
this
.
httpOptions
)
this
.
http
.
p
os
t
(
this
.
HostLocation
+
this
.
endpoint
,
addInformation
,
this
.
httpOptions
)
}
RemoveHost
(
Host_Name
:
string
):
void
{
...
...
ipam_proj/.vscode/launch.json
0 → 100644
View file @
edb53ffc
{
//
Use
IntelliSense
to
learn
about
possible
attributes.
//
Hover
to
view
descriptions
of
existing
attributes.
//
For
more
information
,
visit:
https://go.microsoft.com/fwlink/?linkid=
830387
"version"
:
"0.2.0"
,
"configurations"
:
[
{
"name"
:
"Python: Current File"
,
"type"
:
"python"
,
"request"
:
"launch"
,
"program"
:
"${file}"
,
"console"
:
"integratedTerminal"
},
{
"name"
:
"Python: Django"
,
"type"
:
"python"
,
"request"
:
"launch"
,
"program"
:
"${workspaceFolder}/manage.py"
,
"args"
:
[
"runserver"
,
"--noreload"
,
"--nothreading"
],
"django"
:
true
}
]
}
\ No newline at end of file
ipam_proj/ipam/__pycache__/models.cpython-36.pyc
View file @
edb53ffc
No preview for this file type
ipam_proj/ipam/__pycache__/serializers.cpython-36.pyc
View file @
edb53ffc
No preview for this file type
ipam_proj/ipam/__pycache__/views.cpython-36.pyc
View file @
edb53ffc
No preview for this file type
ipam_proj/ipam/models.py
View file @
edb53ffc
...
...
@@ -65,4 +65,4 @@ class IP(models.Model):
if
self
.
ipv4
is
not
None
:
return
self
.
ipv4
if
self
.
ipv6
is
not
None
:
return
ipv6
\ No newline at end of file
return
self
.
ipv6
\ No newline at end of file
ipam_proj/ipam/serializers.py
View file @
edb53ffc
...
...
@@ -7,7 +7,7 @@ class RecordSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
Record
fields
=
'__all__'
depth
=
2
depth
=
1
class
HostSerializer
(
serializers
.
ModelSerializer
):
adapter
=
serializers
.
PrimaryKeyRelatedField
(
many
=
False
,
read_only
=
True
)
...
...
ipam_proj/ipam/views.py
View file @
edb53ffc
...
...
@@ -32,9 +32,31 @@ class IPRangeViewset(viewsets.ModelViewSet):
serializer
=
self
.
get_serializer
(
queryset
,
many
=
True
)
return
Response
(
serializer
.
data
)
class
AddRecordViewset
(
viewsets
.
ModelViewSet
):
queryset
=
Record
.
objects
.
all
()
serializer_class
=
RecordSerializer
def
add_host
(
request
):
if
request
.
method
==
'POST'
:
record
=
request
.
POST
.
get
(
'record_type'
)
record_serializer
=
RecordSerializer
(
data
=
record
)
record_serializer
.
save
()
host
=
request
.
POST
.
get
(
'host_name'
)
host_serializer
=
HostSerializer
(
data
=
host
)
host_serializer
.
save
()
return
Response
(
serializer
.
data
)
class
AddHostViewset
(
viewsets
.
ModelViewSet
):
queryset
=
Host
.
objects
.
all
()
serializer_class
=
RecordSerializer
serializer_class
=
HostSerializer
def
add_host
(
request
):
if
request
.
method
==
'POST'
:
host
=
request
.
POST
.
get
(
'host_name'
)
record_id
=
request
.
POST
.
get
(
'id'
)
new_host
=
Host
(
host_name
=
host
,
record
=
record_id
)
new_host
.
save
()
return
Response
(
serializer
.
data
)
class
AddPreambleViewset
(
viewsets
.
ModelViewSet
):
queryset
=
Preamble
.
objects
.
all
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment