Posts

Showing posts from November, 2015

[Django] How to upload a file to via Django REST Framework?

Here is an example to use Parser: MultiPartParser to parse the media type: multipart/form-data. You also can take a look at this for more in detail: http://www.django-rest-framework.org/api-guide/parsers

Client Side via curl: ( Basically you can use either PUT or POST)
Command format:
curl -X PUT -H 'Content-Type:multipart/form-data' -F 'data=@/{your_file}' -u {account}:{password} http://{your server ip address}/

for instance:
curl -X PUT -H 'Content-Type:multipart/form-data' -F 'data=@/Users/administrator/Desktop/2015.12.01.yaml' -udanny:password http://192.168.1.100:8000/api/upload_func/file/



Server side ( Django REST Framework )

in your settings.py, add the following lines
==>
    'DEFAULT_PARSER_CLASSES': (
        'rest_framework.parsers.MultiPartParser',
    )


For your_api.py, you can refer to this example as below:

class UploadAction(APIView):
    permission_classes = (IsAuthenticated, IsAdminOrReadOnly)
    parser_classes = (MultiPa…

[Virtual Switching] What are macvlan and macvtap?

I excerpt the content of the following URL about what macvlan and macvtap are for reference quickly.
https://www.netdev01.org/docs/netdev_tutorial_bridge_makita_150213.pdf

macvlan
VLAN using not 802.1Q tag butmac address
    • 4 types of mode
        • private
        • vepa
        • bridge
        • passthru
Using unicast filtering if supported, instead of promiscuous mode (except for passthru)
    • Unicast filtering allows

NIC to receive multiple mac addresses
    • Light weight bridge
    • No source learning
    • No STP
Only one uplink
Allow traffic between macvlans (via macvlan stack)


macvtap
withKVM has three mode
    Private
vepa
bridge
tap-like macvlan variant
    • packet reception
        -> file read
    • filewrite
        -> packet transmission



Further reading:
http://140.120.15.179/Presentation/20150203/
Virtual networking: TUN/TAP, MacVLAN, and MacVTap

[GitHub] How to rebase your branch from upstream branch?

If you fork a copy (branch) from a repository and you want to rebase your branch with this upstream repository, you can refer to the following URLs or directly see the content below.

https://help.github.com/articles/configuring-a-remote-for-a-fork/
https://help.github.com/articles/syncing-a-fork/

List the current configured remote repository for your fork. git remote -v# origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)# origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push) Specify a new remote upstream repository that will be synced with the fork. git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git Verify the new upstream repository you've specified for your fork. git remote -v