diff --git a/_modules/maasng.py b/_modules/maasng.py
index f10b3bc..1939b80 100644
--- a/_modules/maasng.py
+++ b/_modules/maasng.py
@@ -22,7 +22,7 @@
 import os.path
 import time
 import urllib2
-#Salt utils
+# Salt utils
 from salt.exceptions import CommandExecutionError, SaltInvocationError
 
 LOG = logging.getLogger(__name__)
@@ -61,13 +61,15 @@
 
 APIKEY_FILE = '/var/lib/maas/.maas_credentials'
 
+
 def _format_data(data):
     class Lazy:
         def __str__(self):
             return ' '.join(['{0}={1}'.format(k, v)
-                            for k, v in data.iteritems()])
+                             for k, v in data.iteritems()])
     return Lazy()
 
+
 def _create_maas_client():
     global APIKEY_FILE
     try:
@@ -80,22 +82,26 @@
     dispatcher = MAASDispatcher()
     return MAASClient(auth, dispatcher, api_url)
 
-def _get_blockdevice_id_by_name(hostname,device):
 
-    ##TODO validation
+def _get_blockdevice_id_by_name(hostname, device):
+
+    # TODO validation
     return list_blockdevices(hostname)[device]["id"]
 
-def _get_volume_group_id_by_name(hostname,device):
 
-    ##TODO validation
+def _get_volume_group_id_by_name(hostname, device):
+
+    # TODO validation
     return list_volume_groups(hostname)[device]["id"]
 
+
 def _get_partition_id_by_name(hostname, device, partition):
 
-    ##TODO validation
+    # TODO validation
     return list_partitions(hostname, device)[partition]["id"]
 
-####MACHINE SECTION
+# MACHINE SECTION
+
 
 def get_machine(hostname):
     '''
@@ -112,6 +118,7 @@
     except KeyError:
         return {"error": "Machine not found on MaaS server"}
 
+
 def list_machines():
     '''
     Get list of all machines from maas server
@@ -122,27 +129,30 @@
 
         salt 'maas-node' maasng.list_machines
     '''
-    machines={}
-    maas=_create_maas_client()
+    machines = {}
+    maas = _create_maas_client()
     json_res = json.loads(maas.get(u'api/2.0/machines/').read())
     for item in json_res:
         machines[item["hostname"]] = item
     return machines
 
+
 def create_machine():
-    ##TODO
+    # TODO
 
     return False
 
+
 def update_machine():
-    ##TODO
+    # TODO
 
     return False
 
-####MACHINE OPERATIONS
-##TODO
+# MACHINE OPERATIONS
+# TODO
 
-####RAID SECTION
+# RAID SECTION
+
 
 def create_raid(hostname, name, level, disks=[], partitions=[], **kwargs):
     '''
@@ -165,18 +175,20 @@
 
     for disk in disks:
         try:
-            disk_ids.append(str(_get_blockdevice_id_by_name(hostname,disk)))
+            disk_ids.append(str(_get_blockdevice_id_by_name(hostname, disk)))
         except KeyError:
-            result["error"] = "Device {0} does not exists on machine {1}".format(disk, hostname)
+            result["error"] = "Device {0} does not exists on machine {1}".format(
+                disk, hostname)
             return result
 
     for partition in partitions:
         try:
             device = partition.split("-")[0]
-            device_part = list_partitions(hostname,device)
+            device_part = list_partitions(hostname, device)
             partition_ids.append(str(device_part[partition]["id"]))
         except KeyError:
-            result["error"] = "Partition {0} does not exists on machine {1}".format(partition,hostname)
+            result["error"] = "Partition {0} does not exists on machine {1}".format(
+                partition, hostname)
             return result
 
     data = {
@@ -186,18 +198,20 @@
         "partitions": partition_ids,
     }
 
-    maas=_create_maas_client()
+    maas = _create_maas_client()
     system_id = get_machine(hostname)["system_id"]
     LOG.info(system_id)
 
-    #TODO validation
+    # TODO validation
     LOG.info(data)
-    json_res = json.loads(maas.post(u"api/2.0/nodes/{0}/raids/".format(system_id), None, **data).read())
+    json_res = json.loads(
+        maas.post(u"api/2.0/nodes/{0}/raids/".format(system_id), None, **data).read())
     LOG.info(json_res)
     result["new"] = "Raid {0} created".format(name)
 
     return result
 
