Commit f879ad65 authored by Venkat's avatar Venkat
Browse files

fixed merge conflicts

parents b2dacef0 29eb9a45
{
"python.pythonPath": "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3",
"python.pythonPath": "/usr/bin/python3",
"python.linting.pylintEnabled": false,
"python.linting.enabled": false,
"python.linting.pylamaEnabled": true
......
......@@ -50,8 +50,8 @@ export class AppComponent {
// this.getUserInformation();
//this.getAvailableIPs();
//this.testRecords.push(this.new_record);
//this.UpdateIp();
this.getAllIps();
this.UpdateIp();
//this.getAllIps();
//this.getRecords(3);
//this.PutRecords();
//this.getIPsByRange()
......@@ -108,7 +108,11 @@ export class AppComponent {
.toPromise()
.then((res) => {
res.forEach(x => {
<<<<<<< HEAD
let item = new IPResultSet(x.id != null ? x.id : null , x.ipv4, x.ipv6, x.mac_addr != null ? x.mac_addr.adapter.host.host_name: null, x.mac_addr != null ? x.mac_addr.mac : null, x.mac_addr!== null && x.mac_addr.adapter !== null ? x.mac_addr.adapter.adapter_name : null, x.subnet !== null ? x.subnet.subnet_name : null, null, x.mac_addr !== null ? x.mac_addr.adapter.host.id : null);
=======
let item = new IPResultSet(x.id != null ? x.id : null , x.ipv4, x.ipv6, x.mac_addr != null ? x.mac_addr.adapter.host.host_name: null, x.mac_addr != null ? x.mac_addr.mac : null, x.mac_addr!== null && x.mac_addr.adapter !== null ? x.mac_addr.adapter.adapter_name : null, x.subnet !== null ? x.subnet.subnet_name : null, this.hostRecords);
>>>>>>> 29eb9a4595cf6f43a75bd2798aac5f05d1c75c04
this.ipResultSet.push(item)
})
this.dataSource = this.ipResultSet;
......@@ -158,7 +162,7 @@ export class AppComponent {
}
UpdateIp(): void{
this.sampleService.PutIP(70, 2, 2, '192.168.0.2', '')
this.sampleService.PutIP('4', '2', '2', '192.168.0.2', 'ipv6')
.toPromise()
.then((res) => {
console.log('update ip called')
......
......@@ -45,7 +45,8 @@ export class SampleService {
id: null,
Data: null,
record_type: 'A',
host:null
host:null,
dropDownRecordType: null
}
recordIDList = []
......@@ -162,7 +163,7 @@ export class SampleService {
this.new_ip.subnet = subnet_id;
this.new_ip.ipv4 = IPV4;
this.new_ip.ipv6 = IPV6
return this.http.patch<IPs>(this.HostLocation + this.endpoint, this.new_ip);
return this.http.put<IPs>(this.HostLocation + this.endpoint, this.new_ip);
}
DeleteHost(id): any {
......
......@@ -14,7 +14,7 @@ class Record(models.Model):
max_length=12,
choices=RECORD_TYPES,
)
host = models.ForeignKey(Host, related_name='record', on_delete=models.CASCADE)
host = models.ForeignKey(Host, related_name='records', on_delete=models.CASCADE)
def __str__(self):
return self.record_type + ', id: ' + str(self.id)
......
......@@ -5,12 +5,15 @@ from .models import Record, Host, Adapter, Mac_Addr, Role, Preamble, Subnet, IP
class RecordSerializer(serializers.ModelSerializer):
class Meta:
model = Record
fields = '__all__'
fields = ('record_type', 'RECORD_TYPES')
depth = 5
class HostSerializer(serializers.ModelSerializer):
records = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
class Meta:
model = Host
fields = '__all__'
fields = ('host_name', 'records')
depth = 1
class AdapterSerializer(serializers.ModelSerializer):
class Meta:
......@@ -21,6 +24,7 @@ class MacAddrSerializer(serializers.ModelSerializer):
class Meta:
model = Mac_Addr
fields = '__all__'
depth = 1
class RoleSerializer(serializers.ModelSerializer):
class Meta:
......@@ -43,6 +47,24 @@ class IPSerializer(serializers.ModelSerializer):
fields = '__all__'
depth = 5
class IPUpdateSerializer(serializers.ModelSerializer):
mac_addr = serializers.PrimaryKeyRelatedField(queryset=Mac_Addr.objects.all(), read_only=False)
class Meta:
model = IP
fields = ('mac_addr', 'subnet', 'ipv4', 'ipv6')
depth = 1
def update(self, instance, validation_data):
print(validation_data)
print(instance.mac_addr)
instance.mac_addr = validation_data.get('mac_addr', instance.mac_addr)
print(instance.subnet)
instance.subnet = validation_data.get('subnet', instance.subnet)
instance.ipv4 = validation_data.get('ipv4', instance.ipv4)
instance.ipv6 = validation_data.get('ipv6', instance.ipv6)
instance.save()
return instance
class SubentSerializer(serializers.ModelSerializer):
class Meta:
model = Subnet
......
......@@ -12,7 +12,7 @@ class ListAvailaleIPs(generics.ListAPIView):
# permission_classes = (permissions.IsAuthenticated)
serializer_class = serializers.IPSerializer
class ListAllIps(generics.ListAPIView):
class CreateAndListIps(generics.ListCreateAPIView):
queryset = models.IP.objects.all()
# permission_classes = (permissions.IsAuthenticated)
serializer_class = serializers.IPSerializer
......@@ -22,16 +22,12 @@ class ListSubnet(generics.ListAPIView):
#permission_class = (permissions.IsAuthenticated)
serializer_class = serializers.SubnetSerializer
class ListRecords(generics.ListAPIView):
queryset = models.Record.objects.all()
serializer_class = serializers.RecordSerializer
class ListIPRange(generics.ListAPIView):
queryset = models.IP.objects.all()
# permission_classes = (permissions.IsAuthenticated)
serializer_class = serializers.IPSerializer
class CreateRecord(generics.CreateAPIView):
class CreateAndListRecord(generics.ListCreateAPIView):
queryset = models.Record.objects.all()
# permission_classes = (permissions.IsAuthenticated)
serializer_class = serializers.RecordSerializer
......@@ -51,15 +47,10 @@ class CreateMac(generics.ListCreateAPIView):
# permission_classes = (permissions.IsAuthenticated)
serializer_class = serializers.MacAddrSerializer
class createIP(generics.CreateAPIView):
queryset = models.IP.objects.all()
# permission_classes = (permissions.IsAuthenticated)
serializer_class = serializers.IPSerializer
class UpdateIp(generics.UpdateAPIView):
queryset = models.IP.objects.all()
# permission_classes = (permissions.IsAuthenticated)
serializer_class = serializers.IPSerializer
serializer_class = serializers.IPUpdateSerializer
class DeleteHost(generics.DestroyAPIView):
queryset = models.Host.objects.all()
......
......@@ -5,10 +5,10 @@ import ipam.views as views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^ipam/listavailaleips/', view=views.ListAvailaleIPs.as_view()),
url(r'^ipam/listallips/', view=views.ListAllIps.as_view()),
url(r'^ipam/listallips/', view=views.CreateAndListIps.as_view()),
url(r'^ipam/listsubnets/', view=views.ListSubnet.as_view()),
url(r'^ipam/listrecords/(?P<id>\d+)/$', view=views.ListRecords.as_view()),
url(r'^ipam/createrecord/', view=views.CreateRecord.as_view()),
url(r'^ipam/listrecords/', view=views.CreateAndListRecord.as_view()),
url(r'^ipam/createrecord/', view=views.CreateAndListRecord.as_view()),
url(r'^ipam/createhost/', view=views.CreateHost.as_view()),
url(r'^ipam/createadapter/', view=views.CreateAdapter.as_view()),
url(r'^ipam/createmac/', view=views.CreateMac.as_view()),
......@@ -18,6 +18,5 @@ urlpatterns = [
url(r'^ipam/updatehost/(?P<pk>\d+)/$', view=views.UpdateHost.as_view()),
url(r'^ipam/updateadapter/(?P<pk>\d+)/$', view=views.UpdateAdapter.as_view()),
url(r'^ipam/updatemac/(?P<pk>\d+)/$', view=views.UpdateMac.as_view()),
]
#(?P<id>\d+)/$
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment