Glance-puppet, not fully working yet

This commit is contained in:
Przemyslaw Kaminski 2015-07-17 15:14:35 +02:00 committed by Bogdan Dobrelya
parent f904b620b3
commit 47b52a27aa
9 changed files with 278 additions and 0 deletions

View File

@ -354,6 +354,41 @@ def deploy():
# signals.connect(rabbitmq_service1, nova_network_puppet, {'ip': 'rabbitmq_host', 'port': 'rabbitmq_port'})
# GLANCE
# glance = vr.create('glance', 'templates/glance.yml', {
# 'idx': '1',
# 'ip': 'node1::ip',
# 'ssh_key': 'node1::ssh_key',
# 'ssh_user': 'node1::ssh_user',
# 'db_login_user': 'mariadb_service1::login_user',
# 'db_login_password': 'mariadb_service1::root_password',
# 'db_host': 'mariadb_service1::ip',
# 'db_port': 'mariadb_service1::port',
# 'db_name': 'glance',
# 'db_user': 'glance',
# 'db_password': 'glance123',
# })[0]
glance_puppet = vr.create('glance_puppet', 'resources/glance_puppet', {})[0]
glance_db_user = vr.create('glance_db_user', 'resources/mariadb_keystone_user/', {'new_user_name': 'glance', 'new_user_password': 'glance'})[0]
glance_db = vr.create('glance_db', 'resources/mariadb_keystone_db/', {'db_name': 'glance', 'login_user': 'root'})[0]
glance_keystone_user = vr.create('glance_keystone_user', 'resources/keystone_user', {'user_name': 'glance', 'user_password': 'glance123'})[0]
glance_keystone_role = vr.create('glance_keystone_role', 'resources/keystone_role', {'role_name': 'glance'})[0]
signals.connect(node1, glance_puppet, {})
signals.connect(mariadb_service1, glance_db)
signals.connect(mariadb_service1, glance_db, {'port': 'login_port', 'root_password': 'login_password'})
signals.connect(services_tenant, glance_keystone_user, {'tenant_name': 'tenant_name'})
signals.connect(keystone_puppet, glance_keystone_user)
signals.connect(keystone_puppet, glance_keystone_user, {'ip': 'keystone_host', 'port': 'keystone_port'})
signals.connect(keystone_puppet, glance_puppet, {'ip': 'keystone_host', 'port': 'keystone_port'})
signals.connect(glance_keystone_user, glance_keystone_role)
signals.connect(mariadb_service1, glance_puppet, {'ip': 'db_host', 'port': 'db_port'})
signals.connect(glance_db, glance_db_user)
signals.connect(glance_db, glance_puppet, {'db_name': 'db_name'})
signals.connect(glance_db_user, glance_puppet, {'new_user_name': 'db_user', 'new_user_password': 'db_password'})
has_errors = False
for r in locals().values():
if not isinstance(r, resource.Resource):
@ -409,6 +444,14 @@ def deploy():
actions.resource_action(nova_api, 'run')
actions.resource_action(nova_keystone_service_endpoint, 'run')
actions.resource_action(glance_keystone_user, 'run')
actions.resource_action(glance_keystone_role, 'run')
actions.resource_action(glance_db_user, 'run')
actions.resource_action(glance_db, 'run')
actions.resource_action(glance_puppet, 'run')
#actions.resource_action(glance, 'run')
time.sleep(10)
@ -417,6 +460,11 @@ def undeploy():
db = get_db()
to_remove = [
'glance_puppet',
'glance_db',
'glance_db_user',
'glance_keystone_role',
'glance_keystone_user',
'nova_db',
'nova_db_user',
'nova_keystone_service_endpoint',

View File

@ -0,0 +1,5 @@
# `glance_puppet` resource
Wraps OpenStack's `glance` Puppet resource from
https://github.com/openstack/puppet-glance (`stable/juno` branch).

View File

@ -0,0 +1,27 @@
$resource = hiera($::resource_name)
$ip = $resource['input']['ip']['value']
#class {'glance':
# package_ensure => 'absent'
#}
#
#user { 'glance':
# name => 'glance',
# ensure => 'absent',
# home => '/home/glance',
# system => true
#}
class { 'glance::api':
#package_ensure => 'absent',
verbose => true
}
class { 'glance::registry':
package_ensure => 'absent',
verbose => true
}
class { 'glance::backend::file': }

View File

@ -0,0 +1,53 @@
$resource = hiera($::resource_name)
$ip = $resource['input']['ip']['value']
$db_host = $resource['input']['db_host']['value']
$db_port = $resource['input']['db_port']['value']
$db_user = $resource['input']['db_user']['value']
$db_password = $resource['input']['db_password']['value']
$db_name = $resource['input']['db_name']['value']
$keystone_host = $resource['input']['keystone_host']['value']
$keystone_port = $resource['input']['keystone_port']['value']
$keystone_user = $resource['input']['keystone_user']['value']
$keystone_password = $resource['input']['keystone_password']['value']
$keystone_role = $resource['input']['keystone_role']['value']
$keystone_tenant = $resource['input']['keystone_tenant']['value']
#user { 'glance':
# name => 'glance',
# ensure => 'present',
# home => '/home/glance',
# system => true
#}
#
#class {'glance':
# package_ensure => 'present'
#}
class { 'glance::api':
#package_ensure => 'present',
verbose => true,
keystone_tenant => $keystone_tenant,
keystone_user => $keystone_user,
keystone_password => $keystone_password,
database_connection => "mysql://$db_user:$db_password@$db_host/$db_name",
}
class { 'glance::registry':
package_ensure => 'present',
verbose => true,
keystone_tenant => $keystone_tenant,
keystone_user => $keystone_user,
keystone_password => $keystone_password,
database_connection => "mysql://$db_user:$db_password@$db_host/$db_name",
}
class { 'glance::backend::file': }
#file { '/etc/keystone/keystone-exports':
# owner => 'root',
# group => 'root',
# content => template('keystone/exports.erb')
#}

View File

@ -0,0 +1,7 @@
class {'keystone':
verbose => True,
catalog_type => 'sql',
admin_token => '{{ admin_token }}',
sql_connection => 'mysql://{{ db_user }}:{{ db_password }}@{{ ip }}/{{ db_name }}',
public_port => '{{ port }}'
}

View File

@ -0,0 +1,55 @@
id: glance_puppet
handler: puppet
puppet_module: glance
version: 1.0.0
input:
db_host:
schema: str!
value:
db_port:
schema: int!
value:
db_user:
schema: str!
value: keystone
db_password:
schema: str!
value: keystone
db_name:
schema: str!
value: keystone
keystone_host:
schema: str!
value:
keystone_port:
schema: int!
value: 5000
keystone_user:
schema: str!
value: glance
keystone_role:
schema: str!
value: glance
keystone_password:
schema: str!
value: glance123
keystone_tenant:
schema: str!
value: services
git:
schema: {repository: str!, branch: str!}
value: {repository: 'https://github.com/openstack/puppet-glance', branch: 'stable/juno'}
ip:
schema: str!
value:
ssh_key:
schema: str!
value:
ssh_user:
schema: str!
value:
tags: [resource/glance_service, resources/glance]

View File

@ -0,0 +1,30 @@
import json
import requests
from solar.core.log import log
def test(resource):
log.debug('Testing glance_puppet')
res = requests.get(
'http://%s:9292' % resource.args['ip'].value
)
token_data = requests.post(
'http://%s:%s/v2.0/tokens' % (resource.args['keystone_host'].value,
resource.args['keystone_port'].value),
json.dumps({
'auth': {
'tenantName': resource.args['tenant_name'].value,
'passwordCredentials': {
'username': resource.args['user_name'].value,
'password': resource.args['user_password'].value,
},
},
}),
headers={'Content-Type': 'application/json'}
)
token = token_data.json()['access']['token']['id']
print res.json()

23
templates/glance.yml Normal file
View File

@ -0,0 +1,23 @@
id: glance_{{idx}}
resources:
- id: glance_base_{{ idx }}
from: templates/glance_db.yml
values:
idx: '{{ idx }}'
db_name: '{{ db_name }}'
db_user: '{{ db_user }}'
db_password: '{{ db_password }}'
db_host: '{{ db_host }}'
db_login_port: '{{ db_port }}'
db_login_user: '{{ db_login_user }}'
db_login_password: '{{ db_login_password }}'
ip: '{{ ip }}'
ssh_user: '{{ ssh_user }}'
ssh_key: '{{ ssh_key }}'
tags: ['resources/glance', 'resource/glance_api', 'resource/glance_registry']

30
templates/glance_db.yml Normal file
View File

@ -0,0 +1,30 @@
id: glance_db_{{ idx }}
resources:
- id: glance_db_db_{{ idx }}
from: resources/mariadb_db
values:
db_name: '{{ db_name }}'
login_user: '{{ db_login_user }}'
login_password: '{{ db_login_password }}'
login_port: '{{ db_login_port }}'
ip: '{{ ip }}'
ssh_user: '{{ ssh_user }}'
ssh_key: '{{ ssh_key }}'
- id: glance_db_user
from: resources/mariadb_user
values:
user_password: '{{ db_password }}'
user_name: '{{ db_user }}'
db_name: '{{ db_name }}'
login_user: '{{ db_login_user }}'
login_password: '{{ db_login_password }}'
login_port: '{{ db_login_port }}'
ip: '{{ ip }}'
ssh_user: '{{ ssh_user }}'
ssh_key: '{{ ssh_key }}'