def __init__(self, args_str=None):
        self._args = None
        if not args_str:
            args_str = ' '.join(sys.argv[1:])
        self._parse_args(args_str)

        httpclient = HTTPClient(
            username='******',
            tenant_name='demo',
            password='******',
            # region_name=self._region_name,
            auth_url='http://%s:5000/v2.0' % (self._args.api_server_ip))
        httpclient.authenticate()

        #OS_URL = httpclient.endpoint_url
        OS_URL = 'http://%s:9696/' % (self._args.api_server_ip)
        OS_TOKEN = httpclient.auth_token
        self._quantum = client.Client('2.0',
                                      endpoint_url=OS_URL,
                                      token=OS_TOKEN)

        self._vnc_lib = VncApi(self._args.admin_user,
                               self._args.admin_password,
                               self._args.admin_tenant_name,
                               self._args.api_server_ip,
                               self._args.api_server_port, '/')

        self._create_vn('public', self._args.public_subnet)
        self._policy_link_vns()
def run(args):

    # instantiate client
    qclient = client.Client('2.0',
                            auth_url=os.environ['OS_AUTH_URL'],
                            username=os.environ['OS_USERNAME'],
                            tenant_name=os.environ['OS_TENANT_NAME'],
                            password=os.environ['OS_PASSWORD'])

    # set json return type
    qclient.format = 'json'

    if args.l3_agent_check:
        LOG.info("Performing L3 Agent Health Check")
        l3_agent_check(qclient, args.noop)

    if args.l3_agent_migrate:
        LOG.info("Performing L3 Agent Migration for Offline L3 Agents")
        l3_agent_migrate(qclient, args.noop)

    if args.l3_agent_rebalance:
        LOG.info("Rebalancing L3 Agent Router Count")
        l3_agent_rebalance(qclient, args.noop)

    if args.replicate_dhcp:
        LOG.info("Performing DHCP Replication of Networks to Agents")
        replicate_dhcp(qclient, args.noop)
    def __init__(self, project, user, passwd, api_server_ip):
        AUTH_URL = 'http://%s:5000/v2.0' % (api_server_ip)
        httpclient = HTTPClient(username=user, tenant_name=project,
                                password=passwd, auth_url=AUTH_URL)
        httpclient.authenticate()

        OS_URL = 'http://%s:9696/' % (api_server_ip)
        OS_TOKEN = httpclient.auth_token
        self._quantum = client.Client('2.0', endpoint_url=OS_URL,
                                      token=OS_TOKEN)
示例#4
0
    def __init__(self, openrc, options, log=None):
        self.log = log
        self.auth_config = openrc
        self.options = options
        self.agents = {}
        self.debug = options.get('debug')
        self.RESCHEDULING_CALLS = {
            'dhcp': self._reschedule_agent_dhcp,
            'l3': self._reschedule_agent_l3,
        }

        ret_count = self.options.get('retries', 1)

        while True:
            if ret_count <= 0:
                print(
                    ">>> Keystone error: no more retries for connect to keystone server."
                )
                sys.exit(1)
            try:
                self.keystone = ks_client.Client(
                    username=openrc['OS_USERNAME'],
                    password=openrc['OS_PASSWORD'],
                    tenant_name=openrc['OS_TENANT_NAME'],
                    auth_url=openrc['OS_AUTH_URL'],
                )
                break
            except Exception as e:
                errmsg = e.message.strip()
                if re.search(r"Connection\s+refused$", errmsg, re.I) or \
                   re.search(r"Connection\s+timed\s+out$", errmsg, re.I) or\
                   re.search(r"Service\s+Unavailable$", errmsg, re.I) or\
                   re.search(r"'*NoneType'*\s+object\s+has\s+no\s+attribute\s+'*__getitem__'*$", errmsg, re.I) or \
                   re.search(r"No\s+route\s+to\s+host$", errmsg, re.I):
                    print(">>> Can't connect to {0}, wait for server ready...".
                          format(self.auth_config['OS_AUTH_URL']))
                    time.sleep(self.options.sleep)
                else:
                    print(">>> Keystone error:\n{0}".format(e.message))
                    raise e
            ret_count -= 1
        self.token = self.keystone.auth_token
        self.client = q_client.Client(
            API_VER,
            endpoint_url=self.keystone.service_catalog.url_for(
                service_type='network'),
            token=self.token,
        )
示例#5
0
def get_quantum_client(tenant_name):
    kcsub = ksclient.Client(auth_url=settings.OS_AUTH_URL, username=settings.OS_ADMIN_USER, password=settings.OS_ADMIN_PASS, tenant_name=tenant_name)
    client = qclient.Client('2.0', endpoint_url=settings.OS_QUANTUM_URL, token=kcsub.auth_token)
    client.format = 'json'
    return client
示例#6
0
                    type=str,
                    help='filter by specific host')
parser.add_argument('--agent-type',
                    metavar='type',
                    type=str,
                    help='filter by specific agent type')
parser.add_argument('--warn-disabled',
                    action='store_true',
                    default=False,
                    help='warn if any agents administratively disabled')
args = parser.parse_args()

try:
    c = client.Client('2.0',
                      username=args.username,
                      tenant_name=args.tenant,
                      password=args.password,
                      auth_url=args.auth_url,
                      region_name=args.region_name)
    params = {}
    if args.host: params['host'] = args.host
    if args.agent_type: params['agent_type'] = args.agent_type
    agents = c.list_agents(**params)
except Exception as e:
    print str(e)
    sys.exit(STATE_CRITICAL)

agents_down = []
agents_disabled = []
messages = []
exit_state = STATE_OK
for a in agents['agents']: