summaryrefslogtreecommitdiffstats
path: root/mvn-be.cmd
blob: 8ecbe75cb66730f088a61f05d19812791412214d (plain)
1
mvn clean install -Pcatalog -pl catalog-be -am %*
.highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#!/usr/bin/env python
# ============LICENSE_START=======================================================
# org.onap.dcae
# ================================================================================
# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#      http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============LICENSE_END=========================================================
#
# ECOMP is a trademark and service mark of AT&T Intellectual Property.

import designateclient
from designateclient.v2 import client as designate_client
from designateclient import shell

from keystoneauth1.identity import generic
from keystoneauth1 import session as keystone_session
import json
import socket
import sys
import yaml

def find_entry_by_name(entry_list, entry_name):
    for entry in entry_list:
        if entry['name'] == entry_name:
            return entry
    return none 



def main():
    if len(sys.argv) != 6 and len(sys.argv) != 2:
        print("Usgae:  {} input_file [auth_url username password tenant]".format(sys.argv[0]))
        exit(1)
    if len(sys.argv) == 6:
        print("Creating DNS records using record defs from {}, authurl {}, username {}, tenant {}".format(
          sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[5]))
    else:
        print("Creating DNS records using record defs from {}, authurl {}, username {}, tenant {}".format(
          shell.env('OS_AUTH_URL'), shell.env('OS_USERNAME'), shell.env('OS_PASSWORD'), shell.env('OS_PROJECT_NAME')))

    print("Usage:  {} disabled until changed".format(sys.argv[0]))
    exit(1)

    inputfilepath = sys.argv[1]
    auth = ""

    if len(sys.argv) == 2:
        auth = generic.Password(
          auth_url=shell.env('OS_AUTH_URL'),
          username=shell.env('OS_USERNAME'),
          password=shell.env('OS_PASSWORD'),
          project_name=shell.env('OS_PROJECT_NAME'),
          project_domain_id='default',
          user_domain_id='default')
    else:
        auth = generic.Password(
          auth_url=sys.argv[2],
          username=sys.argv[3],
          password=sys.argv[4],
          project_name=sys.argv[5],
          project_domain_id='default',
          user_domain_id='default')

    if not auth:
        print("Fail to get authenticated from OpenStack")
        exit(1)

    session = keystone_session.Session(auth=auth)
    client = designate_client.Client(session=session)

    zone_name = 'simpledemo.onap.org'
    zone_name_dot = zone_name + '.'

    zone_list = client.zones.list()
    print("before: \n{}".format(json.dumps(zone_list, indent=4)))

    zone = find_entry_by_name(entry_list = zone_list, entry_name = zone_name_dot)
    if zone:
        print("exitsing zone: zone id {}".format(zone['id']))
    else:
        zone = client.zones.create(zone_name_dot, email='lji@research.att.com')
        print("newly created zone: zone id {}".format(zone['id']))

    recordsets = client.recordsets.list(zone['id'])
    # delete all exitsing A and CNAME records under the zone_name
    for recordset in recordsets:
        if not recordset['name'].endswith(zone_name_dot):
            continue
        print("Deleting recordset {}".format(recordset['name']))
        if recordset['type'] == 'A':
            client.recordsets.delete(zone['id'], recordset['id'])
        elif recordset['type'] == 'CNAME':
            client.recordsets.delete(zone['id'], recordset['id'])


    with open(inputfilepath, 'r') as inputfile:
        records_to_add = yaml.load(inputfile)
        for key, value in records_to_add.iteritems():
           if not key.endswith(zone_name):
               continue
           try:
               socket.inet_aton(value)
               # take zone name out (including the . before it)
               key = key[:-(len(zone_name)+1)]
               print("Creating DNS A record for: {} - {}".format(key, value))
               rs = client.recordsets.create(zone['id'], key, 'A', [value])
           except:
               print()

        for key, value in records_to_add.iteritems():
           if not key.endswith(zone_name):
               continue
           try:
               socket.inet_aton(value)
           except:
               # take zone name out (and the . before it)
               key = key[:-(len(zone_name)+1)]
               if not value.endswith('.'):
                   value = value + '.'
               print("Creating DNS CNAME record for: {} - {}".format(key, value))
               rs = client.recordsets.create(zone['id'], key, 'CNAME', [value])

    recordsets = client.recordsets.list(zone['id'])
    print("before: \n{}".format(json.dumps(recordsets, indent=4)))

 
########################################
if __name__ == "__main__":
    main()