+
 def list_raids(hostname):
     '''
     Get list all raids on machine
@@ -209,16 +223,18 @@
         salt-call maasng.list_raids server_hostname
     '''
 
-    maas=_create_maas_client()
+    maas = _create_maas_client()
     system_id = get_machine(hostname)["system_id"]
     LOG.info(system_id)
-    #TODO validation
-    json_res = json.loads(maas.get(u"api/2.0/nodes/{0}/raids/".format(system_id)).read())
+    # TODO validation
+    json_res = json.loads(
+        maas.get(u"api/2.0/nodes/{0}/raids/".format(system_id)).read())
     LOG.info(json_res)
 
-    ##TODO return list of raid devices
+    # TODO return list of raid devices
     return True
 
+
 def get_raid(hostname, name):
     '''
     Get information about specific raid on machine
@@ -233,7 +249,7 @@
     return list_raids(hostname)[name]
 
 
-####BLOCKDEVICES SECTION
+# BLOCKDEVICES SECTION
 
 def list_blockdevices(hostname):
     '''
@@ -248,19 +264,21 @@
     '''
     ret = {}
 
-    maas=_create_maas_client()
+    maas = _create_maas_client()
     system_id = get_machine(hostname)["system_id"]
     LOG.info(system_id)
 
-    #TODO validation if exists
+    # TODO validation if exists
 
-    json_res = json.loads(maas.get(u"api/2.0/nodes/{0}/blockdevices/".format(system_id)).read())
+    json_res = json.loads(
+        maas.get(u"api/2.0/nodes/{0}/blockdevices/".format(system_id)).read())
     LOG.info(json_res)
     for item in json_res:
         ret[item["name"]] = item
 
     return ret
 
+
 def get_blockdevice(hostname, name):
     '''
     Get information about blockdevice (disk) on machine
@@ -276,7 +294,7 @@
     return list_blockdevices(hostname)[name]
 
 
-####PARTITIONS
+# PARTITIONS
 
 def list_partitions(hostname, device):
     '''
@@ -290,15 +308,15 @@
         salt-call maasng.list_partitions server_hostname sda
     '''
     ret = {}
-    maas=_create_maas_client()
+    maas = _create_maas_client()
     system_id = get_machine(hostname)["system_id"]
     LOG.info(system_id)
 
-    partitions = get_blockdevice(hostname,device)["partitions"]
+    partitions = get_blockdevice(hostname, device)["partitions"]
     LOG.info(partitions)
 
     #json_res = json.loads(maas.get(u"api/2.0/nodes/{0}/blockdevices/{1}/partitions/".format(system_id, device_id)).read())
-    #LOG.info(json_res)
+    # LOG.info(json_res)
 
     if len(device) > 0:
         for item in partitions:
@@ -307,6 +325,7 @@
 
     return ret
 
+
 def get_partition(hostname, device, partition):
     '''
     Get information about specific parition on device located on machine
@@ -323,6 +342,7 @@
 
     return list_partitions(partition)[name]
 
+
 def create_partition(hostname, disk, size, fs_type=None, mount=None):
     '''
     Create new partition on device.
