def _get_amqp_manager():
    return AMQPManager(
        host=config.instance.amqp_management_host,
        username=config.instance.amqp_username,
        password=config.instance.amqp_password,
        verify=config.instance.amqp_ca_path
    )
 def _get_amqp_manager(self):
     return AMQPManager(
         host=instance.amqp_management_host,
         username=instance.amqp_username,
         password=instance.amqp_password,
         verify=instance.amqp_ca_path
     )
def setup_amqp_manager():
    amqp_manager = AMQPManager(
        host=config.instance.amqp_management_host or "localhost",
        username=config.instance.amqp_username or "cloudify",
        password=config.instance.amqp_password or "c10udify",
        verify=config.instance.amqp_ca_path or DEFAULT_CA_CERT,
    )
    return amqp_manager
Exemple #4
0
def _get_amqp_manager(script_config):
    with tempfile.NamedTemporaryFile(delete=False, mode='wb') as f:
        f.write(script_config['rabbitmq_ca_cert'])
    broker = script_config['rabbitmq_brokers'][0]
    atexit.register(os.unlink, f.name)
    return AMQPManager(host=broker['management_host'],
                       username=broker['username'],
                       password=broker['password'],
                       verify=f.name)
def setup_amqp_manager():
    global amqp_manager
    if not amqp_manager:
        conf_file_str = read_manager_file('/opt/manager/cloudify-rest.conf')
        config = yaml.load(conf_file_str)
        amqp_manager = AMQPManager(host=config['amqp_host'],
                                   username=config['amqp_username'],
                                   password=config['amqp_password'])
    return amqp_manager
    def _handle_default_db_config(server):
        server.db.create_all()
        admin_user = get_admin_user()

        fd, temp_auth_file = tempfile.mkstemp()
        os.close(fd)
        with open(temp_auth_file, 'w') as f:
            yaml.dump(auth_dict, f)

        try:
            # We're mocking the AMQPManager, we aren't really using Rabbit here
            default_tenant = create_default_user_tenant_and_roles(
                admin_username=admin_user['username'],
                admin_password=admin_user['password'],
                amqp_manager=MagicMock(),
                authorization_file_path=temp_auth_file)
            default_tenant.rabbitmq_password = encrypt(
                AMQPManager._generate_user_password())
        finally:
            os.remove(temp_auth_file)

        utils.set_current_tenant(default_tenant)
Exemple #7
0
 def put_agent(self,
               agent_name='agent_1',
               instance_id='node_instance_1',
               deployment_id='deployment_1'):
     node_instance = self._get_or_create_node_instance(
         instance_id, deployment_id)
     agent = Agent(id=agent_name,
                   name=agent_name,
                   ip='127.0.0.1',
                   install_method='remote',
                   system='centos core',
                   version='4.5.5',
                   visibility='tenant',
                   state=AgentState.CREATING,
                   rabbitmq_username='******'.format(agent_name),
                   rabbitmq_password=encrypt(
                       AMQPManager._generate_user_password()),
                   rabbitmq_exchange=agent_name,
                   created_at=get_formatted_timestamp(),
                   updated_at=get_formatted_timestamp())
     agent.node_instance = node_instance
     return self.sm.put(agent)
Exemple #8
0
#
# 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.

from os import environ
from manager_rest.config import instance
from manager_rest.amqp_manager import AMQPManager
from manager_rest.flask_utils import setup_flask_app


environ['MANAGER_REST_CONFIG_PATH'] = '/opt/manager/cloudify-rest.conf'
app = setup_flask_app()

with app.app_context():
    instance.load_configuration()
    amqp_manager = AMQPManager(
        host=instance.amqp_host,
        username=instance.amqp_username,
        password=instance.amqp_password
    )
    amqp_manager.sync_metadata()
Exemple #9
0
#
# 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.

from os import environ
from manager_rest.config import instance
from manager_rest.amqp_manager import AMQPManager
from manager_rest.flask_utils import setup_flask_app
from manager_rest.constants import SECURITY_FILE_LOCATION

environ['MANAGER_REST_CONFIG_PATH'] = '/opt/manager/cloudify-rest.conf'
environ['MANAGER_REST_SECURITY_CONFIG_PATH'] = SECURITY_FILE_LOCATION
app = setup_flask_app()

with app.app_context():
    instance.load_configuration()
    amqp_manager = AMQPManager(host=instance.amqp_management_host,
                               username=instance.amqp_username,
                               password=instance.amqp_password,
                               verify=instance.amqp_ca_path)
    amqp_manager.sync_metadata()
def _get_amqp_manager(config):
    return AMQPManager(host=config['amqp_host'],
                       username=config['amqp_username'],
                       password=config['amqp_password'])
# 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.

from os import environ
from manager_rest.config import instance
from manager_rest.amqp_manager import AMQPManager
from manager_rest.flask_utils import setup_flask_app
from manager_rest.constants import SECURITY_FILE_LOCATION


environ['MANAGER_REST_CONFIG_PATH'] = '/opt/manager/cloudify-rest.conf'
environ['MANAGER_REST_SECURITY_CONFIG_PATH'] = SECURITY_FILE_LOCATION
app = setup_flask_app()

with app.app_context():
    instance.load_configuration()
    amqp_manager = AMQPManager(
        host=instance.amqp_management_host,
        username=instance.amqp_username,
        password=instance.amqp_password,
        verify=instance.amqp_ca_path
    )
    amqp_manager.sync_metadata()