# -*- coding: utf-8 -*-

import sys
import logging

sys.path.append("./")

from vspk.vsdk.v3_2 import *
from vspk.vsdk.v3_2.utils import set_log_level

set_log_level(logging.INFO)

# Start a session
session = NUVSDSession(username=u'csproot',
                       password=u'csproot',
                       enterprise=u'csp',
                       api_url=u'https://135.227.222.46:8443')
session.start()

# Define an enterprise according to an ID
enterprise = NUEnterprise(id=u'd4ea408f-7253-4914-8b3a-36ebddc47bd8')

# Note: We don't need to fetch information from the server to manipulate the enterprise

# Select our first domain in this enterprise
enterprise.domains.fetch()
domain = enterprise.domains[0]

# Create an app for the selected domain
app = NUApp(name='My App',
            associated_domain_id=domain.id,
import sys
import logging

sys.path.append("./")

from vspk.vsdk.v3_2 import *
from vspk.vsdk.v3_2.utils import set_log_level

set_log_level(logging.ERROR)


# Callback method
def mycallback(current_object, connection):
    print str(current_object)
    print str(connection)

session = NUVSDSession(username=u'csproot', password=u'csproot', enterprise=u'csp', api_url=u'https://135.227.222.46:8443')
session.start()
csproot = session.user

# Fetch app information asynchronously
my_app = NUApp(id='9cca1662-ed66-44d6-940c-7244ffc5dca9')
my_app.fetch(async=True, callback=mycallback)
import sys
import logging
import inspect

sys.path.append("./")

from vspk.vsdk.v3_2 import *
from vspk.vsdk.v3_2.utils import set_log_level

set_log_level(logging.ERROR)

session = NUVSDSession(username=u'csproot', password=u'csproot', enterprise=u'csp', api_url=u'https://135.227.222.112:8443', version='3.2')
session.start()
csproot = session.user

vcenter = NUVCenter(id='c7a1a893-a3ad-4844-94a6-d89537f4cd3c')

# Get the first datacenter in vcenter which name is demo.
datacenter = vcenter.vcenter_data_centers.get_first(filter='name == "demo"')

# Delete the datacenter on the backend
datacenter.delete()
from vspk.vsdk import v3_2 as vsdk

import logging
from vspk.vsdk.v3_2.utils import set_log_level

set_log_level(logging.INFO)


def create_datacenter_gateway_template(
    name, personality, network_port_names, access_port_names, vlan_range, vlans_values, vsdsession, description=None
):
    """ Creates a DC Gateway template

        Args:
            name (string): the name of the gateway template
            personality (string): the personality of the gateway template
            description (string): the description of the gateway template
            network_port_names (list): list of string representing the physical names of the network ports to create
            access_port_names (list): list of string representing the physical names of the access ports to create
            vlan_range (string): the default VLAN range for the access ports
            vlans_values (list): list of int representing the value of the VLAN to create in each access port
            vsdsession (vsdk.NUVSDSession): the VSD session to use

        Returns:
            vsdk.NUGatewayTemplate: the newly created gateway template.
    """

    # create the gateway template
    gateway_template = vsdk.NUGatewayTemplate(name=name, personality=personality, description=description)

    vsdsession.user.create_child(gateway_template)