@@ -334,13 +354,13 @@
         salt 'maas-node' maasng.create_partition server_hostname disk_name 10 ext4 "/"
         salt-call maasng.create_partition server_hostname disk_name 10 ext4 "/"
     '''
-    ##TODO validation
+    # TODO validation
     result = {}
-    maas=_create_maas_client()
+    maas = _create_maas_client()
     system_id = get_machine(hostname)["system_id"]
     LOG.info(system_id)
 
-    device_id = _get_blockdevice_id_by_name(hostname,disk)
+    device_id = _get_blockdevice_id_by_name(hostname, disk)
     LOG.info(device_id)
 
     value, unit = size[:-1], size[-1]
@@ -351,8 +371,9 @@
         "size": calc_size
     }
 
-    #TODO validation
-    partition = json.loads(maas.post(u"api/2.0/nodes/{0}/blockdevices/{1}/partitions/".format(system_id, device_id), None, **data).read())
+    # TODO validation
+    partition = json.loads(maas.post(
+        u"api/2.0/nodes/{0}/blockdevices/{1}/partitions/".format(system_id, device_id), None, **data).read())
     LOG.info(partition)
     result["partition"] = "Partition created on {0}".format(disk)
 
@@ -362,8 +383,9 @@
         }
         partition_id = str(partition["id"])
         LOG.info("Partition id: " + partition_id)
-        #TODO validation
-        json_res = json.loads(maas.post(u"api/2.0/nodes/{0}/blockdevices/{1}/partition/{2}".format(system_id, device_id, partition_id), "format", **data_fs_type).read())
+        # TODO validation
+        json_res = json.loads(maas.post(u"api/2.0/nodes/{0}/blockdevices/{1}/partition/{2}".format(
+            system_id, device_id, partition_id), "format", **data_fs_type).read())
         LOG.info(json_res)
         result["filesystem"] = "Filesystem {0} created".format(fs_type)
 
@@ -372,14 +394,15 @@
             "mount_point": mount
         }
 
-        #TODO validation
-        json_res = json.loads(maas.post(u"api/2.0/nodes/{0}/blockdevices/{1}/partition/{2}".format(system_id, device_id, str(partition['id'])), "mount", **data).read())
+        # TODO validation
+        json_res = json.loads(maas.post(u"api/2.0/nodes/{0}/blockdevices/{1}/partition/{2}".format(
+            system_id, device_id, str(partition['id'])), "mount", **data).read())
         LOG.info(json_res)
         result["mount"] = "Mount point {0} created".format(mount)
 
-
     return result
 
+
 def delete_partition(hostname, disk, partition_name):
     '''
     Delete partition on device.
@@ -395,19 +418,21 @@
     '''
     result = {}
     data = {}
-    maas=_create_maas_client()
+    maas = _create_maas_client()
     system_id = get_machine(hostname)["system_id"]
     LOG.info(system_id)
 
-    device_id = _get_blockdevice_id_by_name(hostname,disk)
+    device_id = _get_blockdevice_id_by_name(hostname, disk)
     LOG.info(device_id)
 
-    partition_id = _get_partition_id_by_name(hostname,disk,partition_name)
+    partition_id = _get_partition_id_by_name(hostname, disk, partition_name)
 
-    maas.delete(u"api/2.0/nodes/{0}/blockdevices/{1}/partition/{2}".format(system_id, device_id, partition_id)).read()
+    maas.delete(u"api/2.0/nodes/{0}/blockdevices/{1}/partition/{2}".format(
+        system_id, device_id, partition_id)).read()
     result["new"] = "Partition {0} deleted".format(partition_name)
     return result
 
+
 def delete_partition_by_id(hostname, disk, partition_id):
     '''
     Delete partition on device. Partition spefified by id of parition
@@ -423,19 +448,21 @@
     '''
     result = {}
     data = {}
-    maas=_create_maas_client()
+    maas = _create_maas_client()
     system_id = get_machine(hostname)["system_id"]
     LOG.info(system_id)
 
-    device_id = _get_blockdevice_id_by_name(hostname,disk)
+    device_id = _get_blockdevice_id_by_name(hostname, disk)
     LOG.info(device_id)
 
-    maas.delete(u"api/2.0/nodes/{0}/blockdevices/{1}/partition/{2}".format(system_id, device_id, partition_id)).read()
+    maas.delete(u"api/2.0/nodes/{0}/blockdevices/{1}/partition/{2}".format(
+        system_id, device_id, partition_id)).read()
     result["new"] = "Partition {0} deleted".format(partition_id)
     return result
 
-####CREATE DISK LAYOUT
-##TODO
+# CREATE DISK LAYOUT
+# TODO
+
 
 def update_disk_layout(hostname, layout, root_size=None, root_device=None, volume_group=None, volume_name=None, volume_size=None):
     '''
@@ -455,7 +482,7 @@
         "storage_layout": layout,
     }
 
-    maas=_create_maas_client()
+    maas = _create_maas_client()
     system_id = get_machine(hostname)["system_id"]
     LOG.info(system_id)
 
@@ -464,10 +491,10 @@
         LOG.info(bit_size)
         data["root_size"] = bit_size
 
