Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 69 additions & 4 deletions etc/nca47.conf.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[DEFAULT]

#
# Options defined in ironic.common.exception
#
Expand Down Expand Up @@ -224,9 +223,9 @@

# MySQL engine to use. (string value)
#mysql_engine=InnoDB
connection=mysql://nca47:passw0rd@192.168.33.10:3306/nca47


#
#
# Options defined in oslo.db
#

Expand Down Expand Up @@ -325,7 +324,6 @@
# database operation up to db_max_retry_interval. (boolean
# value)
#db_inc_retry_interval=true

# If db_inc_retry_interval is set, the maximum seconds between
# retries of a database operation. (integer value)
#db_max_retry_interval=10
Expand Down Expand Up @@ -384,3 +382,70 @@
# Sets the list of available ciphers. value should be a string
# in the OpenSSL cipher list format. (string value)
#ciphers=<None>

[oslo_messaging_rabbit]

# The RabbitMQ broker address where a single node is used. (string value)
rabbit_host = 192.168.33.1
#rabbit_host = 192.168.0.104
#rabbit_host = 192.168.1.105

# The RabbitMQ userid. (string value)
#rabbit_userid = nca47
rabbit_userid = stackrabbit
#rabbit_userid = guest
#rabbit_port = 15672

# The RabbitMQ password. (string value)
#rabbit_password = nca47
rabbit_password = passw0rd
#rabbit_password = guest

[backend_driver]
dns_driver = zdns
firewall_driver = fw
# cli_driver value is cli or fake
cli_driver = cli


# [agent] section use to configure agent host node information
# api/cli interface to show agent lists will use below informations
[agent]
agent_ip = 127.0.0.1
agent_nat_ip = 127.0.0.1
dc_name = PDC
network_zone = BIZ
agent_type = FW

# Seconds between nodes reporting state to server should be less than agent_down_time,
# best if it is half or less than agent_down_time.
report_interval = 30
# Seconds to regard the agent is down; should be at least twice report_interval,
# to be sure the agent is down for good.
agent_down_time = 75

[zdns]
dns_vres_id = eef520f4-1be5-44ca-bc1f-bc23389acc66
host_ip = 192.168.1.235
port = 20120
view_id = default
auth_name = admin
auth_pw = zdns

# backend firewall device's access infos
[firewall_backend]
host = 192.168.1.234
username = admin
password = admin_default


# backend device's command-line interface's access infos
[cli_backend]
device_type = cisco
host = 192.168.1.118
port = 22
username = admin
password = Cisco123
authorize = False
auth_pass = password

Expand Down
60 changes: 60 additions & 0 deletions nca47/agent/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from oslo_config import cfg
from oslo_log import log as logging
from nca47.agent import cli_driver
from nca47.agent import dns_driver
from nca47.agent import firewall_driver
from nca47.common import exception
from nca47.common.i18n import _

LOG = logging.getLogger(__name__)

DRIVER_OPTS = [
cfg.StrOpt('dns_driver', default='zdns',
help=_('The dns driver for nca47 calling.')),
cfg.StrOpt('firewall_driver', default='fake',
help=_('The firewall driver for nca47 calling.')),
cfg.StrOpt('cli_driver', default='cli',
help=_('The backend device type for nca47 in calling.'))
]

CONF = cfg.CONF
opt_group = cfg.OptGroup(name='backend_driver',
title='Options for the backend device service')
CONF.register_group(opt_group)

CONF.register_opts(DRIVER_OPTS, opt_group)


def get_dns_backend():
LOG.debug("Loading dns backend driver by conf file")
driver_name = CONF.backend_driver.dns_driver
if driver_name == 'zdns':
return dns_driver.zdns_driver.dns_zone_driver.get_instance()
elif driver_name == 'fake':
return dns_driver.fake_driver.fake_dns_driver.get_instance()
else:
raise exception.DriverNotFound(driver_name=driver_name)


def get_firewall_backend():
LOG.debug("Loading firewall backend driver by conf file")
driver_name = CONF.backend_driver.firewall_driver
if driver_name == 'fw':
return firewall_driver.fw_driver.fw_driver.get_instance()
# return fw_driver.zdns_driver.dns_zone_driver.get_instance()
elif driver_name == 'fake':
return firewall_driver.fake_driver.fake_driver.get_instance()
else:
raise exception.DriverNotFound(driver_name=driver_name)


def get_cli_backend(**kwargs):
"""
Get backend command-line interface device
"""
LOG.debug("Loading backend command-line interface infos by conf file")
driver_name = CONF.backend_driver.cli_driver
if driver_name == 'cli':
return cli_driver.clios
else:
raise exception.DriverNotFound(driver_name=driver_name)
File renamed without changes.
43 changes: 43 additions & 0 deletions nca47/agent/agentFlag/agent_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from oslo_config import cfg
from oslo_log import log as logging
from nca47.common.i18n import _

CONF = cfg.CONF
LOG = logging.getLogger(__name__)

AGENT_OPTS = [
cfg.StrOpt('agent_net_ip',
default='0.0.0.0',
help=_('The public ip address of agent host '
'on which run agent service.')),
cfg.StrOpt('agent_ip',
default='0.0.0.0',
help=_('The internal ip address of agent host '
'on which run agent service')),
cfg.StrOpt('dc_name',
default='PDC',
help=_('The DataCenter name which the agent belongs to')),
cfg.StrOpt('network_zone',
default='BIZ',
help=_('The network zone name which the agent belongs to')),
cfg.StrOpt('agent_type',
default='zdns',
help=_('The device type which agent would be connect'))
]

opt_group = cfg.OptGroup(name='agent',
title='Options for nca47 agent node info')
CONF.register_group(opt_group)
CONF.register_opts(AGENT_OPTS, opt_group)


def getAgent_config():
host = CONF.agent.agent_ip
nat_ip = CONF.agent.agent_net_ip
dc_name = CONF.agent.dc_name
network_zone = CONF.agent.network_zone
agent_type = CONF.agent.agent_type
agent = {"agent_ip": host, "agent_nat_ip": nat_ip, "dc_name": dc_name,
"network_zone": network_zone, "agent_type": agent_type
}
return agent
47 changes: 47 additions & 0 deletions nca47/agent/agentFlag/agent_rpcapi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import oslo_messaging as messaging
from oslo_config import cfg
from oslo_log import log as logging
from nca47.common import rpc
from nca47.common.i18n import _LI

CONF = cfg.CONF
LOG = logging.getLogger(__name__)

AGENT_API = None


class AgentAPI(object):
"""
Client side of the agent manager RPC API.

API version history:

1.0 - Initial version
"""
RPC_API_VERSION = '1.0'

def __init__(self, topic='check_agent_heartbeat'):
rpc.init(CONF)
target = messaging.Target(topic=topic, version=self.RPC_API_VERSION)
self.client = rpc.get_client(target, version_cap=self.RPC_API_VERSION)

@classmethod
def get_instance(cls):
"""
The rpc.get_client() which is called upon the API object initialization
will cause a assertion error if the designate.rpc.TRANSPORT isn't setup
by rpc.init() before.

This fixes that by creating the rpcapi when demanded.
"""
global AGENT_API
if not AGENT_API:
AGENT_API = cls()
return AGENT_API

def report_agent_state(self, agentinfo):
LOG.info(_LI("Checking agent heartbeat: Calling service's "
"report_agent_state."))
context = {}
return self.client.call(context, 'report_agent_state',
agent_info=agentinfo)
1 change: 1 addition & 0 deletions nca47/agent/cli_driver/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import clios
Loading