Changes:
- Renamed actions related to Solutions API - Added openstack-release config to provide solution version Signed-off-by: plumgrid <Junaid Ali>
This commit is contained in:
parent
9818c1a1c5
commit
d1ff1526f9
@ -1,8 +1,8 @@
|
|||||||
restart-pg:
|
restart-pg:
|
||||||
description: Restart the plumgrid-director unit's service.
|
description: Restart the plumgrid-director unit's service.
|
||||||
post-ips:
|
sapi-post-ips:
|
||||||
description: Post PLUMgrid nodes IPs to Solutions API server.
|
description: Post PLUMgrid nodes IPs to Solutions API server.
|
||||||
post-zone-info:
|
sapi-post-zone-info:
|
||||||
description: Post Zone info to Solutions API server.
|
description: Post Zone info to Solutions API server.
|
||||||
post-license:
|
sapi-post-license:
|
||||||
description: Post PLUMgrid License to Solutions API server.
|
description: Post PLUMgrid License to Solutions API server.
|
||||||
|
@ -44,8 +44,8 @@ def post_license(args):
|
|||||||
|
|
||||||
# A dictionary of all the defined actions to callables (which take
|
# A dictionary of all the defined actions to callables (which take
|
||||||
# parsed arguments).
|
# parsed arguments).
|
||||||
ACTIONS = {"restart-pg": restart_pg, "post-ips": post_ips, "post-zone-info": post_zone_info,
|
ACTIONS = {"restart-pg": restart_pg, "sapi-post-ips": post_ips, "sapi-post-zone-info": post_zone_info,
|
||||||
"post-license": post_license}
|
"sapi-post-license": post_license}
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
|
@ -67,3 +67,9 @@ options:
|
|||||||
default: pgzone
|
default: pgzone
|
||||||
type: string
|
type: string
|
||||||
description: Zone name used by Solutions API to get/post cloud information.
|
description: Zone name used by Solutions API to get/post cloud information.
|
||||||
|
openstack-release:
|
||||||
|
default: kilo
|
||||||
|
type: string
|
||||||
|
description: |
|
||||||
|
OpenStack release to determine solution version that will be posted to
|
||||||
|
Solutions API server.
|
||||||
|
@ -160,7 +160,6 @@ def config_changed():
|
|||||||
for rid in relation_ids('plumgrid'):
|
for rid in relation_ids('plumgrid'):
|
||||||
plumgrid_joined(rid)
|
plumgrid_joined(rid)
|
||||||
stop_pg()
|
stop_pg()
|
||||||
# TODO
|
|
||||||
if (charm_config.changed('sapi-port') or
|
if (charm_config.changed('sapi-port') or
|
||||||
charm_config.changed('lcm-ip') or
|
charm_config.changed('lcm-ip') or
|
||||||
charm_config.changed('sapi-zone')):
|
charm_config.changed('sapi-zone')):
|
||||||
|
@ -62,6 +62,14 @@ OPS_CONF = '%s/conf/etc/00-pg.conf' % PG_LXC_DATA_PATH
|
|||||||
AUTH_KEY_PATH = '%s/root/.ssh/authorized_keys' % PG_LXC_DATA_PATH
|
AUTH_KEY_PATH = '%s/root/.ssh/authorized_keys' % PG_LXC_DATA_PATH
|
||||||
TEMP_LICENSE_FILE = '/tmp/license'
|
TEMP_LICENSE_FILE = '/tmp/license'
|
||||||
|
|
||||||
|
# Constant values for OpenStack releases as Canonical-Ubuntu
|
||||||
|
# doesn't have any specific solution version associated
|
||||||
|
OPENSTACK_RELEASE_VERS = {
|
||||||
|
'kilo': '10',
|
||||||
|
'liberty': '11',
|
||||||
|
'mitaka': '12'
|
||||||
|
}
|
||||||
|
|
||||||
BASE_RESOURCE_MAP = OrderedDict([
|
BASE_RESOURCE_MAP = OrderedDict([
|
||||||
(PG_KA_CONF, {
|
(PG_KA_CONF, {
|
||||||
'services': ['plumgrid'],
|
'services': ['plumgrid'],
|
||||||
@ -435,10 +443,13 @@ def sapi_post_ips():
|
|||||||
'PUT -d \'{{{0}}}\' http://{1}' + ':' + '{2}/v1/zones/{3}/allIps'
|
'PUT -d \'{{{0}}}\' http://{1}' + ':' + '{2}/v1/zones/{3}/allIps'
|
||||||
).format(JSON_IPS, config('lcm-ip'), config('sapi-port'),
|
).format(JSON_IPS, config('lcm-ip'), config('sapi-port'),
|
||||||
config('sapi-zone'))
|
config('sapi-zone'))
|
||||||
if 'success' in _exec_cmd_output(
|
POST_ZONE_IPs = _exec_cmd_output(
|
||||||
status,
|
status,
|
||||||
'No response from specified LCM IP!'):
|
'Posting Zone IPs to Solutions API server failed!')
|
||||||
log('Successfully posted Zone IPs to Solutions API server!')
|
if POST_ZONE_IPs:
|
||||||
|
if 'success' in POST_ZONE_IPs:
|
||||||
|
log('Successfully posted Zone IPs to Solutions API server!')
|
||||||
|
log(POST_ZONE_IPs)
|
||||||
|
|
||||||
|
|
||||||
def _exec_cmd_output(cmd=None, error_msg='Command exited with ERRORs',
|
def _exec_cmd_output(cmd=None, error_msg='Command exited with ERRORs',
|
||||||
@ -472,11 +483,14 @@ def sapi_post_license():
|
|||||||
'PUT -d \'{{{0}}}\' http://{1}' + ':' + '{2}/v1/zones/{3}/pgLicense'
|
'PUT -d \'{{{0}}}\' http://{1}' + ':' + '{2}/v1/zones/{3}/pgLicense'
|
||||||
).format(JSON_LICENSE, config('lcm-ip'), config('sapi-port'),
|
).format(JSON_LICENSE, config('lcm-ip'), config('sapi-port'),
|
||||||
config('sapi-zone'))
|
config('sapi-zone'))
|
||||||
if 'success' in _exec_cmd_output(
|
POST_LICENSE = _exec_cmd_output(
|
||||||
status,
|
status,
|
||||||
'No response from specified LCM IP!'):
|
'Posting PLUMgrid License to Solutions API server failed!')
|
||||||
log('Successfully posted license file for zone "{}"!'
|
if POST_LICENSE:
|
||||||
.format(config('sapi-zone')))
|
if 'success' in POST_LICENSE:
|
||||||
|
log('Successfully posted license file for zone "{}"!'
|
||||||
|
.format(config('sapi-zone')))
|
||||||
|
log(POST_LICENSE)
|
||||||
|
|
||||||
|
|
||||||
def sapi_post_zone_info():
|
def sapi_post_zone_info():
|
||||||
@ -484,9 +498,13 @@ def sapi_post_zone_info():
|
|||||||
Posts zone information to solutions api server
|
Posts zone information to solutions api server
|
||||||
'''
|
'''
|
||||||
sol_name = '"solution_name":"Ubuntu OpenStack"'
|
sol_name = '"solution_name":"Ubuntu OpenStack"'
|
||||||
# As there is no solution version for Ubuntu OpenStack,
|
release = config('openstack-release')
|
||||||
# so, passing a random value
|
for key, value in OPENSTACK_RELEASE_VERS.iteritems():
|
||||||
sol_version = '"solution_version":"12"'
|
if release == value:
|
||||||
|
sol_version = value
|
||||||
|
else:
|
||||||
|
sol_version = 10
|
||||||
|
sol_version = '"solution_version":"{}"'.format(sol_version)
|
||||||
pg_ons_version = _exec_cmd_output(
|
pg_ons_version = _exec_cmd_output(
|
||||||
'dpkg -l | grep plumgrid | awk \'{print $3}\' | '
|
'dpkg -l | grep plumgrid | awk \'{print $3}\' | '
|
||||||
'sed \'s/-/./\' | cut -f1 -d"-"',
|
'sed \'s/-/./\' | cut -f1 -d"-"',
|
||||||
@ -536,10 +554,14 @@ def sapi_post_zone_info():
|
|||||||
'PUT -d \'{{{0}}}\' http://{1}:{2}/v1/zones/{3}/zoneinfo'
|
'PUT -d \'{{{0}}}\' http://{1}:{2}/v1/zones/{3}/zoneinfo'
|
||||||
).format(JSON_ZONE_INFO, config('lcm-ip'), config('sapi-port'),
|
).format(JSON_ZONE_INFO, config('lcm-ip'), config('sapi-port'),
|
||||||
config('sapi-zone'))
|
config('sapi-zone'))
|
||||||
if 'success' in _exec_cmd_output(
|
POST_ZONE_INFO = _exec_cmd_output(
|
||||||
status,
|
status,
|
||||||
'No response from specified LCM IP!'):
|
'Posting Zone Information to Solutions API server failed!')
|
||||||
log('Successfully posted Zone info to Solutions API server!')
|
if POST_ZONE_INFO:
|
||||||
|
if 'success' in POST_ZONE_INFO:
|
||||||
|
log('Successfully posted Zone information to Solutions API'
|
||||||
|
' server!')
|
||||||
|
log(POST_ZONE_INFO)
|
||||||
|
|
||||||
|
|
||||||
def load_iptables():
|
def load_iptables():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user