-
     if root_device != None:
         LOG.info(root_device)
-        data["root_device"] = str(_get_blockdevice_id_by_name(hostname,root_device))
+        data["root_device"] = str(
+            _get_blockdevice_id_by_name(hostname, root_device))
 
     if layout == 'lvm':
         if volume_group != None:
@@ -481,9 +508,9 @@
             LOG.info(vol_size)
             data["lv_size"] = vol_size
 
-
-    #TODO validation
-    json_res = json.loads(maas.post(u"api/2.0/machines/{0}/".format(system_id), "set_storage_layout", **data).read())
+    # TODO validation
+    json_res = json.loads(maas.post(
+        u"api/2.0/machines/{0}/".format(system_id), "set_storage_layout", **data).read())
     LOG.info(json_res)
     result["new"] = {
         "storage_layout": layout,
@@ -492,8 +519,8 @@
     return result
 
 
-####LVM
-##TODO
+# LVM
+# TODO
 
 def list_volume_groups(hostname):
     '''
@@ -508,17 +535,18 @@
     '''
     volume_groups = {}
 
-    maas=_create_maas_client()
+    maas = _create_maas_client()
     system_id = get_machine(hostname)["system_id"]
     LOG.info(system_id)
 
-    #TODO validation if exists
+    # TODO validation if exists
 
-    json_res = json.loads(maas.get(u"api/2.0/nodes/{0}/volume-groups/".format(system_id)).read())
+    json_res = json.loads(
+        maas.get(u"api/2.0/nodes/{0}/volume-groups/".format(system_id)).read())
     LOG.info(json_res)
     for item in json_res:
         volume_groups[item["name"]] = item
-    #return
+    # return
     return volume_groups
 
 
@@ -533,7 +561,7 @@
         salt 'maas-node' maasng.list_blockdevices server_hostname
         salt-call maasng.list_blockdevices server_hostname
     '''
-    ##TODO validation that exists
+    # TODO validation that exists
     return list_volume_groups(hostname)[name]
 
 
@@ -554,7 +582,7 @@
         "name": volume_group_name,
     }
 
-    maas=_create_maas_client()
+    maas = _create_maas_client()
     system_id = get_machine(hostname)["system_id"]
     LOG.info(system_id)
 
@@ -566,16 +594,18 @@
         if p_disk["partition_table_type"] == None:
             disk_ids.append(str(p_disk["id"]))
         else:
-            result["error"] = "Device {0} on machine {1} cointains partition table".format(disk,hostname)
+            result["error"] = "Device {0} on machine {1} cointains partition table".format(
+                disk, hostname)
             return result
 
     for partition in partitions:
         try:
             device = partition.split("-")[0]
-            device_part = list_partitions(hostname,device)
+            device_part = list_partitions(hostname, device)
             partition_ids.append(str(device_part[partition]["id"]))
         except KeyError:
-            result["error"] = "Partition {0} does not exists on machine {1}".format(partition,hostname)
+            result["error"] = "Partition {0} does not exists on machine {1}".format(
+                partition, hostname)
             return result
 
     data["block_devices"] = disk_ids
@@ -583,13 +613,15 @@
     LOG.info(partition_ids)
     LOG.info(partitions)
 
-    #TODO validation
-    json_res = json.loads(maas.post(u"api/2.0/nodes/{0}/volume-groups/".format(system_id), None, **data).read())
+    # TODO validation
+    json_res = json.loads(maas.post(
+        u"api/2.0/nodes/{0}/volume-groups/".format(system_id), None, **data).read())
     LOG.info(json_res)
     result["new"] = "Volume group {0} created".format(json_res["name"])
 
     return result
 
+
 def delete_volume_group(hostname, name):
     '''
     Delete volume group on machine.
@@ -602,20 +634,21 @@
         salt-call maasng.delete_volume_group server_hostname vg0
     '''
 
-    maas=_create_maas_client()
+    maas = _create_maas_client()
     system_id = get_machine(hostname)["system_id"]
     LOG.info(system_id)
 
-    #TODO partitions
-    #for partition in partitions:
+    # TODO partitions
+    # for partition in partitions:
     #    temp = disk.split("-")
     #    disk_ids.append(str(_get_blockdevice_id_by_name(hostname, temp[] partition)))
 
-    #TODO partitions
+    # TODO partitions
     vg_id = name
 
-    #TODO validation
-    json_res = json.loads(maas.delete(u"api/2.0/nodes/{0}/volume-group/{1}/".format(system_id, vg_id)).read())
+    # TODO validation
+    json_res = json.loads(maas.delete(
+        u"api/2.0/nodes/{0}/volume-group/{1}/".format(system_id, vg_id)).read())
     LOG.info(json_res)
 
     return True
@@ -643,7 +676,7 @@
 
     data["size"] = bit_size
 
-    maas=_create_maas_client()
+    maas = _create_maas_client()
     system_id = get_machine(hostname)["system_id"]
     LOG.info(system_id)
 
@@ -651,57 +684,66 @@
 
     LOG.info(volume_group_id)
 
-    #TODO validation
-    json_res = json.loads(maas.post(u"api/2.0/nodes/{0}/volume-group/{1}/".format(system_id, volume_group_id), "create_logical_volume", **data).read())
+    # TODO validation
+    json_res = json.loads(maas.post(u"api/2.0/nodes/{0}/volume-group/{1}/".format(
+        system_id, volume_group_id), "create_logical_volume", **data).read())
     LOG.info(json_res)
 
     if fs_type != None or mount != None:
-        ret = create_volume_filesystem(hostname, volume_group + "-" + volume_name, fs_type, mount)
+        ret = create_volume_filesystem(
+            hostname, volume_group + "-" + volume_name, fs_type, mount)
 
     return True
 
-def create_volume_filesystem(hostname, device, fs_type= None, mount = None):
 
-    maas=_create_maas_client()
+def create_volume_filesystem(hostname, device, fs_type=None, mount=None):
+
+    maas = _create_maas_client()
     system_id = get_machine(hostname)["system_id"]
 
     blockdevices_id = _get_blockdevice_id_by_name(hostname, device)
     data = {}
     if fs_type != None:
         data["fstype"] = fs_type
-        #TODO validation
-        json_res = json.loads(maas.post(u"/api/2.0/nodes/{0}/blockdevices/{1}/".format(system_id, blockdevices_id), "format", **data).read())
+        # TODO validation
+        json_res = json.loads(maas.post(u"/api/2.0/nodes/{0}/blockdevices/{1}/".format(
+            system_id, blockdevices_id), "format", **data).read())
         LOG.info(json_res)
 
     if mount != None:
         data["mount_point"] = mount
-        #TODO validation
-        json_res = json.loads(maas.post(u"/api/2.0/nodes/{0}/blockdevices/{1}/".format(system_id, blockdevices_id), "mount", **data).read())
+        # TODO validation
+        json_res = json.loads(maas.post(u"/api/2.0/nodes/{0}/blockdevices/{1}/".format(
+            system_id, blockdevices_id), "mount", **data).read())
         LOG.info(json_res)
 
     return True
 
-def create_partition_filesystem(hostname, partition, fs_type= None, mount = None):
 
-    maas=_create_maas_client()
+def create_partition_filesystem(hostname, partition, fs_type=None, mount=None):
+
+    maas = _create_maas_client()
     system_id = get_machine(hostname)["system_id"]
 
     blockdevices_id = _get_blockdevice_id_by_name(hostname, device)
     data = {}
     if fs_type != None:
         data["fstype"] = fs_type
-        #TODO validation
-        json_res = json.loads(maas.post(u"/api/2.0/nodes/{0}/blockdevices/{1}/".format(system_id, blockdevices_id), "format", **data).read())
+        # TODO validation
+        json_res = json.loads(maas.post(u"/api/2.0/nodes/{0}/blockdevices/{1}/".format(
+            system_id, blockdevices_id), "format", **data).read())
         LOG.info(json_res)
 
     if mount != None:
         data["mount_point"] = mount
-        #TODO validation
-        json_res = json.loads(maas.post(u"/api/2.0/nodes/{0}/blockdevices/{1}/".format(system_id, blockdevices_id), "mount", **data).read())
+        # TODO validation
+        json_res = json.loads(maas.post(u"/api/2.0/nodes/{0}/blockdevices/{1}/".format(
+            system_id, blockdevices_id), "mount", **data).read())
         LOG.info(json_res)
 
     return True
 
+
 def set_boot_disk(hostname, name):
     '''
     Create volume on volume group.
@@ -715,12 +757,142 @@
     '''
     data = {}
     result = {}
-    maas=_create_maas_client()
+    maas = _create_maas_client()
     system_id = get_machine(hostname)["system_id"]
     blockdevices_id = _get_blockdevice_id_by_name(hostname, name)
 
-    maas.post(u"/api/2.0/nodes/{0}/blockdevices/{1}/".format(system_id, blockdevices_id), "set_boot_disk", **data).read()
-    #TODO validation for error response (disk does not exists and node does not exists)
+    maas.post(u"/api/2.0/nodes/{0}/blockdevices/{1}/".format(
+        system_id, blockdevices_id), "set_boot_disk", **data).read()
+    # TODO validation for error response (disk does not exists and node does not exists)
     result["new"] = "Disk {0} was set as bootable".format(name)
 
     return result
+
+
+def list_fabric():
+    '''
+    Get list of all fabric
+
+    CLI Example:
+
+    .. code-block:: bash
+
+        salt 'maas-node' maasng.list_fabric
+    '''
+    fabrics = {}
+    maas = _create_maas_client()
+    json_res = json.loads(maas.get(u'api/2.0/fabrics/').read())
+    LOG.info(json_res)
+    for item in json_res:
+        fabrics[item["name"]] = item
+    return fabrics
+
+
+def create_fabric(name):
+    '''
+    Create new fabric.
+
+    CLI Example:
+
+    .. code-block:: bash
+
+        salt 'maas-node' maasng.create_fabric
+    '''
+    result = {}
+    data = {
+        "name": name,
+        "description": '',
+        "class_type": '',
+
+    }
+
+    maas = _create_maas_client()
+    json_res = json.loads(maas.post(u"api/2.0/fabrics/", None, **data).read())
+    LOG.info(json_res)
+    result["new"] = "Fabrics {0} created".format(json_res["name"])
+    return result
+
+
+def list_subnet():
+    '''
+    Get list of all subnets
+
+    CLI Example:
+
+    .. code-block:: bash
+
+        salt 'maas-node' maasng.list_subnet
+    '''
+    subnets = {}
+    maas = _create_maas_client()
+    json_res = json.loads(maas.get(u'api/2.0/subnets/').read())
+    LOG.info(json_res)
+    for item in json_res:
+        subnets[item["name"]] = item
+    return subnets
+
+
+def list_vlans(fabric):
+    '''
+    Get list of all vlans for specific fabric
+
+    CLI Example:
+
+    .. code-block:: bash
+
+        salt 'maas-node' maasng.list_vlans
+    '''
+    vlans = {}
+    maas = _create_maas_client()
+    fabric_id = get_fabric(fabric)
+
+    json_res = json.loads(
+        maas.get(u'api/2.0/fabrics/{0}/vlans/'.format(fabric_id)).read())
+    LOG.info(json_res)
+    for item in json_res:
+        vlans[item["name"]] = item
+    return vlans
+
+
+def get_fabric(fabric):
+    '''
+    Get id for specific fabric
+
+    CLI Example:
+
+    .. code-block:: bash
+
+        salt-call maasng.get_fabric fabric_name
+    '''
+    try:
+        return list_fabric()[fabric]['id']
+    except KeyError:
+        return {"error": "Frabic not found on MaaS server"}
+
+
+def update_vlan(name, fabric, vid, description, dhcp_on=False):
+    '''
+    Update vlan
+
+    CLI Example:
+
+    .. code-block:: bash
+
+        salt 'maas-node' maasng.update_vlan name, fabric, vid, description, dhcp_on
+    '''
+    result = {}
+
+    data = {
+        "name": name,
+        "dhcp_on": str(dhcp_on),
+        "description": description,
+    }
+    maas = _create_maas_client()
+    fabric_id = get_fabric(fabric)
+
+    json_res = json.loads(maas.put(
+        u'api/2.0/fabrics/{0}/vlans/{1}/'.format(fabric_id, vid), **data).read())
+    print(json_res)
+    result["new"] = "Vlan {0} was updated".format(json_res["name"])
+
+    return result
