<commit_before>import argparse
from keystoneclient.v2_0 import client
from heatclient.client import Client
import json
import yaml
from subprocess import call


def get_stack_list(heat):

    stacks = heat.stacks.list()
    while True:
        try:
            stack = stacks.next()
            print stack.stack_name + " (" + stack.id + "): " + stack.stack_status
        except StopIteration:
            break

def autheticate(cip, username, password, tenant):
    auth_url = 'http://'+ str(cip)+':5000/v2.0'
    keystone = client.Client(username=username, password=password, tenant_name=tenant, auth_url=auth_url)
    auth_token = keystone.auth_ref['token']['id']
    tenant_id = keystone.tenant_id
    heat_url = 'http://'+str(cip)+':8004/v1/%s' % tenant_id
    heat = Client('1', endpoint=heat_url, token=auth_token)
    return heat

def write_server(server,stackname):
    s_name =server['resource_name']
    s_id = server['physical_resource_id']
    server = heat.resources.get(stackname, s_name).to_dict()
    flavor = server['attributes']['flavor']
    server_dict = {'server_name': s_name, 'server_id' : s_id}
    return server_dict

def write_port(in_rec,stackname):
    in_rec = heat.resources.get(stackname, in_rec['resource_name']).to_dict()
    ip1 = in_rec['attributes']['fixed_ips']
    ip = ip1[0]['ip_address']
    port_dict = {'name': in_rec['attributes']['name'], 'MAC_address' : in_rec['attributes']['mac_address'], 'IP_address' : ip }
    return port_dict

def write_net(in_rec,stackname):
    in_rec = heat.resources.get(stackname, in_rec['resource_name']).to_dict()   
    seg_id = in_rec['attributes']['provider:segmentation_id']
    net_name = in_rec['resource_name']
    net_id = in_rec['attributes']['id']
    sub_id = in_rec['attributes']['subnets']
    sub_name = net_name.replace(':net',':subnet')
    net_dict = {'segmentation_id': seg_id, 'net_name': net_name, 'net_id' : net_id, 'subnet_id': sub_id[0], 'subnet_name': sub_name}
    return net_dict

parser = argparse.ArgumentParser()
parser.add_argument("-cf", "--configuration", nargs=4, help="pass the cloud url, username, password and tenant name",
                    required=True)  # option configurations, needs to be required
parser.add_argument("-d", "--delete", help="delete this stack")  # option delete
parser.add_argument("-s", "--status", help="return the status of the stack")  # option status
parser.add_argument("--composition", help="return the status of the stack")  # option status<commit_msg>fixed server & net name<commit_after>import argparse
from keystoneclient.v2_0 import client
from heatclient.client import Client
import json
import yaml
from subprocess import call


def get_stack_list(heat):

    stacks = heat.stacks.list()
    while True:
        try:
            stack = stacks.next()
            print stack.stack_name + " (" + stack.id + "): " + stack.stack_status
        except StopIteration:
            break

def autheticate(cip, username, password, tenant):
    auth_url = 'http://'+ str(cip)+':5000/v2.0'
    keystone = client.Client(username=username, password=password, tenant_name=tenant, auth_url=auth_url)
    auth_token = keystone.auth_ref['token']['id']
    tenant_id = keystone.tenant_id
    heat_url = 'http://'+str(cip)+':8004/v1/%s' % tenant_id
    heat = Client('1', endpoint=heat_url, token=auth_token)
    return heat

def write_server(server,stackname):
    s_id = server['physical_resource_id']
    server = heat.resources.get(stackname, server['resource_name']).to_dict()
    s_name =server['attributes']['name']
    flavor = server['attributes']['flavor']
    server_dict = {'server_name': s_name, 'server_id' : s_id}
    return server_dict

def write_port(in_rec,stackname):
    in_rec = heat.resources.get(stackname, in_rec['resource_name']).to_dict()
    ip1 = in_rec['attributes']['fixed_ips']
    ip = ip1[0]['ip_address']
    port_dict = {'name': in_rec['attributes']['name'], 'MAC_address' : in_rec['attributes']['mac_address'], 'IP_address' : ip }
    return port_dict

def write_net(in_rec,stackname):
    in_rec = heat.resources.get(stackname, in_rec['resource_name']).to_dict()   
    seg_id = in_rec['attributes']['provider:segmentation_id']
    net_name = in_rec['attributes']['name']
    net_id = in_rec['attributes']['id']
    sub_id = in_rec['attributes']['subnets']
    sub_name = net_name.replace(':net',':subnet')
    obj = open ('tested.json', 'a+')
    json.dump(in_rec, obj,indent=4, sort_keys=True)
    net_dict = {'segmentation_id': seg_id, 'net_name': net_name, 'net_id' : net_id, 'subnet_id': sub_id[0], 'subnet_name': sub_name}
    return net_dict

parser = argparse.ArgumentParser()
parser.add_argument("-cf", "--configuration", nargs=4, help="pass the cloud url, username, password and tenant name",
                    required=True)  # option configurations, needs to be required
parser.add_argument("-d", "--delete", help="delete this stack")  # option delete
parser.add_argument("-s", "--status", help="return the status of the stack")  # option status
parser.add_argument("--composition", help="return the status of the stack")  # option status
{'fraction_non_alphanumeric': 0.1485167837626854, 'fraction_numerical': 0.007611241217798595, 'mean_word_length': 4.481283422459893, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4869484', 'n_tokens_mistral': 1677, 'n_tokens_neox': 1651, 'n_words': 351}